mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Merge pull request #88 from processing/fix_mac_os_save
This commit is contained in:
+13
-2
@@ -1,12 +1,22 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="Processing PDE" default="build">
|
||||
|
||||
<property name="vaqua.url" value="https://violetlib.org/release/vaqua" />
|
||||
|
||||
<target name="clean" description="Clean the build directories">
|
||||
<delete dir="bin" />
|
||||
<delete file="pde.jar" />
|
||||
</target>
|
||||
|
||||
<target name="compile" description="Compile sources">
|
||||
<target name="download-vaqua">
|
||||
|
||||
<get dest="lib" usetimestamp="true">
|
||||
<url url="${vaqua.url}/7/VAqua7.jar" />
|
||||
</get>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="compile" description="Compile sources" depends="download-vaqua">
|
||||
<condition property="core-built">
|
||||
<available file="../core/library/core.jar" />
|
||||
</condition>
|
||||
@@ -39,7 +49,8 @@
|
||||
lib/ant.jar;
|
||||
lib/ant-launcher.jar;
|
||||
lib/jna.jar;
|
||||
lib/jna-platform.jar"
|
||||
lib/jna-platform.jar;
|
||||
lib/VAqua7.jar"
|
||||
debug="on"
|
||||
nowarn="true">
|
||||
<src path="src" />
|
||||
|
||||
@@ -841,7 +841,10 @@ public class Sketch {
|
||||
// TODO rewrite this to use shared version from PApplet (But because that
|
||||
// specifies a callback function, this needs to wait until the refactoring)
|
||||
final String PROMPT = Language.text("save");
|
||||
if (Preferences.getBoolean("chooser.files.native")) {
|
||||
|
||||
// https://github.com/processing/processing4/issues/77
|
||||
boolean useNative = Preferences.getBoolean("chooser.files.native");
|
||||
if (useNative) {
|
||||
// get new name for folder
|
||||
FileDialog fd = new FileDialog(editor, PROMPT, FileDialog.SAVE);
|
||||
if (isReadOnly() || isUntitled()) {
|
||||
|
||||
@@ -23,14 +23,19 @@
|
||||
|
||||
package processing.app.platform;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Graphics;
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import com.sun.jna.Library;
|
||||
import com.sun.jna.Native;
|
||||
import org.violetlib.aqua.AquaLookAndFeel;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Preferences;
|
||||
@@ -75,7 +80,21 @@ public class DefaultPlatform {
|
||||
public void setLookAndFeel() throws Exception {
|
||||
String laf = Preferences.get("editor.laf");
|
||||
if (laf == null || laf.length() == 0) { // normal situation
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
boolean isMac = System.getProperty("os.name", "").startsWith("Mac OS");
|
||||
if (isMac && Preferences.getBoolean("editor.allow_vaqua")) {
|
||||
UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel");
|
||||
|
||||
Icon collapse = new MacTreeIcon(true);
|
||||
Icon open = new MacTreeIcon(false);
|
||||
Icon leaf = new MacEmptyIcon();
|
||||
UIManager.put("Tree.closedIcon", leaf);
|
||||
UIManager.put("Tree.openIcon", leaf);
|
||||
UIManager.put("Tree.collapsedIcon", open);
|
||||
UIManager.put("Tree.expandedIcon", collapse);
|
||||
UIManager.put("Tree.leafIcon", leaf);
|
||||
} else {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
} else {
|
||||
UIManager.setLookAndFeel(laf);
|
||||
}
|
||||
@@ -188,4 +207,80 @@ public class DefaultPlatform {
|
||||
return ZOOM_DEFAULT_SIZING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spacer icon for mac when using Vaqua.
|
||||
*
|
||||
* <p>
|
||||
* Due to potential rendering issues, this small spacer is used to ensure that rendering is stable
|
||||
* while using Vaqua with non-standard swing components. Without this, some sizing calculations
|
||||
* non-standard components may fail or become unreliable.
|
||||
* </p>
|
||||
*/
|
||||
class MacEmptyIcon implements Icon {
|
||||
private final int SIZE = 1;
|
||||
|
||||
/**
|
||||
* Create a new single pixel spacer icon.
|
||||
*/
|
||||
public MacEmptyIcon() {}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replacement tree icon for mac when using Vaqua.
|
||||
*
|
||||
* <p>
|
||||
* Due to potential rendering issues with the regular tree icon set, this replacement tree icon
|
||||
* for mac ensures stable rendering when using Vaqua with non-standard swing components. Without
|
||||
* this, some sizing calculations within non-standard components may fail or become unreliable.
|
||||
* </p>
|
||||
*/
|
||||
private class MacTreeIcon implements Icon {
|
||||
private final int SIZE = 12;
|
||||
private final boolean isOpen;
|
||||
|
||||
/**
|
||||
* Create a new tree icon.
|
||||
*
|
||||
* @param newIsOpen Flag indicating if the icon should be in the open or closed state at
|
||||
* construction. True if open false otherwise.
|
||||
*/
|
||||
public MacTreeIcon(boolean newIsOpen) {
|
||||
isOpen = newIsOpen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
g.setColor(Color.GRAY);
|
||||
|
||||
g.drawLine(x + SIZE / 2 - 3, y + SIZE / 2, x + SIZE / 2 + 3, y + SIZE / 2);
|
||||
|
||||
if (!isOpen) {
|
||||
g.drawLine(x + SIZE / 2, y + SIZE / 2 - 3, x + SIZE / 2, y + SIZE / 2 + 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -188,7 +188,8 @@ public class EditorConsole extends JScrollPane {
|
||||
StyleConstants.setBold(errStyle, font.isBold());
|
||||
StyleConstants.setItalic(errStyle, font.isItalic());
|
||||
|
||||
if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
|
||||
String lookAndFeel = UIManager.getLookAndFeel().getID();
|
||||
if (lookAndFeel.equals("Nimbus") || lookAndFeel.equals("VAqua")) {
|
||||
getViewport().setBackground(bgColor);
|
||||
consoleTextPane.setOpaque(false);
|
||||
consoleTextPane.setBackground(new Color(0, 0, 0, 0));
|
||||
|
||||
+4
-1
@@ -426,6 +426,7 @@
|
||||
<include name="app/lib/jna-platform.jar" />
|
||||
<include name="app/lib/ant.jar" />
|
||||
<include name="app/lib/ant-launcher.jar" />
|
||||
<include name="app/lib/VAqua7.jar" />
|
||||
</fileset>
|
||||
|
||||
<target name="build" description="Build Processing.">
|
||||
@@ -706,7 +707,8 @@
|
||||
copyright="© The Processing Foundation"
|
||||
shortVersion="${version}"
|
||||
version="${revision}"
|
||||
mainClassName="processing.app.BaseSplash">
|
||||
mainClassName="processing.app.BaseSplash"
|
||||
minimumSystemVersion="10.10.0">
|
||||
|
||||
<!-- The appbundler task needs a couple files (the Info.plist and
|
||||
anything else outside /jdk) from the full JDK, even though
|
||||
@@ -723,6 +725,7 @@
|
||||
<classpath file="../app/lib/jna-platform.jar" />
|
||||
<classpath file="../app/lib/ant.jar" />
|
||||
<classpath file="../app/lib/ant-launcher.jar" />
|
||||
<classpath file="../app/lib/VAqua7.jar" />
|
||||
|
||||
<!-- plus core.jar... note that this is no longer shared -->
|
||||
<classpath file="../core/library/core.jar" />
|
||||
|
||||
@@ -74,6 +74,7 @@ recent.count = 10
|
||||
|
||||
# Default to the native (AWT) file selector where possible
|
||||
chooser.files.native = true
|
||||
chooser.files.native.macosx = false # except on mac where it's broken
|
||||
|
||||
|
||||
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
@@ -167,6 +168,9 @@ editor.watcher.debug = false
|
||||
# The window of time (in milliseconds) in which a change won't be counted
|
||||
editor.watcher.window = 1500
|
||||
|
||||
# allow vaqua on mac
|
||||
editor.allow_vaqua = true
|
||||
|
||||
# Format and search engine to use for online queries
|
||||
search.format = https://google.com/search?q=%s
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<string>@@sketch@@</string>
|
||||
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.8.5</string>
|
||||
<string>10.10.0</string>
|
||||
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
@@ -61,7 +61,7 @@
|
||||
<array>
|
||||
@@jvm_options_list@@
|
||||
<string>-Xdock:icon=$APP_ROOT/Contents/Resources/sketch.icns</string>
|
||||
<string>-Djava.library.path=$APP_ROOT/Contents/Java</string>
|
||||
<string>-Djava.library.path=$APP_ROOT/Contents/Java</string>
|
||||
<string>-Dapple.laf.useScreenMenuBar=true</string>
|
||||
<string>-Dcom.apple.macos.use-file-dialog-packages=true</string>
|
||||
<string>-Dcom.apple.macos.useScreenMenuBar=true</string>
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
<pathelement location="../app/lib/apple.jar" />
|
||||
<pathelement location="../app/lib/jna.jar" />
|
||||
<pathelement location="../app/lib/jna-platform.jar" />
|
||||
<pathelement location="../app/lib/VAqua7.jar" />
|
||||
|
||||
<pathelement location="mode/antlr-4.7.2-complete.jar" />
|
||||
<pathelement location="mode/classpath-explorer-1.0.jar" />
|
||||
|
||||
@@ -610,7 +610,7 @@ public class VariableInspector extends JDialog {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
setForeground(tree.isEnabled() ? Color.BLACK : Color.GRAY);
|
||||
//setForeground(tree.isEnabled() ? Color.BLACK : Color.GRAY);
|
||||
|
||||
if (value instanceof VariableNode) {
|
||||
VariableNode var = (VariableNode) value;
|
||||
|
||||
Reference in New Issue
Block a user