Browse Source

Moved custom decorations base classes to own module as not all implementations of custom decorations are JNI based.

Signed-off-by: weisj <weisj@arcor.de>
pull/60/head
weisj 5 years ago
parent
commit
c917e6c11c
  1. 1
      core/build.gradle.kts
  2. 10
      core/src/main/java/com/github/weisj/darklaf/DarkLaf.java
  3. 13
      core/src/main/java/com/github/weisj/darklaf/platform/Decorations.java
  4. 8
      core/src/main/java/com/github/weisj/darklaf/platform/DefaultDecorationsProvider.java
  5. 2
      core/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java
  6. 2
      core/src/main/java/com/github/weisj/darklaf/theme/Theme.java
  7. 2
      core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java
  8. 8
      core/src/main/java/com/github/weisj/darklaf/ui/rootpane/DarkRootPaneUI.java
  9. 9
      core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java
  10. 2
      core/src/test/java/theme/MyCustomTheme.java
  11. 3
      decorations-base/build.gradle.kts
  12. 2
      decorations-base/src/main/java/com/github/weisj/decorations/CustomTitlePane.java
  13. 10
      decorations-base/src/main/java/com/github/weisj/decorations/DecorationsProvider.java
  14. 1
      settings.gradle.kts
  15. 2
      utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.java
  16. 1
      windows/build.gradle.kts
  17. 4
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java
  18. 10
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java
  19. 4
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/DarkTitlePaneWindows.java

1
core/build.gradle.kts

