diff --git a/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/RadianceLogo.java b/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/RadianceLogo.java index e1b54a361..b20db4b8a 100644 --- a/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/RadianceLogo.java +++ b/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/RadianceLogo.java @@ -36,7 +36,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.palette.SurfaceRenderColorTokens; import javax.swing.*; import java.awt.*; @@ -53,10 +53,11 @@ public static RadianceIcon getLogoIcon(RadianceColorScheme scheme) { return base; } - public static RadianceIcon getLogoIcon(ContainerRenderColorTokens renderColorTokens) { + public static RadianceIcon getLogoIcon(SurfaceRenderColorTokens renderColorTokens) { // Step 1 - create a colorized version of the transcoded Radiance logo RadianceIcon base = radiance_menu.factory().createNewIcon(); - base.setColorFilter(color -> renderColorTokens.getOnContainerColorTokens().getOnContainer()); + base.setColorFilter(color -> renderColorTokens.getSurfaceContainerRenderColorTokens() + .getOnContainerColorTokens().getOnContainer()); // Step 2 - configure the colorized version to be 16x16 base.setDimension(new Dimension(16, 16)); // Step 3 - good to go @@ -67,7 +68,7 @@ public static BufferedImage getLogoImage(Component comp, RadianceColorScheme sch return getLogoIcon(scheme).toImage(RadianceCommonCortex.getScaleFactor(comp)); } - public static BufferedImage getLogoImage(Component comp, ContainerRenderColorTokens renderColorTokens) { + public static BufferedImage getLogoImage(Component comp, SurfaceRenderColorTokens renderColorTokens) { return getLogoIcon(renderColorTokens).toImage(RadianceCommonCortex.getScaleFactor(comp)); } diff --git a/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/palette/ControlStates.java b/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/palette/ControlStates.java index e3b27fd21..a016bf14e 100644 --- a/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/palette/ControlStates.java +++ b/demos/theming-demo/src/main/java/org/pushingpixels/radiance/demo/theming/main/palette/ControlStates.java @@ -95,13 +95,13 @@ public SampleSkin(RadianceColorScheme accentScheme) { RadianceThemingSlices.DecorationAreaType.HEADER); // First tonal configuration - Hct seedHct = Hct.fromInt(0xFF20F290); + Hct seedHct = Hct.fromInt(0xFF9020F4); double seedHue = seedHct.getHue(); double seedChroma = seedHct.getChroma(); TonalPalette primary = TonalPalette.fromHueAndChroma(seedHue, seedChroma); - TonalPalette neutral = TonalPalette.fromHueAndChroma(seedHue, 10.0); - TonalPalette neutralVariant = TonalPalette.fromHueAndChroma(seedHue, 16.0); + TonalPalette neutral = TonalPalette.fromHueAndChroma(seedHue, 6.0); + TonalPalette neutralVariant = TonalPalette.fromHueAndChroma(seedHue, 8.0); Palettes samplePalettes = Palettes.builder() .setNeutralPalette(neutral) @@ -114,10 +114,11 @@ public SampleSkin(RadianceColorScheme accentScheme) { this.registerDecorationAreaColorScheme(lightColorScheme, RadianceThemingSlices.DecorationAreaType.NONE); - this.registerAsDecorationArea(lightColorScheme.getTonalContainerTokens(), - RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE, - RadianceThemingSlices.DecorationAreaType.SECONDARY_TITLE_PANE, - RadianceThemingSlices.DecorationAreaType.HEADER); + this.registerAsDecorationArea( + lightColorScheme.getTonalSurfaceRenderColorTokens(), + RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE, + RadianceThemingSlices.DecorationAreaType.SECONDARY_TITLE_PANE, + RadianceThemingSlices.DecorationAreaType.HEADER); this.buttonShaper = new ClassicButtonShaper(); this.fillPainter = new ClassicTonalFillPainter(); 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 a168b745e..39163c3d8 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 @@ -39,6 +39,7 @@ import org.pushingpixels.radiance.theming.api.painter.overlay.RadianceOverlayPainter; import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens; import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2; +import org.pushingpixels.radiance.theming.api.palette.SurfaceRenderColorTokens; import org.pushingpixels.radiance.theming.api.palette.TonalSkin; import org.pushingpixels.radiance.theming.api.shaper.RadianceButtonShaper; import org.pushingpixels.radiance.theming.api.trait.RadianceTrait; @@ -202,7 +203,7 @@ public RadianceColorScheme getWindowChromeAccent() { */ private Map backgroundColorSchemeMap; - private Map tonalBackgroundRenderColorTokensMap; + private Map tonalBackgroundRenderColorTokensMap; /** * Maps decoration area type to the registered overlay painters. Each @@ -568,16 +569,15 @@ public void registerDecorationAreaSchemeBundle( } public void registerDecorationAreaColorScheme( - RadianceColorScheme2 colorScheme, - ContainerRenderColorTokens backgroundRenderColorTokens, - RadianceThemingSlices.DecorationAreaType... areaTypes) { + RadianceColorScheme2 colorScheme, + SurfaceRenderColorTokens backgroundRenderColorTokens, + RadianceThemingSlices.DecorationAreaType... areaTypes) { if (colorScheme == null) { return; } if (backgroundRenderColorTokens == null) { - throw new IllegalArgumentException( - "Cannot pass null background color render tokens"); + throw new IllegalArgumentException("Cannot pass null background color render tokens"); } for (RadianceThemingSlices.DecorationAreaType areaType : areaTypes) { @@ -603,7 +603,7 @@ public void registerDecorationAreaSchemeBundle( public void registerDecorationAreaColorScheme( RadianceColorScheme2 colorScheme, RadianceThemingSlices.DecorationAreaType... areaTypes) { - this.registerDecorationAreaColorScheme(colorScheme, colorScheme.getMutedContainerTokens(), + this.registerDecorationAreaColorScheme(colorScheme, colorScheme.getSurfaceRenderColorTokens(), areaTypes); } @@ -629,7 +629,7 @@ public void registerAsDecorationArea(RadianceColorScheme backgroundColorScheme, } } - public void registerAsDecorationArea(ContainerRenderColorTokens backgroundRenderColorTokens, + public void registerAsDecorationArea(SurfaceRenderColorTokens backgroundRenderColorTokens, RadianceThemingSlices.DecorationAreaType... areaTypes) { if (backgroundRenderColorTokens == null) { throw new IllegalArgumentException( @@ -978,7 +978,7 @@ public final RadianceColorScheme getBackgroundColorScheme(RadianceThemingSlices. return this.backgroundColorSchemeMap.get(RadianceThemingSlices.DecorationAreaType.NONE); } - public final ContainerRenderColorTokens getBackgroundRenderColorTokens( + public final SurfaceRenderColorTokens getBackgroundRenderColorTokens( RadianceThemingSlices.DecorationAreaType decorationAreaType) { // 1 - check the registered background scheme for this specific area type. if (this.tonalBackgroundRenderColorTokensMap.containsKey(decorationAreaType)) { @@ -986,8 +986,8 @@ public final ContainerRenderColorTokens getBackgroundRenderColorTokens( } // 2 - check the registered scheme bundle for this specific area type. if (this.tonalColorSchemeMap.containsKey(decorationAreaType)) { - ContainerRenderColorTokens registered = this.tonalColorSchemeMap.get( - decorationAreaType).getMutedContainerTokens(); + SurfaceRenderColorTokens registered = this.tonalBackgroundRenderColorTokensMap. + get(decorationAreaType); if (registered != null) { return registered; } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/ArcDecorationPainter.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/ArcDecorationPainter.java index e95a3701c..813f2d5ba 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/ArcDecorationPainter.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/ArcDecorationPainter.java @@ -32,7 +32,8 @@ 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.ContainerRenderColorTokens; +import org.pushingpixels.radiance.theming.api.palette.ContainerColorTokens; +import org.pushingpixels.radiance.theming.api.palette.SurfaceRenderColorTokens; import org.pushingpixels.radiance.theming.api.palette.TonalSkin; import org.pushingpixels.radiance.theming.internal.utils.RadianceCoreUtilities; @@ -146,7 +147,10 @@ private void paintTitleBackground(Graphics2D original, Component comp, int width } private void paintTitleBackground(Graphics2D original, Component comp, int width, int height, - ContainerRenderColorTokens renderColorTokens) { + SurfaceRenderColorTokens renderColorTokens) { + ContainerColorTokens containerColorTokens = + renderColorTokens.getSurfaceContainerRenderColorTokens().getContainerColorTokens(); + // Create a new Graphics2D object so that we can apply clipping to it without having // to reset the state after we're done Graphics2D g2d = (Graphics2D) original.create(); @@ -161,11 +165,12 @@ private void paintTitleBackground(Graphics2D original, Component comp, int width g2d.setClip(clipTop); LinearGradientPaint gradientTop = new LinearGradientPaint(0, 0, width, 0, - new float[] { 0.0f, 0.5f, 1.0f }, new Color[] { - renderColorTokens.getContainerColorTokens().getContainer(), - renderColorTokens.getContainerColorTokens().getContainerLowest(), - renderColorTokens.getContainerColorTokens().getContainer() }, - CycleMethod.REPEAT); + new float[] { 0.0f, 0.5f, 1.0f }, + new Color[] { + containerColorTokens.getContainer(), + containerColorTokens.getContainerLowest(), + containerColorTokens.getContainer() }, + CycleMethod.REPEAT); g2d.setPaint(gradientTop); g2d.fillRect(0, 0, width, height); @@ -178,12 +183,13 @@ private void paintTitleBackground(Graphics2D original, Component comp, int width g2d.setClip(clipBottom); LinearGradientPaint gradientBottom = new LinearGradientPaint(0, 0, width, 0, - new float[] { 0.0f, 0.5f, 1.0f }, - new Color[] { - renderColorTokens.getContainerColorTokens().getContainerHighest(), - renderColorTokens.getContainerColorTokens().getContainer(), - renderColorTokens.getContainerColorTokens().getContainerHighest() }, - CycleMethod.REPEAT); + new float[] { 0.0f, 0.5f, 1.0f }, + new Color[] { + containerColorTokens.getContainerHighest(), + containerColorTokens.getContainer(), + containerColorTokens.getContainerHighest() + }, + CycleMethod.REPEAT); g2d.setPaint(gradientBottom); g2d.fillRect(0, 0, width, height); @@ -239,7 +245,10 @@ private void paintExtraBackground(Graphics2D graphics, Container parent, Compone } private void paintExtraBackground(Graphics2D graphics, Container parent, Component comp, - int width, int height, ContainerRenderColorTokens renderColorTokens) { + int width, int height, SurfaceRenderColorTokens renderColorTokens) { + ContainerColorTokens containerColorTokens = + renderColorTokens.getSurfaceContainerRenderColorTokens().getContainerColorTokens(); + Point offset = RadianceCoreUtilities.getOffsetInRootPaneCoords(comp); JRootPane rootPane = SwingUtilities.getRootPane(parent); // fix for bug 234 - Window doesn't have a root pane. @@ -250,14 +259,15 @@ private void paintExtraBackground(Graphics2D graphics, Container parent, Compone : layeredPane.getWidth() - layeredPaneInsets.left - layeredPaneInsets.right; if (pWidth != 0) { - LinearGradientPaint gradientBottom = new LinearGradientPaint(-offset.x, 0, - -offset.x + pWidth, 0, new float[] { 0.0f, 0.5f, 1.0f }, - new Color[] { - renderColorTokens.getContainerColorTokens().getContainerHighest(), - renderColorTokens.getContainerColorTokens().getContainer(), - renderColorTokens.getContainerColorTokens().getContainerHighest() - }, - CycleMethod.REPEAT); + LinearGradientPaint gradientBottom = new LinearGradientPaint( + -offset.x, 0, -offset.x + pWidth, 0, + new float[] { 0.0f, 0.5f, 1.0f }, + new Color[] { + containerColorTokens.getContainerHighest(), + containerColorTokens.getContainer(), + containerColorTokens.getContainerHighest() + }, + CycleMethod.REPEAT); Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setPaint(gradientBottom); g2d.fillRect(-offset.x, 0, pWidth, height); @@ -293,8 +303,12 @@ public void paintDecorationArea(Graphics2D graphics, Component comp, RadianceThe @Override public void paintDecorationArea(Graphics2D graphics, Component comp, - RadianceThemingSlices.DecorationAreaType decorationAreaType, Shape contour, - ContainerRenderColorTokens renderColorTokens) { + RadianceThemingSlices.DecorationAreaType decorationAreaType, Shape contour, + SurfaceRenderColorTokens renderColorTokens) { + + ContainerColorTokens containerColorTokens = + renderColorTokens.getSurfaceContainerRenderColorTokens().getContainerColorTokens(); + Component parent = RadianceCoreUtilities.getHeaderParent(comp); Point offset = RadianceCoreUtilities.getOffsetInRootPaneCoords(comp); JRootPane rootPane = SwingUtilities.getRootPane(parent); @@ -306,14 +320,15 @@ public void paintDecorationArea(Graphics2D graphics, Component comp, : layeredPane.getWidth() - layeredPaneInsets.left - layeredPaneInsets.right; if (pWidth != 0) { - LinearGradientPaint gradientBottom = new LinearGradientPaint(-offset.x, 0, - -offset.x + pWidth, 0, new float[] { 0.0f, 0.5f, 1.0f }, - new Color[] { - renderColorTokens.getContainerColorTokens().getContainerHighest(), - renderColorTokens.getContainerColorTokens().getContainer(), - renderColorTokens.getContainerColorTokens().getContainerHighest() - }, - CycleMethod.REPEAT); + LinearGradientPaint gradientBottom = new LinearGradientPaint( + -offset.x, 0, -offset.x + pWidth, 0, + new float[] { 0.0f, 0.5f, 1.0f }, + new Color[] { + containerColorTokens.getContainerHighest(), + containerColorTokens.getContainer(), + containerColorTokens.getContainerHighest() + }, + CycleMethod.REPEAT); Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setPaint(gradientBottom); g2d.fill(contour); diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/ImageWrapperDecorationPainter.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/ImageWrapperDecorationPainter.java index 09984b959..5e058689b 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/ImageWrapperDecorationPainter.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/ImageWrapperDecorationPainter.java @@ -33,7 +33,7 @@ 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.ContainerRenderColorTokens; +import org.pushingpixels.radiance.theming.api.palette.SurfaceRenderColorTokens; import org.pushingpixels.radiance.theming.api.palette.TonalSkin; import org.pushingpixels.radiance.theming.internal.utils.RadianceCoreUtilities; import org.pushingpixels.radiance.theming.internal.utils.RadianceImageCreator; @@ -118,10 +118,11 @@ private void paintTitleBackground(Graphics2D graphics, Component comp, RadianceThemingSlices.DecorationAreaType decorationAreaType, int width, int height, RadianceSkin skin) { if (skin instanceof TonalSkin) { - ContainerRenderColorTokens tileRenderColorTokens = + SurfaceRenderColorTokens tileRenderColorTokens = skin.getBackgroundRenderColorTokens(decorationAreaType); if (this.baseDecorationPainter == null) { - graphics.setColor(tileRenderColorTokens.getContainerColorTokens().getContainerHigh()); + graphics.setColor(tileRenderColorTokens.getSurfaceContainerRenderColorTokens(). + getContainerColorTokens().getContainerHigh()); graphics.fillRect(0, 0, width, height); } else { this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType, @@ -168,12 +169,13 @@ private void paintExtraBackground(Graphics2D graphics, Component comp, Point offset = RadianceCoreUtilities.getOffsetInRootPaneCoords(comp); if (skin instanceof TonalSkin) { - ContainerRenderColorTokens tileRenderColorTokens = - skin.getBackgroundRenderColorTokens(decorationAreaType); + SurfaceRenderColorTokens tileRenderColorTokens = + skin.getBackgroundRenderColorTokens(decorationAreaType); if (this.baseDecorationPainter != null) { this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType, width, height, skin); } else { - graphics.setColor(tileRenderColorTokens.getContainerColorTokens().getContainerHigh()); + graphics.setColor(tileRenderColorTokens.getSurfaceContainerRenderColorTokens() + .getContainerColorTokens().getContainerHigh()); graphics.fillRect(0, 0, width, height); } Graphics2D temp = (Graphics2D) graphics.create(); @@ -217,13 +219,14 @@ public void paintDecorationArea(Graphics2D graphics, Component comp, RadianceThe @Override public void paintDecorationArea(Graphics2D graphics, Component comp, RadianceThemingSlices.DecorationAreaType decorationAreaType, Shape contour, - ContainerRenderColorTokens renderColorTokens) { + SurfaceRenderColorTokens renderColorTokens) { Point offset = RadianceCoreUtilities.getOffsetInRootPaneCoords(comp); if (this.baseDecorationPainter != null) { this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType, contour, renderColorTokens); } else { - graphics.setColor(renderColorTokens.getContainerColorTokens().getContainerHigh()); + graphics.setColor(renderColorTokens.getSurfaceContainerRenderColorTokens() + .getContainerColorTokens().getContainerHigh()); graphics.fill(contour); } Graphics2D temp = (Graphics2D) graphics.create(); @@ -282,7 +285,7 @@ private void tileArea(Graphics2D g, Component comp, RadianceColorScheme tileSche graphics.dispose(); } - private void tileArea(Graphics2D g, Component comp, ContainerRenderColorTokens tileRenderColorTokens, + private void tileArea(Graphics2D g, Component comp, SurfaceRenderColorTokens tileRenderColorTokens, int offsetTextureX, int offsetTextureY, int width, int height) { Graphics2D graphics = (Graphics2D) g.create(); graphics.setComposite(WidgetUtilities.getAlphaComposite(comp, this.textureAlpha, g)); @@ -354,7 +357,7 @@ protected BufferedImage getColorizedTile(double scale, RadianceColorScheme schem return result; } - protected BufferedImage getColorizedTile(double scale, ContainerRenderColorTokens renderColorTokens) { + protected BufferedImage getColorizedTile(double scale, SurfaceRenderColorTokens renderColorTokens) { String key = scale + ":" + renderColorTokens.hashCode(); BufferedImage result = this.colorizedTileMap.get(key); if (result == null) { @@ -367,7 +370,8 @@ protected BufferedImage getColorizedTile(double scale, ContainerRenderColorToken tile2D.drawImage(this.originalTile, 0, 0, (int) (tileWidth / scale), (int) ( tileHeight / scale), null); tile2D.dispose(); - result = RadianceImageCreator.getColorSchemeImage(tileBi, renderColorTokens, 0.0f, 1.0f); + result = RadianceImageCreator.getColorSchemeImage(tileBi, + renderColorTokens.getSurfaceContainerRenderColorTokens(), 0.0f, 1.0f); this.colorizedTileMap.put(key, result); } return result; diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/RadianceDecorationPainter.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/RadianceDecorationPainter.java index b3382b7ff..dbd52c0f9 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/RadianceDecorationPainter.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/decoration/RadianceDecorationPainter.java @@ -32,7 +32,7 @@ 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.ContainerRenderColorTokens; +import org.pushingpixels.radiance.theming.api.palette.SurfaceRenderColorTokens; import org.pushingpixels.radiance.theming.api.trait.RadianceTrait; import java.awt.*; @@ -72,6 +72,6 @@ void paintDecorationArea(Graphics2D graphics, Component comp, RadianceColorScheme colorScheme); default void paintDecorationArea(Graphics2D graphics, Component comp, - RadianceThemingSlices.DecorationAreaType decorationAreaType, Shape contour, - ContainerRenderColorTokens renderColorTokens) {} + RadianceThemingSlices.DecorationAreaType decorationAreaType, Shape contour, + SurfaceRenderColorTokens renderColorTokens) {} } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/fill/ClassicTonalFillPainter.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/fill/ClassicTonalFillPainter.java index 38b2638de..3442e1b4d 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/fill/ClassicTonalFillPainter.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/painter/fill/ClassicTonalFillPainter.java @@ -50,9 +50,9 @@ public ClassicTonalFillPainter() { super("Classic", new float[] {0.0f, 0.5f, 1.0f}, new ContainerColorTokensSingleColorQuery[] { - ContainerColorTokensSingleColorQuery.CONTAINER_HIGH, ContainerColorTokensSingleColorQuery.CONTAINER, - ContainerColorTokensSingleColorQuery.CONTAINER_LOW + ContainerColorTokensSingleColorQuery.CONTAINER_LOW, + ContainerColorTokensSingleColorQuery.CONTAINER_LOWEST } ); } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/ColorSchemeUtils.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/ColorSchemeUtils.java index e4fb7550a..876099818 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/ColorSchemeUtils.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/ColorSchemeUtils.java @@ -337,7 +337,7 @@ public ContainerRenderColorTokens getPrimaryContainerTokens() { @Override public ContainerRenderColorTokens getStateRenderTokens(ComponentState componentState) { // TODO: TONAL - configurable at the skin definition level - ContainerRenderColorTokens defaultActive = this.getPrimaryContainerTokens(); + ContainerRenderColorTokens defaultActive = this.getTonalContainerTokens(); // TODO: TONAL - configurable at the component state level int mixinAmount = 40; if (componentState == ComponentState.PRESSED_UNSELECTED) { @@ -706,7 +706,7 @@ public ContainerRenderColorTokens getPrimaryContainerTokens() { @Override public ContainerRenderColorTokens getStateRenderTokens(ComponentState componentState) { // TODO: TONAL - configurable at the skin definition level - ContainerRenderColorTokens defaultActive = this.getPrimaryContainerTokens(); + ContainerRenderColorTokens defaultActive = this.getTonalContainerTokens(); // TODO: TONAL - configurable at the component state level int mixinAmount = 40; if (componentState == ComponentState.PRESSED_UNSELECTED) { diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteResolverUtils.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteResolverUtils.java index 036af50ea..48aad9c1e 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteResolverUtils.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteResolverUtils.java @@ -221,7 +221,7 @@ public Color getContainerOutlineVariant(Palettes palettes) { return new PaletteColorResolver() { @Override public Color getSurface(Palettes palettes) { - return new Color(palettes.getNeutralPalette().tone(98)); + return new Color(palettes.getNeutralPalette().tone(99)); } @Override diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/RadianceColorScheme2.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/RadianceColorScheme2.java index 332eca7ee..a416052b0 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/RadianceColorScheme2.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/RadianceColorScheme2.java @@ -49,4 +49,46 @@ public interface RadianceColorScheme2 { ContainerRenderColorTokens getPrimaryContainerTokens(); ContainerRenderColorTokens getStateRenderTokens(ComponentState componentState); + + default SurfaceRenderColorTokens getSurfaceRenderColorTokens() { + return getSurfaceRenderColorTokens(getSurfaceContainerTokens()); + } + + default SurfaceRenderColorTokens getMutedSurfaceRenderColorTokens() { + return getSurfaceRenderColorTokens(getMutedContainerTokens()); + } + + default SurfaceRenderColorTokens getTonalSurfaceRenderColorTokens() { + return getSurfaceRenderColorTokens(getTonalContainerTokens()); + } + + default SurfaceRenderColorTokens getPrimarySurfaceRenderColorTokens() { + return getSurfaceRenderColorTokens(getPrimaryContainerTokens()); + } + + private SurfaceRenderColorTokens getSurfaceRenderColorTokens( + ContainerRenderColorTokens containerRenderColorTokens) { + RadianceColorScheme2 me = this; + return new SurfaceRenderColorTokens() { + @Override + public Color getSurface() { + return me.getSurface(); + } + + @Override + public Color getSurfaceDim() { + return me.getSurfaceDim(); + } + + @Override + public Color getSurfaceBright() { + return me.getSurfaceBright(); + } + + @Override + public ContainerRenderColorTokens getSurfaceContainerRenderColorTokens() { + return containerRenderColorTokens; + } + }; + } } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SurfaceRenderColorTokens.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SurfaceRenderColorTokens.java new file mode 100644 index 000000000..ab1139499 --- /dev/null +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SurfaceRenderColorTokens.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2005-2024 Radiance Kirill Grouchnikov. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * o Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * o Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * o Neither the name of the copyright holder nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.pushingpixels.radiance.theming.api.palette; + +import java.awt.*; + +public interface SurfaceRenderColorTokens { + Color getSurface(); + Color getSurfaceDim(); + Color getSurfaceBright(); + ContainerRenderColorTokens getSurfaceContainerRenderColorTokens(); +} 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 160576ca8..82f1d8ae6 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 @@ -191,7 +191,8 @@ public static ContainerRenderColorTokens getRenderColorTokens(Component componen && (componentState == ComponentState.ENABLED))) { // TODO: TONAL - verify that we don't need to use the old logic. // TODO: TONAL - colorization - return skin.getBackgroundRenderColorTokens( DecorationPainterUtils.getDecorationType(component)); + return skin.getBackgroundRenderColorTokens(DecorationPainterUtils.getDecorationType(component)) + .getSurfaceContainerRenderColorTokens(); // component = component.getParent(); } @@ -257,7 +258,8 @@ public static ContainerRenderColorTokens getRenderColorTokens(Component componen && RadianceCoreUtilities.hasFlatAppearance(component, false) && (componentState == ComponentState.ENABLED)) { // TODO: TONAL - verify that we don't need to use the old logic. - return skin.getBackgroundRenderColorTokens( DecorationPainterUtils.getDecorationType(component)); + return skin.getBackgroundRenderColorTokens( DecorationPainterUtils.getDecorationType(component)) + .getSurfaceContainerRenderColorTokens(); // component = component.getParent(); } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceCoreUtilities.java b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceCoreUtilities.java index 3dab737b3..213072f8f 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceCoreUtilities.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/RadianceCoreUtilities.java @@ -42,6 +42,7 @@ import org.pushingpixels.radiance.theming.api.painter.border.RadianceBorderPainter; import org.pushingpixels.radiance.theming.api.painter.decoration.RadianceDecorationPainter; import org.pushingpixels.radiance.theming.api.painter.fill.RadianceFillPainter; +import org.pushingpixels.radiance.theming.api.palette.TonalSkin; import org.pushingpixels.radiance.theming.api.shaper.RadianceButtonShaper; import org.pushingpixels.radiance.theming.api.tabbed.TabCloseCallback; import org.pushingpixels.radiance.theming.api.titlepane.DefaultTitlePaneButtonsProvider; @@ -1831,7 +1832,12 @@ public static Color getBackgroundFill(RadianceSkin skin, RadianceThemingSlices.D if (overlay != null) { return overlay; } - return skin.getBackgroundColorScheme(decorationAreaType).getBackgroundFillColor(); + if (skin instanceof TonalSkin) { + // TODO: TONAL - need configuration APIs? + return skin.getBackgroundRenderColorTokens(decorationAreaType).getSurface(); + } else { + return skin.getBackgroundColorScheme(decorationAreaType).getBackgroundFillColor(); + } } public static Color getTextBackgroundFill(Component component, ComponentState componentState) { 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 8903fb8ef..a9deadeb7 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 @@ -883,7 +883,7 @@ public void paintComponent(Graphics g) { if (skin instanceof TonalSkin) { ContainerRenderColorTokens renderColorTokens = skin.getBackgroundRenderColorTokens( - RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE); + RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE).getSurfaceContainerRenderColorTokens(); // TODO: TONAL - finalize the text echo color logic RadianceTextUtilities.paintTextWithDropShadow(this, graphics, renderColorTokens.getOnContainerColorTokens().getOnContainer(), diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/border/RadiancePaneBorder.java b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/border/RadiancePaneBorder.java index 8e92915af..a2428bfdd 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/border/RadiancePaneBorder.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/internal/utils/border/RadiancePaneBorder.java @@ -71,7 +71,7 @@ public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) { if (skin instanceof TonalSkin) { ContainerRenderColorTokens backgroundRenderColorTokens = skin.getBackgroundRenderColorTokens( - RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE); + RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE).getSurfaceContainerRenderColorTokens(); Component titlePaneComp = RadianceCoreUtilities.getTitlePaneComponent( SwingUtilities.windowForComponent(c)); ContainerRenderColorTokens titleRenderColorTokens = skin.getColorRenderTokens(