diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 337ec2aba..f22d0c733 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -195,8 +195,9 @@ public class Base { // Set the look and feel before opening the window try { Platform.setLookAndFeel(); + Platform.setInterfaceZoom(); } catch (Exception e) { - Messages.loge("Could not set the Look & Feel", e); //$NON-NLS-1$ + Messages.loge("Error while setting up the interface", e); //$NON-NLS-1$ } boolean sketchbookPrompt = false; diff --git a/app/src/processing/app/BaseSplash.java b/app/src/processing/app/BaseSplash.java index 5dc125f6a..cc9364c9e 100644 --- a/app/src/processing/app/BaseSplash.java +++ b/app/src/processing/app/BaseSplash.java @@ -15,6 +15,7 @@ public class BaseSplash { SplashWindow.splash(splashFile.toURI().toURL(), hidpi); SplashWindow.invokeMain("processing.app.Base", args); SplashWindow.disposeSplash(); + } catch (Exception e) { e.printStackTrace(); // !@#!@$$! umm diff --git a/app/src/processing/app/Platform.java b/app/src/processing/app/Platform.java index abcbf5b6e..1e12dc733 100644 --- a/app/src/processing/app/Platform.java +++ b/app/src/processing/app/Platform.java @@ -3,7 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2012-15 The Processing Foundation + Copyright (c) 2012-20 The Processing Foundation Copyright (c) 2008-12 Ben Fry and Casey Reas This program is free software; you can redistribute it and/or modify @@ -75,7 +75,8 @@ public class Platform { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - static public boolean isInit() { + + static public boolean isAvailable() { return inst != null; } @@ -109,6 +110,16 @@ public class Platform { } + static public void setInterfaceZoom() throws Exception { + inst.setInterfaceZoom(); + } + + + static public float getSystemZoom() { + return inst == null ? 1 : inst.getSystemZoom(); + } + + static public File getSettingsFolder() throws Exception { return inst.getSettingsFolder(); } @@ -405,12 +416,4 @@ public class Platform { static public int unsetenv(String variable) { return inst.unsetenv(variable); } - - - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - static public float getSystemZoom() { - return inst.getSystemZoom(); - } - } diff --git a/app/src/processing/app/platform/DefaultPlatform.java b/app/src/processing/app/platform/DefaultPlatform.java index 702037d36..6cba3b164 100644 --- a/app/src/processing/app/platform/DefaultPlatform.java +++ b/app/src/processing/app/platform/DefaultPlatform.java @@ -23,22 +23,17 @@ package processing.app.platform; -import java.awt.Color; -import java.awt.Component; import java.awt.Desktop; import java.awt.Font; -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 processing.app.Base; -import processing.app.Platform; import processing.app.Preferences; import processing.app.ui.Toolkit; @@ -91,7 +86,6 @@ public class DefaultPlatform { Base base; - private final float ZOOM_DEFAULT_SIZING = 1; public void initBase(Base base) { this.base = base; @@ -112,24 +106,14 @@ public class DefaultPlatform { public void setLookAndFeel() throws Exception { String laf = Preferences.get("editor.laf"); if (laf == null || laf.length() == 0) { // normal situation - if (Platform.isMacOS() && Preferences.getBoolean("editor.laf.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()); - } + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } else { UIManager.setLookAndFeel(laf); } + } + + public void setInterfaceZoom() throws Exception { // Specify font when scaling is active. if (!Preferences.getBoolean("editor.zoom.auto")) { for (String widgetName : FONT_SCALING_WIDGETS) { @@ -245,39 +229,10 @@ public class DefaultPlatform { * 125% (25% additional zoom). */ public float getSystemZoom() { - return ZOOM_DEFAULT_SIZING; + return 1; } - /** - * Spacer icon for mac when using Vaqua. - * - *
- * 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. - *
- */ - 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) {} - } /** * Set the default font for the widget by the given name. @@ -290,58 +245,12 @@ public class DefaultPlatform { String fontPropertyName = name + ".font"; Font currentFont = (Font) UIManager.get(fontPropertyName); - System.out.println(currentFont); +// System.out.println(currentFont); float newSize = Toolkit.zoom(currentFont.getSize()); - System.out.println(newSize); +// System.out.println(newSize); Font newFont = currentFont.deriveFont(newSize); - System.out.println(newFont); +// System.out.println(newFont); UIManager.put(fontPropertyName, newFont); } - - /** - * Replacement tree icon for mac when using Vaqua. - * - *- * 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. - *
- */ - 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); - } - } - } - } diff --git a/app/src/processing/app/platform/MacPlatform.java b/app/src/processing/app/platform/MacPlatform.java index 659b0d723..d5eb731da 100644 --- a/app/src/processing/app/platform/MacPlatform.java +++ b/app/src/processing/app/platform/MacPlatform.java @@ -22,17 +22,23 @@ 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.io.FileNotFoundException; import java.io.IOException; import java.net.URI; +import javax.swing.Icon; import javax.swing.JMenu; import javax.swing.JMenuBar; +import javax.swing.UIManager; import processing.app.Base; import processing.app.Messages; +import processing.app.Preferences; import processing.app.ui.About; @@ -96,6 +102,24 @@ public class MacPlatform extends DefaultPlatform { } + @Override + public void setLookAndFeel() throws Exception { + super.setLookAndFeel(); + + String laf = Preferences.get("editor.laf"); + if ("org.violetlib.aqua.AquaLookAndFeel".equals(laf)) { + Icon collapse = new VAquaTreeIcon(true); + Icon open = new VAquaTreeIcon(false); + Icon leaf = new VAquaEmptyIcon(); + 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); + } + } + + public File getSettingsFolder() throws Exception { return new File(getLibraryFolder(), "Processing"); } @@ -173,4 +197,80 @@ public class MacPlatform extends DefaultPlatform { return FileManager.findFolder(kUserDomain, kDocumentsFolderType); } */ + + + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + // VAQUA WORKAROUNDS FROM SAM + + + /** + * Spacer icon for macOS when using Vaqua. + + * 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. + */ + class VAquaEmptyIcon implements Icon { + private final int SIZE = 1; + + @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 macOS when using Vaqua. + * + * Due to potential rendering issues with the regular tree icon set, + * this replacement tree icon for macOS 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. + */ + private class VAquaTreeIcon 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 VAquaTreeIcon(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); + } + } + } } diff --git a/app/src/processing/app/platform/WindowsPlatform.java b/app/src/processing/app/platform/WindowsPlatform.java index 2bc33f6fc..433381ea6 100644 --- a/app/src/processing/app/platform/WindowsPlatform.java +++ b/app/src/processing/app/platform/WindowsPlatform.java @@ -636,14 +636,15 @@ public class WindowsPlatform extends DefaultPlatform { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + public float getSystemZoom() { if (cachedDisplayScaling.isEmpty()) { cachedDisplayScaling = Optional.of(calculateSystemZoom()); } - return cachedDisplayScaling.get(); } + private float calculateSystemZoom() { WinDef.HDC hdc = GDI32.INSTANCE.CreateCompatibleDC(null); @@ -659,5 +660,4 @@ public class WindowsPlatform extends DefaultPlatform { return logicalResolution / virtualResolution; } - } diff --git a/build/shared/lib/defaults.txt b/build/shared/lib/defaults.txt index ed13dd7f8..d40b5c2f8 100644 --- a/build/shared/lib/defaults.txt +++ b/build/shared/lib/defaults.txt @@ -239,8 +239,8 @@ editor.untitled.suffix=yyMMdd # is to do a Synth LAF that gives us something not awful. editor.laf.linux = javax.swing.plaf.nimbus.NimbusLookAndFeel -# enable/disable vaqua on mac -editor.laf.vaqua = false +# use this to enable the VAqua Look and Feel (may be removed later) +#editor.laf.macosx = org.violetlib.aqua.AquaLookAndFeel # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/core/todo.txt b/core/todo.txt index e5830b37b..f0c0cce89 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -23,6 +23,8 @@ _ Complaints that size() is not working _ Windows: https://github.com/processing/processing/issues/6046 _ Linux: https://github.com/processing/processing/issues/5912 +_ why does GL flash red when resizing? + _ JDK 11.0.7+ workarounds/hacks in place, fix them _ https://github.com/processing/processing4/issues/124 diff --git a/java/src/processing/mode/java/preproc/PreprocessIssueMessageSimplifier.java b/java/src/processing/mode/java/preproc/PreprocessIssueMessageSimplifier.java index 39ab6d6ff..4e112d161 100644 --- a/java/src/processing/mode/java/preproc/PreprocessIssueMessageSimplifier.java +++ b/java/src/processing/mode/java/preproc/PreprocessIssueMessageSimplifier.java @@ -81,7 +81,7 @@ public class PreprocessIssueMessageSimplifier { String errStr; String retStr; - if (Platform.isInit()) { + if (Platform.isAvailable()) { errStr = Language.text("editor.status.error.syntax"); retStr = Language.text(stringName); } else { diff --git a/todo.txt b/todo.txt index 2a8fd6ca0..930761665 100755 --- a/todo.txt +++ b/todo.txt @@ -29,6 +29,9 @@ X install Java 11 should link to OpenJDK site X set minimum version on Windows, fix JDK download URL o 'Basics' folder always open in examples list X couldn't reproduce on another machine +X Platform cleanup +X get rid of editor.laf.vaqua +X move macOS code out of DefaultPlatform and into MacPlatform contribs X Updates and fixes for PDE_pt.properties (Portugese translation) @@ -48,6 +51,12 @@ X automate notarization in the build process X https://github.com/processing/processing4/issues/24 +_ getSystemZoom() not available to splash screen +_ https://github.com/processing/processing4/issues/145 +_ move all platform code out that doesn't require additional setup? +_ i.e. all the things that rely on preferences can be inited separately (later) + + already fixed in 4.x? (confirm/close on release) _ HDPI support GNOME desktop _ https://github.com/processing/processing/issues/6059