Browse Source

Merge pull request #48 from weisJ/modules

Make darklaf-windows self contained.
pull/52/head
Jannis Weis 5 years ago committed by GitHub
parent
commit
2a30eb9e1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      core/build.gradle.kts
  2. 3
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java
  3. 8
      core/src/main/java/com/github/weisj/darklaf/LafManager.java
  4. 2
      core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java
  5. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java
  6. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java
  7. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContent.java
  8. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java
  9. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopup.java
  10. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTab.java
  11. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java
  12. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java
  13. 2
      core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameUI.java
  14. 2
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/DarkToolTip.java
  15. 2
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java
  16. 2
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareButton.java
  17. 2
      core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareToggleButton.java
  18. 5
      core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java
  19. 7
      core/src/main/java/com/github/weisj/darklaf/platform/JNIDecorations.java
  20. 2
      core/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java
  21. 17
      core/src/main/java/com/github/weisj/darklaf/theme/Theme.java
  22. 4
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java
  23. 8
      core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java
  24. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java
  25. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java
  26. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java
  27. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java
  28. 8
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java
  29. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java
  30. 16
      core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java
  31. 2
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java
  32. 8
      core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java
  33. 3
      core/src/test/java/icon/AllIcons.java
  34. 2
      core/src/test/java/ui/tabFrame/TabFrameDemo.java
  35. 2
      core/src/test/java/ui/toolTip/ToolTipDemo.java
  36. 10
      native-utils/src/main/java/com/github/weisj/darklaf/decorations/JNIDecorationsProvider.java
  37. 12
      native-utils/src/main/java/com/github/weisj/darklaf/platform/SystemInfo.java
  38. 9
      property-loader/build.gradle.kts
  39. 38
      property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java
  40. 29
      property-loader/src/main/java/com/github/weisj/darklaf/icons/AwareIconStyle.java
  41. 0
      property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java
  42. 14
      property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkUIAwareIcon.java
  43. 0
      property-loader/src/main/java/com/github/weisj/darklaf/icons/EmptyIcon.java
  44. 9
      property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java
  45. 29
      property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java
  46. 0
      property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java
  47. 0
      property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIcon.java
  48. 2
      property-loader/src/main/java/com/github/weisj/darklaf/icons/RotatableIcon.java
  49. 12
      property-loader/src/main/java/com/github/weisj/darklaf/icons/ScaledIcon.java
  50. 8
      property-loader/src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java
  51. 2
      property-loader/src/main/java/com/github/weisj/darklaf/icons/UIAwareIcon.java
  52. 4
      settings.gradle.kts
  53. 3
      utils/build.gradle.kts
  54. 4
      utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java
  55. 2
      utils/src/main/java/com/github/weisj/darklaf/util/AlignmentHelper.java
  56. 1
      utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java
  57. 0
      utils/src/main/java/com/github/weisj/darklaf/util/Pair.java
  58. 5
      utils/src/main/java/com/github/weisj/darklaf/util/Scale.java
  59. 0
      utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java
  60. 2
      windows/build.gradle.kts
  61. 18
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java
  62. 79
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/CloseButtonUI.java
  63. 17
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/DarkTitlePaneWindows.java
  64. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/duke.svg
  65. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeActive.svg
  66. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeHover.svg
  67. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeInactive.svg
  68. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximize.svg
  69. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximizeInactive.svg
  70. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimize.svg
  71. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimizeInactive.svg
  72. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restore.svg
  73. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restoreInactive.svg
  74. 50
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_decorations.properties
  75. 0
      windows/src/main/resources/com/github/weisj/darklaf/platform/windows/windows_icons.properties
  76. 51
      windows/src/main/resources/com/github/weisj/darklaf/properties/platform/windows_decorations.properties

5
core/build.gradle.kts

