diff --git a/app/src/processing/app/contrib/ContributionTab.java b/app/src/processing/app/contrib/ContributionTab.java index 45c60a94f..0243452c1 100644 --- a/app/src/processing/app/contrib/ContributionTab.java +++ b/app/src/processing/app/contrib/ContributionTab.java @@ -191,56 +191,6 @@ public class ContributionTab extends JPanel { filterLibraries(); }); - /* - categoryChooser.setBorder(null); - categoryChooser.setBackground(Color.GREEN); - categoryChooser.setForeground(Color.RED); - - // want this to be com.formdev.flatlaf.ui.FlatComboBoxUI$FlatComboPopup - //System.out.println("ui class for chooser is " + categoryChooser.getUI().getClass()); - - categoryChooser.setRenderer(new DefaultListCellRenderer() { - @Override - //public Component getListCellRendererComponent(JList list, String value, int index, boolean isSelected, boolean cellHasFocus) { - // https://docs.oracle.com/javase/7/docs/api/javax/swing/ListCellRenderer.html - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - //return null; - if (isSelected) { - setForeground(Color.GREEN); - setBackground(Color.BLUE); - } else { - setForeground(Color.WHITE); - setBackground(Color.BLACK); - } - - Container parent = getParent(); - if (parent instanceof CellRendererPane) { - Container crp = parent.getParent(); - // anonymous class javax.swing.plaf.basic.BasicComboPopup$1 - if (crp instanceof JComponent) { - Container viewport = crp.getParent(); - if (viewport instanceof JViewport) { - Container scrollPane = viewport.getParent(); - if (scrollPane instanceof JScrollPane) { - Container popup = scrollPane.getParent(); - if (popup instanceof JComponent) { - // com.formdev.flatlaf.ui.FlatComboBoxUI$FlatComboPopup - JComponent c = (JComponent) popup; - if (!(c.getBorder() instanceof EmptyBorder)) { // just once - c.setBorder(new EmptyBorder(0, 0, 0, 0)); - } - } - } - } - } - } - - setText(String.valueOf(value)); - return this; - } - }); - */ - filterField = new FilterField(); } diff --git a/app/src/processing/app/laf/PdeComboBoxUI.java b/app/src/processing/app/laf/PdeComboBoxUI.java index 7dee8ab5f..84bc6c5c7 100644 --- a/app/src/processing/app/laf/PdeComboBoxUI.java +++ b/app/src/processing/app/laf/PdeComboBoxUI.java @@ -4,6 +4,8 @@ import processing.app.ui.Theme; import processing.app.ui.Toolkit; import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; import javax.swing.plaf.basic.BasicComboBoxUI; import java.awt.*; @@ -62,7 +64,35 @@ public class PdeComboBoxUI extends BasicComboBoxUI { return new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - //return null; + // TODO There must be a less convoluted way to do this [fry 220505] + Container parent = getParent(); + if (parent instanceof CellRendererPane) { + Container crp = parent.getParent(); + // anonymous class javax.swing.plaf.basic.BasicComboPopup$1 + if (crp instanceof JComponent) { + Container viewport = crp.getParent(); + if (viewport instanceof JViewport) { + Container scrollPane = viewport.getParent(); + if (scrollPane instanceof JScrollPane) { + Container popup = scrollPane.getParent(); + if (popup instanceof JComponent) { + // com.formdev.flatlaf.ui.FlatComboBoxUI$FlatComboPopup + JComponent c = (JComponent) popup; + if (!(c.getBorder() instanceof EmptyBorder)) { // just once + // remove the black outline from the popup + c.setBorder(new EmptyBorder(0, 0, 0, 0)); + } + } + } + } + } + } + + // Can't use instanceof because FlatLaf Border is EmptyBorder subclass. + // If this is the currently selected item (index == -1), do not add + // extra left indent, so the list items left-align with the selection. + setBorder(new EmptyBorder(2, index == -1 ? 0 : 6, 2, 2)); + if (isSelected) { setForeground(selectedFgColor); setBackground(selectedBgColor); @@ -91,21 +121,21 @@ public class PdeComboBoxUI extends BasicComboBoxUI { } c.setFont(comboBox.getFont()); // if (hasFocus && !isPopupVisible(comboBox)) { -// //c.setForeground(listBox.getSelectionForeground()); // TODO do we need to mess with listBox? +// //c.setForeground(listBox.getSelectionForeground()); // //c.setBackground(listBox.getSelectionBackground()); // c.setForeground(selectedFgColor); // c.setBackground(selectedBgColor); // // } else { - if (comboBox.isEnabled()) { + if (comboBox.isEnabled()) { // c.setForeground(comboBox.getForeground()); // c.setBackground(comboBox.getBackground()); - c.setForeground(enabledFgColor); - c.setBackground(enabledBgColor); - } else { - c.setForeground(disabledFgColor); - c.setBackground(disabledBgColor); - } + c.setForeground(enabledFgColor); + c.setBackground(enabledBgColor); + } else { + c.setForeground(disabledFgColor); + c.setBackground(disabledBgColor); + } // } // Fix for 4238829: should lay out the JPanel. diff --git a/todo.txt b/todo.txt index f1f5662b1..bd981841c 100755 --- a/todo.txt +++ b/todo.txt @@ -48,6 +48,8 @@ X override flatlaf for components (search, buttons, dropdown menu) in manager X popup menu coloring (contribs) X progress bar in contrib manager X need monochrome icon for foundation +o do we need other color states for list item icons +X they seem to be find for now X remove JProgressBar from ContributionTab/UpdateContributionTab X StatusPanelDetail creates its own, which is the one used _ still need to work to prevent multiple from colliding @@ -61,7 +63,6 @@ _ these should be read from theme.txt instead _ or not used at all: the defaults from ui.font and FlatLaf should do design/manager/waiting -_ do we need other color states for list item icons _ update lib/theme.txt to clean up current Frankenstein status _ just replace with the blue default once that's updated