Sfoglia il codice sorgente

IconButton: the state rule's colours get their own name (190je's local shadowed 190iv's Look member)

Round 190je's paintButton named its colours 'look', the name of round 190iv's IconButton::Look member read
at the top of the same function. Merged, the member is read first (190iv's looks keep their own painter);
the local is now 'state', so no later edit reads the wrong one.
Ka1-S 2 settimane fa
parent
commit
e4d0bd289e
1 ha cambiato i file con 13 aggiunte e 13 eliminazioni
  1. 13 13
      src/ui/Icons.cpp

+ 13 - 13
src/ui/Icons.cpp

@@ -1044,49 +1044,49 @@ void IconButton::paintButton (juce::Graphics& g, bool highlighted, bool down)
 
     // one state rule for every button kind (round 190je, core/ThemePalette.h buttonLook)
     const auto kind = ! flat ? themes::ButtonKind::secondary : isSwitch ? themes::ButtonKind::flatToggle : themes::ButtonKind::flatMomentary;
-    auto look = buttonColours (kind, on, h, down, enabled);
+    auto state = buttonColours (kind, on, h, down, enabled);
     const auto ownOn = onColour != colour::accent; // a button with "on" colours of its own (bg6 + a red icon, a wash)
     if (on && enabled && (ownOn || flat))
     {
-        look.fill = down ? colour::accentPressed : onColour.interpolatedWith (onColour.brighter (0.12f), h);
-        look.edge = {};
+        state.fill = down ? colour::accentPressed : onColour.interpolatedWith (onColour.brighter (0.12f), h);
+        state.edge = {};
     }
     else if (on && ! enabled && (ownOn || flat))
-        look.fill = onColour.withMultipliedAlpha (0.5f);
+        state.fill = onColour.withMultipliedAlpha (0.5f);
     else if (enabled && ! on && ! down && isSwitch && flat && ownOn)
     {
         // the preview of this switch's own "on" look (bg6 with a red icon, a wash)
-        look.fill = onColour.withMultipliedAlpha (0.7f * h);
-        look.edge = iconOnColour.withAlpha (0.5f * h);
+        state.fill = onColour.withMultipliedAlpha (0.7f * h);
+        state.edge = iconOnColour.withAlpha (0.5f * h);
     }
 
     // the icon / text: as at rest before (a light grey), towards white under the mouse, towards the "on" colour on a switch
     const auto idleFg = ! iconColour.isTransparent() ? iconColour : colour::textSecondary.brighter (0.25f);
     const auto hoverFg = isSwitch && flat ? (ownOn ? iconOnColour : colour::accentHover)
                                           : (! iconColour.isTransparent() ? iconColour.brighter (0.2f) : colour::textPrimary);
-    look.content = ! enabled ? colour::textDisabled : on ? iconOnColour : idleFg.interpolatedWith (down ? colour::textPrimary : hoverFg, down ? 1.0f : h);
+    state.content = ! enabled ? colour::textDisabled : on ? iconOnColour : idleFg.interpolatedWith (down ? colour::textPrimary : hoverFg, down ? 1.0f : h);
 
-    if (! look.fill.isTransparent() || ! look.edge.isTransparent())
+    if (! state.fill.isTransparent() || ! state.edge.isTransparent())
     {
         juce::Path p;
         p.addRoundedRectangle (bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), radius::md, radius::md,
                                roundLeft, roundRight, roundLeft, roundRight);
-        if (! look.fill.isTransparent())
+        if (! state.fill.isTransparent())
         {
-            g.setColour (look.fill);
+            g.setColour (state.fill);
             g.fillPath (p);
         }
-        if (! look.edge.isTransparent())
+        if (! state.edge.isTransparent())
         {
             juce::Path edge; // (on the pixel centres: `bounds` is inset by half a pixel, a crisp 1 px line)
             edge.addRoundedRectangle (bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), radius::md, radius::md,
                                       roundLeft, roundRight, roundLeft, roundRight);
-            g.setColour (look.edge);
+            g.setColour (state.edge);
             g.strokePath (edge, juce::PathStrokeType (1.0f));
         }
     }
 
-    const auto fg = look.content;
+    const auto fg = state.content;
 
     auto area = getLocalBounds().toFloat();
     const auto iconSize = juce::jmin (area.getHeight() * iconFraction, iconMax);