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 {
implementation(project(":darklaf-native-utils"))
implementation(project(":darklaf-utils"))
implementation(project(":darklaf-windows"))
implementation("com.formdev:svgSalamander")
implementation("net.java.dev.jna:jna")
implementation(project(":darklaf-property-loader"))
implementation("org.swinglabs:jxlayer")
compileOnly("org.swinglabs:swingx")
testImplementation("com.formdev:svgSalamander")
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.theme.Theme;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.util.PropertyLoader;
import sun.awt.AppContext;
import javax.swing.*;
@ -167,7 +166,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
currentTheme.loadUIProperties(uiProps, defaults);
currentTheme.loadIconProperties(uiProps, defaults);
currentTheme.loadPlatformProperties(uiProps, defaults);
currentTheme.loadDecorationProperties(uiProps, defaults);
JNIDecorations.loadDecorationProperties(uiProps, defaults);
adjustPlatformSpecifics(uiProps);
defaults.putAll(uiProps);

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

@ -23,6 +23,8 @@
*/
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.IntelliJTheme;
import com.github.weisj.darklaf.theme.Theme;
@ -110,7 +112,7 @@ public final class LafManager {
*/
public static Theme getTheme() {
if (theme == null) {
theme = new IntelliJTheme();
setTheme(new IntelliJTheme());
}
return theme;
}
@ -122,6 +124,9 @@ public final class LafManager {
*/
public static void setTheme(final 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() {
try {
getTheme();
UIManager.setLookAndFeel(DarkLaf.class.getCanonicalName());
updateLaf();
} 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;
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.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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.ui.tabframe.TabFrameTransferHandler;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.decorators.AncestorAdapter;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.icons.EmptyIcon;
import com.github.weisj.darklaf.ui.tabframe.DarkTabFrameTabLabelUI;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.plaf.ComponentUI;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.decorators.AncestorAdapter;
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.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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.alignment.AlignmentStrategy;
import com.github.weisj.darklaf.ui.tooltip.DarkTooltipBorder;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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 javax.swing.*;
import java.util.Properties;
public class DefaultDecorationsProvider implements JNIDecorationsProvider {
@Override
@ -47,4 +48,8 @@ public class DefaultDecorationsProvider implements JNIDecorationsProvider {
public boolean updateLibrary() {
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.JNIDecorationsProvider;
import com.github.weisj.darklaf.platform.windows.ui.WindowsDecorationsProvider;
import com.github.weisj.darklaf.platform.windows.WindowsDecorationsProvider;
import javax.swing.*;
import java.util.Properties;
public final class JNIDecorations {
@ -54,4 +55,8 @@ public final class JNIDecorations {
public static boolean 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;
import com.github.weisj.darklaf.util.PropertyLoader;
import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.platform.SystemInfo;
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.DarkMetalTheme;
import com.github.weisj.darklaf.PropertyLoader;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.util.PropertyLoader;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
@ -139,21 +139,6 @@ public abstract class Theme {
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";
}

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

@ -24,8 +24,8 @@
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.util.Alignment;
import com.github.weisj.darklaf.util.ColorUtil;
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;
}
}
}
}

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

@ -23,18 +23,14 @@
*/
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.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsUtil;
import javax.swing.*;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.*;
/**
* @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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.border.MutableLineBorder;
import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.PanelPopup;
import com.github.weisj.darklaf.components.tooltip.ToolTipContext;
import com.github.weisj.darklaf.components.uiresource.JLabelUIResource;
import com.github.weisj.darklaf.ui.panel.DarkPanelUI;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil;
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;
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.icons.EmptyIcon;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.TabFrameTabContainer;
import com.github.weisj.darklaf.decorators.HoverListener;
import com.github.weisj.darklaf.ui.panel.DarkPanelUI;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.TabFrameTabLabel;
import com.github.weisj.darklaf.decorators.HoverListener;
import com.github.weisj.darklaf.icons.RotatableIcon;
import com.github.weisj.darklaf.ui.label.DarkLabelUI;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.border.MutableLineBorder;
import com.github.weisj.darklaf.components.tabframe.JTabFrame;
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.tabframe.*;
import com.github.weisj.darklaf.components.uiresource.JPanelUIResource;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.Pair;
import org.jdesktop.jxlayer.JXLayer;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.JTabFrame;
import com.github.weisj.darklaf.components.tabframe.TabFrameTab;
import com.github.weisj.darklaf.util.Alignment;
import java.awt.*;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.tabframe.JTabFrame;
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.util.Alignment;
import com.github.weisj.darklaf.util.ImageUtil;
import javax.swing.*;
@ -35,19 +35,7 @@ import java.awt.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DragGestureEvent;
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.dnd.*;
import java.awt.event.InputEvent;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.components.border.BubbleBorder;
import com.github.weisj.darklaf.components.border.DropShadowBorder;
import com.github.weisj.darklaf.components.tooltip.ToolTipStyle;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil;
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.DarkUIUtil;
import javax.swing.*;
@ -32,11 +32,7 @@ import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicToolTipUI;
import javax.swing.text.View;
import java.awt.*;
import java.awt.event.HierarchyEvent;
import java.awt.event.HierarchyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.*;
import java.awt.geom.Area;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

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

@ -93,7 +93,8 @@ public class AllIcons {
for (File f : files) {
if (f.getName().endsWith(".svg")) {
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();
int autosize = svgIcon.getAutosize();
svgIcon.setAutosize(SVGIcon.AUTOSIZE_NONE);

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

@ -23,13 +23,13 @@
*/
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.TabbedPopup;
import com.github.weisj.darklaf.components.text.NonWrappingTextPane;
import com.github.weisj.darklaf.components.text.NumberedTextComponent;
import com.github.weisj.darklaf.components.text.NumberingPane;
import com.github.weisj.darklaf.icons.IconLoader;
import com.github.weisj.darklaf.util.Alignment;
import com.github.weisj.darklaf.util.StringUtil;
import ui.ComponentDemo;
import ui.DemoResources;

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

@ -23,11 +23,11 @@
*/
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.tooltip.ToolTipContext;
import com.github.weisj.darklaf.components.tooltip.ToolTipStyle;
import com.github.weisj.darklaf.components.tooltip.TooltipAwareButton;
import com.github.weisj.darklaf.util.Alignment;
import ui.ComponentDemo;
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;
import javax.swing.*;
import java.util.Properties;
public interface JNIDecorationsProvider {
@ -48,4 +49,13 @@ public interface JNIDecorationsProvider {
* @return true if successful and library wasn't already loaded.
*/
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;
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");
@ -52,9 +49,6 @@ 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();
@ -70,12 +64,6 @@ public class SystemInfo {
isX64 = X64.equals(jreArchitecture);
isX86 = X86.equals(jreArchitecture);
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) {

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
* 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.EmptyIcon;
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.plaf.ColorUIResource;
@ -74,19 +76,25 @@ public final class PropertyLoader {
public static Properties loadProperties(final Class<?> clazz, final String name, final String path) {
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);
} catch (IOException e) {
LOGGER.log(Level.SEVERE, "Could not load" + name + ".properties", e.getMessage());
} catch (IOException | NullPointerException e) {
LOGGER.log(Level.SEVERE, "Could not load " + p + " " + e.getMessage(), e.getStackTrace());
}
return properties;
}
public static void putProperties(final Properties properties, final Properties accumulator,
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()) {
final String value = properties.getProperty(key);
Object parsed = parseValue(key, value, accumulator);
Object parsed = parseValue(key, value, accumulator, iconLoader);
if (parsed instanceof ObjectRequest) {
objectsToLoad.add((ObjectRequest) parsed);
} else if (parsed != null) {
@ -98,8 +106,8 @@ public final class PropertyLoader {
}
private static Object parseValue(final String key, final String value,
final Map<Object, Object> defaults) {
return parseValue(key, value, false, defaults);
final Map<Object, Object> defaults, final IconLoader iconLoader) {
return parseValue(key, value, false, defaults, iconLoader);
}
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,
final boolean ignoreRequest, final Map<Object, Object> defaults) {
final boolean ignoreRequest, final Map<Object, Object> defaults,
final IconLoader iconLoader) {
if ("null".equals(value)) {
return null;
}
@ -132,7 +141,7 @@ public final class PropertyLoader {
} else if (key.endsWith(".font")) {
returnVal = parseFont(value);
} else if (key.endsWith(".icon") || key.endsWith("Icon")) {
returnVal = parseIcon(value);
returnVal = parseIcon(value, iconLoader);
} else if (key.endsWith("Size") || key.endsWith(".size")) {
returnVal = parseSize(value);
} else if ("null".equalsIgnoreCase(value)) {
@ -174,7 +183,6 @@ public final class PropertyLoader {
Integer.parseInt(numbers.get(3)));
}
private static Object parseFont(final String value) {
try {
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;
Dimension dim = new Dimension(16, 16);
if (value.charAt(value.length() - 1) == ')') {
@ -209,9 +217,9 @@ public final class PropertyLoader {
}
String iconPath = path.substring(0, path.length() - tag.length());
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 {
DarkUIAwareIcon icon = ICON_LOADER.getUIAwareIcon(iconPath, dim.width, dim.height);
DarkUIAwareIcon icon = iconLoader.getUIAwareIcon(iconPath, dim.width, dim.height);
if (tag.equals(DUAL_KEY)) {
return icon.getDual();
} else {
@ -222,7 +230,7 @@ public final class PropertyLoader {
if (path.equals("empty")) {
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 {
Object obj = parseObject(value);
if (obj == null) {
obj = parseValue(key, value, true, defaults);
obj = parseValue(key, value, true, defaults, ICON_LOADER);
if (obj instanceof ObjectRequest) {
LOGGER.severe("Failed to resolve object. " + this);
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;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.Theme;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
@ -46,9 +43,10 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
private final int w;
private final int h;
private final Class<?> parentClass;
private Theme currentTheme;
private transient boolean loaded;
private transient Icon icon;
private AwareIconStyle currentStyle;
/**
* 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,
final Class<?> parentClass) {
IconLoader.registerAwareIcon(this, null);
this.darkKey = darkKey;
this.lightKey = lightKey;
this.w = w;
@ -72,6 +71,7 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
private DarkUIAwareIcon(final DarkUIAwareIcon dual) {
IconLoader.registerAwareIcon(this, null);
this.darkKey = dual.lightKey;
this.lightKey = dual.darkKey;
this.dual = dual;
@ -98,12 +98,12 @@ public class DarkUIAwareIcon implements UIAwareIcon, UIResource, Serializable {
private boolean isLoaded() {
return loaded && LafManager.getTheme().equals(currentTheme);
return loaded && (currentStyle != IconLoader.getAwareStyle(this));
}
private void loadIcon() {
currentTheme = LafManager.getTheme();
if (currentTheme.useDarkIcons()) {
currentStyle = IconLoader.getAwareStyle(this);
if (currentStyle == AwareIconStyle.DARK) {
icon = IconLoader.get(parentClass).getIcon(darkKey, w, h);
} else {
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;
import com.github.weisj.darklaf.util.Pair;
import com.kitfox.svg.Defs;
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.*;
import com.kitfox.svg.animation.AnimationElement;
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.Map;
import java.util.Objects;
import java.util.WeakHashMap;
import java.util.logging.Level;
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 Map<Class<?>, IconLoader> iconLoaderMap = new HashMap<>();
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_H = 16;
private final Class<?> parentClass;
private final Map<IconKey, DarkUIAwareIcon> awareIconMap = new HashMap<>();
private final Map<IconKey, Icon> iconMap = new HashMap<>();
private IconLoader(final Class<?> parentClass) {
this.parentClass = parentClass;
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) {
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;
import com.github.weisj.darklaf.components.alignment.Alignment;
import com.github.weisj.darklaf.util.Alignment;
import javax.swing.*;
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
* 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 java.awt.*;
@ -31,8 +31,6 @@ import java.awt.*;
public class ScaledIcon implements Icon {
private Image img;
public ScaledIcon(final Image 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) {
Graphics2D g = (Graphics2D) g2;
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);
}
@Override
public int getIconWidth() {
return (int) (img.getWidth(null) / SystemInfo.SCALE_X);
return (int) (img.getWidth(null) / Scale.SCALE_X);
}
@Override
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;
import com.github.weisj.darklaf.LafManager;
import com.github.weisj.darklaf.theme.Theme;
import java.awt.*;
import java.net.URI;
@ -34,10 +31,11 @@ import java.net.URI;
*/
public class ThemedSVGIcon extends DarkSVGIcon {
private Theme currentTheme;
private Object currentTheme;
public ThemedSVGIcon(final URI uri, final int displayWidth, final int displayHeight) {
super(uri, displayWidth, displayHeight);
IconLoader.registerThemedIcon(this, new Object());
}
@Override
@ -47,7 +45,7 @@ public class ThemedSVGIcon extends DarkSVGIcon {
}
private void ensureTheme() {
Theme theme = LafManager.getTheme();
Object theme = IconLoader.getThemeStatus(this);
if (currentTheme != theme) {
IconColorMapper.patchColors(getSVGIcon());
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 {
UIAwareIcon getDual();
}

4
settings.gradle.kts

@ -18,7 +18,9 @@ include(
"dependencies-bom",
"native-utils",
"core",
"windows"
"windows",
"property-loader",
"utils"
)
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
* SOFTWARE.
*/
package com.github.weisj.darklaf.components.alignment;
package com.github.weisj.darklaf.util;
import java.awt.*;
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

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
* SOFTWARE.
*/
package com.github.weisj.darklaf.components.alignment;
package com.github.weisj.darklaf.util;
import java.awt.*;
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) {
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;
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_X;
public static final double SCALE_Y;
private static final Logger LOGGER = Logger.getLogger(Scale.class.getName());
static {
DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
@ -38,7 +36,6 @@ public final class Scale {
SCALE_X = mode.getWidth() / (double) screenSize.width;
SCALE_Y = mode.getHeight() / (double) screenSize.height;
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 {
javaImplementation(project(":darklaf-native-utils"))
javaImplementation(project(":darklaf-utils"))
javaImplementation(project(":darklaf-property-loader"))
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
* 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.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 java.util.Properties;
public class WindowsDecorationsProvider implements JNIDecorationsProvider {
@ -45,4 +48,15 @@ public class WindowsDecorationsProvider implements JNIDecorationsProvider {
public boolean 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;
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.util.Scale;
import sun.awt.SunToolkit;
import javax.accessibility.AccessibleContext;
@ -574,12 +575,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((int) (SystemInfo.SCALE_X * ICON_SIZE),
(int) (SystemInfo.SCALE_Y * ICON_SIZE),
systemIcon = new ScaledIcon(icons.get(0).getScaledInstance(Scale.scaleWidth(ICON_SIZE),
Scale.scaleHeight(ICON_SIZE),
Image.SCALE_AREA_AVERAGING));
} else {
systemIcon = new ScaledIcon(SunToolkit.getScaledIconImage(icons, (int) (SystemInfo.SCALE_X * ICON_SIZE),
(int) (SystemInfo.SCALE_Y * ICON_SIZE))
systemIcon = new ScaledIcon(SunToolkit.getScaledIconImage(icons, Scale.scaleWidth(ICON_SIZE),
Scale.scaleHeight(ICON_SIZE))
);
}
if (windowIconButton != null) {
@ -713,9 +714,9 @@ public class DarkTitlePaneWindows extends CustomTitlePane {
}
JNIDecorationsWindows.updateValues(windowHandle,
(int) (SystemInfo.SCALE_X * left),
(int) (SystemInfo.SCALE_X * right),
(int) (SystemInfo.SCALE_Y * height));
Scale.scaleWidth(left),
Scale.scaleWidth(right),
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