|
|
@ -28,71 +28,56 @@ import javax.swing.JComponent; |
|
|
|
import javax.swing.JScrollPane; |
|
|
|
import javax.swing.JScrollPane; |
|
|
|
import javax.swing.UIManager; |
|
|
|
import javax.swing.UIManager; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
|
|
|
|
|
|
|
|
import com.github.weisj.darklaf.components.OverlayScrollPane; |
|
|
|
import com.github.weisj.darklaf.components.OverlayScrollPane; |
|
|
|
import com.github.weisj.darklaf.util.DarkUIUtil; |
|
|
|
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.ComponentFactoryDelegate; |
|
|
|
import com.github.weisj.swingdsl.laf.DefaultComponentFactory; |
|
|
|
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.DefaultWrappedComponent; |
|
|
|
import com.github.weisj.swingdsl.laf.SeparatorSpec; |
|
|
|
import com.github.weisj.swingdsl.laf.StateValue; |
|
|
|
import com.github.weisj.swingdsl.laf.TextProperty; |
|
|
|
|
|
|
|
import com.github.weisj.swingdsl.laf.WrappedComponent; |
|
|
|
import com.github.weisj.swingdsl.laf.WrappedComponent; |
|
|
|
|
|
|
|
|
|
|
|
public class DarklafComponentFactory extends ComponentFactoryDelegate { |
|
|
|
public class DarklafComponentFactory extends ComponentFactoryDelegate { |
|
|
|
|
|
|
|
|
|
|
|
private final DefaultSupplier<Color> 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<Icon> 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<Icon> 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() { |
|
|
|
public DarklafComponentFactory() { |
|
|
|
super(DefaultComponentFactory.create()); |
|
|
|
super(DefaultComponentFactory.create()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public WrappedComponent<JScrollPane> createScrollPane(final JComponent content) { |
|
|
|
public @NotNull WrappedComponent<JScrollPane> createScrollPane(final @NotNull JComponent content) { |
|
|
|
OverlayScrollPane sp = new OverlayScrollPane(content); |
|
|
|
OverlayScrollPane sp = new OverlayScrollPane(content); |
|
|
|
return new DefaultWrappedComponent<>(sp.getScrollPane(), sp); |
|
|
|
return new DefaultWrappedComponent<>(sp.getScrollPane(), sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public SeparatorSpec<JComponent, SeparatorSpec.Default> createSeparatorComponent(final TextProperty label) { |
|
|
|
public @NotNull Color getBorderColor() { |
|
|
|
return new SeparatorSpec<>(null, new SeparatorSpec.Default(lineColorSupplier)); |
|
|
|
return UIManager.getColor("border"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public @NotNull StateValue<Color> getDividerColor() { |
|
|
|
|
|
|
|
return new StateValue<>( |
|
|
|
|
|
|
|
UIManager.getColor("borderSecondary"), |
|
|
|
|
|
|
|
UIManager.getColor("widgetBorderInactive")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public @NotNull Color getHyperlinkColor() { |
|
|
|
|
|
|
|
return UIManager.getColor("hyperlink"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public @NotNull StateValue<Icon> getExpandedIcon() { |
|
|
|
|
|
|
|
return new StateValue<>( |
|
|
|
|
|
|
|
DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowDown.svg"), |
|
|
|
|
|
|
|
DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowDownDisabled.svg")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public SeparatorSpec<CollapsibleComponent, SeparatorSpec.DefaultCollapsible> createCollapsibleSeparatorComponent( |
|
|
|
public @NotNull StateValue<Icon> getCollapsedIcon() { |
|
|
|
final TextProperty label) { |
|
|
|
return new StateValue<>( |
|
|
|
return new SeparatorSpec<>(null, |
|
|
|
DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowRight.svg"), |
|
|
|
new SeparatorSpec.DefaultCollapsible( |
|
|
|
DarkUIUtil.ICON_LOADER.getIcon("navigation/arrow/thick/arrowRightDisabled.svg")); |
|
|
|
lineColorSupplier, |
|
|
|
|
|
|
|
collapsedIconSupplier, |
|
|
|
|
|
|
|
expandedIconSupplier)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|