mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[ui] search text field on mac has minimum size to accommodate icons
This commit is contained in:
committed by
Julia Beliaeva
parent
f6310d9d50
commit
ebc968da04
+20
-1
@@ -135,7 +135,26 @@ public class MacIntelliJTextFieldUI extends TextFieldWithPopupHandlerUI {
|
||||
@Override
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
Dimension size = super.getPreferredSize(c);
|
||||
return new Dimension(size.width, Math.max(26, size.height));
|
||||
return new Dimension(size.width + getIconsWidth(c), Math.max(26, size.height));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize(JComponent c) {
|
||||
Dimension minimumSize = super.getMinimumSize(c);
|
||||
return new Dimension(minimumSize.width + getIconsWidth(c), minimumSize.height);
|
||||
}
|
||||
|
||||
private int getIconsWidth(JComponent c) {
|
||||
int width = 0;
|
||||
if (isSearchField(c)) {
|
||||
Icon label = getSearchIcon(c);
|
||||
width += label.getIconWidth();
|
||||
if (hasText()) {
|
||||
Icon clearIcon = MacIntelliJIconCache.getIcon("searchFieldClear");
|
||||
width += clearIcon.getIconWidth() + 3;
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
protected void paintSearchField(Graphics2D g, JTextComponent c, Rectangle r) {
|
||||
|
||||
Reference in New Issue
Block a user