mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 19:31:16 +01:00
Odd/even bordering for library list on OSX
This commit is contained in:
@@ -66,7 +66,9 @@ public class LibraryListPanel extends JPanel {
|
||||
configureInfoPane();
|
||||
|
||||
setShowInfo(false);
|
||||
updateColors();
|
||||
updateLibraryListSize();
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
for (Component c : LibraryListPanel.this.getComponents()) {
|
||||
@@ -76,6 +78,7 @@ public class LibraryListPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
setShowInfo(true);
|
||||
updateColors();
|
||||
updateLibraryListSize();
|
||||
}
|
||||
});
|
||||
@@ -172,14 +175,8 @@ public class LibraryListPanel extends JPanel {
|
||||
CardLayout cardLayout = (CardLayout) infoPanel.getLayout();
|
||||
|
||||
if (isInfoShown) {
|
||||
setBackground(UIManager.getColor("List.selectionBackground"));
|
||||
cascadeForgroundColor(this, UIManager.getColor("List.selectionForeground"));
|
||||
|
||||
cardLayout.show(infoPanel, clickedCardId);
|
||||
} else {
|
||||
setBackground(UIManager.getColor("List.background"));
|
||||
cascadeForgroundColor(this, UIManager.getColor("List.foreground"));
|
||||
|
||||
cardLayout.show(infoPanel, unclickedCardId);
|
||||
}
|
||||
|
||||
@@ -318,6 +315,34 @@ public class LibraryListPanel extends JPanel {
|
||||
|
||||
return noLines;
|
||||
}
|
||||
|
||||
private void updateColors() {
|
||||
|
||||
int count = 0;
|
||||
for (Component c : getComponents()) {
|
||||
if (c instanceof LibraryPanel) {
|
||||
LibraryPanel libPanel = (LibraryPanel) c;
|
||||
|
||||
if (libPanel.isInfoShown) {
|
||||
libPanel.setBackground(UIManager.getColor("List.selectionBackground"));
|
||||
cascadeForgroundColor(libPanel, UIManager.getColor("List.selectionForeground"));
|
||||
libPanel.setBorder(UIManager.getBorder("List.focusCellHighlightBorder"));
|
||||
} else {
|
||||
if (Base.isMacOS()) {
|
||||
if (count % 2 == 1) {
|
||||
libPanel.setBorder(UIManager.getBorder("List.evenRowBackgroundPainter"));
|
||||
} else {
|
||||
libPanel.setBorder(UIManager.getBorder("List.oddRowBackgroundPainter"));
|
||||
}
|
||||
}
|
||||
libPanel.setBackground(UIManager.getColor("List.background"));
|
||||
cascadeForgroundColor(libPanel, UIManager.getColor("List.foreground"));
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the height in pixels of the text in a JTextArea given a width
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2004-09 Ben Fry and Casey Reas
|
||||
Copyright (c) 2004-11 Ben Fry and Casey Reas
|
||||
Copyright (c) 2001-04 Massachusetts Institute of Technology
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
||||
Reference in New Issue
Block a user