Browse Source

Moved remaining windows specific code to darklaf-windows.

Signed-off-by: weisj <weisj@arcor.de>
pull/48/head
weisj 5 years ago
parent
commit
990e748c1e
  1. 3
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java
  2. 5
      core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java
  3. 8
      core/src/main/java/com/github/weisj/darklaf/platform/JNIDecorations.java
  4. 26
      core/src/main/java/com/github/weisj/darklaf/theme/Theme.java
  5. 2
      core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java
  6. 3
      core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java
  7. 11
      core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java
  8. 0
      core/src/main/resources/com/github/weisj/darklaf/icons/frame/closeActive.svg
  9. 16
      core/src/main/resources/com/github/weisj/darklaf/icons/frame/frame.svg
  10. 0
      core/src/main/resources/com/github/weisj/darklaf/icons/frame/help.svg
  11. 4
      core/src/main/resources/com/github/weisj/darklaf/icons/frame/helpInactive.svg
  12. 0
      core/src/main/resources/com/github/weisj/darklaf/icons/frame/maximize.svg
  13. 0
      core/src/main/resources/com/github/weisj/darklaf/icons/frame/minimize.svg
  14. 0
      core/src/main/resources/com/github/weisj/darklaf/icons/frame/restore.svg
  15. 12
      core/src/main/resources/com/github/weisj/darklaf/icons/window/frame.svg
  16. 0
      core/src/main/resources/com/github/weisj/darklaf/properties/icons/frame.properties
  17. 31
      core/src/main/resources/com/github/weisj/darklaf/properties/platform/windows.properties
  18. 2
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties
  19. 12
      core/src/main/resources/com/github/weisj/darklaf/properties/ui/internalFrame.properties
  20. 9
      core/src/test/java/ui/button/ButtonDemo.java
  21. 4
      core/src/test/java/ui/internalFrame/DemoInternalFrame.java
  22. 4
      core/src/test/java/ui/internalFrame/InternalFrameDemo.java
  23. 3
      native-utils/src/main/java/com/github/weisj/darklaf/decorations/CustomTitlePane.java
  24. 2
      native-utils/src/main/java/com/github/weisj/darklaf/decorations/JNIDecorationsProvider.java
  25. 18
      native-utils/src/main/java/com/github/weisj/darklaf/platform/SystemInfo.java
  26. 39
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/CloseButtonUI.java
  27. 45
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/DarkTitlePaneWindows.java
  28. 10
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/ScaledIcon.java
  29. 2
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/TitlePaneIcon.java
  30. 4
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsDecorationsProvider.java
  31. 0
      windows/src/main/resources/com/github/weisj/darklaf/icons/duke.svg
  32. 12
      windows/src/main/resources/com/github/weisj/darklaf/icons/windows/closeActive.svg
  33. 4
      windows/src/main/resources/com/github/weisj/darklaf/icons/windows/closeHover.svg
  34. 4
      windows/src/main/resources/com/github/weisj/darklaf/icons/windows/closeInactive.svg
  35. 10
      windows/src/main/resources/com/github/weisj/darklaf/icons/windows/maximize.svg
  36. 4
      windows/src/main/resources/com/github/weisj/darklaf/icons/windows/maximizeInactive.svg
  37. 9
      windows/src/main/resources/com/github/weisj/darklaf/icons/windows/minimize.svg
  38. 5
      windows/src/main/resources/com/github/weisj/darklaf/icons/windows/minimizeInactive.svg
  39. 15
      windows/src/main/resources/com/github/weisj/darklaf/icons/windows/restore.svg
  40. 4
      windows/src/main/resources/com/github/weisj/darklaf/icons/windows/restoreInactive.svg
  41. 51
      windows/src/main/resources/com/github/weisj/darklaf/properties/platform/windows_decorations.properties
  42. 36
      windows/src/main/resources/com/github/weisj/darklaf/properties/platform/windows_icons.properties

3
core/src/main/java/com/github/weisj/darklaf/DarkLaf.java

@ -24,7 +24,7 @@
package com.github.weisj.darklaf;
import com.github.weisj.darklaf.components.border.DarkBorders;
import com.github.weisj.darklaf.decorations.JNIDecorations;
import com.github.weisj.darklaf.platform.JNIDecorations;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
@ -167,6 +167,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
currentTheme.loadUIProperties(uiProps, defaults);
currentTheme.loadIconProperties(uiProps, defaults);
currentTheme.loadPlatformProperties(uiProps, defaults);
currentTheme.loadDecorationProperties(uiProps, defaults);
adjustPlatformSpecifics(uiProps);
defaults.putAll(uiProps);

5
core/src/main/java/com/github/weisj/darklaf/decorations/DefaultDecorationsProvider.java → core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java

@ -21,9 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf.decorations;
package com.github.weisj.darklaf.platform;
import com.github.weisj.darklaf.ui.rootpane.CustomTitlePane;
import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.decorations.JNIDecorationsProvider;
import javax.swing.*;

