Skip to content

Commit

Permalink
RootPane: Added logging for size calculations.
Browse files Browse the repository at this point in the history
[MacOS] TitlePane: Added logging for decorations installation.
  • Loading branch information
weisJ committed Mar 2, 2021
1 parent 29fe875 commit 53ebf4e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
public static final String KEY_UNIFIED_MENUBAR = KEY_PREFIX + "unifiedMenuBar";
protected static final String[] borderKeys = new String[] {"RootPane.border", "RootPane.frameBorder",
"RootPane.plainDialogBorder", "RootPane.informationDialogBorder", "RootPane.errorDialogBorder",
"RootPane.colorChooserDialogBorder", "RootPane.fileChooserDialogBorder", "RootPane.questionDialogBorder",
"RootPane.warningDialogBorder"};
"RootPane.colorChooserDialogBorder", "RootPane.fileChooserDialogBorder",
"RootPane.questionDialogBorder", "RootPane.warningDialogBorder"};

private Window window;
private CustomTitlePane titlePane;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,23 @@
package com.github.weisj.darklaf.ui.rootpane;

import java.awt.*;
import java.util.logging.Logger;

import javax.swing.*;

import com.github.weisj.darklaf.platform.DecorationsHandler;
import com.github.weisj.darklaf.platform.decorations.CustomTitlePane;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.LogUtil;

/**
* @author Konstantin Bulenkov
* @author Jannis Weis
*/
class DarkSubstanceRootLayout implements LayoutManager2 {

private static final Logger LOGGER = LogUtil.getLogger(DarkSubstanceRootLayout.class);

@Override
public void addLayoutComponent(final String name, final Component comp) {}

Expand Down Expand Up @@ -62,6 +66,7 @@ public Dimension preferredLayoutSize(final Container parent) {
} else {
cpd = root.getSize();
}
LOGGER.finer("[PrefSize] JRootPane content size: " + cpd);
if (cpd != null) {
cpWidth = cpd.width;
cpHeight = cpd.height;
Expand All @@ -81,6 +86,7 @@ public Dimension preferredLayoutSize(final Container parent) {
tpWidth = tpd.width;
tpHeight = tpd.height;
}
LOGGER.finer("[PrefSize] JRootPane titlePane size: " + tpd);
}

return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
Expand All @@ -97,12 +103,14 @@ public Dimension minimumLayoutSize(final Container parent) {
int tpHeight = 0;
Insets i = parent.getInsets();
JRootPane root = (JRootPane) parent;
CustomTitlePane titlePane = getTitlePane(root);

if (root.getContentPane() != null) {
cpd = root.getContentPane().getMinimumSize();
} else {
cpd = root.getSize();
}
LOGGER.finer("[MinSize] JRootPane content size: " + cpd);
if (cpd != null) {
cpWidth = cpd.width;
cpHeight = cpd.height;
Expand All @@ -115,15 +123,14 @@ public Dimension minimumLayoutSize(final Container parent) {
mbHeight = mbd.height;
}
}
if ((root.getWindowDecorationStyle() != JRootPane.NONE) && (root.getUI() instanceof DarkRootPaneUI)) {
JComponent titlePane = ((DarkRootPaneUI) root.getUI()).getTitlePane();
if (titlePane != null) {
tpd = titlePane.getMinimumSize();
if (tpd != null) {
tpWidth = tpd.width;
tpHeight = tpd.height;
}

if (titlePane != null) {
tpd = titlePane.getMinimumSize();
if (tpd != null) {
tpWidth = tpd.width;
tpHeight = tpd.height;
}
LOGGER.finer("[MinSize] JRootPane titlePane size: " + tpd);
}

return new Dimension(Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
package com.github.weisj.darklaf.platform.macos.ui;

import java.awt.*;
import java.util.logging.Logger;

import javax.swing.*;

import com.github.weisj.darklaf.platform.macos.JNIDecorationsMacOS;
import com.github.weisj.darklaf.util.LogUtil;
import com.github.weisj.darklaf.util.PropertyUtil;
import com.github.weisj.darklaf.util.SystemInfo;

public final class MacOSDecorationsUtil {

private static final Logger LOGGER = LogUtil.getLogger(MacOSDecorationsUtil.class);
private static final String FULL_WINDOW_CONTENT_KEY = "apple.awt.fullWindowContent";
private static final String TRANSPARENT_TITLE_BAR_KEY = "apple.awt.transparentTitleBar";

Expand All @@ -42,6 +45,7 @@ protected static DecorationInformation installDecorations(final JRootPane rootPa
if (windowHandle == 0) {
return new DecorationInformation(0, false, false, false, false, rootPane, false, 0, 0);
}
LOGGER.fine("Installing decorations for window " + windowHandle);
JNIDecorationsMacOS.retainWindow(windowHandle);
boolean fullWindowContent = isFullWindowContentEnabled(rootPane);
boolean transparentTitleBar = isTransparentTitleBarEnabled(rootPane);
Expand Down

0 comments on commit 53ebf4e

Please sign in to comment.