Skip to content

Commit

Permalink
First pass for tonal Night Shade skin
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Jan 24, 2025
1 parent 5aea799 commit 407af1c
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 32 deletions.
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.MarinerSkin;
import org.pushingpixels.radiance.theming.api.skin.NightShadeSkin;

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

public class TonalCheck {
public static void main(String[] args) {
RadianceSkin tonalSkin = new MarinerSkin.MarinerTonalSkin();
RadianceSkin tonalSkin = new NightShadeSkin.NightShadeTonalSkin();

RadianceThemingCortex.GlobalScope.registerWidget("org.pushingpixels.radiance.theming" +
".extras.api.tabbed.TabHoverPreviewWidget", JTabbedPane.class, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@ public Palettes getPalettes() {
}
}

public static RadianceColorScheme2 getColorScheme(
PalettesSource palettesSource,
RadianceThemingSlices.ActiveContainerType activeContainerType,
boolean isDark) {
return getColorScheme(palettesSource, activeContainerType, isDark,
SchemeResolverUtils.getSchemeColorResolver());
}

public static RadianceColorScheme2 getColorScheme(
PalettesSource palettesSource,
RadianceThemingSlices.ActiveContainerType activeContainerType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,20 @@
*/
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.RadianceSkin;
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices;
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.ColorTransform;
import org.pushingpixels.radiance.theming.api.colorscheme.ContainerColorTokensSingleColorQuery;
import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.painter.border.ClassicBorderPainter;
import org.pushingpixels.radiance.theming.api.painter.border.CompositeBorderPainter;
import org.pushingpixels.radiance.theming.api.painter.border.DelegateFractionBasedBorderPainter;
import org.pushingpixels.radiance.theming.api.painter.border.*;
import org.pushingpixels.radiance.theming.api.painter.decoration.MatteDecorationPainter;
import org.pushingpixels.radiance.theming.api.painter.fill.ClassicFillPainter;
import org.pushingpixels.radiance.theming.api.painter.fill.ClassicTonalFillPainter;
import org.pushingpixels.radiance.theming.api.painter.fill.FractionBasedFillPainter;
import org.pushingpixels.radiance.theming.api.painter.overlay.BottomLineOverlayPainter;
import org.pushingpixels.radiance.theming.api.painter.overlay.BottomShadowOverlayPainter;
import org.pushingpixels.radiance.theming.api.painter.overlay.RadianceOverlayPainter;
import org.pushingpixels.radiance.theming.api.painter.overlay.TopBezelOverlayPainter;
import org.pushingpixels.radiance.theming.api.painter.fill.FractionBasedTonalFillPainter;
import org.pushingpixels.radiance.theming.api.painter.overlay.*;
import org.pushingpixels.radiance.theming.api.palette.*;
import org.pushingpixels.radiance.theming.api.shaper.ClassicButtonShaper;

/**
Expand Down Expand Up @@ -162,41 +159,196 @@ public NightShadeSkin() {
RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE, RadianceThemingSlices.DecorationAreaType.SECONDARY_TITLE_PANE,
RadianceThemingSlices.DecorationAreaType.HEADER);

this.configureOverlayPainters();

this.buttonShaper = new ClassicButtonShaper();
this.fillPainter = new FractionBasedFillPainter("Night Shade",
new float[]{0.0f, 0.5f, 1.0f},
new ColorSchemeSingleColorQuery[]{ColorSchemeSingleColorQuery.ULTRALIGHT,
ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.LIGHT});
this.decorationPainter = new MatteDecorationPainter();
this.highlightFillPainter = new ClassicFillPainter();
this.borderPainter = new CompositeBorderPainter("Night Shade", new ClassicBorderPainter(),
new DelegateFractionBasedBorderPainter("Night Shade Inner", new ClassicBorderPainter(),
new int[]{0x40FFFFFF, 0x20FFFFFF, 0x00FFFFFF},
scheme -> scheme.tint(0.2f)));
}

void configureOverlayPainters() {
// Add overlay painters to paint drop shadows along the bottom
// edges of toolbars and footers
this.addOverlayPainter(BottomShadowOverlayPainter.getInstance(100),
RadianceThemingSlices.DecorationAreaType.TOOLBAR, RadianceThemingSlices.DecorationAreaType.FOOTER);
RadianceThemingSlices.DecorationAreaType.TOOLBAR, RadianceThemingSlices.DecorationAreaType.FOOTER);

// add an overlay painter to paint a dark line along the bottom
// edge of toolbars
RadianceOverlayPainter toolbarBottomLineOverlayPainter = new BottomLineOverlayPainter(
ColorSchemeSingleColorQuery.composite(ColorSchemeSingleColorQuery.ULTRADARK,
ColorTransform.brightness(-0.5f)));
ColorSchemeSingleColorQuery.composite(ColorSchemeSingleColorQuery.ULTRADARK,
ColorTransform.brightness(-0.5f)));
this.addOverlayPainter(toolbarBottomLineOverlayPainter, RadianceThemingSlices.DecorationAreaType.TOOLBAR);

// add an overlay painter to paint a bezel line along the top
// edge of footer
RadianceOverlayPainter footerTopBezelOverlayPainter = new TopBezelOverlayPainter(
ColorSchemeSingleColorQuery.composite(ColorSchemeSingleColorQuery.ULTRADARK,
ColorTransform.brightness(-0.5f)),
ColorSchemeSingleColorQuery.composite(ColorSchemeSingleColorQuery.FOREGROUND,
ColorTransform.alpha(32)));
ColorSchemeSingleColorQuery.composite(ColorSchemeSingleColorQuery.ULTRADARK,
ColorTransform.brightness(-0.5f)),
ColorSchemeSingleColorQuery.composite(ColorSchemeSingleColorQuery.FOREGROUND,
ColorTransform.alpha(32)));
this.addOverlayPainter(footerTopBezelOverlayPainter, RadianceThemingSlices.DecorationAreaType.FOOTER);

this.buttonShaper = new ClassicButtonShaper();
this.fillPainter = new FractionBasedFillPainter("Night Shade",
new float[]{0.0f, 0.5f, 1.0f},
new ColorSchemeSingleColorQuery[]{ColorSchemeSingleColorQuery.ULTRALIGHT,
ColorSchemeSingleColorQuery.LIGHT, ColorSchemeSingleColorQuery.LIGHT});
this.decorationPainter = new MatteDecorationPainter();
this.highlightFillPainter = new ClassicFillPainter();
this.borderPainter = new CompositeBorderPainter("Night Shade", new ClassicBorderPainter(),
new DelegateFractionBasedBorderPainter("Night Shade Inner", new ClassicBorderPainter(),
new int[]{0x40FFFFFF, 0x20FFFFFF, 0x00FFFFFF},
scheme -> scheme.tint(0.2f)));
}

public String getDisplayName() {
return NAME;
}
public static class NightShadeTonalSkin extends NightShadeSkin implements TonalSkin {
public static final String NAME = "Night Shade Tonal";

public NightShadeTonalSkin() {
RadianceColorScheme2 nightShadeColorScheme = ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFF4e5562), Hct.fromInt(0xFF373B45), Hct.fromInt(0xFF292A32)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ true,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());

ContainerColorTokens nightShadeSelectedContainerTokens =
ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFF3D4B63),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isFidelity */ true,
/* isDark */ true);
ContainerColorTokens nightShadeSelectedHighlightContainerTokens =
ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFF414752),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isFidelity */ true,
/* isDark */ true);