8
core/src/main/java/com/github/weisj/darklaf/decorations/JNIDecorations.java → core/src/main/java/com/github/weisj/darklaf/platform/JNIDecorations.java

@ -21,11 +21,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf.decorations;
package com.github.weisj.darklaf.platform;
import com.github.weisj.darklaf.decorations.windows.WindowsDecorationsProvider;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.ui.rootpane.CustomTitlePane;
import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.decorations.JNIDecorationsProvider;
import com.github.weisj.darklaf.platform.windows.ui.WindowsDecorationsProvider;
import javax.swing.*;

26
core/src/main/java/com/github/weisj/darklaf/theme/Theme.java

@ -25,8 +25,8 @@ package com.github.weisj.darklaf.theme;
import com.github.weisj.darklaf.DarkLaf;
import com.github.weisj.darklaf.DarkMetalTheme;
import com.github.weisj.darklaf.util.PropertyLoader;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.util.PropertyLoader;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
@ -53,7 +53,7 @@ public abstract class Theme {
"toggleButton", "toolBar", "toolTip", "tree",
};
private static final String[] ICON_PROPERTIES = new String[]{
"control", "dialog", "files", "indicator", "menu", "misc", "navigation", "window"
"control", "dialog", "files", "frame", "indicator", "menu", "misc", "navigation"
};
public UIManager.LookAndFeelInfo createLookAndFeelInfo() {
@ -135,9 +135,27 @@ public abstract class Theme {
* @param currentDefaults the current ui defaults.
*/
public void loadPlatformProperties(final Properties properties, final UIDefaults currentDefaults) {
final String osPrefix = SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux";
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, osPrefix, "properties/platform/"),
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, getOsName(), "properties/platform/"),
properties, currentDefaults);
}
/**
* Load the platform defaults.
*
* @param properties the properties to load the values into.
* @param currentDefaults the current ui defaults.
*/
public void loadDecorationProperties(final Properties properties, final UIDefaults currentDefaults) {
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, getOsName() + "_decorations",
"properties/platform/"),
properties, currentDefaults);
PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, getOsName() + "_icons",
"properties/platform/"),
properties, currentDefaults);
}
private String getOsName() {
return SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux";
}
/**

2
core/src/main/java/com/github/weisj/darklaf/ui/internalframe/DarkInternalFrameTitlePane.java

@ -23,8 +23,8 @@
*/
package com.github.weisj.darklaf.ui.internalframe;
import com.github.weisj.darklaf.decorations.windows.TitlePaneIcon;
import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.platform.windows.ui.TitlePaneIcon;
import sun.swing.SwingUtilities2;
import javax.accessibility.AccessibleContext;

3
core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java

@ -24,7 +24,8 @@
package com.github.weisj.darklaf.ui.rootpane;
import com.github.weisj.darklaf.decorations.JNIDecorations;
import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.platform.JNIDecorations;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;

11
core/src/main/java/com/github/weisj/darklaf/util/ImageUtil.java

