Skip to content

Commit

Permalink
Tweak the background fill of active text components
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Jan 23, 2025
1 parent c2b38a8 commit be5bf8b
Showing 1 changed file with 21 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -471,37 +471,29 @@ public static Color getTextBackgroundTonalFillColor(JComponent comp) {
return backgroundFillColor;
}

ComponentUI ui = componentForTransitions.getUI();
if (ui instanceof TransitionAwareUI) {
TransitionAwareUI trackable = (TransitionAwareUI) ui;
StateTransitionTracker stateTransitionTracker = trackable.getTransitionTracker();

float selectionStrength = stateTransitionTracker.getFacetStrength(
RadianceThemingSlices.ComponentStateFacet.SELECTION);
float rolloverStrength = stateTransitionTracker.getFacetStrength(
RadianceThemingSlices.ComponentStateFacet.ROLLOVER);

if (selectionStrength > 0.0f) {
// Account for the selected strength
backgroundFillColor =
RadianceColorUtilities.getInterpolatedColor(backgroundFillColor,
RadianceColorSchemeUtilities.getContainerTokens(componentForTransitions,
ComponentState.SELECTED,
RadianceThemingSlices.ContainerType.NEUTRAL).getContainerSurface(),
1.0f - 0.2f * selectionStrength);
}
if (rolloverStrength > 0.0f) {
// Account for the selected strength
backgroundFillColor =
RadianceColorUtilities.getInterpolatedColor(backgroundFillColor,
RadianceColorSchemeUtilities.getContainerTokens(componentForTransitions,
ComponentState.ROLLOVER_UNSELECTED,
RadianceThemingSlices.ContainerType.NEUTRAL).getContainerSurface(),
1.0f - 0.2f * rolloverStrength);
}
ComponentUI ui = componentForTransitions.getUI();
if (ui instanceof TransitionAwareUI) {
TransitionAwareUI trackable = (TransitionAwareUI) ui;
StateTransitionTracker stateTransitionTracker = trackable.getTransitionTracker();

float selectionStrength = stateTransitionTracker.getFacetStrength(
RadianceThemingSlices.ComponentStateFacet.SELECTION);
float rolloverStrength = stateTransitionTracker.getFacetStrength(
RadianceThemingSlices.ComponentStateFacet.ROLLOVER);

float activeStrength = Math.max(selectionStrength, rolloverStrength);
if (activeStrength > 0.0f) {
// Account for the selection / rollover state
backgroundFillColor =
RadianceColorUtilities.getInterpolatedColor(backgroundFillColor,
RadianceColorSchemeUtilities.getContainerTokens(componentForTransitions,
ComponentState.ENABLED,
RadianceThemingSlices.ContainerType.NEUTRAL).getContainerSurfaceLowest(),
1.0f - activeStrength);
}
}

return backgroundFillColor;
return backgroundFillColor;
}

public static Color getTextSelectionBackground(JTextComponent comp) {
Expand Down

0 comments on commit be5bf8b

Please sign in to comment.