Skip to content

Commit

Permalink
Rework the API surface of accented tonal skin builders
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Feb 5, 2025
1 parent db1b5cf commit 422ac9b
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,85 +192,61 @@ public RadianceColorScheme getWindowChromeAccent() {

public static abstract class TonalAccented extends RadianceSkin implements TonalSkin {
public final static class AccentBuilder {
private RadianceColorScheme2 windowChromeAccent;
private ContainerColorTokens windowChromeHighlightsAccent;
private RadianceColorScheme2 enabledControlsAccent;
private RadianceColorScheme2 activeControlsAccent;
private ContainerColorTokens highlightsAccent;
private RadianceColorScheme2 backgroundAccent;
private RadianceColorScheme2 defaultAreaColorScheme;
private ContainerColorTokens defaultAreaHighlightsAccent;
private RadianceColorScheme2 headerAreaColorScheme;
private ContainerColorTokens headerAreaHighlightsAccent;

public AccentBuilder() {
}

public AccentBuilder withWindowChromeAccent(RadianceColorScheme2 windowChromeAccent) {
this.windowChromeAccent = windowChromeAccent;
public AccentBuilder withDefaultAreaColorScheme(RadianceColorScheme2 defaultAreaColorScheme) {
this.defaultAreaColorScheme = defaultAreaColorScheme;
return this;
}

public AccentBuilder withWindowChromeHighlightsAccent(ContainerColorTokens windowChromeHighlightsAccent) {
this.windowChromeHighlightsAccent = windowChromeHighlightsAccent;
public AccentBuilder withDefaultAreaHighlightsAccent(ContainerColorTokens defaultAreaHighlightsAccent) {
this.defaultAreaHighlightsAccent = defaultAreaHighlightsAccent;
return this;
}

public AccentBuilder withActiveControlsAccent(RadianceColorScheme2 activeControlsAccent) {
this.activeControlsAccent = activeControlsAccent;
public AccentBuilder withHeaderAreaColorScheme(RadianceColorScheme2 headerAreaColorScheme) {
this.headerAreaColorScheme = headerAreaColorScheme;
return this;
}

public AccentBuilder withEnabledControlsAccent(RadianceColorScheme2 enabledControlsAccent) {
this.enabledControlsAccent = enabledControlsAccent;
return this;
}

public AccentBuilder withHighlightsAccent(ContainerColorTokens highlightsAccent) {
this.highlightsAccent = highlightsAccent;
return this;
}

public AccentBuilder withBackgroundAccent(RadianceColorScheme2 backgroundAccent) {
this.backgroundAccent = backgroundAccent;
public AccentBuilder withHeaderAreaHighlightsAccent(ContainerColorTokens headerAreaHighlightsAccent) {
this.headerAreaHighlightsAccent = headerAreaHighlightsAccent;
return this;
}
}

private final RadianceColorScheme2 windowChromeAccent;
private final ContainerColorTokens windowChromeHighlightsAccent;
private final RadianceColorScheme2 activeControlsAccent;
private final RadianceColorScheme2 enabledControlsAccent;
private final ContainerColorTokens highlightsAccent;
private final RadianceColorScheme2 backgroundAccent;
private final RadianceColorScheme2 defaultAreaColorScheme;
private final ContainerColorTokens defaultAreaHighlightsAccent;
private final RadianceColorScheme2 headerAreaColorScheme;
private final ContainerColorTokens headerAreaHighlightsAccent;

protected TonalAccented(AccentBuilder accentBuilder) {
this.windowChromeAccent = accentBuilder.windowChromeAccent;
this.windowChromeHighlightsAccent = accentBuilder.windowChromeHighlightsAccent;
this.activeControlsAccent = accentBuilder.activeControlsAccent;
this.enabledControlsAccent = accentBuilder.enabledControlsAccent;
this.highlightsAccent = accentBuilder.highlightsAccent;
this.backgroundAccent = accentBuilder.backgroundAccent;
}

public RadianceColorScheme2 getBackgroundAccent() {
return this.backgroundAccent;
this.defaultAreaColorScheme = accentBuilder.defaultAreaColorScheme;
this.defaultAreaHighlightsAccent = accentBuilder.defaultAreaHighlightsAccent;
this.headerAreaColorScheme = accentBuilder.headerAreaColorScheme;
this.headerAreaHighlightsAccent = accentBuilder.headerAreaHighlightsAccent;
}

public RadianceColorScheme2 getActiveControlsAccent() {
return this.activeControlsAccent;
}

public RadianceColorScheme2 getEnabledControlsAccent() {
return this.enabledControlsAccent;
public RadianceColorScheme2 getDefaultAreaColorScheme() {
return this.defaultAreaColorScheme;
}

public ContainerColorTokens getHighlightsAccent() {
return this.highlightsAccent;
public ContainerColorTokens getDefaultAreaHighlightsAccent() {
return this.defaultAreaHighlightsAccent;
}

public RadianceColorScheme2 getWindowChromeAccent() {
return this.windowChromeAccent;
public RadianceColorScheme2 getHeaderAreaColorScheme() {
return this.headerAreaColorScheme;
}

public ContainerColorTokens getWindowChromeHighlightsAccent() {
return this.windowChromeHighlightsAccent;
public ContainerColorTokens getHeaderAreaHighlightsAccent() {
return this.headerAreaHighlightsAccent;
}
}

Expand Down Expand Up @@ -827,12 +803,11 @@ public final RadianceColorScheme getActiveColorScheme(

public final ContainerColorTokens getActiveContainerTokens(
RadianceThemingSlices.DecorationAreaType decorationAreaType) {
// TODO: TONAL - configure what is active
if (this.tonalColorSchemeMap.containsKey(decorationAreaType)) {
return this.tonalColorSchemeMap.get(decorationAreaType).getMainColorScheme().getTonalContainerTokens();
return this.tonalColorSchemeMap.get(decorationAreaType).getMainColorScheme().getActiveContainerTokens();
}
return this.tonalColorSchemeMap.get(RadianceThemingSlices.DecorationAreaType.NONE)
.getMainColorScheme().getTonalContainerTokens();
.getMainColorScheme().getActiveContainerTokens();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,27 @@ protected BusinessAccentedTonalSkin(AccentBuilder accentBuilder) {
super(accentBuilder);

RadianceColorSchemeBundle2 businessDefaultBundle =
new RadianceColorSchemeBundle2(this.getActiveControlsAccent());
businessDefaultBundle.registerActiveContainerTokens(this.getHighlightsAccent(),
new RadianceColorSchemeBundle2(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFEAEDF3), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE5EAEF)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false));
businessDefaultBundle.registerActiveContainerTokens(this.getDefaultAreaHighlightsAccent(),
RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT,
ComponentState.getActiveStates());
businessDefaultBundle.registerActiveContainerTokens(
this.getActiveControlsAccent().getActiveContainerTokens(),
this.getDefaultAreaColorScheme().getActiveContainerTokens(),
RadianceThemingSlices.ContainerColorTokensAssociationKind.TAB,
ComponentState.SELECTED, ComponentState.ROLLOVER_SELECTED);
this.registerDecorationAreaSchemeBundle(businessDefaultBundle,
businessDefaultBundle.getMainColorScheme().getExtendedTonalContainerTokens(),
RadianceThemingSlices.DecorationAreaType.NONE);

RadianceColorSchemeBundle2 businessDefaultHeaderBundle =
new RadianceColorSchemeBundle2(this.getWindowChromeAccent());
if (this.getWindowChromeHighlightsAccent() != null) {
new RadianceColorSchemeBundle2(this.getHeaderAreaColorScheme());
if (this.getHeaderAreaHighlightsAccent() != null) {
businessDefaultHeaderBundle.registerActiveContainerTokens(
this.getWindowChromeHighlightsAccent(),
this.getHeaderAreaHighlightsAccent(),
RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT,
ComponentState.getActiveStates());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,22 @@ public static class BusinessBlackSteelTonalSkin extends BusinessAccentedTonalSki

public BusinessBlackSteelTonalSkin() {
super(new AccentBuilder()
.withWindowChromeAccent(ColorSchemeUtils.getColorScheme(
.withHeaderAreaColorScheme(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFF555555), Hct.fromInt(0xFF606060), Hct.fromInt(0xFF707070)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ true))
.withWindowChromeHighlightsAccent(ColorSchemeUtils.getContainerTokens(
.withHeaderAreaHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFF85A3B5),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isFidelity */ true,
/* isDark */ false))
.withActiveControlsAccent(ColorSchemeUtils.getColorScheme(
.withDefaultAreaColorScheme(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFF98B7CC), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false))
.withHighlightsAccent(ColorSchemeUtils.getContainerTokens(
.withDefaultAreaHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFFA1BCCF),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isFidelity */ true,
Expand All @@ -138,7 +138,7 @@ public BusinessBlackSteelTonalSkin() {
RadianceColorSchemeBundle2 businessBlackSteelControlBundle =
new RadianceColorSchemeBundle2(controlPaneColorScheme);
businessBlackSteelControlBundle.registerActiveContainerTokens(
getActiveControlsAccent().getActiveContainerTokens(),
getDefaultAreaColorScheme().getActiveContainerTokens(),
RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT,
ComponentState.getActiveStates());
this.registerDecorationAreaSchemeBundle(businessBlackSteelControlBundle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ public static class BusinessBlueSteelTonalSkin extends BusinessAccentedTonalSkin

public BusinessBlueSteelTonalSkin() {
super(new AccentBuilder()
.withWindowChromeAccent(ColorSchemeUtils.getColorScheme(
.withHeaderAreaColorScheme(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFA1BCD0), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false))
.withWindowChromeHighlightsAccent(ColorSchemeUtils.getContainerTokens(
.withHeaderAreaHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFF83AFCE),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isFidelity */ true,
/* isDark */ false))
.withActiveControlsAccent(ColorSchemeUtils.getColorScheme(
.withDefaultAreaColorScheme(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFF98B7CC), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false))
.withHighlightsAccent(ColorSchemeUtils.getContainerTokens(
.withDefaultAreaHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFFEBD296),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isFidelity */ true,
Expand All @@ -128,7 +128,7 @@ public BusinessBlueSteelTonalSkin() {
RadianceColorSchemeBundle2 businessBlueSteelControlBundle =
new RadianceColorSchemeBundle2(controlPaneColorScheme);
businessBlueSteelControlBundle.registerActiveContainerTokens(
getActiveControlsAccent().getActiveContainerTokens(),
getDefaultAreaColorScheme().getActiveContainerTokens(),
RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT,
ComponentState.getActiveStates());
this.registerDecorationAreaSchemeBundle(businessBlueSteelControlBundle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ public static class BusinessTonalSkin extends BusinessAccentedTonalSkin {

public BusinessTonalSkin() {
super(new AccentBuilder()
.withWindowChromeAccent(ColorSchemeUtils.getColorScheme(
.withHeaderAreaColorScheme(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFBDC8D3), Hct.fromInt(0xFFDEDDDF), Hct.fromInt(0xFFE4EAF0)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false))
.withWindowChromeHighlightsAccent(ColorSchemeUtils.getContainerTokens(
.withHeaderAreaHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFFEBD296),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isFidelity */ true,
/* isDark */ false))
.withActiveControlsAccent(ColorSchemeUtils.getColorScheme(
.withDefaultAreaColorScheme(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFEAEDF3), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE5EAEF)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false))
.withHighlightsAccent(ColorSchemeUtils.getContainerTokens(
.withDefaultAreaHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFFEBD296),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isFidelity */ true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected NebulaAccentedTonalSkin(AccentBuilder accentBuilder) {
RadianceThemingSlices.DecorationAreaType.FOOTER);

RadianceColorSchemeBundle2 nebulaDefaultHeaderBundle =
new RadianceColorSchemeBundle2(this.getWindowChromeAccent());
new RadianceColorSchemeBundle2(this.getHeaderAreaColorScheme());
nebulaDefaultHeaderBundle.registerActiveContainerTokens(
nebulaRolloverHighlightContainerTokens,
RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static class NebulaAmethystTonalSkin extends NebulaAccentedTonalSkin {

public NebulaAmethystTonalSkin() {
super(new AccentBuilder()
.withWindowChromeAccent(ColorSchemeUtils.getColorScheme(
.withHeaderAreaColorScheme(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFD1A9F1), Hct.fromInt(0xFFD7DBE1), Hct.fromInt(0xFFF3F7FD)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static class NebulaBrickWallTonalSkin extends NebulaAccentedTonalSkin {

public NebulaBrickWallTonalSkin() {
super(new AccentBuilder()
.withWindowChromeAccent(ColorSchemeUtils.getColorScheme(
.withHeaderAreaColorScheme(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFF6C272), Hct.fromInt(0xFFD7DBE1), Hct.fromInt(0xFFF3F7FD)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static class NebulaTonalSkin extends NebulaAccentedTonalSkin {

public NebulaTonalSkin() {
super(new AccentBuilder()
.withWindowChromeAccent(ColorSchemeUtils.getColorScheme(
.withHeaderAreaColorScheme(ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFD6E3EE), Hct.fromInt(0xFFD7DBE1), Hct.fromInt(0xFFF3F7FD)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
Expand Down

0 comments on commit 422ac9b

Please sign in to comment.