Fix search field offsets for search icon, cursor and empty text.

This commit is contained in:
Alexander Lobas
2018-12-05 20:32:57 +03:00
parent 85433ccb65
commit 2809db8070
4 changed files with 8 additions and 10 deletions
@@ -33,7 +33,7 @@ public interface ExtendableTextComponent {
return scale(5);
}
default int getBeforeIconOffset() {
default int getAfterIconOffset() {
return 0;
}
@@ -213,10 +213,10 @@ public class PluginManagerConfigurableNew
mySearchTextField.setBorder(JBUI.Borders.customLine(SEARCH_FIELD_BORDER_COLOR));
JBTextField editor = mySearchTextField.getTextEditor();
editor.putClientProperty("JTextField.Search.Gap", JBUI.scale(-24));
editor.putClientProperty("JTextField.Search.Gap", JBUI.scale(6));
editor.putClientProperty("JTextField.Search.GapEmptyText", JBUI.scale(-1));
editor.putClientProperty("StatusVisibleFunction", (BooleanFunction<JBTextField>)field -> field.getText().isEmpty());
editor.setBorder(JBUI.Borders.empty(0, 25));
editor.setBorder(JBUI.Borders.empty(0, 6));
editor.setOpaque(true);
editor.setBackground(SEARCH_BG_COLOR);
}
@@ -112,7 +112,7 @@ public class PluginsGroupComponent extends JBPanelWithEmptyText {
myGroups.add(groupIndex == -1 ? myGroups.size() : groupIndex, uiGroup);
OpaquePanel panel = new OpaquePanel(new BorderLayout(), SECTION_HEADER_BACKGROUND);
panel.setBorder(JBUI.Borders.empty(4, 13));
panel.setBorder(JBUI.Borders.empty(4, 10));
JLabel title = new JLabel(group.title) {
@Override
@@ -128,14 +128,12 @@ public abstract class TextFieldWithPopupHandlerUI extends BasicTextFieldUI imple
for (IconHolder holder : icons.values()) {
int gap = holder.extension.getIconGap();
if (holder.extension.isIconBeforeText()) {
int offset = holder.extension.getBeforeIconOffset();
bounds.x += offset;
bounds.width -= offset;
int offset = holder.extension.getAfterIconOffset();
holder.bounds.x = bounds.x;
bounds.width -= holder.bounds.width + gap;
bounds.x += holder.bounds.width + gap;
bounds.x += holder.bounds.width + gap + offset;
margin.left += offset + holder.bounds.width + gap;
margin.left += holder.bounds.width + gap + offset;
}
else {
bounds.width -= holder.bounds.width + gap;
@@ -592,7 +590,7 @@ public abstract class TextFieldWithPopupHandlerUI extends BasicTextFieldUI imple
}
@Override
public int getBeforeIconOffset() {
public int getAfterIconOffset() {
Integer gap = (Integer)getComponent().getClientProperty("JTextField.Search.Gap");
return gap == null ? 0 : gap;
}