Skip to content

Commit

Permalink
Flatten container color tokens
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Dec 16, 2024
1 parent 884a8d9 commit dfcf094
Show file tree
Hide file tree
Showing 32 changed files with 269 additions and 431 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static RadianceIcon getLogoIcon(ExtendedContainerRenderColorTokens render
// Step 1 - create a colorized version of the transcoded Radiance logo
RadianceIcon base = radiance_menu.factory().createNewIcon();
base.setColorFilter(color -> renderColorTokens.getBaseContainerColorTokens()
.getOnContainerColorTokens().getOnContainer());
.getOnContainer());
// Step 2 - configure the colorized version to be 16x16
base.setDimension(new Dimension(16, 16));
// Step 3 - good to go
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens,
int start = iconSize / 4;
int end = iconSize - start;

Color primaryColor = renderColorTokens.getOnContainerColorTokens().getOnContainer();
Color primaryColor = renderColorTokens.getOnContainer();

Stroke primaryStroke = new BasicStroke(1.5f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
Expand Down Expand Up @@ -135,7 +135,7 @@ public void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens,
int start = iconSize / 4;
int end = iconSize - start;

Color primaryColor = renderColorTokens.getOnContainerColorTokens().getOnContainer();
Color primaryColor = renderColorTokens.getOnContainer();

Stroke primaryStroke = new BasicStroke(1.5f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
Expand Down Expand Up @@ -192,7 +192,7 @@ public void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens,
int start = iconSize / 4;
int end = iconSize - start;

Color primaryColor = renderColorTokens.getOnContainerColorTokens().getOnContainer();
Color primaryColor = renderColorTokens.getOnContainer();

Stroke primaryStroke = new BasicStroke(1.5f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
Expand Down Expand Up @@ -250,7 +250,7 @@ public void drawIcon(Graphics2D g, ContainerRenderColorTokens renderColorTokens,
int end = iconSize - start;
int mid = (start + end) / 2;

Color primaryColor = renderColorTokens.getOnContainerColorTokens().getOnContainer();
Color primaryColor = renderColorTokens.getOnContainer();

Stroke primaryStroke = new BasicStroke(1.5f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected void paintComponent(Graphics g) {
ExtendedContainerRenderColorTokens colorTokens = skin.getBackgroundRenderColorTokens(
DecorationPainterUtils.getDecorationType(this));
accentedFill = colorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainerLow();
.getContainerLow();
} else {
RadianceThemingSlices.DecorationAreaType decorationAreaType =
RadianceThemingCortex.ComponentOrParentChainScope.getDecorationType(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,29 @@ public void paint(Graphics g) {
int xOffset = 0;

// Container colors
paintSquare(g2d, xOffset, height, colorTokens.getContainerColorTokens().getContainerLowest());
paintSquare(g2d, xOffset, height, colorTokens.getContainerLowest());
xOffset += (height + smallGap);
paintSquare(g2d, xOffset, height, colorTokens.getContainerColorTokens().getContainerLow());
paintSquare(g2d, xOffset, height, colorTokens.getContainerLow());
xOffset += (height + smallGap);
paintSquare(g2d, xOffset, height, colorTokens.getContainerColorTokens().getContainer());
paintSquare(g2d, xOffset, height, colorTokens.getContainer());
xOffset += (height + smallGap);
paintSquare(g2d, xOffset, height, colorTokens.getContainerColorTokens().getContainerHigh());
paintSquare(g2d, xOffset, height, colorTokens.getContainerHigh());
xOffset += (height + smallGap);
paintSquare(g2d, xOffset, height, colorTokens.getContainerColorTokens().getContainerHighest());
paintSquare(g2d, xOffset, height, colorTokens.getContainerHighest());

xOffset += (height + bigGap);

// On container colors
paintSquare(g2d, xOffset, height, colorTokens.getOnContainerColorTokens().getOnContainer());
paintSquare(g2d, xOffset, height, colorTokens.getOnContainer());
xOffset += (height + smallGap);
paintSquare(g2d, xOffset, height, colorTokens.getOnContainerColorTokens().getOnContainerVariant());
paintSquare(g2d, xOffset, height, colorTokens.getOnContainerVariant());

xOffset += (height + bigGap);

// Container outline colors
paintSquare(g2d, xOffset, height, colorTokens.getContainerOutlineColorTokens().getContainerOutline());
paintSquare(g2d, xOffset, height, colorTokens.getContainerOutline());
xOffset += (height + smallGap);
paintSquare(g2d, xOffset, height, colorTokens.getContainerOutlineColorTokens().getContainerOutlineVariant());
paintSquare(g2d, xOffset, height, colorTokens.getContainerOutlineVariant());

g2d.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public RadianceIcon getInspectIcon(int preferredSize,
public RadianceIcon getInspectIcon(int preferredSize, ContainerRenderColorTokens preferredIconColorTokens) {
RadianceIcon result = adjust_black_24dp.uiResourceOf(preferredSize, preferredSize);
result.setColorFilter(color ->
preferredIconColorTokens.getOnContainerColorTokens().getOnContainerVariant());
preferredIconColorTokens.getOnContainerVariant());
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.ContainerColorTokens;
import org.pushingpixels.radiance.theming.api.palette.ContainerRenderColorTokens;
import org.pushingpixels.radiance.theming.api.palette.ExtendedContainerRenderColorTokens;
import org.pushingpixels.radiance.theming.api.palette.TonalSkin;
import org.pushingpixels.radiance.theming.internal.utils.RadianceCoreUtilities;
Expand Down Expand Up @@ -150,8 +150,8 @@ 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();
ContainerRenderColorTokens containerColorTokens =
renderColorTokens.getBaseContainerColorTokens();

// Create a new Graphics2D object so that we can apply clipping to it without having
// to reset the state after we're done
Expand Down Expand Up @@ -249,8 +249,8 @@ 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();
ContainerRenderColorTokens containerColorTokens =
renderColorTokens.getBaseContainerColorTokens();

Point offset = RadianceCoreUtilities.getOffsetInRootPaneCoords(comp);
JRootPane rootPane = SwingUtilities.getRootPane(parent);
Expand Down Expand Up @@ -310,8 +310,8 @@ public void paintDecorationArea(Graphics2D graphics, Component comp,
ExtendedContainerRenderColorTokens renderColorTokens) {

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

Component parent = RadianceCoreUtilities.getHeaderParent(comp);
Point offset = RadianceCoreUtilities.getOffsetInRootPaneCoords(comp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ private void paintTitleBackground(Graphics2D graphics, Component comp,
ExtendedContainerRenderColorTokens tileRenderColorTokens =
skin.getBackgroundRenderColorTokens(decorationAreaType);
if (this.baseDecorationPainter == null) {
graphics.setColor(tileRenderColorTokens.getBaseContainerColorTokens().
getContainerColorTokens().getContainerHigh());
graphics.setColor(tileRenderColorTokens.getBaseContainerColorTokens().getContainerHigh());
graphics.fillRect(0, 0, width, height);
} else {
this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType,
Expand Down Expand Up @@ -175,7 +174,7 @@ private void paintExtraBackground(Graphics2D graphics, Component comp,
this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType, width, height, skin);
} else {
graphics.setColor(tileRenderColorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainerHigh());
.getContainerHigh());
graphics.fillRect(0, 0, width, height);
}
Graphics2D temp = (Graphics2D) graphics.create();
Expand Down Expand Up @@ -226,7 +225,7 @@ public void paintDecorationArea(Graphics2D graphics, Component comp,
contour, renderColorTokens);
} else {
graphics.setColor(renderColorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainerHigh());
.getContainerHigh());
graphics.fill(contour);
}
Graphics2D temp = (Graphics2D) graphics.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ protected void fill(Graphics2D graphics, ExtendedContainerRenderColorTokens rend
// flex - : medium fill

Color startColor = renderColorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainerLowest();
.getContainerLowest();
Color endColor = renderColorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainer();
.getContainer();

int gradientHeight = Math.max(FLEX_POINT, height + offsetY);
Paint paint = (gradientHeight == FLEX_POINT) ?
Expand Down Expand Up @@ -218,9 +218,9 @@ public void paintDecorationArea(Graphics2D graphics, Component comp,
Point offset = RadianceCoreUtilities.getOffsetInRootPaneCoords(comp);

Color startColor = renderColorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainerHigh();
.getContainerHigh();
Color endColor = renderColorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainerHighest();
.getContainerHighest();

int gradientHeight = Math.max(FLEX_POINT, comp.getHeight() + offset.y);
Paint paint = (gradientHeight == FLEX_POINT) ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public void paintContourBackground(Graphics g, Component comp, float width, floa

if ((shineWidth > 0) && (shineHeight > 0)) {
BufferedImage shineImage = getShineImage(comp, contour,
renderColorTokens.getContainerColorTokens().getContainerLowest(),
renderColorTokens.getContainerColorTokens().getContainerLow(),
renderColorTokens.getContainerLowest(),
renderColorTokens.getContainerLow(),
this.alpha, shineWidth, shineHeight);

Graphics2D graphics = (Graphics2D) g.create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void paintOverlay(Graphics2D graphics, Component comp,
Color shadowColor = (skin instanceof TonalSkin)
? RadianceColorSchemeUtilities.getExtendedRenderColorTokens(comp, ComponentState.ENABLED,
RadianceThemingSlices.ContainerType.NEUTRAL).getBaseContainerColorTokens()
.getContainerOutlineColorTokens().getContainerOutline()
.getContainerOutline()
:RadianceColorUtilities.deriveByBrightness(
RadianceColorUtilities.getBackgroundFillColor(comp), -0.4f);

Expand Down
Loading

0 comments on commit dfcf094

Please sign in to comment.