Skip to content

Commit

Permalink
Add system tonal palettes and container tokens
Browse files Browse the repository at this point in the history
And wire support for modified animation on tonal buttons for #400
  • Loading branch information
kirill-grouchnikov committed Dec 3, 2024
1 parent e8b267c commit 267178c
Show file tree
Hide file tree
Showing 12 changed files with 943 additions and 485 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2;
import org.pushingpixels.radiance.theming.api.palette.TonalSkin;
import org.pushingpixels.radiance.theming.api.shaper.ClassicButtonShaper;
import org.pushingpixels.radiance.theming.internal.RadianceSynapse;

import javax.swing.*;
import java.awt.*;
Expand All @@ -60,12 +61,19 @@ public ControlStates() {
super("Control states");

this.setLayout(new FlowLayout());

JButton attentionButton = new JButton("attention");
attentionButton.putClientProperty(RadianceSynapse.CONTENTS_MODIFIED, Boolean.TRUE);

JToggleButton toggleButton = new JToggleButton("selected");
toggleButton.setSelected(true);

JButton enabledButton = new JButton("enabled");

JButton disabledButton = new JButton("disabled");
disabledButton.setEnabled(false);

this.add(attentionButton);
this.add(toggleButton);
this.add(enabledButton);
this.add(disabledButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public final RadianceColorScheme getColorScheme(Component comp,
}

public final ContainerRenderColorTokens getColorRenderTokens(Component comp,
ComponentState componentState) {
ComponentState componentState) {
if (componentState.isDisabled()) {
// TODO: TONAL - finalize this
// Use the enabled match, and alpha will be applied during rendering
Expand All @@ -421,29 +421,71 @@ public final ContainerRenderColorTokens getColorRenderTokens(Component comp,
// are decoration-specific scheme bundles.
if (this.tonalColorSchemeMap.size() > 1) {
RadianceThemingSlices.DecorationAreaType decorationAreaType = (comp == null) ?
RadianceThemingSlices.DecorationAreaType.NONE :
RadianceThemingCortex.ComponentOrParentChainScope.getDecorationType(comp);
RadianceThemingSlices.DecorationAreaType.NONE :
RadianceThemingCortex.ComponentOrParentChainScope.getDecorationType(comp);
if (this.tonalColorSchemeMap.containsKey(decorationAreaType)) {
RadianceColorScheme2 registered = this.tonalColorSchemeMap.get(decorationAreaType);
if (registered == null) {
throw new IllegalStateException("Color scheme shouldn't be null here. Please "
+ "report this issue");
+ "report this issue");
}

return componentState.isActive() ? registered.getStateRenderTokens(componentState)
: registered.getMutedContainerTokens();
: registered.getMutedContainerTokens();
}
}

RadianceColorScheme2 registered =
this.tonalColorSchemeMap.get(RadianceThemingSlices.DecorationAreaType.NONE);
this.tonalColorSchemeMap.get(RadianceThemingSlices.DecorationAreaType.NONE);
if (registered == null) {
throw new IllegalStateException("Color scheme shouldn't be null here. Please report " + "this issue");
}


return componentState.isActive() ? registered.getStateRenderTokens(componentState)
: registered.getMutedContainerTokens();
: registered.getMutedContainerTokens();
}

public final ContainerRenderColorTokens getSystemColorRenderTokens(Component comp,
RadianceThemingSlices.SystemContainerType systemContainerType) {
// small optimization - lookup the decoration area only if there
// are decoration-specific scheme bundles.
if (this.tonalColorSchemeMap.size() > 1) {
RadianceThemingSlices.DecorationAreaType decorationAreaType = (comp == null) ?
RadianceThemingSlices.DecorationAreaType.NONE :
RadianceThemingCortex.ComponentOrParentChainScope.getDecorationType(comp);
if (this.tonalColorSchemeMap.containsKey(decorationAreaType)) {
RadianceColorScheme2 registered = this.tonalColorSchemeMap.get(decorationAreaType);
if (registered == null) {
throw new IllegalStateException("Color scheme shouldn't be null here. Please "
+ "report this issue");
}

switch (systemContainerType) {
case INFO: return registered.getSystemInfoContainerTokens();
case WARNING: return registered.getSystemWarningContainerTokens();
case ERROR: return registered.getSystemErrorContainerTokens();
case SUCCESS: return registered.getSystemSuccessContainerTokens();
case EMERGENCY: return registered.getSystemEmergencyContainerTokens();
}
}
}

RadianceColorScheme2 registered =
this.tonalColorSchemeMap.get(RadianceThemingSlices.DecorationAreaType.NONE);
if (registered == null) {
throw new IllegalStateException("Color scheme shouldn't be null here. Please report " + "this issue");
}

switch (systemContainerType) {
case INFO: return registered.getSystemInfoContainerTokens();
case WARNING: return registered.getSystemWarningContainerTokens();
case ERROR: return registered.getSystemErrorContainerTokens();
case SUCCESS: return registered.getSystemSuccessContainerTokens();
case EMERGENCY: return registered.getSystemEmergencyContainerTokens();
}

return registered.getSystemInfoContainerTokens();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,14 @@ public enum ColorOverlayType {
SELECTION_FOREGROUND
}

public enum SystemContainerType {
INFO,
WARNING,
ERROR,
SUCCESS,
EMERGENCY
}

/**
* Enumerates available icon filter strategies.
*
Expand Down
Loading

0 comments on commit 267178c

Please sign in to comment.