From 81ac9792172fbf94ced9098368c73f44654ecba6 Mon Sep 17 00:00:00 2001 From: weisj <31143295+weisJ@users.noreply.github.com> Date: Sun, 11 Apr 2021 23:11:19 +0200 Subject: [PATCH] Update implementation of DarklafComponentFactory. --- core/build.gradle.kts | 2 + .../swingdsl/DarklafComponentFactory.java | 73 ++++++++----------- dependencies-bom/build.gradle.kts | 1 + gradle.properties | 1 + 4 files changed, 33 insertions(+), 44 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 364eaf7f..dd1f2932 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -17,6 +17,8 @@ dependencies { implementation("org.swinglabs:jxlayer") implementation("com.formdev:svgSalamander") implementation("com.github.weisj:swing-dsl-laf-support") + + compileOnly("org.jetbrains:annotations") compileOnly("org.swinglabs:swingx") testImplementation("com.formdev:svgSalamander") diff --git a/core/src/main/java/com/github/weisj/darklaf/swingdsl/DarklafComponentFactory.java b/core/src/main/java/com/github/weisj/darklaf/swingdsl/DarklafComponentFactory.java index d9c849e8..6f564c74 100644 --- a/core/src/main/java/com/github/weisj/darklaf/swingdsl/DarklafComponentFactory.java +++ b/core/src/main/java/com/github/weisj/darklaf/swingdsl/DarklafComponentFactory.java @@ -28,71 +28,56 @@ import javax.swing.JComponent; import javax.swing.JScrollPane; import javax.swing.UIManager; +import org.jetbrains.annotations.NotNull; + import com.github.weisj.darklaf.components.OverlayScrollPane; import com.github.weisj.darklaf.util.DarkUIUtil; -import com.github.weisj.swingdsl.laf.CollapsibleComponent; import com.github.weisj.swingdsl.laf.ComponentFactoryDelegate; import com.github.weisj.swingdsl.laf.DefaultComponentFactory; -import com.github.weisj.swingdsl.laf.DefaultSupplier; import com.github.weisj.swingdsl.laf.DefaultWrappedComponent; -import com.github.weisj.swingdsl.laf.SeparatorSpec; -import com.github.weisj.swingdsl.laf.TextProperty; +import com.github.weisj.swingdsl.laf.StateValue; import com.github.weisj.swingdsl.laf.WrappedComponent; public class DarklafComponentFactory extends ComponentFactoryDelegate { - private final DefaultSupplier lineColorSupplier = enabled -> { - if (enabled) { - Color c = UIManager.getColor("borderSecondary"); - if (c != null) return c; - c = UIManager.getColor("Label.foreground"); - if (c != null) return c; - return Color.BLACK; - } else { - Color c = UIManager.getColor("widgetBorderInactive"); - if (c != null) return c; - c = UIManager.getColor("Label.disabledForeground"); - if (c != null) return c; - return Color.GRAY; - } - }; - private final DefaultSupplier expandedIconSupplier = enabled -> { - if (enabled) { - return DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowDown.svg"); - } else { - return DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowDownDisabled.svg"); - } - }; - private final DefaultSupplier collapsedIconSupplier = enabled -> { - if (enabled) { - return DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowRight.svg"); - } else { - return DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowRightDisabled.svg"); - } - }; - public DarklafComponentFactory() { super(DefaultComponentFactory.create()); } @Override - public WrappedComponent createScrollPane(final JComponent content) { + public @NotNull WrappedComponent createScrollPane(final @NotNull JComponent content) { OverlayScrollPane sp = new OverlayScrollPane(content); return new DefaultWrappedComponent<>(sp.getScrollPane(), sp); } @Override - public SeparatorSpec createSeparatorComponent(final TextProperty label) { - return new SeparatorSpec<>(null, new SeparatorSpec.Default(lineColorSupplier)); + public @NotNull Color getBorderColor() { + return UIManager.getColor("border"); + } + + @Override + public @NotNull StateValue getDividerColor() { + return new StateValue<>( + UIManager.getColor("borderSecondary"), + UIManager.getColor("widgetBorderInactive")); + } + + @Override + public @NotNull Color getHyperlinkColor() { + return UIManager.getColor("hyperlink"); + } + + @Override + public @NotNull StateValue getExpandedIcon() { + return new StateValue<>( + DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowDown.svg"), + DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowDownDisabled.svg")); } @Override - public SeparatorSpec createCollapsibleSeparatorComponent( - final TextProperty label) { - return new SeparatorSpec<>(null, - new SeparatorSpec.DefaultCollapsible( - lineColorSupplier, - collapsedIconSupplier, - expandedIconSupplier)); + public @NotNull StateValue getCollapsedIcon() { + return new StateValue<>( + DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowRight.svg"), + DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowRightDisabled.svg")); } } diff --git a/dependencies-bom/build.gradle.kts b/dependencies-bom/build.gradle.kts index 44dac4b9..04d65fed 100644 --- a/dependencies-bom/build.gradle.kts +++ b/dependencies-bom/build.gradle.kts @@ -42,5 +42,6 @@ dependencies { apiv("com.google.auto.service:auto-service", "auto-service") apiv("com.github.lgooddatepicker:LGoodDatePicker") apiv("com.github.weisj:swing-dsl-laf-support", "swing-dsl") + apiv("org.jetbrains:annotations") } } diff --git a/gradle.properties b/gradle.properties index 36484fdc..9f59e7f8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,3 +25,4 @@ rsyntaxtextarea.version = 3.1.1 auto-service.version = 1.0-rc7 LGoodDatePicker.version = 11.0.2 swing-dsl.version = latest.integration +annotations.version = 16.0.2