Skip to content

Commit

Permalink
Move tonal scroll bar background logic into a common place
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Dec 12, 2024
1 parent 81ed925 commit 001b33a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,7 @@ protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
}
RadianceSkin skin = RadianceCoreUtilities.getSkin(this.scrollbar);
if (skin instanceof TonalSkin) {
Color backgroundFill = RadianceColorSchemeUtilities.getRenderColorTokens(
this.scrollbar,
this.scrollbar.isEnabled() ? ComponentState.ENABLED :
ComponentState.DISABLED_UNSELECTED,
RadianceThemingSlices.ContainerType.NEUTRAL)
.getContainerColorTokens().getContainer();
graphics.setColor(backgroundFill);
graphics.setColor(RadianceColorUtilities.getBackgroundTonalFillColorScrollBar(this.scrollbar));
} else {
graphics.setColor(RadianceColorUtilities.getBackgroundFillColorScrollBar(this.scrollbar));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@
import org.pushingpixels.radiance.animation.api.Timeline;
import org.pushingpixels.radiance.animation.api.swing.EventDispatchThreadTimelineCallbackAdapter;
import org.pushingpixels.radiance.animation.api.swing.SwingComponentTimeline;
import org.pushingpixels.radiance.theming.api.ComponentState;
import org.pushingpixels.radiance.theming.api.RadianceSkin;
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices;
import org.pushingpixels.radiance.theming.api.RadianceThemingWidget;
import org.pushingpixels.radiance.theming.api.palette.TonalSkin;
import org.pushingpixels.radiance.theming.internal.AnimationConfigurationManager;
import org.pushingpixels.radiance.theming.internal.RadianceThemingWidgetRepository;
import org.pushingpixels.radiance.theming.internal.painter.BackgroundPaintingUtils;
import org.pushingpixels.radiance.theming.internal.utils.RadianceColorSchemeUtilities;
import org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities;
import org.pushingpixels.radiance.theming.internal.utils.RadianceCoreUtilities;

Expand Down Expand Up @@ -284,13 +282,8 @@ public void update(Graphics g, JComponent c) {
Graphics2D g2d = (Graphics2D) g.create();
RadianceSkin skin = RadianceCoreUtilities.getSkin(this.scrollpane);
if (skin instanceof TonalSkin) {
Color backgroundFill = RadianceColorSchemeUtilities.getRenderColorTokens(
this.scrollpane.getVerticalScrollBar(),
this.scrollpane.isEnabled() ? ComponentState.ENABLED :
ComponentState.DISABLED_UNSELECTED,
RadianceThemingSlices.ContainerType.NEUTRAL)
.getContainerColorTokens().getContainer();
g2d.setColor(backgroundFill);
g2d.setColor(RadianceColorUtilities.getBackgroundTonalFillColorScrollBar(
this.scrollpane.getVerticalScrollBar()));
} else {
g2d.setColor(RadianceColorUtilities.getBackgroundFillColorScrollBar(
this.scrollpane.getVerticalScrollBar()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,11 @@ public static Color getBackgroundFillColorScrollBar(JScrollBar scrollbar) {
}

public static Color getBackgroundTonalFillColorScrollBar(JScrollBar scrollbar) {
RadianceSkin skin = RadianceCoreUtilities.getSkin(scrollbar);
RadianceColorUtilities.getTonalBackgroundFillColor(scrollbar,
ContainerRenderColorTokens colorTokens = RadianceColorSchemeUtilities.getRenderColorTokens(
scrollbar,
scrollbar.isEnabled() ? ComponentState.ENABLED : ComponentState.DISABLED_UNSELECTED,
RadianceThemingSlices.ContainerType.NEUTRAL);
ExtendedContainerRenderColorTokens renderColorTokens =
skin.getBackgroundRenderColorTokens(DecorationPainterUtils.getDecorationType(scrollbar));
return renderColorTokens.getSurfaceContainerTokens().getContainerColorTokens().getContainerLow();
return colorTokens.getContainerColorTokens().getContainer();
}

/**
Expand Down

0 comments on commit 001b33a

Please sign in to comment.