diff --git a/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/check/CustomTitlePaneButtonsProvider.java b/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/check/CustomTitlePaneButtonsProvider.java index a2f7e49ec..4e9a2e538 100644 --- a/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/check/CustomTitlePaneButtonsProvider.java +++ b/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/check/CustomTitlePaneButtonsProvider.java @@ -30,6 +30,7 @@ package org.pushingpixels.radiance.demo.theming.main.check; import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme; +import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; import org.pushingpixels.radiance.theming.api.titlepane.DefaultTitlePaneButtonsProvider; import org.pushingpixels.radiance.theming.api.titlepane.TitlePaneButtonProvider; @@ -64,6 +65,33 @@ public void drawIcon(Graphics2D g, RadianceColorScheme scheme, float alpha, int graphics.dispose(); } + + @Override + public void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, + float alpha, int iconSize) { + Graphics2D graphics = (Graphics2D) g.create(); + graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + + int start = iconSize / 4; + int end = iconSize - start; + + Color primaryColor = renderColorTokens.getOnContainerColorTokens().getOnContainer(); + + Stroke primaryStroke = new BasicStroke(1.5f, + BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); + + graphics.setStroke(primaryStroke); + graphics.setColor(primaryColor); + // Triangle + graphics.drawLine(start, start, end, start); + graphics.drawLine(end, start, end, end); + graphics.drawLine(end, end, start, start); + + graphics.dispose(); + } }; } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/RadianceSkin.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/RadianceSkin.java index 89425f00f..cce24b6b1 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/RadianceSkin.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/RadianceSkin.java @@ -418,7 +418,7 @@ public final ContainerRenderColorTokens getColorRenderTokens(Component comp, throw new IllegalStateException("Color scheme shouldn't be null here. Please " + "report this issue"); } - return componentState.isActive() ? registered.getTonalContainerTokens() + return componentState.isActive() ? registered.getPrimaryContainerTokens() : registered.getMutedContainerTokens(); } } @@ -428,7 +428,7 @@ public final ContainerRenderColorTokens getColorRenderTokens(Component comp, if (registered == null) { throw new IllegalStateException("Color scheme shouldn't be null here. Please report " + "this issue"); } - return componentState.isActive() ? registered.getTonalContainerTokens() + return componentState.isActive() ? registered.getPrimaryContainerTokens() : registered.getMutedContainerTokens(); } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/titlepane/DefaultTitlePaneButtonsProvider.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/titlepane/DefaultTitlePaneButtonsProvider.java index 270cff851..62d5a14a8 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/titlepane/DefaultTitlePaneButtonsProvider.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/titlepane/DefaultTitlePaneButtonsProvider.java @@ -31,6 +31,7 @@ import org.pushingpixels.radiance.theming.api.RadianceThemingCortex; import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme; +import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; import org.pushingpixels.radiance.theming.internal.blade.BladeIconUtils; import org.pushingpixels.radiance.theming.internal.utils.RadianceCoreUtilities; import org.pushingpixels.radiance.theming.internal.utils.RadianceSizeUtils; @@ -58,6 +59,12 @@ public void drawIcon(Graphics2D g, RadianceColorScheme scheme, float alpha, int BladeIconUtils.drawCloseIcon(g, iconSize, RadianceSizeUtils.getCloseIconStrokeWidth(iconSize), scheme); } + + @Override + public void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha, int iconSize) { + BladeIconUtils.drawCloseIcon(g, iconSize, + RadianceSizeUtils.getCloseIconStrokeWidth(iconSize), renderColorTokens); + } } @Override @@ -75,6 +82,11 @@ public String getText(JRootPane rootPane) { public void drawIcon(Graphics2D g, RadianceColorScheme scheme, float alpha, int iconSize) { BladeIconUtils.drawRestoreIcon(g, iconSize, scheme); } + + @Override + public void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha, int iconSize) { + BladeIconUtils.drawRestoreIcon(g, iconSize, renderColorTokens); + } } @Override @@ -92,6 +104,11 @@ public String getText(JRootPane rootPane) { public void drawIcon(Graphics2D g, RadianceColorScheme scheme, float alpha, int iconSize) { BladeIconUtils.drawIconifyIcon(g, iconSize, scheme); } + + @Override + public void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha, int iconSize) { + BladeIconUtils.drawIconifyIcon(g, iconSize, renderColorTokens); + } } @Override @@ -109,6 +126,11 @@ public String getText(JRootPane rootPane) { public void drawIcon(Graphics2D g, RadianceColorScheme scheme, float alpha, int iconSize) { BladeIconUtils.drawMaximizeIcon(g, iconSize, scheme); } + + @Override + public void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha, int iconSize) { + BladeIconUtils.drawMaximizeIcon(g, iconSize, renderColorTokens); + } } @Override diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/titlepane/TitlePaneButtonProvider.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/titlepane/TitlePaneButtonProvider.java index ce5659d1e..f275fc7a3 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/titlepane/TitlePaneButtonProvider.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/titlepane/TitlePaneButtonProvider.java @@ -30,6 +30,7 @@ package org.pushingpixels.radiance.theming.api.titlepane; import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme; +import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; import javax.swing.*; import java.awt.*; @@ -46,4 +47,10 @@ public interface TitlePaneButtonProvider { * Draws the icon for this button. */ void drawIcon(Graphics2D g, RadianceColorScheme scheme, float alpha, int iconSize); + + /** + * Draws the icon for this button. + */ + default void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, + float alpha, int iconSize) {} } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeArrowButtonTransitionAwareIcon.java b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeArrowButtonTransitionAwareIcon.java index 781d065a7..c496b7c11 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeArrowButtonTransitionAwareIcon.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeArrowButtonTransitionAwareIcon.java @@ -30,11 +30,14 @@ package org.pushingpixels.radiance.theming.internal.blade; 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.colorscheme.RadianceColorScheme; +import org.pushingpixels.radiance.theming.api.palette.TonalSkin; import org.pushingpixels.radiance.theming.internal.animation.StateTransitionTracker; import org.pushingpixels.radiance.theming.internal.animation.TransitionAwareUI; import org.pushingpixels.radiance.theming.internal.utils.RadianceColorSchemeUtilities; +import org.pushingpixels.radiance.theming.internal.utils.RadianceCoreUtilities; import org.pushingpixels.radiance.theming.internal.utils.RadianceSizeUtils; import org.pushingpixels.radiance.theming.internal.utils.icon.TransitionAware; @@ -135,7 +138,16 @@ public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D graphics = (Graphics2D) g.create(); graphics.translate(x, y); - this.delegate.drawColorSchemeIcon(graphics, mutableColorScheme, iconAlpha); + RadianceSkin skin = RadianceCoreUtilities.getSkin(c); + if (skin instanceof TonalSkin) { + this.delegate.drawColorSchemeIcon(graphics, + BladeUtils.getDefaultColorSchemeDelegate(this.component, + this.colorSchemeAssociationKindDelegate) + .getRenderColorTokensForCurrentState(currState), + iconAlpha); + } else { + this.delegate.drawColorSchemeIcon(graphics, mutableColorScheme, iconAlpha); + } graphics.dispose(); } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeIconUtils.java b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeIconUtils.java index c6db80efc..c16a30278 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeIconUtils.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeIconUtils.java @@ -37,6 +37,7 @@ import org.pushingpixels.radiance.theming.api.painter.border.RadianceBorderPainter; import org.pushingpixels.radiance.theming.api.painter.fill.FractionBasedFillPainter; import org.pushingpixels.radiance.theming.api.painter.fill.RadianceFillPainter; +import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; import org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities; import org.pushingpixels.radiance.theming.internal.utils.RadianceOutlineUtilities; import org.pushingpixels.radiance.theming.internal.utils.RadianceSizeUtils; @@ -374,6 +375,30 @@ public static void drawCloseIcon(Graphics2D g, int iconSize, graphics.dispose(); } + public static void drawCloseIcon(Graphics2D g, int iconSize, + float primaryStrokeWidth, ContainerRenderColorTokens renderColorTokens) { + Graphics2D graphics = (Graphics2D) g.create(); + graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + + int start = iconSize / 4; + int end = iconSize - start; + + Color primaryColor = renderColorTokens.getOnContainerColorTokens().getOnContainer(); + + Stroke primaryStroke = new BasicStroke(primaryStrokeWidth, + BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); + + graphics.setStroke(primaryStroke); + graphics.setColor(primaryColor); + graphics.drawLine(start, start, end, end); + graphics.drawLine(start, end, end, start); + + graphics.dispose(); + } + public static void drawIconifyIcon(Graphics2D g, int iconSize, RadianceColorScheme scheme) { Graphics2D graphics = (Graphics2D) g.create(); @@ -393,6 +418,25 @@ public static void drawIconifyIcon(Graphics2D g, int iconSize, graphics.dispose(); } + public static void drawIconifyIcon(Graphics2D g, int iconSize, + ContainerRenderColorTokens renderColorTokens) { + Graphics2D graphics = (Graphics2D) g.create(); + graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + + int start = iconSize / 4 - 2; + int end = 3 * iconSize / 4; + int size = end - start - 2; + + Color primaryColor = renderColorTokens.getOnContainerColorTokens().getOnContainer(); + + graphics.setColor(primaryColor); + graphics.fillRect(start + 2, end - 1, size, 3); + graphics.dispose(); + } + public static void drawMaximizeIcon(Graphics2D g, int iconSize, RadianceColorScheme scheme) { Graphics2D graphics = (Graphics2D) g.create(); @@ -418,6 +462,31 @@ public static void drawMaximizeIcon(Graphics2D g, int iconSize, graphics.dispose(); } + public static void drawMaximizeIcon(Graphics2D g, int iconSize, + ContainerRenderColorTokens renderColorTokens) { + Graphics2D graphics = (Graphics2D) g.create(); + graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + + int start = iconSize / 4 - 1; + int end = iconSize - start; + + Color primaryColor = renderColorTokens.getOnContainerColorTokens().getOnContainer(); + + graphics.setColor(primaryColor); + // top (thicker) + graphics.fillRect(start, start, end - start, 2); + // left + graphics.fillRect(start, start, 1, end - start); + // right + graphics.fillRect(end - 1, start, 1, end - start); + // bottom + graphics.fillRect(start, end - 1, end - start, 1); + graphics.dispose(); + } + public static void drawRestoreIcon(Graphics2D g, int iconSize, RadianceColorScheme scheme) { Graphics2D graphics = (Graphics2D) g.create(); @@ -460,6 +529,48 @@ public static void drawRestoreIcon(Graphics2D g, int iconSize, graphics.dispose(); } + public static void drawRestoreIcon(Graphics2D g, int iconSize, + ContainerRenderColorTokens renderColorTokens) { + Graphics2D graphics = (Graphics2D) g.create(); + graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BICUBIC); + + int start = iconSize / 4 - 1; + int end = iconSize - start; + int smallSquareSize = end - start - 3; + Color primaryColor = renderColorTokens.getOnContainerColorTokens().getOnContainer(); + + graphics.setColor(primaryColor); + + // "Main" rectangle + int mainStartX = start; + int mainStartY = end - smallSquareSize; + // top (thicker) + graphics.fillRect(mainStartX, mainStartY, smallSquareSize, 2); + // left + graphics.fillRect(mainStartX, mainStartY, 1, smallSquareSize); + // right + graphics.fillRect(mainStartX + smallSquareSize - 1, mainStartY, 1, smallSquareSize); + // bottom + graphics.fillRect(mainStartX, mainStartY + smallSquareSize - 1, smallSquareSize, 1); + + // "Secondary rectangle" + int secondaryStartX = mainStartX + 3; + int secondaryStartY = mainStartY - 3; + // top (thicker) + graphics.fillRect(secondaryStartX, secondaryStartY, smallSquareSize, 2); + // right + graphics.fillRect(secondaryStartX + smallSquareSize - 1, secondaryStartY, 1, + smallSquareSize); + // bottom (partial) + graphics.fillRect(mainStartX + smallSquareSize + 1, secondaryStartY + smallSquareSize - 1, + 2, 1); + + graphics.dispose(); + } + public static void drawHexaMarker(Graphics2D g, int value, RadianceColorScheme colorScheme) { value %= 16; boolean isDark = colorScheme.isDark(); diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeTransitionAwareIcon.java b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeTransitionAwareIcon.java index 0531220ef..1b7b8edb6 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeTransitionAwareIcon.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeTransitionAwareIcon.java @@ -30,9 +30,12 @@ package org.pushingpixels.radiance.theming.internal.blade; import org.pushingpixels.radiance.theming.api.ComponentState; +import org.pushingpixels.radiance.theming.api.RadianceSkin; import org.pushingpixels.radiance.theming.api.RadianceThemingSlices.ColorSchemeAssociationKind; import org.pushingpixels.radiance.theming.api.RadianceThemingSlices.ComponentStateFacet; import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme; +import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; +import org.pushingpixels.radiance.theming.api.palette.TonalSkin; import org.pushingpixels.radiance.theming.internal.animation.StateTransitionTracker; import org.pushingpixels.radiance.theming.internal.animation.TransitionAwareUI; import org.pushingpixels.radiance.theming.internal.utils.RadianceColorSchemeUtilities; @@ -61,6 +64,9 @@ public class BladeTransitionAwareIcon implements Icon { public interface Delegate { void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float alpha); + default void drawColorSchemeIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, + float alpha) {} + Dimension getIconDimension(); } @@ -158,7 +164,17 @@ public void paintIcon(Component c, Graphics g, int x, int y) { Graphics2D graphics = (Graphics2D) g.create(); graphics.translate(x, y); - this.delegate.drawColorSchemeIcon(graphics, mutableColorScheme, iconAlpha); + + RadianceSkin skin = RadianceCoreUtilities.getSkin(c); + if (skin instanceof TonalSkin) { + this.delegate.drawColorSchemeIcon(graphics, + BladeUtils.getDefaultColorSchemeDelegate(c, + this.colorSchemeAssociationKindDelegate) + .getRenderColorTokensForCurrentState(currState), + iconAlpha); + } else { + this.delegate.drawColorSchemeIcon(graphics, mutableColorScheme, iconAlpha); + } graphics.dispose(); } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeUtils.java b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeUtils.java index 46cb8b476..fbed80132 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeUtils.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/blade/BladeUtils.java @@ -33,6 +33,7 @@ import org.pushingpixels.radiance.theming.api.ComponentState; import org.pushingpixels.radiance.theming.api.RadianceThemingSlices; import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme; +import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; import org.pushingpixels.radiance.theming.internal.animation.StateTransitionTracker; import org.pushingpixels.radiance.theming.internal.utils.RadianceColorSchemeUtilities; import org.pushingpixels.radiance.theming.internal.utils.RadianceColorUtilities; @@ -222,6 +223,14 @@ public static void populateColorScheme( public interface ColorSchemeDelegate { RadianceColorScheme getColorSchemeForCurrentState(ComponentState state); RadianceColorScheme getColorSchemeForActiveState(ComponentState state); + + default ContainerRenderColorTokens getRenderColorTokensForCurrentState(ComponentState state) { + return null; + } + + default ContainerRenderColorTokens getRenderColorTokensForActiveState(ComponentState state) { + return null; + } } public static ColorSchemeDelegate getDefaultColorSchemeDelegate(Component component, @@ -238,6 +247,18 @@ public RadianceColorScheme getColorSchemeForActiveState(ComponentState state) { return RadianceColorSchemeUtilities.getColorScheme(component, colorSchemeAssociationKindDelegate.getColorSchemeAssociationKind(state), state); } + + @Override + public ContainerRenderColorTokens getRenderColorTokensForCurrentState(ComponentState state) { + return RadianceColorSchemeUtilities.getColorRenderTokens(component, + colorSchemeAssociationKindDelegate.getColorSchemeAssociationKind(state), state); + } + + @Override + public ContainerRenderColorTokens getRenderColorTokensForActiveState(ComponentState state) { + return RadianceColorSchemeUtilities.getColorRenderTokens(component, + colorSchemeAssociationKindDelegate.getColorSchemeAssociationKind(state), state); + } }; } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceColorSchemeUtilities.java b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceColorSchemeUtilities.java index 77ac819e6..7af63996f 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceColorSchemeUtilities.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceColorSchemeUtilities.java @@ -30,10 +30,11 @@ package org.pushingpixels.radiance.theming.internal.utils; import org.pushingpixels.radiance.theming.api.ComponentState; +import org.pushingpixels.radiance.theming.api.RadianceSkin; import org.pushingpixels.radiance.theming.api.RadianceThemingCortex; import org.pushingpixels.radiance.theming.api.RadianceThemingSlices; -import org.pushingpixels.radiance.theming.api.RadianceSkin; import org.pushingpixels.radiance.theming.api.colorscheme.*; +import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; import javax.swing.*; import javax.swing.plaf.UIResource; @@ -205,6 +206,37 @@ public static RadianceColorScheme getColorScheme(Component component, return getColorizedScheme(component, nonColorized, !componentState.isDisabled()); } + /** + * Returns the color scheme of the component. + * + * @param component Component. + * @param associationKind Association kind. + * @param componentState Component state. + * @return Component color scheme. + */ + public static ContainerRenderColorTokens getColorRenderTokens(Component component, + RadianceThemingSlices.ColorSchemeAssociationKind associationKind, + ComponentState componentState) { + // special case - if the component is marked as flat and + // it is in the enabled state, get the color scheme of the parent. + // However, flat toolbars should be ignored, since they are + // the "top" level decoration area. + if (!(component instanceof JToolBar) + && RadianceCoreUtilities.hasFlatAppearance(component, false) + && (componentState == ComponentState.ENABLED)) { + component = component.getParent(); + } + + RadianceSkin skin = RadianceCoreUtilities.getSkin(component); + if (skin == null) { + RadianceCoreUtilities.traceRadianceApiUsage(component, + "Radiance delegate used when Radiance is not the current LAF"); + } + ContainerRenderColorTokens nonColorized = skin.getColorRenderTokens(component, + componentState); + return nonColorized; + } + /** * Returns the color scheme of the component. * diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceColorUtilities.java b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceColorUtilities.java index 31a37a71d..69dc1e308 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceColorUtilities.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceColorUtilities.java @@ -34,6 +34,8 @@ import org.pushingpixels.radiance.theming.api.RadianceThemingCortex; import org.pushingpixels.radiance.theming.api.RadianceThemingSlices; import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme; +import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; +import org.pushingpixels.radiance.theming.api.palette.TonalSkin; import org.pushingpixels.radiance.theming.internal.animation.StateTransitionTracker; import org.pushingpixels.radiance.theming.internal.animation.TransitionAwareUI; import org.pushingpixels.radiance.theming.internal.painter.DecorationPainterUtils; @@ -412,28 +414,32 @@ public static Color getForegroundColor(Component component, } } - RadianceColorScheme colorScheme = RadianceColorSchemeUtilities - .getColorScheme(component, currState); - if (currState.isDisabled() || (activeStates == null) - || (activeStates.size() == 1)) { - return colorScheme.getForegroundColor(); - } + RadianceSkin skin = RadianceCoreUtilities.getSkin(component); + if (skin instanceof TonalSkin) { + ContainerRenderColorTokens colorTokens = skin.getColorRenderTokens(component, currState); + return colorTokens.getOnContainerColorTokens().getOnContainer(); + } else { + RadianceColorScheme colorScheme = RadianceColorSchemeUtilities.getColorScheme(component, currState); + if (currState.isDisabled() || (activeStates == null) || (activeStates.size() == 1)) { + return colorScheme.getForegroundColor(); + } - float aggrRed = 0; - float aggrGreen = 0; - float aggrBlue = 0; - for (Map.Entry activeEntry : - activeStates.entrySet()) { - ComponentState activeState = activeEntry.getKey(); - float alpha = activeEntry.getValue().getContribution(); - RadianceColorScheme activeColorScheme = RadianceColorSchemeUtilities - .getColorScheme(component, activeState); - Color activeForeground = activeColorScheme.getForegroundColor(); - aggrRed += alpha * activeForeground.getRed(); - aggrGreen += alpha * activeForeground.getGreen(); - aggrBlue += alpha * activeForeground.getBlue(); + float aggrRed = 0; + float aggrGreen = 0; + float aggrBlue = 0; + for (Map.Entry activeEntry : + activeStates.entrySet()) { + ComponentState activeState = activeEntry.getKey(); + float alpha = activeEntry.getValue().getContribution(); + RadianceColorScheme activeColorScheme = RadianceColorSchemeUtilities.getColorScheme( + component, activeState); + Color activeForeground = activeColorScheme.getForegroundColor(); + aggrRed += alpha * activeForeground.getRed(); + aggrGreen += alpha * activeForeground.getGreen(); + aggrBlue += alpha * activeForeground.getBlue(); + } + return new Color((int) aggrRed, (int) aggrGreen, (int) aggrBlue); } - return new Color((int) aggrRed, (int) aggrGreen, (int) aggrBlue); } /** diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceTitlePane.java b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceTitlePane.java index 7332705a5..da4996f17 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceTitlePane.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceTitlePane.java @@ -34,6 +34,7 @@ import org.pushingpixels.radiance.theming.api.RadianceThemingCortex; import org.pushingpixels.radiance.theming.api.RadianceThemingSlices; import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme; +import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; import org.pushingpixels.radiance.theming.api.skin.SkinInfo; import org.pushingpixels.radiance.theming.api.titlepane.TitlePaneButtonProvider; import org.pushingpixels.radiance.theming.api.titlepane.TitlePaneButtonsProvider; @@ -470,6 +471,12 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha) { + closeButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize(); @@ -502,6 +509,12 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha) { + minimizeButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize(); @@ -532,6 +545,12 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha) { + restoreButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize(); @@ -552,6 +571,13 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, + ContainerRenderColorTokens renderColorTokens, float alpha) { + maximizeButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize(); @@ -644,6 +670,13 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, + ContainerRenderColorTokens renderColorTokens, float alpha) { + restoreButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize(); @@ -665,6 +698,13 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, + ContainerRenderColorTokens renderColorTokens, float alpha) { + maximizeButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize(); @@ -871,6 +911,12 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha) { + closeButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize(); @@ -904,6 +950,12 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha) { + minimizeButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize(); @@ -938,6 +990,14 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, + ContainerRenderColorTokens renderColorTokens, + float alpha) { + restoreButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize(); @@ -979,6 +1039,12 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float RadianceSizeUtils.getTitlePaneIconSize()); } + @Override + public void drawColorSchemeIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens, float alpha) { + maximizeButtonProvider.drawIcon(g, renderColorTokens, alpha, + RadianceSizeUtils.getTitlePaneIconSize()); + } + @Override public Dimension getIconDimension() { int size = RadianceSizeUtils.getTitlePaneIconSize();