@ -9,11 +9,12 @@ plugins {
dependencies { dependencies {
implementation(project(":darklaf-native-utils")) implementation(project(":darklaf-native-utils"))
implementation(project(":darklaf-utils"))
implementation(project(":darklaf-windows")) implementation(project(":darklaf-windows"))
implementation("com.formdev:svgSalamander") implementation(project(":darklaf-property-loader"))
implementation("net.java.dev.jna:jna")
implementation("org.swinglabs:jxlayer") implementation("org.swinglabs:jxlayer")
compileOnly("org.swinglabs:swingx") compileOnly("org.swinglabs:swingx")
testImplementation("com.formdev:svgSalamander")
testImplementation("org.swinglabs:swingx") testImplementation("org.swinglabs:swingx")
} }

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

@ -28,7 +28,6 @@ import com.github.weisj.darklaf.platform.JNIDecorations;
import com.github.weisj.darklaf.platform.SystemInfo; import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI; import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.util.PropertyLoader;
import sun.awt.AppContext; import sun.awt.AppContext;
import javax.swing.*; import javax.swing.*;
@ -167,7 +166,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
currentTheme.loadUIProperties(uiProps, defaults); currentTheme.loadUIProperties(uiProps, defaults);
currentTheme.loadIconProperties(uiProps, defaults); currentTheme.loadIconProperties(uiProps, defaults);
currentTheme.loadPlatformProperties(uiProps, defaults); currentTheme.loadPlatformProperties(uiProps, defaults);
currentTheme.loadDecorationProperties(uiProps, defaults); JNIDecorations.loadDecorationProperties(uiProps, defaults);
adjustPlatformSpecifics(uiProps); adjustPlatformSpecifics(uiProps);
defaults.putAll(uiProps); defaults.putAll(uiProps);

8
core/src/main/java/com/github/weisj/darklaf/LafManager.java

@ -23,6 +23,8 @@
*/ */
package com.github.weisj.darklaf; package com.github.weisj.darklaf;
import com.github.weisj.darklaf.icons.AwareIconStyle;
import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.theme.DarculaTheme; import com.github.weisj.darklaf.theme.DarculaTheme;
import com.github.weisj.darklaf.theme.IntelliJTheme; import com.github.weisj.darklaf.theme.IntelliJTheme;
import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.theme.Theme;
@ -110,7 +112,7 @@ public final class LafManager {
*/ */
public static Theme getTheme() { public static Theme getTheme() {
if (theme == null) { if (theme == null) {
theme = new IntelliJTheme(); setTheme(new IntelliJTheme());
} }
return theme; return theme;
} }
@ -122,6 +124,9 @@ public final class LafManager {
*/ */
public static void setTheme(final Theme theme) { public static void setTheme(final Theme theme) {
LafManager.theme = theme; LafManager.theme = theme;
IconLoader.updateAwareStyle(theme.useDarkIcons() ? AwareIconStyle.DARK
: AwareIconStyle.LIGHT);
IconLoader.updateThemeStatus(theme);
} }
@ -163,6 +168,7 @@ public final class LafManager {
*/ */
public static void install() { public static void install() {
try { try {
getTheme();
UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName()); UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName());
updateLaf(); updateLaf();
} catch (final ClassNotFoundException } catch (final ClassNotFoundException

2
core/src/main/java/com/github/weisj/darklaf/components/border/BubbleBorder.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.components.border; package com.github.weisj.darklaf.components.border;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.GraphicsContext; import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil; import com.github.weisj.darklaf.util.GraphicsUtil;

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/JTabFrame.java

@ -23,8 +23,8 @@
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.ui.tabframe.TabFrameTransferHandler; import com.github.weisj.darklaf.ui.tabframe.TabFrameTransferHandler;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/PanelPopup.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContent.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import java.awt.*; import java.awt.*;

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameContentPane.java

@ -23,8 +23,8 @@
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.decorators.AncestorAdapter; import com.github.weisj.darklaf.decorators.AncestorAdapter;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorEvent;

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFramePopup.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTab.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import java.awt.*; import java.awt.*;

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabContainer.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameTabLabel.java

@ -23,9 +23,9 @@
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.icons.EmptyIcon; import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.ui.tabframe.DarkTabFrameTabLabelUI; import com.github.weisj.darklaf.ui.tabframe.DarkTabFrameTabLabelUI;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

2
core/src/main/java/com/github/weisj/darklaf/components/tabframe/TabFrameUI.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.components.tabframe; package com.github.weisj.darklaf.components.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import java.awt.*; import java.awt.*;

2
core/src/main/java/com/github/weisj/darklaf/components/tooltip/DarkToolTip.java

@ -23,9 +23,9 @@
*/ */
package com.github.weisj.darklaf.components.tooltip; package com.github.weisj.darklaf.components.tooltip;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.decorators.AncestorAdapter; import com.github.weisj.darklaf.decorators.AncestorAdapter;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder; import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.Animator; import com.github.weisj.darklaf.util.Animator;
import com.github.weisj.darklaf.util.GraphicsContext; import com.github.weisj.darklaf.util.GraphicsContext;

2
core/src/main/java/com/github/weisj/darklaf/components/tooltip/ToolTipContext.java

@ -23,9 +23,9 @@
*/ */
package com.github.weisj.darklaf.components.tooltip; package com.github.weisj.darklaf.components.tooltip;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.alignment.AlignmentStrategy; import com.github.weisj.darklaf.components.alignment.AlignmentStrategy;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder; import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import javax.swing.*; import javax.swing.*;

2
core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareButton.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.components.tooltip; package com.github.weisj.darklaf.components.tooltip;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

2
core/src/main/java/com/github/weisj/darklaf/components/tooltip/TooltipAwareToggleButton.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.components.tooltip; package com.github.weisj.darklaf.components.tooltip;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

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

@ -27,6 +27,7 @@ import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.decorations.JNIDecorationsProvider; import com.github.weisj.darklaf.decorations.JNIDecorationsProvider;
import javax.swing.*; import javax.swing.*;
import java.util.Properties;
public class DefaultDecorationsProvider implements JNIDecorationsProvider { public class DefaultDecorationsProvider implements JNIDecorationsProvider {
@Override @Override
@ -47,4 +48,8 @@ public class DefaultDecorationsProvider implements JNIDecorationsProvider {
public boolean updateLibrary() { public boolean updateLibrary() {
return false; return false;
} }
@Override
public void loadDecorationProperties(final Properties properties, final UIDefaults currentDefaults) {
}
} }

7
core/src/main/java/com/github/weisj/darklaf/platform/JNIDecorations.java

@ -25,9 +25,10 @@ package com.github.weisj.darklaf.platform;
import com.github.weisj.darklaf.decorations.CustomTitlePane; import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.decorations.JNIDecorationsProvider; import com.github.weisj.darklaf.decorations.JNIDecorationsProvider;
import com.github.weisj.darklaf.platform.windows.ui.WindowsDecorationsProvider; import com.github.weisj.darklaf.platform.windows.WindowsDecorationsProvider;
import javax.swing.*; import javax.swing.*;
import java.util.Properties;
public final class JNIDecorations { public final class JNIDecorations {
@ -54,4 +55,8 @@ public final class JNIDecorations {
public static boolean updateLibrary() { public static boolean updateLibrary() {
return decorationsProvider.updateLibrary(); return decorationsProvider.updateLibrary();
} }
public static void loadDecorationProperties(final Properties uiProps, final UIDefaults defaults) {
decorationsProvider.loadDecorationProperties(uiProps, defaults);
}
} }

2
core/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.theme; package com.github.weisj.darklaf.theme;
import com.github.weisj.darklaf.util.PropertyLoader; import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.platform.SystemInfo; import com.github.weisj.darklaf.platform.SystemInfo;
import javax.swing.*; import javax.swing.*;

17
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.DarkLaf;
import com.github.weisj.darklaf.DarkMetalTheme; import com.github.weisj.darklaf.DarkMetalTheme;
import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.platform.SystemInfo; import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.util.PropertyLoader;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel; import javax.swing.plaf.metal.MetalLookAndFeel;
@ -139,21 +139,6 @@ public abstract class Theme {
properties, currentDefaults); 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() { private String getOsName() {
return SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux"; return SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux";
} }

4
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SlideComponent.java

@ -24,8 +24,8 @@
package com.github.weisj.darklaf.ui.colorchooser; package com.github.weisj.darklaf.ui.colorchooser;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tooltip.ToolTipContext; import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.ColorUtil; import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
@ -311,4 +311,4 @@ class SlideComponent extends JComponent implements ColorListener {
return LEVEL.equals(unit) ? LEVEL_MAX_VALUE : PERCENT_MAX_VALUE; return LEVEL.equals(unit) ? LEVEL_MAX_VALUE : PERCENT_MAX_VALUE;
} }
} }
} }

8
core/src/main/java/com/github/weisj/darklaf/ui/colorchooser/SwatchPanel.java

@ -23,18 +23,14 @@
*/ */
package com.github.weisj.darklaf.ui.colorchooser; package com.github.weisj.darklaf.ui.colorchooser;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tooltip.ToolTipContext; import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsUtil; import com.github.weisj.darklaf.util.GraphicsUtil;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.FocusAdapter; import java.awt.event.*;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
/** /**
* @author Jannis Weis * @author Jannis Weis

2
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkPanelPopupUI.java

@ -23,13 +23,13 @@
*/ */
package com.github.weisj.darklaf.ui.tabframe; package com.github.weisj.darklaf.ui.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.border.MutableLineBorder; import com.github.weisj.darklaf.components.border.MutableLineBorder;
import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.PanelPopup; import com.github.weisj.darklaf.components.tabframe.PanelPopup;
import com.github.weisj.darklaf.components.tooltip.ToolTipContext; import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.components.uiresource.JLabelUIResource; import com.github.weisj.darklaf.components.uiresource.JLabelUIResource;
import com.github.weisj.darklaf.ui.panel.DarkPanelUI; import com.github.weisj.darklaf.ui.panel.DarkPanelUI;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import javax.swing.FocusManager; import javax.swing.FocusManager;

2
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameComponentPopupMenu.java

@ -24,9 +24,9 @@
package com.github.weisj.darklaf.ui.tabframe; package com.github.weisj.darklaf.ui.tabframe;
import com.github.weisj.darklaf.components.JXPopupMenu; import com.github.weisj.darklaf.components.JXPopupMenu;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.TabFrameTab; import com.github.weisj.darklaf.components.tabframe.TabFrameTab;
import com.github.weisj.darklaf.icons.EmptyIcon; import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;

2
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabContainerUI.java

@ -23,11 +23,11 @@
*/ */
package com.github.weisj.darklaf.ui.tabframe; package com.github.weisj.darklaf.ui.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.TabFrameTabContainer; import com.github.weisj.darklaf.components.tabframe.TabFrameTabContainer;
import com.github.weisj.darklaf.decorators.HoverListener; import com.github.weisj.darklaf.decorators.HoverListener;
import com.github.weisj.darklaf.ui.panel.DarkPanelUI; import com.github.weisj.darklaf.ui.panel.DarkPanelUI;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import javax.swing.*; import javax.swing.*;

2
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameTabLabelUI.java

@ -23,12 +23,12 @@
*/ */
package com.github.weisj.darklaf.ui.tabframe; package com.github.weisj.darklaf.ui.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.TabFrameTabLabel; import com.github.weisj.darklaf.components.tabframe.TabFrameTabLabel;
import com.github.weisj.darklaf.decorators.HoverListener; import com.github.weisj.darklaf.decorators.HoverListener;
import com.github.weisj.darklaf.icons.RotatableIcon; import com.github.weisj.darklaf.icons.RotatableIcon;
import com.github.weisj.darklaf.ui.label.DarkLabelUI; import com.github.weisj.darklaf.ui.label.DarkLabelUI;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;

8
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/DarkTabFrameUI.java

@ -23,14 +23,10 @@
*/ */
package com.github.weisj.darklaf.ui.tabframe; package com.github.weisj.darklaf.ui.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.border.MutableLineBorder; import com.github.weisj.darklaf.components.border.MutableLineBorder;
import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.*;
import com.github.weisj.darklaf.components.tabframe.PopupContainer;
import com.github.weisj.darklaf.components.tabframe.TabFramePopup;
import com.github.weisj.darklaf.components.tabframe.TabFrameTab;
import com.github.weisj.darklaf.components.tabframe.TabFrameUI;
import com.github.weisj.darklaf.components.uiresource.JPanelUIResource; import com.github.weisj.darklaf.components.uiresource.JPanelUIResource;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.Pair; import com.github.weisj.darklaf.util.Pair;
import org.jdesktop.jxlayer.JXLayer; import org.jdesktop.jxlayer.JXLayer;
import org.pbjar.jxlayer.plaf.ext.transform.DefaultTransformModel; import org.pbjar.jxlayer.plaf.ext.transform.DefaultTransformModel;

2
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameLayout.java

@ -23,9 +23,9 @@
*/ */
package com.github.weisj.darklaf.ui.tabframe; package com.github.weisj.darklaf.ui.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.TabFrameTab; import com.github.weisj.darklaf.components.tabframe.TabFrameTab;
import com.github.weisj.darklaf.util.Alignment;
import java.awt.*; import java.awt.*;
import java.util.Arrays; import java.util.Arrays;

16
core/src/main/java/com/github/weisj/darklaf/ui/tabframe/TabFrameTransferHandler.java

@ -23,11 +23,11 @@
*/ */
package com.github.weisj.darklaf.ui.tabframe; package com.github.weisj.darklaf.ui.tabframe;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.TabFramePopup; import com.github.weisj.darklaf.components.tabframe.TabFramePopup;
import com.github.weisj.darklaf.components.tabframe.TabFrameTab; import com.github.weisj.darklaf.components.tabframe.TabFrameTab;
import com.github.weisj.darklaf.components.tabframe.TabFrameUI; import com.github.weisj.darklaf.components.tabframe.TabFrameUI;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.ImageUtil; import com.github.weisj.darklaf.util.ImageUtil;
import javax.swing.*; import javax.swing.*;
@ -35,19 +35,7 @@ import java.awt.*;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DragGestureEvent; import java.awt.dnd.*;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragGestureRecognizer;
import java.awt.dnd.DragSource;
import java.awt.dnd.DragSourceContext;
import java.awt.dnd.DragSourceDragEvent;
import java.awt.dnd.DragSourceDropEvent;
import java.awt.dnd.DragSourceEvent;
import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DropTargetDragEvent;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent;
import java.awt.dnd.DropTargetListener;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;

2
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipBorder.java

@ -23,10 +23,10 @@
*/ */
package com.github.weisj.darklaf.ui.tooltip; package com.github.weisj.darklaf.ui.tooltip;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.border.BubbleBorder; import com.github.weisj.darklaf.components.border.BubbleBorder;
import com.github.weisj.darklaf.components.border.DropShadowBorder; import com.github.weisj.darklaf.components.border.DropShadowBorder;
import com.github.weisj.darklaf.components.tooltip.ToolTipStyle; import com.github.weisj.darklaf.components.tooltip.ToolTipStyle;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import javax.swing.*; import javax.swing.*;

8
core/src/main/java/com/github/weisj/darklaf/ui/tooltip/DarkTooltipUI.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.ui.tooltip; package com.github.weisj.darklaf.ui.tooltip;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil; import com.github.weisj.darklaf.util.DarkUIUtil;
import javax.swing.*; import javax.swing.*;
@ -32,11 +32,7 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicToolTipUI; import javax.swing.plaf.basic.BasicToolTipUI;
import javax.swing.text.View; import javax.swing.text.View;
import java.awt.*; import java.awt.*;
import java.awt.event.HierarchyEvent; import java.awt.event.*;
import java.awt.event.HierarchyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;

3
core/src/test/java/icon/AllIcons.java

@ -93,7 +93,8 @@ public class AllIcons {
for (File f : files) { for (File f : files) {
if (f.getName().endsWith(".svg")) { if (f.getName().endsWith(".svg")) {
int SIZE = 30; int SIZE = 30;
ThemedSVGIcon icon = (ThemedSVGIcon) IconLoader.get().loadSVGIcon(folder + "/" + f.getName(), SIZE, SIZE, true); ThemedSVGIcon icon = (ThemedSVGIcon) IconLoader.get().loadSVGIcon(folder + "/" + f.getName(),
SIZE, SIZE, true);
SVGIcon svgIcon = icon.getSVGIcon(); SVGIcon svgIcon = icon.getSVGIcon();
int autosize = svgIcon.getAutosize(); int autosize = svgIcon.getAutosize();
svgIcon.setAutosize(SVGIcon.AUTOSIZE_NONE); svgIcon.setAutosize(SVGIcon.AUTOSIZE_NONE);

2
core/src/test/java/ui/tabFrame/TabFrameDemo.java

@ -23,13 +23,13 @@
*/ */
package ui.tabFrame; package ui.tabFrame;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.JTabFrame; import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.TabbedPopup; import com.github.weisj.darklaf.components.tabframe.TabbedPopup;
import com.github.weisj.darklaf.components.text.NonWrappingTextPane; import com.github.weisj.darklaf.components.text.NonWrappingTextPane;
import com.github.weisj.darklaf.components.text.NumberedTextComponent; import com.github.weisj.darklaf.components.text.NumberedTextComponent;
import com.github.weisj.darklaf.components.text.NumberingPane; import com.github.weisj.darklaf.components.text.NumberingPane;
import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.StringUtil; import com.github.weisj.darklaf.util.StringUtil;
import ui.ComponentDemo; import ui.ComponentDemo;
import ui.DemoResources; import ui.DemoResources;

2
core/src/test/java/ui/toolTip/ToolTipDemo.java

@ -23,11 +23,11 @@
*/ */
package ui.toolTip; package ui.toolTip;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.alignment.AlignmentStrategy; import com.github.weisj.darklaf.components.alignment.AlignmentStrategy;
import com.github.weisj.darklaf.components.tooltip.ToolTipContext; import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.components.tooltip.ToolTipStyle; import com.github.weisj.darklaf.components.tooltip.ToolTipStyle;
import com.github.weisj.darklaf.components.tooltip.TooltipAwareButton; import com.github.weisj.darklaf.components.tooltip.TooltipAwareButton;
import com.github.weisj.darklaf.util.Alignment;
import ui.ComponentDemo; import ui.ComponentDemo;
import ui.DemoPanel; import ui.DemoPanel;

10
native-utils/src/main/java/com/github/weisj/darklaf/decorations/JNIDecorationsProvider.java

@ -24,6 +24,7 @@
package com.github.weisj.darklaf.decorations; package com.github.weisj.darklaf.decorations;
import javax.swing.*; import javax.swing.*;
import java.util.Properties;
public interface JNIDecorationsProvider { public interface JNIDecorationsProvider {
@ -48,4 +49,13 @@ public interface JNIDecorationsProvider {
* @return true if successful and library wasn't already loaded. * @return true if successful and library wasn't already loaded.
*/ */
boolean updateLibrary(); boolean updateLibrary();
/**
* Load the necessary properties into the defaults.
*
* @param properties the properties to load the values into.
* @param currentDefaults the current ui defaults.
*/
void loadDecorationProperties(Properties properties, UIDefaults currentDefaults);
} }

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

@ -23,15 +23,12 @@
*/ */
package com.github.weisj.darklaf.platform; package com.github.weisj.darklaf.platform;
import java.awt.*;
import java.util.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* @author Konstantin Bulenkov * @author Konstantin Bulenkov
*/ */
public class SystemInfo { public class SystemInfo {
public static final double SCALE;
public static final String X86 = "32"; public static final String X86 = "32";
public static final String X64 = "64"; public static final String X64 = "64";
public static final String OS_NAME = System.getProperty("os.name"); public static final String OS_NAME = System.getProperty("os.name");
@ -52,9 +49,6 @@ public class SystemInfo {
public static final boolean isX64; public static final boolean isX64;
public static final boolean isUndefined; public static final boolean isUndefined;
protected static final String _OS_NAME; 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 { static {
_OS_NAME = OS_NAME.toLowerCase(); _OS_NAME = OS_NAME.toLowerCase();
@ -70,12 +64,6 @@ public class SystemInfo {
isX64 = X64.equals(jreArchitecture); isX64 = X64.equals(jreArchitecture);
isX86 = X86.equals(jreArchitecture); isX86 = X86.equals(jreArchitecture);
isUndefined = !isX86 & !isX64; isUndefined = !isX86 & !isX64;
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) { public static boolean isOsVersionAtLeast(final String version) {

9
property-loader/build.gradle.kts

@ -0,0 +1,9 @@
plugins {
`java-library`
}
dependencies {
implementation(project(":darklaf-utils"))
implementation("com.formdev:svgSalamander")
}

38
core/src/main/java/com/github/weisj/darklaf/util/PropertyLoader.java → property-loader/src/main/java/com/github/weisj/darklaf/PropertyLoader.java

@ -21,11 +21,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.weisj.darklaf.util; package com.github.weisj.darklaf;
import com.github.weisj.darklaf.icons.DarkUIAwareIcon; import com.github.weisj.darklaf.icons.DarkUIAwareIcon;
import com.github.weisj.darklaf.icons.EmptyIcon; import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.icons.IconLoader; import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.util.ColorUtil;
import com.github.weisj.darklaf.util.StringUtil;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.ColorUIResource; import javax.swing.plaf.ColorUIResource;
@ -74,19 +76,25 @@ public final class PropertyLoader {
public static Properties loadProperties(final Class<?> clazz, final String name, final String path) { public static Properties loadProperties(final Class<?> clazz, final String name, final String path) {
final Properties properties = new Properties(); final Properties properties = new Properties();
try (InputStream stream = clazz.getResourceAsStream(path + name + ".properties")) { String p = path + name + ".properties";
try (InputStream stream = clazz.getResourceAsStream(p)) {
properties.load(stream); properties.load(stream);
} catch (IOException e) { } catch (IOException | NullPointerException e) {
LOGGER.log(Level.SEVERE, "Could not load" + name + ".properties", e.getMessage()); LOGGER.log(Level.SEVERE, "Could not load " + p + " " + e.getMessage(), e.getStackTrace());
} }
return properties; return properties;
} }
public static void putProperties(final Properties properties, final Properties accumulator, public static void putProperties(final Properties properties, final Properties accumulator,
final UIDefaults currentDefaults) { final UIDefaults currentDefaults) {
putProperties(properties, accumulator, currentDefaults, ICON_LOADER);
}
public static void putProperties(final Properties properties, final Properties accumulator,
final UIDefaults currentDefaults, final IconLoader iconLoader) {
for (final String key : properties.stringPropertyNames()) { for (final String key : properties.stringPropertyNames()) {
final String value = properties.getProperty(key); final String value = properties.getProperty(key);
Object parsed = parseValue(key, value, accumulator); Object parsed = parseValue(key, value, accumulator, iconLoader);
if (parsed instanceof ObjectRequest) { if (parsed instanceof ObjectRequest) {
objectsToLoad.add((ObjectRequest) parsed); objectsToLoad.add((ObjectRequest) parsed);
} else if (parsed != null) { } else if (parsed != null) {
@ -98,8 +106,8 @@ public final class PropertyLoader {
} }
private static Object parseValue(final String key, final String value, private static Object parseValue(final String key, final String value,
final Map<Object, Object> defaults) { final Map<Object, Object> defaults, final IconLoader iconLoader) {
return parseValue(key, value, false, defaults); return parseValue(key, value, false, defaults, iconLoader);
} }
private static String parseKey(final String key) { private static String parseKey(final String key) {
@ -108,7 +116,8 @@ public final class PropertyLoader {
private static Object parseValue(final String propertyKey, final String value, private static Object parseValue(final String propertyKey, final String value,
final boolean ignoreRequest, final Map<Object, Object> defaults) { final boolean ignoreRequest, final Map<Object, Object> defaults,
final IconLoader iconLoader) {
if ("null".equals(value)) { if ("null".equals(value)) {
return null; return null;
} }
@ -132,7 +141,7 @@ public final class PropertyLoader {
} else if (key.endsWith(".font")) { } else if (key.endsWith(".font")) {
returnVal = parseFont(value); returnVal = parseFont(value);
} else if (key.endsWith(".icon") || key.endsWith("Icon")) { } else if (key.endsWith(".icon") || key.endsWith("Icon")) {
returnVal = parseIcon(value); returnVal = parseIcon(value, iconLoader);
} else if (key.endsWith("Size") || key.endsWith(".size")) { } else if (key.endsWith("Size") || key.endsWith(".size")) {
returnVal = parseSize(value); returnVal = parseSize(value);
} else if ("null".equalsIgnoreCase(value)) { } else if ("null".equalsIgnoreCase(value)) {
@ -174,7 +183,6 @@ public final class PropertyLoader {
Integer.parseInt(numbers.get(3))); Integer.parseInt(numbers.get(3)));
} }
private static Object parseFont(final String value) { private static Object parseFont(final String value) {
try { try {
final String[] decode = value.split("-"); final String[] decode = value.split("-");
@ -184,7 +192,7 @@ public final class PropertyLoader {
} }
} }
private static Icon parseIcon(final String value) { private static Icon parseIcon(final String value, final IconLoader iconLoader) {
String path = value; String path = value;
Dimension dim = new Dimension(16, 16); Dimension dim = new Dimension(16, 16);
if (value.charAt(value.length() - 1) == ')') { if (value.charAt(value.length() - 1) == ')') {
@ -209,9 +217,9 @@ public final class PropertyLoader {
} }
String iconPath = path.substring(0, path.length() - tag.length()); String iconPath = path.substring(0, path.length() - tag.length());
if (tag.equals(THEMED_KEY)) { if (tag.equals(THEMED_KEY)) {
return ICON_LOADER.getIcon(iconPath, dim.width, dim.height, true); return iconLoader.getIcon(iconPath, dim.width, dim.height, true);
} else { } else {
DarkUIAwareIcon icon = ICON_LOADER.getUIAwareIcon(iconPath, dim.width, dim.height); DarkUIAwareIcon icon = iconLoader.getUIAwareIcon(iconPath, dim.width, dim.height);
if (tag.equals(DUAL_KEY)) { if (tag.equals(DUAL_KEY)) {
return icon.getDual(); return icon.getDual();
} else { } else {
@ -222,7 +230,7 @@ public final class PropertyLoader {
if (path.equals("empty")) { if (path.equals("empty")) {
return EmptyIcon.create(dim.width, dim.height); return EmptyIcon.create(dim.width, dim.height);
} }
return ICON_LOADER.getIcon(path, dim.width, dim.height); return iconLoader.getIcon(path, dim.width, dim.height);
} }
@ -269,7 +277,7 @@ public final class PropertyLoader {
} else { } else {
Object obj = parseObject(value); Object obj = parseObject(value);
if (obj == null) { if (obj == null) {
obj = parseValue(key, value, true, defaults); obj = parseValue(key, value, true, defaults, ICON_LOADER);
if (obj instanceof ObjectRequest) { if (obj instanceof ObjectRequest) {
LOGGER.severe("Failed to resolve object. " + this); LOGGER.severe("Failed to resolve object. " + this);
return; return;

29
property-loader/src/main/java/com/github/weisj/darklaf/icons/AwareIconStyle.java

@ -0,0 +1,29 @@
/*
* 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.
*/
package com.github.weisj.darklaf.icons;
public enum AwareIconStyle {
DARK,
LIGHT
}

0
core/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkSVGIcon.java

14
core/src/main/java/com/github/weisj/darklaf/icons/DarkUIAwareIcon.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/DarkUIAwareIcon.java

@ -23,9 +23,6 @@
*/ */
package com.github.weisj.darklaf.icons; package com.github.weisj.darklaf.icons;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.Theme;
import javax.swing.*; import javax.swing.*;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
import java.awt.*; import java.awt.*;
@ -46,9 +43,10 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
private final int w; private final int w;
private final int h; private final int h;
private final Class<?> parentClass; private final Class<?> parentClass;
private Theme currentTheme;
private transient boolean loaded; private transient boolean loaded;
private transient Icon icon; private transient Icon icon;
private AwareIconStyle currentStyle;
/** /**
* Create new ui aware icon. * Create new ui aware icon.
@ -62,6 +60,7 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
public DarkUIAwareIcon(final String darkKey, final String lightKey, final int w, final int h, public DarkUIAwareIcon(final String darkKey, final String lightKey, final int w, final int h,
final Class<?> parentClass) { final Class<?> parentClass) {
IconLoader.registerAwareIcon(this, null);
this.darkKey = darkKey; this.darkKey = darkKey;
this.lightKey = lightKey; this.lightKey = lightKey;
this.w = w; this.w = w;
@ -72,6 +71,7 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
private DarkUIAwareIcon(final DarkUIAwareIcon dual) { private DarkUIAwareIcon(final DarkUIAwareIcon dual) {
IconLoader.registerAwareIcon(this, null);
this.darkKey = dual.lightKey; this.darkKey = dual.lightKey;
this.lightKey = dual.darkKey; this.lightKey = dual.darkKey;
this.dual = dual; this.dual = dual;
@ -98,12 +98,12 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
private boolean isLoaded() { private boolean isLoaded() {
return loaded && LafManager.getTheme().equals(currentTheme); return loaded && (currentStyle != IconLoader.getAwareStyle(this));
} }
private void loadIcon() { private void loadIcon() {
currentTheme = LafManager.getTheme(); currentStyle = IconLoader.getAwareStyle(this);
if (currentTheme.useDarkIcons()) { if (currentStyle == AwareIconStyle.DARK) {
icon = IconLoader.get(parentClass).getIcon(darkKey, w, h); icon = IconLoader.get(parentClass).getIcon(darkKey, w, h);
} else { } else {
icon = IconLoader.get(parentClass).getIcon(lightKey, w, h); icon = IconLoader.get(parentClass).getIcon(lightKey, w, h);

0
core/src/main/java/com/github/weisj/darklaf/icons/EmptyIcon.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/EmptyIcon.java

9
core/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/IconColorMapper.java

@ -24,14 +24,7 @@
package com.github.weisj.darklaf.icons; package com.github.weisj.darklaf.icons;
import com.github.weisj.darklaf.util.Pair; import com.github.weisj.darklaf.util.Pair;
import com.kitfox.svg.Defs; import com.kitfox.svg.*;
import com.kitfox.svg.LinearGradient;
import com.kitfox.svg.SVGDiagram;
import com.kitfox.svg.SVGElement;
import com.kitfox.svg.SVGElementException;
import com.kitfox.svg.SVGRoot;
import com.kitfox.svg.SVGUniverse;
import com.kitfox.svg.Stop;
import com.kitfox.svg.animation.AnimationElement; import com.kitfox.svg.animation.AnimationElement;
import com.kitfox.svg.app.beans.SVGIcon; import com.kitfox.svg.app.beans.SVGIcon;

29
core/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/IconLoader.java

@ -28,6 +28,7 @@ import java.net.URISyntaxException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.WeakHashMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -38,13 +39,15 @@ public final class IconLoader {
private static final Logger LOGGER = Logger.getLogger(IconLoader.class.getName()); private static final Logger LOGGER = Logger.getLogger(IconLoader.class.getName());
private static final Map<Class<?>, IconLoader> iconLoaderMap = new HashMap<>(); private static final Map<Class<?>, IconLoader> iconLoaderMap = new HashMap<>();
private static final IconLoader instance = new IconLoader(IconLoader.class); private static final IconLoader instance = new IconLoader(IconLoader.class);
private static final Map<UIAwareIcon, AwareIconStyle> uiAwareIconStatus = new WeakHashMap<>();
private static final Map<ThemedSVGIcon, Object> themedIconStatus = new WeakHashMap<>();
private static final int DEFAULT_W = 16; private static final int DEFAULT_W = 16;
private static final int DEFAULT_H = 16; private static final int DEFAULT_H = 16;
private final Class<?> parentClass; private final Class<?> parentClass;
private final Map<IconKey, DarkUIAwareIcon> awareIconMap = new HashMap<>(); private final Map<IconKey, DarkUIAwareIcon> awareIconMap = new HashMap<>();
private final Map<IconKey, Icon> iconMap = new HashMap<>(); private final Map<IconKey, Icon> iconMap = new HashMap<>();
private IconLoader(final Class<?> parentClass) { private IconLoader(final Class<?> parentClass) {
this.parentClass = parentClass; this.parentClass = parentClass;
iconLoaderMap.put(parentClass, this); iconLoaderMap.put(parentClass, this);
@ -65,6 +68,30 @@ public final class IconLoader {
} }
} }
public static void updateAwareStyle(final AwareIconStyle style) {
uiAwareIconStatus.entrySet().forEach(e -> e.setValue(style));
}
public static void updateThemeStatus(final Object theme) {
themedIconStatus.entrySet().forEach(e -> e.setValue(theme));
}
public static AwareIconStyle getAwareStyle(final UIAwareIcon icon) {
return uiAwareIconStatus.get(icon);
}
public static Object getThemeStatus(final ThemedSVGIcon icon) {
return themedIconStatus.get(icon);
}
public static void registerAwareIcon(final UIAwareIcon icon, final AwareIconStyle style) {
uiAwareIconStatus.put(icon, style);
}
public static void registerThemedIcon(final ThemedSVGIcon icon, final Object status) {
themedIconStatus.put(icon, status);
}
public DarkUIAwareIcon getUIAwareIcon(final String path) { public DarkUIAwareIcon getUIAwareIcon(final String path) {
return getUIAwareIcon(path, DEFAULT_W, DEFAULT_H); return getUIAwareIcon(path, DEFAULT_W, DEFAULT_H);
} }

0
core/src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyIcon.java

0
core/src/main/java/com/github/weisj/darklaf/icons/LazyImageIcon.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/LazyImageIcon.java

2
core/src/main/java/com/github/weisj/darklaf/icons/RotatableIcon.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/RotatableIcon.java

@ -23,7 +23,7 @@
*/ */
package com.github.weisj.darklaf.icons; package com.github.weisj.darklaf.icons;
import com.github.weisj.darklaf.components.alignment.Alignment; import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;

12
windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/ScaledIcon.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/ScaledIcon.java

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

8
core/src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/ThemedSVGIcon.java

@ -23,9 +23,6 @@
*/ */
package com.github.weisj.darklaf.icons; package com.github.weisj.darklaf.icons;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.Theme;
import java.awt.*; import java.awt.*;
import java.net.URI; import java.net.URI;
@ -34,10 +31,11 @@ import java.net.URI;
*/ */
public class ThemedSVGIcon extends DarkSVGIcon { public class ThemedSVGIcon extends DarkSVGIcon {
private Theme currentTheme; private Object currentTheme;
public ThemedSVGIcon(final URI uri, final int displayWidth, final int displayHeight) { public ThemedSVGIcon(final URI uri, final int displayWidth, final int displayHeight) {
super(uri, displayWidth, displayHeight); super(uri, displayWidth, displayHeight);
IconLoader.registerThemedIcon(this, new Object());
} }
@Override @Override
@ -47,7 +45,7 @@ public class ThemedSVGIcon extends DarkSVGIcon {
} }
private void ensureTheme() { private void ensureTheme() {
Theme theme = LafManager.getTheme(); Object theme = IconLoader.getThemeStatus(this);
if (currentTheme != theme) { if (currentTheme != theme) {
IconColorMapper.patchColors(getSVGIcon()); IconColorMapper.patchColors(getSVGIcon());
currentTheme = theme; currentTheme = theme;

2
core/src/main/java/com/github/weisj/darklaf/icons/UIAwareIcon.java → property-loader/src/main/java/com/github/weisj/darklaf/icons/UIAwareIcon.java

@ -31,4 +31,6 @@ import javax.swing.*;
public interface UIAwareIcon extends Icon { public interface UIAwareIcon extends Icon {
UIAwareIcon getDual(); UIAwareIcon getDual();
} }

4
settings.gradle.kts

@ -18,7 +18,9 @@ include(
"dependencies-bom", "dependencies-bom",
"native-utils", "native-utils",
"core", "core",
"windows" "windows",
"property-loader",
"utils"
) )
for (p in rootProject.children) { for (p in rootProject.children) {

3
utils/build.gradle.kts

@ -0,0 +1,3 @@
plugins {
`java-library`
}

4
core/src/main/java/com/github/weisj/darklaf/components/alignment/Alignment.java → utils/src/main/java/com/github/weisj/darklaf/util/Alignment.java

@ -21,12 +21,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.weisj.darklaf.components.alignment; package com.github.weisj.darklaf.util;
import java.awt.*; import java.awt.*;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import static com.github.weisj.darklaf.components.alignment.AlignmentHelper.*; import static com.github.weisj.darklaf.util.AlignmentHelper.*;
/** /**
* @author Jannis Weis * @author Jannis Weis

2
core/src/main/java/com/github/weisj/darklaf/components/alignment/AlignmentHelper.java → utils/src/main/java/com/github/weisj/darklaf/util/AlignmentHelper.java

@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.weisj.darklaf.components.alignment; package com.github.weisj.darklaf.util;
import java.awt.*; import java.awt.*;
import java.util.function.BiFunction; import java.util.function.BiFunction;

1
core/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java → utils/src/main/java/com/github/weisj/darklaf/util/ColorUtil.java

@ -82,7 +82,6 @@ public final class ColorUtil {
} }
} }
public static Color removeAlpha(final Color color) { public static Color removeAlpha(final Color color) {
return toAlpha(color, 255); return toAlpha(color, 255);
} }

0
core/src/main/java/com/github/weisj/darklaf/util/Pair.java → utils/src/main/java/com/github/weisj/darklaf/util/Pair.java

5
core/src/main/java/com/github/weisj/darklaf/util/Scale.java → utils/src/main/java/com/github/weisj/darklaf/util/Scale.java

@ -24,13 +24,11 @@
package com.github.weisj.darklaf.util; package com.github.weisj.darklaf.util;
import java.awt.*; import java.awt.*;
import java.util.logging.Logger;
public final class Scale { public class Scale {
public static final double SCALE; public static final double SCALE;
public static final double SCALE_X; public static final double SCALE_X;
public static final double SCALE_Y; public static final double SCALE_Y;
private static final Logger LOGGER = Logger.getLogger(Scale.class.getName());
static { static {
DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode(); DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
@ -38,7 +36,6 @@ public final class Scale {
SCALE_X = mode.getWidth() / (double) screenSize.width; SCALE_X = mode.getWidth() / (double) screenSize.width;
SCALE_Y = mode.getHeight() / (double) screenSize.height; SCALE_Y = mode.getHeight() / (double) screenSize.height;
SCALE = SCALE_X; SCALE = SCALE_X;
LOGGER.info("Using screen scaling SCALE_X=" + SCALE_X + ", SCALE_Y=" + SCALE_Y);
} }

0
core/src/main/java/com/github/weisj/darklaf/util/StringUtil.java → utils/src/main/java/com/github/weisj/darklaf/util/StringUtil.java

2
windows/build.gradle.kts

@ -9,6 +9,8 @@ fun DependencyHandlerScope.javaImplementation(dep: Any) {
dependencies { dependencies {
javaImplementation(project(":darklaf-native-utils")) javaImplementation(project(":darklaf-native-utils"))
javaImplementation(project(":darklaf-utils"))
javaImplementation(project(":darklaf-property-loader"))
javaImplementation("net.java.dev.jna:jna") javaImplementation("net.java.dev.jna:jna")
} }

18
windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsDecorationsProvider.java → windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java

@ -21,13 +21,16 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * SOFTWARE.
*/ */
package com.github.weisj.darklaf.platform.windows.ui; package com.github.weisj.darklaf.platform.windows;
import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.decorations.CustomTitlePane; import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.decorations.JNIDecorationsProvider; import com.github.weisj.darklaf.decorations.JNIDecorationsProvider;
import com.github.weisj.darklaf.platform.windows.JNIDecorationsWindows; import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.platform.windows.ui.DarkTitlePaneWindows;
import javax.swing.*; import javax.swing.*;
import java.util.Properties;
public class WindowsDecorationsProvider implements JNIDecorationsProvider { public class WindowsDecorationsProvider implements JNIDecorationsProvider {
@ -45,4 +48,15 @@ public class WindowsDecorationsProvider implements JNIDecorationsProvider {
public boolean updateLibrary() { public boolean updateLibrary() {
return JNIDecorationsWindows.updateLibrary(); return JNIDecorationsWindows.updateLibrary();
} }
@Override
public void loadDecorationProperties(final Properties properties, final UIDefaults currentDefaults) {
IconLoader iconLoader = IconLoader.get(WindowsDecorationsProvider.class);
PropertyLoader.putProperties(PropertyLoader.loadProperties(WindowsDecorationsProvider.class,
"windows_decorations", ""),
properties, currentDefaults, iconLoader);
PropertyLoader.putProperties(PropertyLoader.loadProperties(WindowsDecorationsProvider.class,
"windows_icons", ""),
properties, currentDefaults, iconLoader);
}
} }

79
windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/CloseButtonUI.java

@ -1,79 +0,0 @@
/*
* 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.
*/
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 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;
@Override
protected void installDefaults(final AbstractButton b) {
super.installDefaults(b);
closeHover = UIManager.getColor("TitlePane.close.rollOverColor");
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
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;
}
}

17
windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/DarkTitlePaneWindows.java

@ -25,8 +25,9 @@
package com.github.weisj.darklaf.platform.windows.ui; package com.github.weisj.darklaf.platform.windows.ui;
import com.github.weisj.darklaf.decorations.CustomTitlePane; import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.platform.SystemInfo; import com.github.weisj.darklaf.icons.ScaledIcon;
import com.github.weisj.darklaf.platform.windows.JNIDecorationsWindows; import com.github.weisj.darklaf.platform.windows.JNIDecorationsWindows;
import com.github.weisj.darklaf.util.Scale;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import javax.accessibility.AccessibleContext; import javax.accessibility.AccessibleContext;
@ -574,12 +575,12 @@ public class DarkTitlePaneWindows extends CustomTitlePane {
if (icons.size() == 0) { if (icons.size() == 0) {
systemIcon = UIManager.getIcon("TitlePane.icon"); systemIcon = UIManager.getIcon("TitlePane.icon");
} else if (icons.size() == 1) { } else if (icons.size() == 1) {
systemIcon = new ScaledIcon(icons.get(0).getScaledInstance((int) (SystemInfo.SCALE_X * ICON_SIZE), systemIcon = new ScaledIcon(icons.get(0).getScaledInstance(Scale.scaleWidth(ICON_SIZE),
(int) (SystemInfo.SCALE_Y * ICON_SIZE), Scale.scaleHeight(ICON_SIZE),
Image.SCALE_AREA_AVERAGING)); Image.SCALE_AREA_AVERAGING));
} else { } else {
systemIcon = new ScaledIcon(SunToolkit.getScaledIconImage(icons, (int) (SystemInfo.SCALE_X * ICON_SIZE), systemIcon = new ScaledIcon(SunToolkit.getScaledIconImage(icons, Scale.scaleWidth(ICON_SIZE),
(int) (SystemInfo.SCALE_Y * ICON_SIZE)) Scale.scaleHeight(ICON_SIZE))
); );
} }
if (windowIconButton != null) { if (windowIconButton != null) {
@ -713,9 +714,9 @@ public class DarkTitlePaneWindows extends CustomTitlePane {
} }
JNIDecorationsWindows.updateValues(windowHandle, JNIDecorationsWindows.updateValues(windowHandle,
(int) (SystemInfo.SCALE_X * left), Scale.scaleWidth(left),
(int) (SystemInfo.SCALE_X * right), Scale.scaleWidth(right),
(int) (SystemInfo.SCALE_Y * height)); Scale.scaleHeight(height));
} }

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

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

0
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/closeActive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeActive.svg

Before

Width:  |  Height:  |  Size: 608 B

After

Width:  |  Height:  |  Size: 608 B

0
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/closeHover.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeHover.svg

Before

Width:  |  Height:  |  Size: 612 B

After

Width:  |  Height:  |  Size: 612 B

0
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/closeInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/closeInactive.svg

Before

Width:  |  Height:  |  Size: 624 B

After

Width:  |  Height:  |  Size: 624 B

0
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/maximize.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximize.svg

Before

Width:  |  Height:  |  Size: 477 B

After

Width:  |  Height:  |  Size: 477 B

0
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/maximizeInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/maximizeInactive.svg

Before

Width:  |  Height:  |  Size: 493 B

After

Width:  |  Height:  |  Size: 493 B

0
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/minimize.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimize.svg

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 435 B

0
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/minimizeInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/minimizeInactive.svg

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 461 B

0
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/restore.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restore.svg

Before

Width:  |  Height:  |  Size: 702 B

After

Width:  |  Height:  |  Size: 702 B

0
windows/src/main/resources/com/github/weisj/darklaf/icons/windows/restoreInactive.svg → windows/src/main/resources/com/github/weisj/darklaf/platform/windows/icons/windows/restoreInactive.svg

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 726 B

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

@ -0,0 +1,50 @@
#
# 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.
#
TitlePane.minimize.icon = icons/windows/minimize.svg[themed]
TitlePane.minimizeInactive.icon = icons/windows/minimizeInactive.svg[themed]
TitlePane.maximize.icon = icons/windows/maximize.svg[themed]
TitlePane.maximizeInactive.icon = icons/windows/maximizeInactive.svg[themed]
TitlePane.restore.icon = icons/windows/restore.svg[themed]
TitlePane.restoreInactive.icon = icons/windows/restoreInactive.svg[themed]
TitlePane.close.icon = icons/windows/closeActive.svg[themed]
TitlePane.closeInactive.icon = icons/windows/closeInactive.svg[themed]
TitlePane.closeHover.icon = icons/windows/closeHover.svg[themed]
TitlePane.close.clickColor = F1707A
TitlePane.close.rollOverColor = E81123
TitlePane.icon = icons/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

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

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

@ -1,51 +0,0 @@
#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
Loading…
Cancel
Save