Skip to content

Commit 75265fd

Browse files
authored
Merge pull request processing#88 from processing/fix_mac_os_save
2 parents 12205d4 + 942fa81 commit 75265fd

9 files changed

Lines changed: 127 additions & 9 deletions

File tree

app/build.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
<?xml version="1.0"?>
22
<project name="Processing PDE" default="build">
33

4+
<property name="vaqua.url" value="https://violetlib.org/release/vaqua" />
5+
46
<target name="clean" description="Clean the build directories">
57
<delete dir="bin" />
68
<delete file="pde.jar" />
79
</target>
810

9-
<target name="compile" description="Compile sources">
11+
<target name="download-vaqua">
12+
13+
<get dest="lib" usetimestamp="true">
14+
<url url="${vaqua.url}/7/VAqua7.jar" />
15+
</get>
16+
17+
</target>
18+
19+
<target name="compile" description="Compile sources" depends="download-vaqua">
1020
<condition property="core-built">
1121
<available file="../core/library/core.jar" />
1222
</condition>
@@ -39,7 +49,8 @@
3949
lib/ant.jar;
4050
lib/ant-launcher.jar;
4151
lib/jna.jar;
42-
lib/jna-platform.jar"
52+
lib/jna-platform.jar;
53+
lib/VAqua7.jar"
4354
debug="on"
4455
nowarn="true">
4556
<src path="src" />

