Browse Source

Added RtL layout support for TitlePane.

Signed-off-by: weisj <weisj@arcor.de>
pull/27/head
weisj 5 years ago
parent
commit
155001b478
  1. 93
      src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkTitlePane.java
  2. 1
      src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties

93
src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkTitlePane.java

@ -676,46 +676,63 @@ public class DarkTitlePane extends JComponent {
int left = 0;
int right = 0;
if (leftToRight) {
if (windowIconButton != null) {
windowIconButton.setBounds(start, y, ICON_WIDTH, height);
start += ICON_WIDTH + PAD;
left = start;
}
if (menuBar != null) {
int menuWidth = getPreferredMenuSize().width;
Insets menuInsets = menuBar.getInsets();
menuBar.setBounds(start, y, menuWidth, height + menuInsets.bottom);
start += menuWidth + PAD;
left += menuWidth;
}
x = w;
if (closeButton != null) {
x -= BUTTON_WIDTH;
right += BUTTON_WIDTH;
closeButton.setBounds(x, y, BUTTON_WIDTH, height);
}
if (getWindowDecorationStyle() == JRootPane.FRAME) {
if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
if (minimizeButton != null && maximizeToggleButton.getParent() != null) {
x -= BUTTON_WIDTH;
right += BUTTON_WIDTH;
maximizeToggleButton.setBounds(x, y, BUTTON_WIDTH, height);
}
if (minimizeButton != null && minimizeButton.getParent() != null) {
x -= BUTTON_WIDTH;
right += BUTTON_WIDTH;
minimizeButton.setBounds(x, y, BUTTON_WIDTH, height);
}
if (windowIconButton != null) {
windowIconButton.setBounds(start, y, ICON_WIDTH, height);
start += ICON_WIDTH + PAD;
left = start;
}
if (menuBar != null) {
int menuWidth = getPreferredMenuSize().width;
Insets menuInsets = menuBar.getInsets();
menuBar.setBounds(start, y, menuWidth, height + menuInsets.bottom);
start += menuWidth + PAD;
left += menuWidth;
}
x = w;
if (closeButton != null) {
x -= BUTTON_WIDTH;
right += BUTTON_WIDTH;
closeButton.setBounds(x, y, BUTTON_WIDTH, height);
}
if (getWindowDecorationStyle() == JRootPane.FRAME) {
if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
if (maximizeToggleButton != null && maximizeToggleButton.getParent() != null) {
x -= BUTTON_WIDTH;
right += BUTTON_WIDTH;
maximizeToggleButton.setBounds(x, y, BUTTON_WIDTH, height);
}
if (minimizeButton != null && minimizeButton.getParent() != null) {
x -= BUTTON_WIDTH;
right += BUTTON_WIDTH;
minimizeButton.setBounds(x, y, BUTTON_WIDTH, height);
}
}
start = Math.max(start, PAD);
titleLabel.setBounds(start, 0, x - start - PAD, height);
JNIDecorations.updateValues(windowHandle, Scale.scaleWidth(left),
Scale.scaleWidth(right),
Scale.scaleHeight(height));
} else {
//Todo.
}
start = Math.max(start, PAD);
titleLabel.setBounds(start, 0, x - start - PAD, height);
if (!leftToRight) {
mirror(windowIconButton, w);
mirror(menuBar, w);
mirror(closeButton, w);
mirror(minimizeButton, w);
mirror(maximizeToggleButton, w);
mirror(titleLabel, w);
int tmp = left;
left = right;
right = tmp;
}
JNIDecorations.updateValues(windowHandle, Scale.scaleWidth(left),
Scale.scaleWidth(right),
Scale.scaleHeight(height));
}
private void mirror(final JComponent component, final int w) {
if (component != null) {
component.setLocation(w - component.getX() - component.getWidth(),
component.getY());
}
}

1
src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties

@ -118,7 +118,6 @@
%hyperlink = 589df6
####Misc####
#Todo Line Colors
%shadow = 000000
%glowFocus = 3e84c9
%glowFocusLine = 466D94

Loading…
Cancel
Save