@ -154,17 +154,6 @@ public final class ImageUtil {
}
public static BufferedImage createImage(final int width, final int height, final int type) {
return new BufferedImage(Scale.scaleWidth(width), Scale.scaleHeight(height), type) {
@Override
public Graphics2D createGraphics() {
Graphics2D g = super.createGraphics();
g.scale(Scale.SCALE_X, Scale.SCALE_Y);
return g;
}
};
}
public static BufferedImage createCompatibleTranslucentImage(final int width,
final int height) {
return isHeadless() ?

0
core/src/main/resources/com/github/weisj/darklaf/icons/window/closeActive.svg → core/src/main/resources/com/github/weisj/darklaf/icons/frame/closeActive.svg

Before

Width:  |  Height:  |  Size: 592 B

After

Width:  |  Height:  |  Size: 592 B

16
core/src/main/resources/com/github/weisj/darklaf/icons/frame/frame.svg

@ -0,0 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.frame.color">
<stop offset="0" stop-color="#AFB1B3"/>
<stop offset="1" stop-color="#AFB1B3"/>
</linearGradient>
</defs>
<g fill="none" fill-rule="evenodd">
<rect fill="url(#Icons.frame.color)" x="2" y="2" width="10" height="1"/>
<rect fill="url(#Icons.frame.color)" x="2" y="2" width="1" height="10"/>
<rect fill="url(#Icons.frame.color)" x="4" y="4" width="1" height="10"/>
<rect fill="url(#Icons.frame.color)" x="4" y="4" width="10" height="1"/>
<rect fill="url(#Icons.frame.color)" x="4" y="13" width="10" height="1"/>
<rect fill="url(#Icons.frame.color)" x="13" y="4" width="1" height="10"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 841 B

0
core/src/main/resources/com/github/weisj/darklaf/icons/window/help.svg → core/src/main/resources/com/github/weisj/darklaf/icons/frame/help.svg

Before

Width:  |  Height:  |  Size: 643 B

After

Width:  |  Height:  |  Size: 643 B

4
core/src/main/resources/com/github/weisj/darklaf/icons/window/helpInactive.svg → core/src/main/resources/com/github/weisj/darklaf/icons/frame/helpInactive.svg

@ -1,11 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.windowHelpInactive.color">
<linearGradient id="Windows.Icons.windowHelpInactive.color">
<stop offset="0" stop-color="#8C8C8C"/>
<stop offset="1" stop-color="#8C8C8C"/>
</linearGradient>
</defs>
<g fill="url(#Icons.windowHelpInactive.color)" fill-rule="evenodd" transform="translate(5 2)">
<g fill="url(#Windows.Icons.windowHelpInactive.color)" fill-rule="evenodd" transform="translate(5 2)">
<path d="M3,0 C0,0 0,2.914678 0,3 C0.666666667,3 1,3 1,3 C1,3 1,1 3,1 C4.1569301,1 5,1.74285714 5,3 C5,5.28571429 2,4.0625 2,8 L3,8 C3,4.625 6,6 6,3 C6,1.58081633 5,0 3,0 Z"/>
<rect width="1" height="1" x="2" y="10"/>
</g>

Before

Width:  |  Height:  |  Size: 659 B

After

Width:  |  Height:  |  Size: 675 B

0
core/src/main/resources/com/github/weisj/darklaf/icons/window/maximize.svg → core/src/main/resources/com/github/weisj/darklaf/icons/frame/maximize.svg

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 461 B

0
core/src/main/resources/com/github/weisj/darklaf/icons/window/minimize.svg → core/src/main/resources/com/github/weisj/darklaf/icons/frame/minimize.svg

Before

Width:  |  Height:  |  Size: 419 B

After

Width:  |  Height:  |  Size: 419 B

0
core/src/main/resources/com/github/weisj/darklaf/icons/window/restore.svg → core/src/main/resources/com/github/weisj/darklaf/icons/frame/restore.svg

Before

Width:  |  Height:  |  Size: 672 B

After

Width:  |  Height:  |  Size: 672 B

12
core/src/main/resources/com/github/weisj/darklaf/icons/window/frame.svg

@ -1,12 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.frame.color">
<stop offset="0" stop-color="#AFB1B3"/>
<stop offset="1" stop-color="#AFB1B3"/>
</linearGradient>
</defs>
<g fill="none" fill-rule="evenodd">
<path fill="url(#Icons.frame.color)" d="M5,3 L15,3 L15,13 L5,13 L5,3 Z M7,5 L7,11 L13,11 L13,5 L7,5 Z"/>
<path fill="url(#Icons.frame.color)" d="M12,2 L4,2 L4,10 L2,10 L2,0 L12,0 L12,2 Z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 559 B

0
core/src/main/resources/com/github/weisj/darklaf/properties/icons/window.properties → core/src/main/resources/com/github/weisj/darklaf/properties/icons/frame.properties

31
core/src/main/resources/com/github/weisj/darklaf/properties/platform/windows.properties

@ -21,37 +21,8 @@
#SOFTWARE.
#
# suppress inspection "UnusedProperty" for whole file
#TitlePane
TitlePane.minimize.icon = window/minimize.svg[themed]
TitlePane.minimizeInactive.icon = window/minimizeInactive.svg[themed]
TitlePane.maximize.icon = window/maximize.svg[themed]
TitlePane.maximizeInactive.icon = window/maximizeInactive.svg[themed]
TitlePane.restore.icon = window/restore.svg[themed]
TitlePane.restoreInactive.icon = window/restoreInactive.svg[themed]
TitlePane.close.icon = window/closeActive.svg[themed]
TitlePane.closeInactive.icon = window/closeInactive.svg[themed]
TitlePane.closeHover.icon = window/closeHover.svg[themed]
TitlePane.close.clickColor = F1707A
TitlePane.close.rollOverColor = E81123
TitlePane.icon = duke.svg
TitlePane.borderColor = %borderSecondary
TitlePane.background = %background
TitlePane.foreground = %textForegroundSecondary
TitlePane.inactiveBackground = %background
TitlePane.inactiveForeground = %textForegroundInactive
OptionPane.errorDialog.titlePane.background = %background
OptionPane.errorDialog.titlePane.foreground = %textForeground
OptionPane.questionDialog.titlePane.background = %background
OptionPane.questionDialog.titlePane.foreground = %textForeground
OptionPane.warningDialog.titlePane.background = %background
OptionPane.warningDialog.titlePane.foreground = %textForeground
FileChooser.listViewWindowsStyle = true
Table.alternateRowColor = false
Tree.alternateRowColor = false
List.alternateRowColor = false
List.alternateRowColor = false

2
core/src/main/resources/com/github/weisj/darklaf/properties/ui/button.properties

@ -58,4 +58,4 @@ Button.fullShadowInsets = 0,0,0,0
Button.shadow.hover = %hoverHighlight
Button.shadow.click = %clickHighlight
defaultButtonFollowFocus = false
Button.defaultButtonFollowFocus = false

12
core/src/main/resources/com/github/weisj/darklaf/properties/ui/internalFrame.properties

@ -51,9 +51,9 @@ DesktopIcon.clickColor = %backgroundHoverSecondary
desktop = %backgroundColorful
#Icons
InternalFrame.icon = duke.svg
InternalFrameTitlePane.close.icon = window/closeActive.svg[themed]
InternalFrameTitlePane.minimize.icon = window/restore.svg[themed]
InternalFrameTitlePane.maximize.icon = window/maximize.svg[themed]
InternalFrameTitlePane.iconify.icon = window/minimize.svg[themed]
DesktopIcon.drag.icon = navigation/horizontalGrip.svg[themed](5,20)
InternalFrame.icon = frame/frame.svg[themed]
InternalFrameTitlePane.close.icon = frame/closeActive.svg[themed]
InternalFrameTitlePane.minimize.icon = frame/restore.svg[themed]
InternalFrameTitlePane.maximize.icon = frame/maximize.svg[themed]
InternalFrameTitlePane.iconify.icon = frame/minimize.svg[themed]
DesktopIcon.drag.icon = navigation/horizontalGrip.svg[themed](5,20)

9
core/src/test/java/ui/button/ButtonDemo.java

@ -96,12 +96,9 @@ public class ButtonDemo implements ComponentDemo {
(b, c) -> button.putClientProperty("JButton.shadow.hover", b ? c : null)));
controlPanel.add(new QuickColorChooser("JButton.shadow.click", Color.BLACK,
(b, c) -> button.putClientProperty("JButton.shadow.click", b ? c : null)));
controlPanel.add(new JCheckBox("defaultButtonFollowsFocus") {{
setSelected(true);
addActionListener(e -> {
UIManager.put("Button.defaultButtonFollowsFocus", isSelected());
button.getRootPane().setDefaultButton(null);
});
controlPanel.add(new JCheckBox("Button.defaultButtonFollowsFocus") {{
setSelected(UIManager.getBoolean("Button.defaultButtonFollowsFocus"));
addActionListener(e -> UIManager.put("Button.defaultButtonFollowsFocus", isSelected()));
}});
return panel;
}

4
core/src/test/java/ui/internalFrame/MyInternalFrame.java → core/src/test/java/ui/internalFrame/DemoInternalFrame.java

@ -25,11 +25,11 @@ package ui.internalFrame;
import javax.swing.*;
public class MyInternalFrame extends JInternalFrame {
public class DemoInternalFrame extends JInternalFrame {
private static final int xOffset = 30, yOffset = 30;
private static int openFrameCount = 0;
public MyInternalFrame() {
public DemoInternalFrame() {
super("Document #" + (++openFrameCount), true, true, true, true);
setSize(300, 300);
setLocation(xOffset * openFrameCount, yOffset * openFrameCount);

4
core/src/test/java/ui/internalFrame/InternalFrameDemo.java

@ -106,7 +106,7 @@ public class InternalFrameDemo extends JFrame implements ActionListener {
//Create a new internal frame.
private void createFrame() {
MyInternalFrame frame = new MyInternalFrame();
DemoInternalFrame frame = new DemoInternalFrame();
frame.setVisible(true);
desktop.add(frame);
try {
@ -129,4 +129,4 @@ public class InternalFrameDemo extends JFrame implements ActionListener {
private void quit() {
System.exit(0);
}
}
}

3
core/src/main/java/com/github/weisj/darklaf/ui/rootpane/CustomTitlePane.java → native-utils/src/main/java/com/github/weisj/darklaf/decorations/CustomTitlePane.java

@ -21,12 +21,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf.ui.rootpane;
package com.github.weisj.darklaf.decorations;
import javax.swing.*;
public abstract class CustomTitlePane extends JComponent {
public abstract void uninstall();
}

2
core/src/main/java/com/github/weisj/darklaf/decorations/JNIDecorationsProvider.java → native-utils/src/main/java/com/github/weisj/darklaf/decorations/JNIDecorationsProvider.java

@ -23,8 +23,6 @@
*/
package com.github.weisj.darklaf.decorations;
import com.github.weisj.darklaf.ui.rootpane.CustomTitlePane;
import javax.swing.*;
public interface JNIDecorationsProvider {

18
native-utils/src/main/java/com/github/weisj/darklaf/platform/SystemInfo.java

@ -23,12 +23,15 @@
*/
package com.github.weisj.darklaf.platform;
import java.awt.*;
import java.util.logging.Logger;
import java.util.regex.Pattern;
/**
* @author Konstantin Bulenkov
*/
public class SystemInfo {
public static final double SCALE;
public static final String X86 = "32";
public static final String X64 = "64";
public static final String OS_NAME = System.getProperty("os.name");
@ -49,6 +52,9 @@ public class SystemInfo {
public static final boolean isX64;
public static final boolean isUndefined;
protected static final String _OS_NAME;
public static final double SCALE_X;
public static final double SCALE_Y;
private static final Logger LOGGER = Logger.getLogger(SystemInfo.class.getName());
static {
_OS_NAME = OS_NAME.toLowerCase();
@ -64,10 +70,12 @@ public class SystemInfo {
isX64 = X64.equals(jreArchitecture);
isX86 = X86.equals(jreArchitecture);
isUndefined = !isX86 & !isX64;
}
public SystemInfo() {
DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
SCALE_X = mode.getWidth() / (double) screenSize.width;
SCALE_Y = mode.getHeight() / (double) screenSize.height;
SCALE = SCALE_X;
LOGGER.fine("Using screen scaling SCALE_X=" + SCALE_X + ", SCALE_Y=" + SCALE_Y);
}
public static boolean isOsVersionAtLeast(final String version) {
@ -133,7 +141,7 @@ public class SystemInfo {
return vendor != null && containsIgnoreCase(vendor, "Apple");
}
private static boolean containsIgnoreCase(String text, String pattern) {
private static boolean containsIgnoreCase(final String text, final String pattern) {
return Pattern.compile(pattern, Pattern.LITERAL | Pattern.CASE_INSENSITIVE)
.matcher(text).find();
}

39
core/src/main/java/com/github/weisj/darklaf/decorations/windows/CloseButtonUI.java → windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/CloseButtonUI.java

@ -21,17 +21,20 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf.decorations.windows;
import com.github.weisj.darklaf.ui.button.DarkButtonUI;
package com.github.weisj.darklaf.platform.windows.ui;
import javax.swing.*;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.*;
/**
* @author Jannis Weis
*/
public class CloseButtonUI extends DarkButtonUI {
public class CloseButtonUI extends BasicButtonUI {
protected static final Rectangle viewRect = new Rectangle();
protected static final Rectangle textRect = new Rectangle();
protected static final Rectangle iconRect = new Rectangle();
protected Color closeHover;
protected Color closeClick;
@ -43,8 +46,34 @@ public class CloseButtonUI extends DarkButtonUI {
closeClick = UIManager.getColor("TitlePane.close.clickColor");
}
protected String layout(final AbstractButton b, final JComponent c, final FontMetrics fm,
final int width, final int height) {
Insets i = b.getInsets();
viewRect.x = i.left;
viewRect.y = i.top;
viewRect.width = width - (i.right + viewRect.x);
viewRect.height = height - (i.bottom + viewRect.y);
textRect.x = textRect.y = textRect.width = textRect.height = 0;
iconRect.x = iconRect.y = iconRect.width = iconRect.height = 0;
// layout the text and icon
return SwingUtilities.layoutCompoundLabel(
b, fm, b.getText(), b.getIcon(),
b.getVerticalAlignment(), b.getHorizontalAlignment(),
b.getVerticalTextPosition(), b.getHorizontalTextPosition(),
viewRect, iconRect, textRect,
b.getText() == null ? 0 : b.getIconTextGap());
}
@Override
protected Color getShadowColor(final AbstractButton c) {
public void paint(final Graphics g, final JComponent c) {
g.setColor(getBackground((AbstractButton) c));
g.fillRect(0, 0, c.getWidth(), c.getHeight());
paintIcon(g, c, iconRect);
}
protected Color getBackground(final AbstractButton c) {
return c.getModel().isArmed() ? closeClick : closeHover;
}
}

45
core/src/main/java/com/github/weisj/darklaf/decorations/windows/DarkTitlePaneWindows.java → windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/DarkTitlePaneWindows.java

@ -22,13 +22,11 @@
* SOFTWARE.
*/
package com.github.weisj.darklaf.decorations.windows;
package com.github.weisj.darklaf.platform.windows.ui;
import com.github.weisj.darklaf.decorators.AncestorAdapter;
import com.github.weisj.darklaf.icons.ScaledIcon;
import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.platform.windows.JNIDecorationsWindows;
import com.github.weisj.darklaf.ui.rootpane.CustomTitlePane;
import com.github.weisj.darklaf.util.Scale;
import sun.awt.SunToolkit;
import javax.accessibility.AccessibleContext;
@ -89,7 +87,7 @@ public class DarkTitlePaneWindows extends CustomTitlePane {
private Action minimizeAction;
private JLabel titleLabel;
private Window window;
private final AncestorListener ancestorListener = new AncestorAdapter() {
private final AncestorListener ancestorListener = new AncestorListener() {
@Override
public void ancestorAdded(final AncestorEvent event) {
if (window != null) {
@ -103,6 +101,14 @@ public class DarkTitlePaneWindows extends CustomTitlePane {
});
}
}
@Override
public void ancestorRemoved(final AncestorEvent event) {
}
@Override
public void ancestorMoved(final AncestorEvent event) {
}
};
private long windowHandle;
private JMenuBar menuBar;
@ -149,16 +155,10 @@ public class DarkTitlePaneWindows extends CustomTitlePane {
private static JButton createButton(final String accessibleName, final Icon icon, final Action action,
final boolean close) {
JButton button;
JButton button = new JButton();
if (close) {
button = new JButton() {
@Override
public void updateUI() {
}
};
button.setUI(new CloseButtonUI());
} else {
button = new JButton();
button.putClientProperty("JButton.shadow.hover", UIManager.getColor("TitlePane.close.rollOverColor"));
button.putClientProperty("JButton.shadow.click", UIManager.getColor("TitlePane.close.clickColor"));
}
button.setFocusable(false);
button.setOpaque(true);
@ -574,12 +574,12 @@ public class DarkTitlePaneWindows extends CustomTitlePane {
if (icons.size() == 0) {
systemIcon = UIManager.getIcon("TitlePane.icon");
} else if (icons.size() == 1) {
systemIcon = new ScaledIcon(icons.get(0).getScaledInstance(Scale.scaleWidth(ICON_SIZE),
Scale.scaleHeight(ICON_SIZE),
systemIcon = new ScaledIcon(icons.get(0).getScaledInstance((int) (SystemInfo.SCALE_X * ICON_SIZE),
(int) (SystemInfo.SCALE_Y * ICON_SIZE),
Image.SCALE_AREA_AVERAGING));
} else {
systemIcon = new ScaledIcon(SunToolkit.getScaledIconImage(icons, Scale.scaleWidth(ICON_SIZE),
Scale.scaleHeight(ICON_SIZE))
systemIcon = new ScaledIcon(SunToolkit.getScaledIconImage(icons, (int) (SystemInfo.SCALE_X * ICON_SIZE),
(int) (SystemInfo.SCALE_Y * ICON_SIZE))
);
}
if (windowIconButton != null) {
@ -712,9 +712,10 @@ public class DarkTitlePaneWindows extends CustomTitlePane {
right = tmp;
}
JNIDecorationsWindows.updateValues(windowHandle, Scale.scaleWidth(left),
Scale.scaleWidth(right),
Scale.scaleHeight(height));
JNIDecorationsWindows.updateValues(windowHandle,
(int) (SystemInfo.SCALE_X * left),
(int) (SystemInfo.SCALE_X * right),
(int) (SystemInfo.SCALE_Y * height));
}

10
core/src/main/java/com/github/weisj/darklaf/icons/ScaledIcon.java → windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/ScaledIcon.java

@ -21,9 +21,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf.icons;
package com.github.weisj.darklaf.platform.windows.ui;
import com.github.weisj.darklaf.util.Scale;
import com.github.weisj.darklaf.platform.SystemInfo;
import javax.swing.*;
import java.awt.*;
@ -41,17 +41,17 @@ public class ScaledIcon implements Icon {
public void paintIcon(final Component c, final Graphics g2, final int x, final int y) {
Graphics2D g = (Graphics2D) g2;
g.translate(x, y);
g.scale(1.0 / Scale.SCALE_X, 1.0 / Scale.SCALE_Y);
g.scale(1.0 / SystemInfo.SCALE_X, 1.0 / SystemInfo.SCALE_Y);
g.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null);
}
@Override
public int getIconWidth() {
return (int) (img.getWidth(null) / Scale.SCALE_X);
return (int) (img.getWidth(null) / SystemInfo.SCALE_X);
}
@Override
public int getIconHeight() {
return (int) (img.getHeight(null) / Scale.SCALE_Y);
return (int) (img.getHeight(null) / SystemInfo.SCALE_Y);
}
}

2
core/src/main/java/com/github/weisj/darklaf/decorations/windows/TitlePaneIcon.java → windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/TitlePaneIcon.java

@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf.decorations.windows;
package com.github.weisj.darklaf.platform.windows.ui;
import javax.swing.*;
import java.awt.*;

4
core/src/main/java/com/github/weisj/darklaf/decorations/windows/WindowsDecorationsProvider.java → windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsDecorationsProvider.java

@ -21,11 +21,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.github.weisj.darklaf.decorations.windows;
package com.github.weisj.darklaf.platform.windows.ui;
import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.decorations.JNIDecorationsProvider;
import com.github.weisj.darklaf.platform.windows.JNIDecorationsWindows;
import com.github.weisj.darklaf.ui.rootpane.CustomTitlePane;
import javax.swing.*;

0
core/src/main/resources/com/github/weisj/darklaf/icons/duke.svg → windows/src/main/resources/com/github/weisj/darklaf/icons/duke.svg

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

12
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/closeActive.svg

@ -0,0 +1,12 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Windows.Icons.windowClose.color">
<stop offset="0" stop-color="#A9A9A9"/>
<stop offset="1" stop-color="#A9A9A9"/>
</linearGradient>
</defs>
<g fill="url(#Windows.Icons.windowClose.color)" fill-rule="evenodd" transform="translate(3 3)">
<rect width="13" height="1" x="-1.5" y="4.5" transform="rotate(45 5 5)"/>
<rect width="13" height="1" x="-1.5" y="4.5" transform="scale(-1 1) rotate(45 0 -7.071)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 608 B

4
core/src/main/resources/com/github/weisj/darklaf/icons/window/closeHover.svg → windows/src/main/resources/com/github/weisj/darklaf/icons/windows/closeHover.svg

@ -1,11 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.windowCloseHover.color">
<linearGradient id="Windows.Icons.windowCloseHover.color">
<stop offset="0" stop-color="#FFF"/>
<stop offset="1" stop-color="#FFF"/>
</linearGradient>
</defs>
<g fill="url(#Icons.windowCloseHover.color)" fill-rule="evenodd" transform="translate(3 3)">
<g fill="url(#Windows.Icons.windowCloseHover.color)" fill-rule="evenodd" transform="translate(3 3)">
<rect width="13" height="1" x="-1.5" y="4.5" transform="rotate(45 5 5)"/>
<rect width="13" height="1" x="-1.5" y="4.5" transform="scale(-1 1) rotate(45 0 -7.071)"/>
</g>

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 612 B

4
core/src/main/resources/com/github/weisj/darklaf/icons/window/closeInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/icons/windows/closeInactive.svg

@ -1,11 +1,11 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.windowCloseInactive.color">
<linearGradient id="Windows.Icons.windowCloseInactive.color">
<stop offset="0" stop-color="#8C8C8C"/>
<stop offset="1" stop-color="#8C8C8C"/>
</linearGradient>
</defs>
<g fill="url(#Icons.windowCloseInactive.color)" fill-rule="evenodd" transform="translate(3 3)">
<g fill="url(#Windows.Icons.windowCloseInactive.color)" fill-rule="evenodd" transform="translate(3 3)">
<rect width="13" height="1" x="-1.5" y="4.5" transform="rotate(45 5 5)"/>
<rect width="13" height="1" x="-1.5" y="4.5" transform="scale(-1 1) rotate(45 0 -7.071)"/>
</g>

Before

Width:  |  Height:  |  Size: 608 B

After

Width:  |  Height:  |  Size: 624 B

10
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/maximize.svg

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Windows.Icons.windowMaximize.color">
<stop offset="0" stop-color="#A9A9A9"/>
<stop offset="1" stop-color="#A9A9A9"/>
</linearGradient>
</defs>
<path fill="url(#Windows.Icons.windowMaximize.color)" fill-rule="evenodd"
d="M3,3 L13,3 L13,13 L3,13 L3,3 Z M4,4 L4,12 L12,12 L12,4 L4,4 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 477 B

4
core/src/main/resources/com/github/weisj/darklaf/icons/window/maximizeInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/icons/windows/maximizeInactive.svg

@ -1,10 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.windowMaximizeInactive.color">
<linearGradient id="Windows.Icons.windowMaximizeInactive.color">
<stop offset="0" stop-color="#8C8C8C"/>
<stop offset="1" stop-color="#8C8C8C"/>
</linearGradient>
</defs>
<path fill="url(#Icons.windowMaximizeInactive.color)" fill-rule="evenodd"
<path fill="url(#Windows.Icons.windowMaximizeInactive.color)" fill-rule="evenodd"
d="M3,3 L13,3 L13,13 L3,13 L3,3 Z M4,4 L4,12 L12,12 L12,4 L4,4 Z"/>
</svg>

Before

Width:  |  Height:  |  Size: 477 B

After

Width:  |  Height:  |  Size: 493 B

9
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/minimize.svg

@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Windows.Icons.windowMinimize.color">
<stop offset="0" stop-color="#A9A9A9"/>
<stop offset="1" stop-color="#A9A9A9"/>
</linearGradient>
</defs>
<rect width="10" height="1" x="3" y="8" fill="url(#Windows.Icons.windowMinimize.color)" fill-rule="evenodd"/>
</svg>

After

Width:  |  Height:  |  Size: 435 B

5
core/src/main/resources/com/github/weisj/darklaf/icons/window/minimizeInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/icons/windows/minimizeInactive.svg

@ -1,9 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.windowMinimizeInactive.color">
<linearGradient id="Windows.Icons.windowMinimizeInactive.color">
<stop offset="0" stop-color="#8C8C8C"/>
<stop offset="1" stop-color="#8C8C8C"/>
</linearGradient>
</defs>
<rect width="10" height="1" x="3" y="8" fill="url(#Icons.windowMinimizeInactive.color)" fill-rule="evenodd"/>
<rect width="10" height="1" x="3" y="8" fill="url(#Windows.Icons.windowMinimizeInactive.color)"
fill-rule="evenodd"/>
</svg>

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 461 B

15
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/restore.svg

@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Windows.Icons.windowRestore.color">
<stop offset="0" stop-color="#A9A9A9"/>
<stop offset="1" stop-color="#A9A9A9"/>
</linearGradient>
</defs>
<g fill="none" fill-rule="evenodd">
<path fill="url(#Windows.Icons.windowRestore.color)"
d="M5,8 L5,7 L7,7 L7,1 L1,1 L1,3 L0,3 L0,0 L8,0 L8,8 L5,8 Z"
transform="translate(5 3)"/>
<path fill="url(#Icons.windowRestore.color)" d="M0,0 L8,0 L8,8 L0,8 L0,0 Z M1,1 L1,7 L7,7 L7,1 L1,1 Z"
transform="translate(3 5)"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 702 B

4
core/src/main/resources/com/github/weisj/darklaf/icons/window/restoreInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/icons/windows/restoreInactive.svg

@ -1,12 +1,12 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<defs id="colors">
<linearGradient id="Icons.windowRestoreInactive.color">
<linearGradient id="Windows.Icons.windowRestoreInactive.color">
<stop offset="0" stop-color="#8C8C8C"/>
<stop offset="1" stop-color="#8C8C8C"/>
</linearGradient>
</defs>
<g fill="none" fill-rule="evenodd">
<path fill="url(#Icons.windowRestoreInactive.color)"
<path fill="url(#Windows.Icons.windowRestoreInactive.color)"
d="M5,8 L5,7 L7,7 L7,1 L1,1 L1,3 L0,3 L0,0 L8,0 L8,8 L5,8 Z"
transform="translate(5 3)"/>
<path fill="url(#Icons.windowRestoreInactive.color)" d="M0,0 L8,0 L8,8 L0,8 L0,0 Z M1,1 L1,7 L7,7 L7,1 L1,1 Z"

Before

Width:  |  Height:  |  Size: 710 B

After

Width:  |  Height:  |  Size: 726 B

51
windows/src/main/resources/com/github/weisj/darklaf/properties/platform/windows_decorations.properties

@ -0,0 +1,51 @@
#MIT License
#
#Copyright (c) 2020 Jannis Weis
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all
#copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.
#
# suppress inspection "UnusedProperty" for whole file
#TitlePane
TitlePane.minimize.icon = windows/minimize.svg[themed]
TitlePane.minimizeInactive.icon = windows/minimizeInactive.svg[themed]
TitlePane.maximize.icon = windows/maximize.svg[themed]
TitlePane.maximizeInactive.icon = windows/maximizeInactive.svg[themed]
TitlePane.restore.icon = windows/restore.svg[themed]
TitlePane.restoreInactive.icon = windows/restoreInactive.svg[themed]
TitlePane.close.icon = windows/closeActive.svg[themed]
TitlePane.closeInactive.icon = windows/closeInactive.svg[themed]
TitlePane.closeHover.icon = windows/closeHover.svg[themed]
TitlePane.close.clickColor = F1707A
TitlePane.close.rollOverColor = E81123
TitlePane.icon = duke.svg
TitlePane.borderColor = %borderSecondary
TitlePane.background = %background
TitlePane.foreground = %textForegroundSecondary
TitlePane.inactiveBackground = %background
TitlePane.inactiveForeground = %textForegroundInactive
OptionPane.errorDialog.titlePane.background = %background
OptionPane.errorDialog.titlePane.foreground = %textForeground
OptionPane.questionDialog.titlePane.background = %background
OptionPane.questionDialog.titlePane.foreground = %textForeground
OptionPane.warningDialog.titlePane.background = %background
OptionPane.warningDialog.titlePane.foreground = %textForeground

36
windows/src/main/resources/com/github/weisj/darklaf/properties/platform/windows_icons.properties

@ -0,0 +1,36 @@
# suppress inspection "UnusedProperty" for whole file
#
# MIT License
#
# Copyright (c) 2020 Jannis Weis
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
Windows.Icons.windowClose.color = %windowButton
Windows.Icons.windowCloseHover.color = %windowCloseHovered
Windows.Icons.windowCloseInactive.color = %windowButtonDisabled
Windows.Icons.windowMaximize.color = %windowButton
Windows.Icons.windowMaximizeInactive.color = %windowButtonDisabled
Windows.Icons.windowMinimize.color = %windowButton
Windows.Icons.windowMinimizeInactive.color = %windowButtonDisabled
Windows.Icons.windowRestore.color = %windowButton
Windows.Icons.windowRestoreInactive.color = %windowButtonDisabled
Loading…
Cancel
Save