Skip to content

Commit

Permalink
Some more tonal API tweaks
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Dec 12, 2024
1 parent 001b33a commit f0e006c
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static RadianceIcon getLogoIcon(RadianceColorScheme scheme) {
public static RadianceIcon getLogoIcon(ExtendedContainerRenderColorTokens renderColorTokens) {
// Step 1 - create a colorized version of the transcoded Radiance logo
RadianceIcon base = radiance_menu.factory().createNewIcon();
base.setColorFilter(color -> renderColorTokens.getSurfaceContainerTokens()
base.setColorFilter(color -> renderColorTokens.getBaseContainerColorTokens()
.getOnContainerColorTokens().getOnContainer());
// Step 2 - configure the colorized version to be 16x16
base.setDimension(new Dimension(16, 16));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected void paintComponent(Graphics g) {
if (skin instanceof TonalSkin) {
ExtendedContainerRenderColorTokens colorTokens = skin.getBackgroundRenderColorTokens(
DecorationPainterUtils.getDecorationType(this));
accentedFill = colorTokens.getSurfaceContainerTokens()
accentedFill = colorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainerLow();
} else {
RadianceThemingSlices.DecorationAreaType decorationAreaType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private void paintTitleBackground(Graphics2D original, Component comp, int width
private void paintTitleBackground(Graphics2D original, Component comp, int width, int height,
ExtendedContainerRenderColorTokens renderColorTokens) {
ContainerColorTokens containerColorTokens =
renderColorTokens.getSurfaceContainerTokens().getContainerColorTokens();
renderColorTokens.getBaseContainerColorTokens().getContainerColorTokens();

// 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 @@ -248,7 +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) {
ContainerColorTokens containerColorTokens =
renderColorTokens.getSurfaceContainerTokens().getContainerColorTokens();
renderColorTokens.getBaseContainerColorTokens().getContainerColorTokens();

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

ContainerColorTokens containerColorTokens =
renderColorTokens.getSurfaceContainerTokens().getContainerColorTokens();
renderColorTokens.getBaseContainerColorTokens().getContainerColorTokens();

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,7 +121,7 @@ private void paintTitleBackground(Graphics2D graphics, Component comp,
ExtendedContainerRenderColorTokens tileRenderColorTokens =
skin.getBackgroundRenderColorTokens(decorationAreaType);
if (this.baseDecorationPainter == null) {
graphics.setColor(tileRenderColorTokens.getSurfaceContainerTokens().
graphics.setColor(tileRenderColorTokens.getBaseContainerColorTokens().
getContainerColorTokens().getContainerHigh());
graphics.fillRect(0, 0, width, height);
} else {
Expand Down Expand Up @@ -174,7 +174,7 @@ private void paintExtraBackground(Graphics2D graphics, Component comp,
if (this.baseDecorationPainter != null) {
this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType, width, height, skin);
} else {
graphics.setColor(tileRenderColorTokens.getSurfaceContainerTokens()
graphics.setColor(tileRenderColorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainerHigh());
graphics.fillRect(0, 0, width, height);
}
Expand Down Expand Up @@ -225,7 +225,7 @@ public void paintDecorationArea(Graphics2D graphics, Component comp,
this.baseDecorationPainter.paintDecorationArea(graphics, comp, decorationAreaType,
contour, renderColorTokens);
} else {
graphics.setColor(renderColorTokens.getSurfaceContainerTokens()
graphics.setColor(renderColorTokens.getBaseContainerColorTokens()
.getContainerColorTokens().getContainerHigh());
graphics.fill(contour);
}
Expand Down Expand Up @@ -371,7 +371,7 @@ protected BufferedImage getColorizedTile(double scale, ExtendedContainerRenderCo
(int) ( tileHeight / scale), null);
tile2D.dispose();
result = RadianceImageCreator.getColorSchemeImage(tileBi,
renderColorTokens.getSurfaceContainerTokens(), 0.0f, 1.0f);
renderColorTokens.getBaseContainerColorTokens(), 0.0f, 1.0f);
this.colorizedTileMap.put(key, result);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ protected void fill(Graphics2D graphics, ExtendedContainerRenderColorTokens rend
// 0 - flex : light -> medium
// flex - : medium fill

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

int gradientHeight = Math.max(FLEX_POINT, height + offsetY);
Expand Down Expand Up @@ -217,9 +217,9 @@ public void paintDecorationArea(Graphics2D graphics, Component comp,

Point offset = RadianceCoreUtilities.getOffsetInRootPaneCoords(comp);

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

int gradientHeight = Math.max(FLEX_POINT, comp.getHeight() + offset.y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void paintOverlay(Graphics2D g, Component comp,
ExtendedContainerRenderColorTokens surfaceTokens =
skin.getBackgroundRenderColorTokens(decorationAreaType);
Color lineColor = this.containerTokensQuery.query(
surfaceTokens.getSurfaceContainerTokens());
surfaceTokens.getBaseContainerColorTokens());
graphics1X.setColor(RadianceColorUtilities.getAlphaColor(lineColor, 128));

int bottomY = (int) (scaleFactor * topMostWithSameDecorationAreaType.getHeight() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void paintOverlay(Graphics2D graphics, Component comp,

Color shadowColor = (skin instanceof TonalSkin)
? RadianceColorSchemeUtilities.getExtendedRenderColorTokens(comp, ComponentState.ENABLED,
RadianceThemingSlices.ContainerType.NEUTRAL).getSurfaceContainerTokens()
RadianceThemingSlices.ContainerType.NEUTRAL).getBaseContainerColorTokens()
.getContainerOutlineColorTokens().getContainerOutline()
:RadianceColorUtilities.deriveByBrightness(
RadianceColorUtilities.getBackgroundFillColor(comp), -0.4f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ public interface ExtendedContainerRenderColorTokens {
Color getSurface();
Color getSurfaceDim();
Color getSurfaceBright();
ContainerRenderColorTokens getSurfaceContainerTokens();
ContainerRenderColorTokens getBaseContainerColorTokens();
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Color getSurfaceBright() {
}

@Override
public ContainerRenderColorTokens getSurfaceContainerTokens() {
public ContainerRenderColorTokens getBaseContainerColorTokens() {
return stateRenderTokens;
}
};
Expand Down Expand Up @@ -144,7 +144,7 @@ public Color getSurfaceBright() {
}

@Override
public ContainerRenderColorTokens getSurfaceContainerTokens() {
public ContainerRenderColorTokens getBaseContainerColorTokens() {
return containerRenderColorTokens;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static void paintSeparator(Component c, Graphics g, int width, int height
// decoration type of that separator
renderColorTokens = RadianceCoreUtilities.getSkin(c).getBackgroundRenderColorTokens(
RadianceThemingCortex.ComponentOrParentChainScope.getDecorationType(c))
.getSurfaceContainerTokens();
.getBaseContainerColorTokens();
}
}
if (renderColorTokens == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public static ContainerRenderColorTokens getRenderColorTokens(Component componen
// TODO: TONAL - verify that we don't need to use the old logic.
// TODO: TONAL - colorization
return skin.getBackgroundRenderColorTokens(DecorationPainterUtils.getDecorationType(component))
.getSurfaceContainerTokens();
.getBaseContainerColorTokens();
// component = component.getParent();
}

Expand Down Expand Up @@ -290,7 +290,7 @@ public static ContainerRenderColorTokens getRenderColorTokens(Component componen
&& RadianceCoreUtilities.hasFlatAppearance(component, false)) {
// TODO: TONAL - verify that we don't need to use the old logic.
return skin.getBackgroundRenderColorTokens(DecorationPainterUtils.getDecorationType(component))
.getSurfaceContainerTokens();
.getBaseContainerColorTokens();
// component = component.getParent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ public static Color getStripedBackground(JComponent component, int rowIndex) {
ExtendedContainerRenderColorTokens colorTokens = skin.getBackgroundRenderColorTokens(
DecorationPainterUtils.getDecorationType(component));
return (rowIndex % 2 == 0) ? colorTokens.getSurface()
: colorTokens.getSurfaceContainerTokens().getContainerColorTokens().getContainerLow();
: colorTokens.getBaseContainerColorTokens().getContainerColorTokens().getContainerLow();
} else {
RadianceColorScheme scheme = skin.getBackgroundColorScheme(
DecorationPainterUtils.getDecorationType(component));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void paintComponent(Graphics g) {
if (skin instanceof TonalSkin) {
ContainerRenderColorTokens renderColorTokens = skin.getBackgroundRenderColorTokens(
RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE)
.getSurfaceContainerTokens();
.getBaseContainerColorTokens();
// TODO: TONAL - support colorization of text
// TODO: TONAL - finalize the text echo color logic
RadianceTextUtilities.paintTextWithDropShadow(this, graphics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public RadianceTitlePane(JRootPane root, RadianceRootPaneUI ui) {
if (skin instanceof TonalSkin) {
this.setForeground(skin.getBackgroundRenderColorTokens(
RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE)
.getSurfaceContainerTokens().getOnContainerColorTokens()
.getBaseContainerColorTokens().getOnContainerColorTokens()
.getOnContainer());
} else {
this.setForeground(RadianceColorUtilities.getForegroundColor(
Expand Down Expand Up @@ -892,7 +892,7 @@ public void paintComponent(Graphics g) {

if (skin instanceof TonalSkin) {
ContainerRenderColorTokens renderColorTokens = skin.getBackgroundRenderColorTokens(
RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE).getSurfaceContainerTokens();
RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE).getBaseContainerColorTokens();
// TODO: TONAL - finalize the text echo color logic
RadianceTextUtilities.paintTextWithDropShadow(this, graphics,
renderColorTokens.getOnContainerColorTokens().getOnContainer(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
SwingUtilities.windowForComponent(c));
ContainerRenderColorTokens titleRenderColorTokens =
skin.getBackgroundRenderColorTokens(DecorationPainterUtils.getDecorationType(titlePaneComp))
.getSurfaceContainerTokens();
.getBaseContainerColorTokens();

Graphics2D graphics = (Graphics2D) g.create();

Expand Down

0 comments on commit f0e006c

Please sign in to comment.