@ -10,6 +10,7 @@ plugins {
dependencies {
implementation(project(":darklaf-native-utils"))
implementation(project(":darklaf-utils"))
implementation(project(":darklaf-decorations-base"))
implementation(project(":darklaf-windows"))
implementation(project(":darklaf-property-loader"))
implementation("org.swinglabs:jxlayer")

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

@ -24,10 +24,10 @@
package com.github.weisj.darklaf;
import com.github.weisj.darklaf.components.border.DarkBorders;
import com.github.weisj.darklaf.platform.JNIDecorations;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.platform.Decorations;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.ui.popupmenu.DarkPopupMenuUI;
import com.github.weisj.darklaf.util.SystemInfo;
import sun.awt.AppContext;
import javax.swing.*;
@ -118,7 +118,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
}
private void setupDecorations() {
JNIDecorations.updateLibrary();
Decorations.initialize();
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
}
@ -186,7 +186,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
currentTheme.loadUIProperties(uiProps, defaults);
currentTheme.loadIconProperties(uiProps, defaults);
currentTheme.loadPlatformProperties(uiProps, defaults);
JNIDecorations.loadDecorationProperties(uiProps, defaults);
Decorations.loadDecorationProperties(uiProps, defaults);
adjustPlatformSpecifics(uiProps);
defaults.putAll(uiProps);
@ -402,7 +402,7 @@ public class DarkLaf extends BasicLookAndFeel implements PropertyChangeListener
public boolean getSupportsWindowDecorations() {
return LafManager.isDecorationsEnabled()
&& LafManager.getTheme().useCustomDecorations()
&& JNIDecorations.isCustomDecorationSupported();
&& Decorations.isCustomDecorationSupported();
}

13
core/src/main/java/com/github/weisj/darklaf/platform/JNIDecorations.java → core/src/main/java/com/github/weisj/darklaf/platform/Decorations.java

@ -23,16 +23,17 @@
*/
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.WindowsDecorationsProvider;
import com.github.weisj.darklaf.util.SystemInfo;
import com.github.weisj.decorations.CustomTitlePane;
import com.github.weisj.decorations.DecorationsProvider;
import javax.swing.*;
import java.util.Properties;
public final class JNIDecorations {
public final class Decorations {
private static JNIDecorationsProvider decorationsProvider;
private static DecorationsProvider decorationsProvider;
static {
//Extend for different platforms.
@ -52,8 +53,8 @@ public final class JNIDecorations {
return decorationsProvider.isCustomDecorationSupported();
}
public static boolean updateLibrary() {
return decorationsProvider.updateLibrary();
public static void initialize() {
decorationsProvider.initialize();
}
public static void loadDecorationProperties(final Properties uiProps, final UIDefaults defaults) {

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

@ -23,13 +23,13 @@
*/
package com.github.weisj.darklaf.platform;
import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.decorations.JNIDecorationsProvider;
import com.github.weisj.decorations.CustomTitlePane;
import com.github.weisj.decorations.DecorationsProvider;
import javax.swing.*;
import java.util.Properties;
public class DefaultDecorationsProvider implements JNIDecorationsProvider {
public class DefaultDecorationsProvider implements DecorationsProvider {
@Override
public CustomTitlePane createTitlePane(final JRootPane rootPane) {
return new CustomTitlePane() {
@ -45,7 +45,7 @@ public class DefaultDecorationsProvider implements JNIDecorationsProvider {
}
@Override
public boolean updateLibrary() {
public boolean initialize() {
return false;
}

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

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

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

@ -26,7 +26,7 @@ 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.SystemInfo;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;

2
core/src/main/java/com/github/weisj/darklaf/ui/button/DarkButtonUI.java

@ -23,10 +23,10 @@
*/
package com.github.weisj.darklaf.ui.button;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.util.GraphicsContext;
import com.github.weisj.darklaf.util.GraphicsUtil;
import com.github.weisj.darklaf.util.SystemInfo;
import sun.swing.SwingUtilities2;
import javax.swing.*;

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

@ -24,8 +24,8 @@
package com.github.weisj.darklaf.ui.rootpane;
import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.platform.JNIDecorations;
import com.github.weisj.darklaf.platform.Decorations;
import com.github.weisj.decorations.CustomTitlePane;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
@ -140,7 +140,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
}
private void installClientDecorations(final JRootPane root) {
CustomTitlePane titlePane = JNIDecorations.createTitlePane(root);
CustomTitlePane titlePane = Decorations.createTitlePane(root);
setTitlePane(root, titlePane);
updateWindow(root.getParent());
installLayout(root);
@ -219,7 +219,7 @@ public class DarkRootPaneUI extends BasicRootPaneUI implements HierarchyListener
if (currWindow != null) {
if (currWindow != window) {
if (!JNIDecorations.isCustomDecorationSupported()
if (!Decorations.isCustomDecorationSupported()
|| rootPane.getWindowDecorationStyle() == JRootPane.NONE) {
uninstallClientDecorations(rootPane);
return;

9
core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java

@ -24,7 +24,7 @@
package com.github.weisj.darklaf.ui.tree;
import com.github.weisj.darklaf.util.DarkUIUtil;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.util.SystemInfo;
import javax.swing.*;
import javax.swing.plaf.ComponentUI;
@ -35,12 +35,7 @@ import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Enumeration;

2
core/src/test/java/theme/MyCustomTheme.java

@ -24,7 +24,7 @@
package theme;
import com.github.weisj.darklaf.theme.Theme;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.util.SystemInfo;
import javax.swing.*;
import java.util.Properties;

3
decorations-base/build.gradle.kts

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

2
native-utils/src/main/java/com/github/weisj/darklaf/decorations/CustomTitlePane.java → decorations-base/src/main/java/com/github/weisj/decorations/CustomTitlePane.java

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

10
native-utils/src/main/java/com/github/weisj/darklaf/decorations/JNIDecorationsProvider.java → decorations-base/src/main/java/com/github/weisj/decorations/DecorationsProvider.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.decorations;
package com.github.weisj.decorations;
import javax.swing.*;
import java.util.Properties;
public interface JNIDecorationsProvider {
public interface DecorationsProvider {
/**
* Create the custom title pane.
@ -44,11 +44,9 @@ public interface JNIDecorationsProvider {
boolean isCustomDecorationSupported();
/**
* Load the decorations library if necessary.
*
* @return true if successful and library wasn't already loaded.
* Initialize all necessary resources.
*/
boolean updateLibrary();
void initialize();
/**
* Load the necessary properties into the defaults.

1
settings.gradle.kts

@ -18,6 +18,7 @@ include(
"dependencies-bom",
"native-utils",
"core",
"decorations-base",
"windows",
"property-loader",
"utils"

2
native-utils/src/main/java/com/github/weisj/darklaf/platform/SystemInfo.java → utils/src/main/java/com/github/weisj/darklaf/util/SystemInfo.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.platform;
package com.github.weisj.darklaf.util;
import java.util.regex.Pattern;

1
windows/build.gradle.kts

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

4
windows/src/main/java/com/github/weisj/darklaf/platform/windows/JNIDecorationsWindows.java

@ -24,7 +24,7 @@
package com.github.weisj.darklaf.platform.windows;
import com.github.weisj.darklaf.platform.NativeUtil;
import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.util.SystemInfo;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
@ -63,7 +63,7 @@ public class JNIDecorationsWindows {
}
/**
* Load the decorations library if necessary.
* Load the decorations-library if necessary.
*
* @return true if successful and library wasn't already loaded.
*/

10
windows/src/main/java/com/github/weisj/darklaf/platform/windows/WindowsDecorationsProvider.java

@ -24,15 +24,15 @@
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.icons.IconLoader;
import com.github.weisj.darklaf.platform.windows.ui.DarkTitlePaneWindows;
import com.github.weisj.decorations.CustomTitlePane;
import com.github.weisj.decorations.DecorationsProvider;
import javax.swing.*;
import java.util.Properties;
public class WindowsDecorationsProvider implements JNIDecorationsProvider {
public class WindowsDecorationsProvider implements DecorationsProvider {
@Override
public CustomTitlePane createTitlePane(final JRootPane rootPane) {
@ -45,8 +45,8 @@ public class WindowsDecorationsProvider implements JNIDecorationsProvider {
}
@Override
public boolean updateLibrary() {
return JNIDecorationsWindows.updateLibrary();
public void initialize() {
JNIDecorationsWindows.updateLibrary();
}
@Override

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

@ -24,10 +24,10 @@
package com.github.weisj.darklaf.platform.windows.ui;
import com.github.weisj.darklaf.decorations.CustomTitlePane;
import com.github.weisj.darklaf.icons.ScaledIcon;
import com.github.weisj.darklaf.platform.windows.JNIDecorationsWindows;
import com.github.weisj.darklaf.util.Scale;
import com.github.weisj.decorations.CustomTitlePane;
import sun.awt.SunToolkit;
import javax.accessibility.AccessibleContext;
@ -57,7 +57,7 @@ public class DarkTitlePaneWindows extends CustomTitlePane {
public void componentAdded(final ContainerEvent e) {
if (e.getChild() instanceof JMenuBar) {
menuBar = getRootPane().getJMenuBar();
//Otherwise a white bar will appear where the menuBar used to be.
//Otherwise, a white bar will appear where the menuBar used to be.
menuBar.setPreferredSize(new Dimension(0, 0));
add(menuBar);
}

Loading…
Cancel
Save