Skip to content

Commit

Permalink
Tonal menu search widget
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Jan 23, 2025
1 parent be5bf8b commit 551e76c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -896,13 +896,13 @@ public static void drawHexaMarker(Graphics2D g, int value, RadianceColorScheme c
value %= 16;
boolean isDark = colorScheme.isDark();
Color offColor = isDark
? RadianceColorUtilities.getInterpolatedColor(colorScheme.getUltraLightColor(),
Color.white, 0.7)
: RadianceColorUtilities.deriveByBrightness(colorScheme.getMidColor(), -0.6f);
? RadianceColorUtilities.getInterpolatedColor(colorScheme.getUltraLightColor(),
Color.white, 0.7)
: RadianceColorUtilities.deriveByBrightness(colorScheme.getMidColor(), -0.6f);
Color onColor = isDark
? RadianceColorUtilities.getInterpolatedColor(colorScheme.getUltraLightColor(),
Color.white, 0.2)
: colorScheme.getForegroundColor();
? RadianceColorUtilities.getInterpolatedColor(colorScheme.getUltraLightColor(),
Color.white, 0.2)
: colorScheme.getForegroundColor();

boolean bit1 = ((value & 0x1) != 0);
boolean bit2 = ((value & 0x2) != 0);
Expand All @@ -911,7 +911,34 @@ public static void drawHexaMarker(Graphics2D g, int value, RadianceColorScheme c

Graphics2D graphics = (Graphics2D) g.create();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
RenderingHints.VALUE_ANTIALIAS_ON);

graphics.setColor(bit1 ? onColor : offColor);
graphics.fillOval(5, 5, 4, 4);
graphics.setColor(bit2 ? onColor : offColor);
graphics.fillOval(5, 0, 4, 4);
graphics.setColor(bit3 ? onColor : offColor);
graphics.fillOval(0, 5, 4, 4);
graphics.setColor(bit4 ? onColor : offColor);
graphics.fillOval(0, 0, 4, 4);

graphics.dispose();
}

public static void drawHexaMarker(Graphics2D g, int value, ContainerColorTokens colorTokens) {
value %= 16;
Color offColor = RadianceColorUtilities.getAlphaColor(
colorTokens.getOnContainerVariant(), 160);
Color onColor = colorTokens.getOnContainer();

boolean bit1 = ((value & 0x1) != 0);
boolean bit2 = ((value & 0x2) != 0);
boolean bit3 = ((value & 0x4) != 0);
boolean bit4 = ((value & 0x8) != 0);

Graphics2D graphics = (Graphics2D) g.create();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);

graphics.setColor(bit1 ? onColor : offColor);
graphics.fillOval(5, 5, 4, 4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices.WidgetType;
import org.pushingpixels.radiance.theming.api.RadianceThemingWidget;
import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.palette.ContainerColorTokens;
import org.pushingpixels.radiance.theming.internal.animation.TransitionAwareUI;
import org.pushingpixels.radiance.theming.internal.blade.BladeIconUtils;
import org.pushingpixels.radiance.theming.internal.blade.BladeTransitionAwareIcon;
Expand Down Expand Up @@ -179,6 +180,11 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float
BladeIconUtils.drawHexaMarker(g, finalCount, scheme);
}

@Override
public void drawColorSchemeIcon(Graphics2D g, ContainerColorTokens colorTokens, float alpha) {
BladeIconUtils.drawHexaMarker(g, finalCount, colorTokens);
}

@Override
public Dimension getIconDimension() {
return new Dimension(9, 9);
Expand Down Expand Up @@ -281,6 +287,13 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float
.paintIcon(null, g, 0, 0);
}

@Override
public void drawColorSchemeIcon(Graphics2D g, ContainerColorTokens colorTokens, float alpha) {
RadianceThemingCortex.GlobalScope.getIconPack()
.getInspectIcon(dimension, colorTokens)
.paintIcon(null, g, 0, 0);
}

@Override
public Dimension getIconDimension() {
return new Dimension(dimension, dimension);
Expand Down Expand Up @@ -539,6 +552,11 @@ public void drawColorSchemeIcon(Graphics2D g, RadianceColorScheme scheme, float
BladeIconUtils.drawHexaMarker(g, index, scheme);
}

@Override
public void drawColorSchemeIcon(Graphics2D g, ContainerColorTokens colorTokens, float alpha) {
BladeIconUtils.drawHexaMarker(g, index, colorTokens);
}

@Override
public Dimension getIconDimension() {
return new Dimension(9, 9);
Expand Down

0 comments on commit 551e76c

Please sign in to comment.