Browse Source

Fixed a bug in MultiChoicePropertyComponent causing the tick colours to not be updated with L&F changes

tags/2021-05-28
ed 6 years ago
parent
commit
4985df9b5d
1 changed files with 15 additions and 9 deletions
  1. +15
    -9
      modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp

+ 15
- 9
modules/juce_gui_basics/properties/juce_MultiChoicePropertyComponent.cpp View File

@@ -43,6 +43,12 @@ public:
} }
}; };
void updateButtonTickColour (ToggleButton* button, bool usingDefault)
{
button->setColour (ToggleButton::tickColourId, button->getLookAndFeel().findColour (ToggleButton::tickColourId)
.withAlpha (usingDefault ? 0.4f : 1.0f));
}
//============================================================================== //==============================================================================
class MultiChoicePropertyComponent::MultiChoiceRemapperSource : public Value::ValueSource, class MultiChoicePropertyComponent::MultiChoiceRemapperSource : public Value::ValueSource,
private Value::Listener private Value::Listener
@@ -127,7 +133,7 @@ public:
{ {
if (arr->contains (varToControl)) if (arr->contains (varToControl))
{ {
updateButtonTickColour();
updateButtonTickColour (buttonToControl, valueWithDefault->isUsingDefault());
return true; return true;
} }
} }
@@ -188,14 +194,6 @@ private:
//============================================================================== //==============================================================================
void valueChanged (Value&) override { sendChangeMessage (true); } void valueChanged (Value&) override { sendChangeMessage (true); }
void updateButtonTickColour() const noexcept
{
auto alpha = valueWithDefault->isUsingDefault() ? 0.4f : 1.0f;
auto baseColour = buttonToControl->findColour (ToggleButton::tickColourId);
buttonToControl->setColour (ToggleButton::tickColourId, baseColour.withAlpha (alpha));
}
//============================================================================== //==============================================================================
WeakReference<ValueWithDefault> valueWithDefault; WeakReference<ValueWithDefault> valueWithDefault;
var varToControl; var varToControl;
@@ -350,6 +348,14 @@ void MultiChoicePropertyComponent::lookAndFeelChanged()
{ {
auto iconColour = findColour (TextEditor::backgroundColourId).contrasting(); auto iconColour = findColour (TextEditor::backgroundColourId).contrasting();
expandButton.setColours (iconColour, iconColour.darker(), iconColour.darker()); expandButton.setColours (iconColour, iconColour.darker(), iconColour.darker());
if (valueWithDefault != nullptr)
{
auto usingDefault = valueWithDefault->isUsingDefault();
for (auto* button : choiceButtons)
updateButtonTickColour (button, usingDefault);
}
} }
} // namespace juce } // namespace juce

Loading…
Cancel
Save