Odd/even bordering for library list on OSX

This commit is contained in:
pesckal
2011-06-20 17:46:16 +00:00
parent 9e3d7b5202
commit 4d6cbb9360
2 changed files with 32 additions and 7 deletions

View File

@@ -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

View File

@@ -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