RadianceColorSchemeBundle2 nightShadeDefaultBundle =
new RadianceColorSchemeBundle2(nightShadeColorScheme);
// More saturated seed for controls in selected state
nightShadeDefaultBundle.registerActiveContainerTokens(nightShadeSelectedContainerTokens,
ComponentState.SELECTED);
// And less saturated seed for selected highlights
nightShadeDefaultBundle.registerActiveContainerTokens(
nightShadeSelectedHighlightContainerTokens,
RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT,
ComponentState.SELECTED);
this.registerDecorationAreaSchemeBundle(nightShadeDefaultBundle,
RadianceThemingSlices.DecorationAreaType.NONE);

// RadianceColorScheme2 marinerHeaderColorScheme = ColorSchemeUtils.getColorScheme(
// /* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
// Hct.fromInt(0xFFF5D47A), Hct.fromInt(0xFF281D1E), Hct.fromInt(0xFF2C2021)),
// /* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
// /* isDark */ true,
// /* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
//
// RadianceColorSchemeBundle2 marinerHeaderBundle =
// new RadianceColorSchemeBundle2(marinerHeaderColorScheme);
// // More saturated seed for controls in selected state
// marinerHeaderBundle.registerActiveContainerTokens(marinerSelectedContainerTokens,
// ComponentState.SELECTED);
// // More saturated highlights
// marinerHeaderBundle.registerActiveContainerTokens(
// marinerSelectedContainerTokens,
// RadianceThemingSlices.ContainerColorTokensAssociationKind.HIGHLIGHT,
// ComponentState.getActiveStates());
// // More muted separators
// marinerHeaderBundle.registerEnabledContainerTokens(
// ColorSchemeUtils.getContainerTokens(
// /* seed */ Hct.fromInt(0xFF261D1E),
// /* isFidelity */ true,
// /* isDark */ true,
// /* contrastLevel */ -0.7,
// /* colorResolver */ PaletteResolverUtils.getPaletteTonalColorResolver().overlayWith(
// PaletteContainerColorsResolverOverlay.builder()
// //.containerOutline(DynamicPalette::getTonalContainerOutlineVariant)
// .build())),
// RadianceThemingSlices.ContainerColorTokensAssociationKind.SEPARATOR);
// this.registerDecorationAreaSchemeBundle(marinerHeaderBundle,
// ColorSchemeUtils.getExtendedContainerTokens(
// /* seed */ Hct.fromInt(0xFF261D1E),
// /* isFidelity */ true,
// /* isDark */ true,
// /* contrastLevel */ 1.0,
// /* colorResolver */ PaletteResolverUtils.getPaletteTonalColorResolver().overlayWith(
// PaletteContainerColorsResolverOverlay.builder()
// .containerOutline(DynamicPalette::getTonalContainerOutlineVariant)
// .build())),
// RadianceThemingSlices.DecorationAreaType.PRIMARY_TITLE_PANE,
// RadianceThemingSlices.DecorationAreaType.SECONDARY_TITLE_PANE,
// RadianceThemingSlices.DecorationAreaType.HEADER);
//
// RadianceColorScheme2 marinerFooterColorScheme = ColorSchemeUtils.getColorScheme(
// /* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
// Hct.fromInt(0xFFF6DD9D), Hct.fromInt(0xFFC5C4C2), Hct.fromInt(0xFFB9B7B9)),
// /* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
// /* isDark */ false,
// /* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
//
// RadianceColorSchemeBundle2 marinerFooterBundle =
// new RadianceColorSchemeBundle2(marinerFooterColorScheme);
// this.registerDecorationAreaSchemeBundle(marinerFooterBundle,
// ColorSchemeUtils.getExtendedContainerTokens(
// /* seed */ Hct.fromInt(0xFFB9B7B9),
// /* isFidelity */ true,
// /* isDark */ false),
// RadianceThemingSlices.DecorationAreaType.FOOTER,
// RadianceThemingSlices.DecorationAreaType.TOOLBAR,
// RadianceThemingSlices.DecorationAreaType.CONTROL_PANE);

