Skip to content

Commit

Permalink
Update UtilityButton paint method to improve color handling
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaldoshi committed Mar 3, 2025
1 parent 7b90be1 commit 59778cb
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions Source/Processors/Editors/GenericEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,25 +871,24 @@ void UtilityButton::paintButton (Graphics& g, bool isMouseOver, bool isButtonDow
{
isEnabled = Button::isEnabled();

Colour backgroundColour = findColour (ThemeColours::widgetBackground);

if (getToggleState())
{
g.setColour (findColour (ThemeColours::highlightedFill));
}
else
{
g.setColour (findColour (ThemeColours::widgetBackground));
backgroundColour = findColour (ThemeColours::highlightedFill);
}

g.fillPath (outlinePath);
auto baseColour = backgroundColour.withMultipliedSaturation (hasKeyboardFocus (true) ? 1.3f : 1.0f)
.withMultipliedAlpha (isEnabled ? 1.0f : 0.5f);

if (isMouseOver || ! isEnabled)
g.setColour (findColour (ThemeColours::outline).withAlpha (0.4f));
else
g.setColour (findColour (ThemeColours::outline));
if (isButtonDown || isMouseOver)
baseColour = baseColour.contrasting (isButtonDown ? 0.2f : 0.05f);

g.strokePath (outlinePath, PathStrokeType (1.0f));
g.setColour (baseColour);
g.fillPath (outlinePath);

//int stringWidth = font.getStringWidth(getName());
g.setColour (findColour (ThemeColours::outline).withAlpha (isEnabled ? 1.0f : 0.5f));
g.strokePath (outlinePath, PathStrokeType (1.0f));

g.setFont (font);

Expand Down

0 comments on commit 59778cb

Please sign in to comment.