app/src/processing/app/Sketch.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,10 @@ public boolean saveAs() throws IOException {
841841
// TODO rewrite this to use shared version from PApplet (But because that
842842
// specifies a callback function, this needs to wait until the refactoring)
843843
final String PROMPT = Language.text("save");
844-
if (Preferences.getBoolean("chooser.files.native")) {
844+
845+
// https://github.com/processing/processing4/issues/77
846+
boolean useNative = Preferences.getBoolean("chooser.files.native");
847+
if (useNative) {
845848
// get new name for folder
846849
FileDialog fd = new FileDialog(editor, PROMPT, FileDialog.SAVE);
847850
if (isReadOnly() || isUntitled()) {

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

Lines changed: 96 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,21 @@ 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+
boolean isMac = System.getProperty("os.name", "").startsWith("Mac OS");
84+
if (isMac && Preferences.getBoolean("editor.allow_vaqua")) {
85+
UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
86+
87+
Icon collapse = new MacTreeIcon(true);
88+
Icon open = new MacTreeIcon(false);
89+
Icon leaf = new MacEmptyIcon();
90+
UIManager.put("Tree.closedIcon", leaf);
91+
UIManager.put("Tree.openIcon", leaf);
92+
UIManager.put("Tree.collapsedIcon", open);
93+
UIManager.put("Tree.expandedIcon", collapse);
94+
UIManager.put("Tree.leafIcon", leaf);
95+
} else {
96+
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
97+
}
7998
} else {
8099
UIManager.setLookAndFeel(laf);
81100
}
@@ -188,4 +207,80 @@ public float getSystemZoom() {
188207
return ZOOM_DEFAULT_SIZING;
189208
}
190209

210+
/**
211+
* Spacer icon for mac when using Vaqua.
212+
*
213+
* <p>
214+
* Due to potential rendering issues, this small spacer is used to ensure that rendering is stable
215+
* while using Vaqua with non-standard swing components. Without this, some sizing calculations
216+
* non-standard components may fail or become unreliable.
217+
* </p>
218+
*/
219+
class MacEmptyIcon implements Icon {
220+
private final int SIZE = 1;
221+
222+
/**
223+
* Create a new single pixel spacer icon.
224+
*/
225+
public MacEmptyIcon() {}
226+
227+
@Override
228+
public int getIconWidth() {
229+
return SIZE;
230+
}
231+
232+
@Override
233+
public int getIconHeight() {
234+
return SIZE;
235+
}
236+
237+
@Override
238+
public void paintIcon(Component c, Graphics g, int x, int y) {}
239+
}
240+
241+
/**
242+
* Replacement tree icon for mac when using Vaqua.
243+
*
244+
* <p>
245+
* Due to potential rendering issues with the regular tree icon set, this replacement tree icon
246+
* for mac ensures stable rendering when using Vaqua with non-standard swing components. Without
247+
* this, some sizing calculations within non-standard components may fail or become unreliable.
248+
* </p>
249+
*/
250+
private class MacTreeIcon implements Icon {
251+
private final int SIZE = 12;
252+
private final boolean isOpen;
253+
254+
/**
255+
* Create a new tree icon.
256+
*
257+
* @param newIsOpen Flag indicating if the icon should be in the open or closed state at
258+
* construction. True if open false otherwise.
259+
*/
260+
public MacTreeIcon(boolean newIsOpen) {
261+
isOpen = newIsOpen;
262+
}
263+
264+
@Override
265+
public int getIconWidth() {
266+
return SIZE;
267+
}
268+
269+
@Override
270+
public int getIconHeight() {
271+
return SIZE;
272+
}
273+
274+
@Override
275+
public void paintIcon(Component c, Graphics g, int x, int y) {
276+
g.setColor(Color.GRAY);
277+
278+
g.drawLine(x + SIZE / 2 - 3, y + SIZE / 2, x + SIZE / 2 + 3, y + SIZE / 2);
279+
280+
if (!isOpen) {
281+
g.drawLine(x + SIZE / 2, y + SIZE / 2 - 3, x + SIZE / 2, y + SIZE / 2 + 3);
282+
}
283+
}
284+
}
285+
191286
}

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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@
426426
<include name="app/lib/jna-platform.jar" />
427427
<include name="app/lib/ant.jar" />
428428
<include name="app/lib/ant-launcher.jar" />
429+
<include name="app/lib/VAqua7.jar" />
429430
</fileset>
430431

431432
<target name="build" description="Build Processing.">
@@ -706,7 +707,8 @@
706707
copyright="© The Processing Foundation"
707708
shortVersion="${version}"
708709
version="${revision}"
709-
mainClassName="processing.app.BaseSplash">
710+
mainClassName="processing.app.BaseSplash"
711+
minimumSystemVersion="10.10.0">
710712

711713
<!-- The appbundler task needs a couple files (the Info.plist and
712714
anything else outside /jdk) from the full JDK, even though
@@ -723,6 +725,7 @@
723725
<classpath file="../app/lib/jna-platform.jar" />
724726
<classpath file="../app/lib/ant.jar" />
725727
<classpath file="../app/lib/ant-launcher.jar" />
728+
<classpath file="../app/lib/VAqua7.jar" />
726729

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

build/shared/lib/defaults.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ recent.count = 10
7474

7575
# Default to the native (AWT) file selector where possible
7676
chooser.files.native = true
77+
chooser.files.native.macosx = false # except on mac where it's broken
7778

7879

7980
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -167,6 +168,9 @@ editor.watcher.debug = false
167168
# The window of time (in milliseconds) in which a change won't be counted
168169
editor.watcher.window = 1500
169170

171+
# allow vaqua on mac
172+
editor.allow_vaqua = true
173+
170174
# Format and search engine to use for online queries
171175
search.format = https://google.com/search?q=%s
172176

java/application/Info.plist.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<string>@@sketch@@</string>
3939

4040
<key>LSMinimumSystemVersion</key>
41-
<string>10.8.5</string>
41+
<string>10.10.0</string>
4242

4343
<key>NSHighResolutionCapable</key>
4444
<true/>
@@ -61,7 +61,7 @@
6161
<array>
6262
@@jvm_options_list@@
6363
<string>-Xdock:icon=$APP_ROOT/Contents/Resources/sketch.icns</string>
64-
<string>-Djava.library.path=$APP_ROOT/Contents/Java</string>
64+
<string>-Djava.library.path=$APP_ROOT/Contents/Java</string>
6565
<string>-Dapple.laf.useScreenMenuBar=true</string>
6666
<string>-Dcom.apple.macos.use-file-dialog-packages=true</string>
6767
<string>-Dcom.apple.macos.useScreenMenuBar=true</string>

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)