Skip to content

Commit

Permalink
Third pass for tonal Business
Browse files Browse the repository at this point in the history
* Add Business Black Steel
* Add isDark() to the ContainerRenderColorTokens
* Update various painters to use different tokens for the dark visuals

For #400
  • Loading branch information
kirill-grouchnikov committed Dec 13, 2024
1 parent 5348990 commit 884a8d9
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@
import org.pushingpixels.radiance.demo.theming.main.check.selector.*;
import org.pushingpixels.radiance.demo.theming.main.check.svg.tango.*;
import org.pushingpixels.radiance.demo.theming.main.check.svg.vaadin.*;
import org.pushingpixels.radiance.theming.api.ComponentState;
import org.pushingpixels.radiance.theming.api.RadianceLookAndFeel;
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex;
import org.pushingpixels.radiance.theming.api.*;
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex.ComponentOrParentChainScope;
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices;
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices.ColorSchemeAssociationKind;
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices.DecorationAreaType;
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices.Side;
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices.TabCloseKind;
import org.pushingpixels.radiance.theming.api.combo.WidestComboPopupPrototype;
import org.pushingpixels.radiance.theming.api.palette.TonalSkin;
import org.pushingpixels.radiance.theming.api.skin.RadianceGeminiLookAndFeel;
import org.pushingpixels.radiance.theming.api.skin.SkinInfo;
import org.pushingpixels.radiance.theming.api.tabbed.TabCloseCallback;
Expand Down Expand Up @@ -84,17 +82,31 @@ public class Check extends JFrame {
public Check() {
super("Radiance test application");

if (UIManager.getLookAndFeel() instanceof RadianceLookAndFeel) {
setIconImage(RadianceLogo.getLogoImage(this,
RadianceThemingCortex.ComponentScope.getCurrentSkin(this.getRootPane())
.getColorScheme(DecorationAreaType.PRIMARY_TITLE_PANE,
ColorSchemeAssociationKind.FILL, ComponentState.ENABLED)));
LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
if (lookAndFeel instanceof RadianceLookAndFeel) {
RadianceSkin skin = RadianceThemingCortex.ComponentScope.getCurrentSkin(this.getRootPane());
if (skin instanceof TonalSkin) {
setIconImage(RadianceLogo.getLogoImage(this,
skin.getBackgroundRenderColorTokens(
RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE)));
} else {
setIconImage(RadianceLogo.getLogoImage(this,
skin.getColorScheme(DecorationAreaType.PRIMARY_TITLE_PANE,
ColorSchemeAssociationKind.FILL, ComponentState.ENABLED)));
}
}
RadianceThemingCortex.GlobalScope.registerSkinChangeListener(() -> SwingUtilities.invokeLater(
() -> setIconImage(RadianceLogo.getLogoImage(Check.this,
RadianceThemingCortex.ComponentScope.getCurrentSkin(Check.this.getRootPane())
.getColorScheme(DecorationAreaType.PRIMARY_TITLE_PANE,
ColorSchemeAssociationKind.FILL, ComponentState.ENABLED)))));
RadianceThemingCortex.GlobalScope.registerSkinChangeListener(() -> SwingUtilities.invokeLater(() -> {
RadianceSkin skin = RadianceThemingCortex.ComponentScope.getCurrentSkin(getRootPane());
if (skin instanceof TonalSkin) {
setIconImage(RadianceLogo.getLogoImage(Check.this,
skin.getBackgroundRenderColorTokens(
DecorationAreaType.PRIMARY_TITLE_PANE)));
} else {
setIconImage(RadianceLogo.getLogoImage(Check.this,
skin.getColorScheme(DecorationAreaType.PRIMARY_TITLE_PANE,
ColorSchemeAssociationKind.FILL, ComponentState.ENABLED)));
}
}));

setLayout(new BorderLayout());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.pushingpixels.radiance.demo.theming.main.Check;
import org.pushingpixels.radiance.theming.api.RadianceSkin;
import org.pushingpixels.radiance.theming.api.RadianceThemingCortex;
import org.pushingpixels.radiance.theming.api.skin.BusinessBlueSteelSkin;
import org.pushingpixels.radiance.theming.api.skin.BusinessBlackSteelSkin;

import javax.swing.*;
import java.awt.*;
Expand All @@ -41,7 +41,7 @@

public class TonalCheck {
public static void main(String[] args) {
RadianceSkin tonalSkin = new BusinessBlueSteelSkin.BusinessBlueSteelTonalSkin();
RadianceSkin tonalSkin = new BusinessBlackSteelSkin.BusinessBlackSteelTonalSkin();
//new ControlStates.SampleSkin(new AquaColorScheme());

RadianceThemingCortex.GlobalScope.registerWidget("org.pushingpixels.radiance.theming" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private void paintTitleBackground(Graphics2D original, Component comp, int width

private void paintTitleBackground(Graphics2D original, Component comp, int width, int height,
ExtendedContainerRenderColorTokens renderColorTokens) {
boolean isDark = renderColorTokens.getBaseContainerColorTokens().isDark();
ContainerColorTokens containerColorTokens =
renderColorTokens.getBaseContainerColorTokens().getContainerColorTokens();

Expand All @@ -169,7 +170,7 @@ private void paintTitleBackground(Graphics2D original, Component comp, int width
new float[] { 0.0f, 0.5f, 1.0f },
new Color[] {
containerColorTokens.getContainer(),
containerColorTokens.getContainerLowest(),
isDark ? containerColorTokens.getContainerHighest() : containerColorTokens.getContainerLowest(),
containerColorTokens.getContainer() },
CycleMethod.REPEAT);
g2d.setPaint(gradientTop);
Expand All @@ -186,9 +187,9 @@ private void paintTitleBackground(Graphics2D original, Component comp, int width
LinearGradientPaint gradientBottom = new LinearGradientPaint(0, 0, width, 0,
new float[] { 0.0f, 0.5f, 1.0f },
new Color[] {
containerColorTokens.getContainerHighest(),
isDark ? containerColorTokens.getContainerLowest() : containerColorTokens.getContainerHighest(),
containerColorTokens.getContainer(),
containerColorTokens.getContainerHighest()
isDark ? containerColorTokens.getContainerLowest() : containerColorTokens.getContainerHighest()
},
CycleMethod.REPEAT);
g2d.setPaint(gradientBottom);
Expand Down Expand Up @@ -247,6 +248,7 @@ private void paintExtraBackground(Graphics2D graphics, Container parent, Compone

private void paintExtraBackground(Graphics2D graphics, Container parent, Component comp,
int width, int height, ExtendedContainerRenderColorTokens renderColorTokens) {
boolean isDark = renderColorTokens.getBaseContainerColorTokens().isDark();
ContainerColorTokens containerColorTokens =
renderColorTokens.getBaseContainerColorTokens().getContainerColorTokens();

Expand All @@ -264,9 +266,9 @@ private void paintExtraBackground(Graphics2D graphics, Container parent, Compone
-offset.x, 0, -offset.x + pWidth, 0,
new float[] { 0.0f, 0.5f, 1.0f },
new Color[] {
containerColorTokens.getContainerHighest(),
isDark ? containerColorTokens.getContainerLowest() : containerColorTokens.getContainerHighest(),
containerColorTokens.getContainer(),
containerColorTokens.getContainerHighest()
isDark ? containerColorTokens.getContainerLowest() : containerColorTokens.getContainerHighest()
},
CycleMethod.REPEAT);
Graphics2D g2d = (Graphics2D) graphics.create();
Expand Down Expand Up @@ -307,6 +309,7 @@ public void paintDecorationArea(Graphics2D graphics, Component comp,
RadianceThemingSlices.DecorationAreaType decorationAreaType, Shape contour,
ExtendedContainerRenderColorTokens renderColorTokens) {

boolean isDark = renderColorTokens.getBaseContainerColorTokens().isDark();
ContainerColorTokens containerColorTokens =
renderColorTokens.getBaseContainerColorTokens().getContainerColorTokens();

Expand All @@ -325,9 +328,9 @@ public void paintDecorationArea(Graphics2D graphics, Component comp,
-offset.x, 0, -offset.x + pWidth, 0,
new float[] { 0.0f, 0.5f, 1.0f },
new Color[] {
containerColorTokens.getContainerHighest(),
isDark ? containerColorTokens.getContainerLowest() : containerColorTokens.getContainerHighest(),
containerColorTokens.getContainer(),
containerColorTokens.getContainerHighest()
isDark ? containerColorTokens.getContainerLowest() : containerColorTokens.getContainerHighest()
},
CycleMethod.REPEAT);
Graphics2D g2d = (Graphics2D) graphics.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ private static ContainerRenderColorTokens getContainerRenderColorTokens(
DynamicScheme dynamicScheme, PaletteContainerColorsResolver tonalContainerColorResolver) {

return new ContainerRenderColorTokens() {
@Override
public boolean isDark() {
return dynamicScheme.isDark;
}

@Override
public ContainerColorTokens getContainerColorTokens() {
return new ContainerColorTokens() {
Expand Down Expand Up @@ -534,6 +539,11 @@ private static ContainerRenderColorTokens overlay(ContainerRenderColorTokens ori
Color containerOutlineVariant = original.getContainerOutlineColorTokens().getContainerOutlineVariant();

return new ContainerRenderColorTokens() {
@Override
public boolean isDark() {
return original.isDark();
}

@Override
public ContainerColorTokens getContainerColorTokens() {
return new ContainerColorTokens() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
package org.pushingpixels.radiance.theming.api.palette;

public interface ContainerRenderColorTokens {
boolean isDark();

ContainerColorTokens getContainerColorTokens();
OnContainerColorTokens getOnContainerColorTokens();
ContainerOutlineColorTokens getContainerOutlineColorTokens();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@

import org.pushingpixels.ephemeral.chroma.hct.Hct;
import org.pushingpixels.radiance.theming.api.*;
import org.pushingpixels.radiance.theming.api.colorscheme.ColorSchemeSingleColorQuery;
import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.painter.border.ClassicTonalBorderPainter;
import org.pushingpixels.radiance.theming.api.painter.decoration.ArcDecorationPainter;
import org.pushingpixels.radiance.theming.api.painter.decoration.BrushedMetalDecorationPainter;
import org.pushingpixels.radiance.theming.api.painter.fill.ClassicTonalFillPainter;
import org.pushingpixels.radiance.theming.api.painter.fill.SpecularRectangularFillPainter;
import org.pushingpixels.radiance.theming.api.painter.overlay.BottomLineOverlayPainter;
import org.pushingpixels.radiance.theming.api.painter.overlay.BottomLineTonalOverlayPainter;
import org.pushingpixels.radiance.theming.api.painter.overlay.TopShadowOverlayPainter;
import org.pushingpixels.radiance.theming.api.palette.ColorSchemeUtils;
import org.pushingpixels.radiance.theming.api.palette.ContainerColorTokensSingleColorQuery;
import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2;
import org.pushingpixels.radiance.theming.api.shaper.ClassicButtonShaper;

Expand Down Expand Up @@ -93,8 +93,8 @@ protected BusinessAccentedTonalSkin(AccentBuilder accentBuilder) {

// add an overlay painter to paint separator lines along the bottom
// edges of title panes and menu bars
BottomLineOverlayPainter bottomLineOverlayPainter = new BottomLineOverlayPainter(
ColorSchemeSingleColorQuery.MID);
BottomLineTonalOverlayPainter bottomLineOverlayPainter = new BottomLineTonalOverlayPainter(
ContainerColorTokensSingleColorQuery.CONTAINER_OUTLINE);
this.addOverlayPainter(bottomLineOverlayPainter, RadianceThemingSlices.DecorationAreaType.HEADER);

this.buttonShaper = new ClassicButtonShaper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
*/
package org.pushingpixels.radiance.theming.api.skin;

import org.pushingpixels.radiance.theming.api.ComponentState;
import org.pushingpixels.radiance.theming.api.RadianceColorSchemeBundle;
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices;
import org.pushingpixels.radiance.theming.api.RadianceSkin;
import org.pushingpixels.ephemeral.chroma.hct.Hct;
import org.pushingpixels.radiance.theming.api.*;
import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.palette.ColorSchemeUtils;
import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2;

/**
* <code>Business Black Steel</code> skin. This class is part of officially supported API.
Expand Down Expand Up @@ -102,4 +102,40 @@ public BusinessBlackSteelSkin() {
public String getDisplayName() {
return NAME;
}

public static class BusinessBlackSteelTonalSkin extends BusinessAccentedTonalSkin {
public static final String NAME = "Business Black Steel Tonal";

public BusinessBlackSteelTonalSkin() {
super(new AccentBuilder()
.withWindowChromeAccent(ColorSchemeUtils.getDarkTonalFidelityColorScheme(
Hct.fromInt(0xFF404040), Hct.fromInt(0xFF565656), Hct.fromInt(0xFF616161)))
.withWindowChromeHighlightsAccent(ColorSchemeUtils.getLightTonalFidelityColorScheme(
Hct.fromInt(0xFF85A3B5), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0)))
.withActiveControlsAccent(ColorSchemeUtils.getLightTonalFidelityColorScheme(
Hct.fromInt(0xFF98B7CC), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0)))
.withHighlightsAccent(ColorSchemeUtils.getLightTonalFidelityColorScheme(
Hct.fromInt(0xFFA1BCCF), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0))));

RadianceColorScheme2 controlPaneColorScheme =
ColorSchemeUtils.getLightTonalFidelityColorScheme(Hct.fromInt(0xFFAFBEC7),
Hct.fromInt(0xFFD5DBDF), Hct.fromInt(0xFFD0D7DC));

RadianceColorSchemeBundle2 businessBlueSteelControlBundle =
new RadianceColorSchemeBundle2(controlPaneColorScheme);
businessBlueSteelControlBundle.registerColorScheme(
getActiveControlsAccent(),
RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT,
ComponentState.getActiveStates());
this.registerDecorationAreaSchemeBundle(businessBlueSteelControlBundle,
controlPaneColorScheme.getExtendedMutedContainerTokens(),
RadianceThemingSlices.DecorationAreaType.CONTROL_PANE,
RadianceThemingSlices.DecorationAreaType.FOOTER);
}

@Override
public String getDisplayName() {
return NAME;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ public class RadianceBusinessBlackSteelLookAndFeel extends
public RadianceBusinessBlackSteelLookAndFeel() {
super(new BusinessBlackSteelSkin());
}

public static class RadianceBusinessBlackSteelTonalLookAndFeel extends RadianceLookAndFeel {
public RadianceBusinessBlackSteelTonalLookAndFeel() {
super(new BusinessBlackSteelSkin.BusinessBlackSteelTonalSkin());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class BladeContainerRenderColorTokens implements ContainerRenderColorToke
private OnContainerColorTokens onContainerColorTokens;
private ContainerOutlineColorTokens containerOutlineColorTokens;

public boolean isDark = false;
public Color containerLowest = Color.white;
public Color containerLow = Color.white;
public Color container = Color.white;
Expand Down Expand Up @@ -106,6 +107,11 @@ public Color getContainerOutlineVariant() {
};
}

@Override
public boolean isDark() {
return this.isDark;
}

@Override
public ContainerColorTokens getContainerColorTokens() {
return this.containerColorTokens;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public static void populateModificationAwareColorTokens(

bladeRenderColorTokens.combinedName = "[" + warningColorTokens.hashCode() + ":" + modificationCyclePosition
+ "], [" + emergencyColorTokens.hashCode() + ":" + (1.0f - modificationCyclePosition) + "]";
bladeRenderColorTokens.isDark = warningColorTokens.isDark() && emergencyColorTokens.isDark();
}

public static void populateColorScheme(
Expand Down Expand Up @@ -319,6 +320,8 @@ public static void populateColorTokens(

nameBuilder.append(currColorTokens.hashCode());

boolean isDark = currColorTokens.isDark();

Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates =
(modelStateInfo == null) ? null : modelStateInfo.getStateContributionMap();

Expand Down Expand Up @@ -367,6 +370,7 @@ public static void populateColorTokens(

nameBuilder.append(", [").append(contributionColorTokens.hashCode()).append(":")
.append(amount).append("]");
isDark = isDark && contributionColorTokens.isDark();
}
}

Expand All @@ -385,6 +389,7 @@ public static void populateColorTokens(
bladeRenderColorTokens.containerOutlineDisabledAlpha = containerOutlineDisabledAlpha;

bladeRenderColorTokens.combinedName = nameBuilder.toString();
bladeRenderColorTokens.isDark = isDark;
}

public interface ColorSchemeDelegate {
Expand Down Expand Up @@ -585,6 +590,8 @@ public static void populateColorTokens(

nameBuilder.append(currColorTokens.hashCode());

boolean isDark = currColorTokens.isDark();

Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates =
(modelStateInfo == null) ? null :
(useNoSelectionStateContributionMap ? modelStateInfo.getStateNoSelectionContributionMap()
Expand Down Expand Up @@ -633,6 +640,7 @@ public static void populateColorTokens(

nameBuilder.append(", [").append(contributionColorTokens.hashCode()).append(":")
.append(amount).append("]");
isDark = isDark && contributionColorTokens.isDark();
}
}

Expand All @@ -651,6 +659,7 @@ public static void populateColorTokens(
bladeRenderColorTokens.containerOutlineDisabledAlpha = containerOutlineDisabledAlpha;

bladeRenderColorTokens.combinedName = nameBuilder.toString();
bladeRenderColorTokens.isDark = isDark;
}

public static void populateColorScheme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,14 @@ public static void paintTonalSeparator(Component c, Graphics g,

Color backgroundFill = RadianceColorUtilities.getTonalBackgroundFillColor(
c, RadianceThemingSlices.ContainerType.NEUTRAL);
Color primary = renderColorTokens.getContainerOutlineColorTokens().getContainerOutline();
Color primary = renderColorTokens.isDark()
? renderColorTokens.getContainerOutlineColorTokens().getContainerOutlineVariant()
: renderColorTokens.getContainerOutlineColorTokens().getContainerOutline();
// TODO: TONAL - verify this across light and dark skins
Color secondary = renderColorTokens.getContainerColorTokens().getContainerLow();
System.out.println("Separator in " + decorationAreaType +
": primary=" + RadianceColorUtilities.encode(primary) + ", secondary=" +
RadianceColorUtilities.encode(secondary));

Color primaryZero = toUseAlphaColors
? RadianceColorUtilities.getAlphaColor(primary, 0)
Expand Down
Loading

0 comments on commit 884a8d9

Please sign in to comment.