Skip to content

Commit a4f112c

Browse files
committed
Switch to VAqua on Mac for dark mode and non-terrible jfilechooser.
1 parent 865281a commit a4f112c

File tree

6 files changed

+71
-4
lines changed

6 files changed

+71
-4
lines changed

app/build.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
lib/ant.jar;
4040
lib/ant-launcher.jar;
4141
lib/jna.jar;
42-
lib/jna-platform.jar"
42+
lib/jna-platform.jar;
43+
lib/vaqua7.jar"
4344
debug="on"
4445
nowarn="true">
4546
<src path="src" />

app/src/processing/app/platform/DefaultPlatform.java

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,19 @@
2323

2424
package processing.app.platform;
2525

26+
import java.awt.Color;
27+
import java.awt.Component;
2628
import java.awt.Desktop;
29+
import java.awt.Graphics;
2730
import java.io.File;
2831
import java.net.URI;
2932

33+
import javax.swing.Icon;
3034
import javax.swing.UIManager;
3135

3236
import com.sun.jna.Library;
3337
import com.sun.jna.Native;
38+
import org.violetlib.aqua.AquaLookAndFeel;
3439

3540
import processing.app.Base;
3641
import processing.app.Preferences;
@@ -75,7 +80,20 @@ public void initBase(Base base) {
7580
public void setLookAndFeel() throws Exception {
7681
String laf = Preferences.get("editor.laf");
7782
if (laf == null || laf.length() == 0) { // normal situation
78-
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
83+
if (System.getProperty("os.name", "").startsWith("Mac OS")) {
84+
UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
85+
86+
Icon collapse = new MacTreeIcon(true);
87+
Icon open = new MacTreeIcon(false);
88+
Icon leaf = new MacEmptyIcon();
89+
UIManager.put("Tree.closedIcon", leaf);
90+
UIManager.put("Tree.openIcon", leaf);
91+
UIManager.put("Tree.collapsedIcon", open);
92+
UIManager.put("Tree.expandedIcon", collapse);
93+
UIManager.put("Tree.leafIcon", leaf);
94+
} else {
95+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
96+
}
7997
} else {
8098
UIManager.setLookAndFeel(laf);
8199
}
@@ -188,4 +206,48 @@ public float getSystemZoom() {
188206
return ZOOM_DEFAULT_SIZING;
189207
}
190208

209+
class MacEmptyIcon implements Icon {
210+
private final int SIZE = 1;
211+
212+
public MacEmptyIcon() {
213+
}
214+
215+
public int getIconWidth() {
216+
return SIZE;
217+
}
218+
219+
public int getIconHeight() {
220+
return SIZE;
221+
}
222+
223+
public void paintIcon(Component c, Graphics g, int x, int y) {}
224+
}
225+
226+
class MacTreeIcon implements Icon {
227+
private final int SIZE = 12;
228+
private final boolean isOpen;
229+
230+
public MacTreeIcon(boolean newIsOpen) {
231+
isOpen = newIsOpen;
232+
}
233+
234+
public int getIconWidth() {
235+
return SIZE;
236+
}
237+
238+
public int getIconHeight() {
239+
return SIZE;
240+
}
241+
242+
public void paintIcon(Component c, Graphics g, int x, int y) {
243+
g.setColor(Color.GRAY);
244+
245+
g.drawLine(x + SIZE / 2 - 3, y + SIZE / 2, x + SIZE / 2 + 3, y + SIZE / 2);
246+
247+
if (!isOpen) {
248+
g.drawLine(x + SIZE / 2, y + SIZE / 2 - 3, x + SIZE / 2, y + SIZE / 2 + 3);
249+
}
250+
}
251+
}
252+
191253
}

app/src/processing/app/ui/EditorConsole.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ protected void updateMode() {
188188
StyleConstants.setBold(errStyle, font.isBold());
189189
StyleConstants.setItalic(errStyle, font.isItalic());
190190

191-
if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
191+
String lookAndFeel = UIManager.getLookAndFeel().getID();
192+
if (lookAndFeel.equals("Nimbus") || lookAndFeel.equals("VAqua")) {
192193
getViewport().setBackground(bgColor);
193194
consoleTextPane.setOpaque(false);
194195
consoleTextPane.setBackground(new Color(0, 0, 0, 0));

build/build.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@
424424
<include name="app/lib/jna-platform.jar" />
425425
<include name="app/lib/ant.jar" />
426426
<include name="app/lib/ant-launcher.jar" />
427+
<include name="app/lib/vaqua7.jar" />
427428
</fileset>
428429

429430
<target name="build" description="Build Processing.">
@@ -721,6 +722,7 @@
721722
<classpath file="../app/lib/jna-platform.jar" />
722723
<classpath file="../app/lib/ant.jar" />
723724
<classpath file="../app/lib/ant-launcher.jar" />
725+
<classpath file="../app/lib/vaqua7.jar" />
724726

725727
<!-- plus core.jar... note that this is no longer shared -->
726728
<classpath file="../core/library/core.jar" />

java/build.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<pathelement location="../app/lib/apple.jar" />
5555
<pathelement location="../app/lib/jna.jar" />
5656
<pathelement location="../app/lib/jna-platform.jar" />
57+
<pathelement location="../app/lib/vaqua7.jar" />
5758

5859
<pathelement location="mode/antlr-4.7.2-complete.jar" />
5960
<pathelement location="mode/classpath-explorer-1.0.jar" />

java/src/processing/mode/java/debug/VariableInspector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ protected void setItalic(boolean on) {
610610
@Override
611611
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
612612
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
613-
setForeground(tree.isEnabled() ? Color.BLACK : Color.GRAY);
613+
//setForeground(tree.isEnabled() ? Color.BLACK : Color.GRAY);
614614

615615
if (value instanceof VariableNode) {
616616
VariableNode var = (VariableNode) value;

0 commit comments

Comments
 (0)