diff --git a/fireplace-app/src/main/java/io/github/bric3/fireplace/AppearanceControl.java b/fireplace-app/src/main/java/io/github/bric3/fireplace/AppearanceControl.java index 4ea0c48e..12284a95 100644 --- a/fireplace-app/src/main/java/io/github/bric3/fireplace/AppearanceControl.java +++ b/fireplace-app/src/main/java/io/github/bric3/fireplace/AppearanceControl.java @@ -5,6 +5,7 @@ import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.extras.FlatAnimatedLafChange; import com.formdev.flatlaf.util.SystemInfo; +import com.github.weisj.darklaf.platform.DecorationsConstants; import com.github.weisj.darklaf.platform.decorations.DecorationsColorProvider; import com.github.weisj.darklaf.platform.decorations.ExternalLafDecorator; import com.github.weisj.darklaf.platform.preferences.SystemPreferencesManager; @@ -53,6 +54,8 @@ static void install(JFrame frame) { rootPane.putClientProperty("apple.awt.fullWindowContent", true); // makes the title bar transparent rootPane.putClientProperty("apple.awt.transparentTitleBar", true); + // hide window title + rootPane.putClientProperty(DecorationsConstants.KEY_HIDE_TITLE, false); } ExternalLafDecorator.instance().install(); @@ -81,6 +84,10 @@ public TitleColor windowTitleColor() { INSTANCE.start(); } + static Rectangle getWindowButtonsRect(JFrame frame){ + return ExternalLafDecorator.instance().decorationsManager().titlePaneLayoutInfo(frame).windowButtonRect(); + } + private static void setGlobalProperties(String title) { if (SystemInfo.isLinux) { // most linux distros have ugly font rendering, but these here can fix that: diff --git a/fireplace-app/src/main/java/io/github/bric3/fireplace/FirePlaceMain.java b/fireplace-app/src/main/java/io/github/bric3/fireplace/FirePlaceMain.java index 5b31a141..f5850b80 100644 --- a/fireplace-app/src/main/java/io/github/bric3/fireplace/FirePlaceMain.java +++ b/fireplace-app/src/main/java/io/github/bric3/fireplace/FirePlaceMain.java @@ -113,9 +113,6 @@ private static void initUI(JFRBinder jfrBinder, List cliPaths) { } var topPanel = new JPanel(new BorderLayout()); - if (SystemInfo.isMacOS) { - openedFileLabel.setBorder(BorderFactory.createEmptyBorder(30, 5, 5, 5)); - } topPanel.add(openedFileLabel, BorderLayout.CENTER); topPanel.add(AppearanceControl.getComponent(), BorderLayout.EAST); @@ -138,8 +135,6 @@ private static void initUI(JFRBinder jfrBinder, List cliPaths) { JfrFilesDropHandler.install(jfrBinder::load, appLayers, hudPanel.getDnDTarget()); var frame = new JFrame("FirePlace"); - - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(new Dimension(1000, 600)); frame.getContentPane().add(appLayers); @@ -161,6 +156,17 @@ public void windowOpened(WindowEvent e) { AppearanceControl.install(frame); frame.setVisible(true); + + + if (SystemInfo.isMacOS) { + var windowButtonsRect = AppearanceControl.getWindowButtonsRect(frame); + openedFileLabel.setBorder(BorderFactory.createEmptyBorder( + 5, + windowButtonsRect.x + windowButtonsRect.width + 5, + 5, + 5 + )); + } }); }