this.buttonShaper = new ClassicButtonShaper();
this.fillPainter = new FractionBasedTonalFillPainter("Night Shade",
new float[] {0.0f, 0.5f, 1.0f},
new ContainerColorTokensSingleColorQuery[] {
ContainerColorTokensSingleColorQuery.CONTAINER_SURFACE_LOW,
ContainerColorTokensSingleColorQuery.CONTAINER_SURFACE,
ContainerColorTokensSingleColorQuery.CONTAINER_SURFACE});

this.decorationPainter = new MatteDecorationPainter();
this.highlightFillPainter = new ClassicTonalFillPainter();

this.borderPainter = new CompositeBorderPainter("Night Shade",
new ClassicTonalBorderPainter(),
new FractionBasedTonalBorderPainter("Night Shade Inner",
new float[]{0.0f, 1.0f},
new ContainerColorTokensSingleColorQuery[]{
ContainerColorTokensSingleColorQuery.composite(
ContainerColorTokensSingleColorQuery.INVERSE_CONTAINER_OUTLINE,
ColorTransform.alpha(92)),
ContainerColorTokensSingleColorQuery.composite(
ContainerColorTokensSingleColorQuery.INVERSE_CONTAINER_OUTLINE,
ColorTransform.alpha(32))
}));
}

@Override
void configureOverlayPainters() {
// Add overlay painters to paint drop shadows along the bottom
// edges of toolbars and footers
this.addOverlayPainter(BottomShadowOverlayPainter.getInstance(100),
RadianceThemingSlices.DecorationAreaType.TOOLBAR, RadianceThemingSlices.DecorationAreaType.FOOTER);

// add an overlay painter to paint a dark line along the bottom
// edge of toolbars
RadianceOverlayPainter toolbarBottomLineOverlayPainter = new BottomLineTonalOverlayPainter(
ContainerColorTokensSingleColorQuery.CONTAINER_OUTLINE_VARIANT);
this.addOverlayPainter(toolbarBottomLineOverlayPainter, RadianceThemingSlices.DecorationAreaType.TOOLBAR);

// add an overlay painter to paint a bezel line along the top
// edge of footer
RadianceOverlayPainter footerTopBezelOverlayPainter = new TopBezelTonalOverlayPainter(
ContainerColorTokensSingleColorQuery.CONTAINER_OUTLINE_VARIANT,
ContainerColorTokensSingleColorQuery.composite(
ContainerColorTokensSingleColorQuery.INVERSE_CONTAINER_OUTLINE,
ColorTransform.alpha(32)));
this.addOverlayPainter(footerTopBezelOverlayPainter, RadianceThemingSlices.DecorationAreaType.FOOTER);
}

@Override
public String getDisplayName() {
return NightShadeTonalSkin.NAME;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,10 @@ public class RadianceNightShadeLookAndFeel extends RadianceLookAndFeel {
public RadianceNightShadeLookAndFeel() {
super(new NightShadeSkin());
}

public static class RadianceNightShadeTonalLookAndFeel extends RadianceLookAndFeel {
public RadianceNightShadeTonalLookAndFeel() {
super(new NightShadeSkin.NightShadeTonalSkin());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public Set<SkinInfo> getSkins() {
result.add(new SkinInfo(MarinerSkin.MarinerTonalSkin.NAME,
MarinerSkin.MarinerTonalSkin.class::getName,
RadianceMarinerLookAndFeel.RadianceMarinerTonalLookAndFeel.class::getName));
result.add(new SkinInfo(NightShadeSkin.NightShadeTonalSkin.NAME,
NightShadeSkin.NightShadeTonalSkin.class::getName,
RadianceNightShadeLookAndFeel.RadianceNightShadeTonalLookAndFeel.class::getName));

return result;
}
Expand Down

0 comments on commit 407af1c

Please sign in to comment.