From: Ben Soares Date: Mon, 16 Jan 2023 23:21:25 +0000 (+0000) Subject: JAL-3416 More tweaking of FlatLaf. Problem with macOS themed FlatLaf solved with... X-Git-Tag: Release_2_11_3_0~23^2~4^2~3 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=9b3bed72df9fa38b8f8007b87a019356d55a030b;p=jalview.git JAL-3416 More tweaking of FlatLaf. Problem with macOS themed FlatLaf solved with new DesktopManager --- diff --git a/j11lib/VAqua5-patch.jar b/j11lib/VAqua5-patch.jar deleted file mode 100644 index 7b5c27b..0000000 Binary files a/j11lib/VAqua5-patch.jar and /dev/null differ diff --git a/j11lib/quaqua-filechooser-only-8.0.jar b/j11lib/quaqua-filechooser-only-8.0.jar deleted file mode 100644 index 182e0da..0000000 Binary files a/j11lib/quaqua-filechooser-only-8.0.jar and /dev/null differ diff --git a/j8lib/VAqua5-patch.jar b/j8lib/VAqua5-patch.jar deleted file mode 100644 index 7b5c27b..0000000 Binary files a/j8lib/VAqua5-patch.jar and /dev/null differ diff --git a/j8lib/quaqua-filechooser-only-8.0.jar b/j8lib/quaqua-filechooser-only-8.0.jar deleted file mode 100644 index 182e0da..0000000 Binary files a/j8lib/quaqua-filechooser-only-8.0.jar and /dev/null differ diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 9472fb3..071d700 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -45,6 +45,8 @@ import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.JDialog; +import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; @@ -52,6 +54,7 @@ import javax.swing.UIManager.LookAndFeelInfo; import javax.swing.UnsupportedLookAndFeelException; import com.formdev.flatlaf.FlatLightLaf; +import com.formdev.flatlaf.themes.FlatMacLightLaf; import com.formdev.flatlaf.util.SystemInfo; import com.threerings.getdown.util.LaunchUtil; @@ -1010,20 +1013,6 @@ public class Jalview Console.error("Could not set requested laf=" + laf); } break; - case "quaqua": - lafSet = setQuaquaLookAndFeel(); - if (!lafSet) - { - Console.error("Could not set requested laf=" + laf); - } - break; - case "vaqua": - lafSet = setVaquaLookAndFeel(); - if (!lafSet) - { - Console.error("Could not set requested laf=" + laf); - } - break; case "mac": lafSet = setMacLookAndFeel(); if (!lafSet) @@ -1133,60 +1122,102 @@ public class Jalview private static boolean setFlatLookAndFeel() { boolean set = false; - if (Platform.isMac()) + if (SystemInfo.isMacOS) { try { - UIManager.setLookAndFeel( - "com.formdev.flatlaf.themes.FlatMacLightLaf"); + UIManager.setLookAndFeel("com.formdev.flatlaf.FlatMacLightLaf"); set = true; - Console.debug("*** Loaded FlatMacLightLaf"); + Console.debug("Using FlatMacLightLaf"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { - Console.debug("Exception loading FlatMacLightLaf", e); + Console.debug("Exception loading FlatLightLaf", e); + } + System.setProperty("apple.laf.useScreenMenuBar", "true"); + System.setProperty("apple.awt.application.name", + ChannelProperties.getProperty("app_name")); + System.setProperty("apple.awt.application.appearance", "system"); + if (SystemInfo.isMacFullWindowContentSupported + && Desktop.desktop != null) + { + Console.debug("Setting transparent title bar"); + Desktop.desktop.getRootPane() + .putClientProperty("apple.awt.fullWindowContent", true); + Desktop.desktop.getRootPane() + .putClientProperty("apple.awt.transparentTitleBar", true); + Desktop.desktop.getRootPane() + .putClientProperty("apple.awt.fullscreenable", true); } + SwingUtilities.invokeLater(() -> { + FlatMacLightLaf.setup(); + }); + Console.debug("Using FlatMacLightLaf"); + set = true; } - if (!set) + else if (SystemInfo.isWindows) { try { UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); set = true; - Console.debug("*** Loaded FlatLightLaf"); + Console.debug("Using FlatLightLaf"); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { Console.debug("Exception loading FlatLightLaf", e); } + // Windows specific properties here + SwingUtilities.invokeLater(() -> { + FlatLightLaf.setup(); + }); + Console.debug("Using FlatLightLaf"); + set = true; } - if (set) + else if (SystemInfo.isLinux) { - if (Platform.isMac()) + try { - System.setProperty("apple.laf.useScreenMenuBar", "true"); - System.setProperty("apple.awt.application.name", - ChannelProperties.getProperty("app_name")); - System.setProperty("apple.awt.application.appearance", "system"); - if (SystemInfo.isMacFullWindowContentSupported - && Desktop.desktop != null) - { - Console.debug("Setting transparent title bar"); - Desktop.desktop.getRootPane() - .putClientProperty("apple.awt.fullWindowContent", true); - Desktop.desktop.getRootPane() - .putClientProperty("apple.awt.transparentTitleBar", true); - } + UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); + set = true; + Console.debug("Using FlatLightLaf"); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) + { + Console.debug("Exception loading FlatLightLaf", e); + } + // enable custom window decorations + JFrame.setDefaultLookAndFeelDecorated(true); + JDialog.setDefaultLookAndFeelDecorated(true); + SwingUtilities.invokeLater(() -> { + FlatLightLaf.setup(); + }); + Console.debug("Using FlatLightLaf"); + set = true; + } - SwingUtilities.invokeLater(() -> { - FlatLightLaf.setup(); - }); + if (!set) + { + try + { + UIManager.setLookAndFeel("com.formdev.flatlaf.FlatLightLaf"); + set = true; + Console.debug("Using FlatLightLaf"); + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException | UnsupportedLookAndFeelException e) + { + Console.debug("Exception loading FlatLightLaf", e); } + } + if (set) + { + UIManager.put("TabbedPane.tabType", "card"); UIManager.put("TabbedPane.showTabSeparators", true); + UIManager.put("TabbedPane.showContentSeparator", true); UIManager.put("TabbedPane.tabSeparatorsFullHeight", true); UIManager.put("TabbedPane.tabsOverlapBorder", true); - // UIManager.put("TabbedPane.hasFullBorder", true); + UIManager.put("TabbedPane.hasFullBorder", true); UIManager.put("TabbedPane.tabLayoutPolicy", "scroll"); UIManager.put("TabbedPane.scrollButtonsPolicy", "asNeeded"); UIManager.put("TabbedPane.smoothScrolling", true); @@ -1198,20 +1229,6 @@ public class Jalview return set; } - private static boolean setQuaquaLookAndFeel() - { - return setSpecificLookAndFeel("quaqua", - ch.randelshofer.quaqua.QuaquaManager.getLookAndFeel().getClass() - .getName(), - false); - } - - private static boolean setVaquaLookAndFeel() - { - return setSpecificLookAndFeel("vaqua", - "org.violetlib.aqua.AquaLookAndFeel", false); - } - private static boolean setMacLookAndFeel() { boolean set = false; diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 6a67148..35c36fc 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -502,11 +502,15 @@ public class Desktop extends jalview.jbgui.GDesktop // This line prevents Windows Look&Feel resizing all new windows to maximum // if previous window was maximised desktop.setDesktopManager(new MyDesktopManager( - (Platform.isWindowsAndNotJS() ? new DefaultDesktopManager() + /* + (Platform.isWindowsAndNotJS() ? new DefaultDesktopManager() + : Platform.isAMacAndNotJS() ? new AquaInternalFrameManager( desktop.getDesktopManager()) : desktop.getDesktopManager()))); + */ + new DefaultDesktopManager())); Rectangle dims = getLastKnownDimensions(""); if (dims != null)