From c7689793f2888526a23f635785a367f660e40547 Mon Sep 17 00:00:00 2001 From: Anthony Nicholls Date: Tue, 21 Mar 2023 17:49:03 +0000 Subject: [PATCH] Widgets: call repaint() in colourChanged() callbacks --- .../components/juce_Component.h | 2 ++ .../juce_gui_basics/widgets/juce_ComboBox.cpp | 18 +++++++++--------- .../widgets/juce_ProgressBar.cpp | 1 + .../juce_gui_basics/widgets/juce_Slider.cpp | 2 +- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index 0d372774f1..d321a7de49 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -2234,6 +2234,8 @@ public: method, which your component can override if it needs to do something when colours are altered. + Note repaint() is not automatically called when a colour is changed. + For more details about colour IDs, see the comments for findColour(). @see findColour, isColourSpecified, colourChanged, LookAndFeel::findColour, LookAndFeel::setColour diff --git a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp index 4ea4940374..f36007f0cf 100644 --- a/modules/juce_gui_basics/widgets/juce_ComboBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ComboBox.cpp @@ -392,7 +392,14 @@ void ComboBox::enablementChanged() void ComboBox::colourChanged() { - lookAndFeelChanged(); + label->setColour (Label::backgroundColourId, Colours::transparentBlack); + label->setColour (Label::textColourId, findColour (ComboBox::textColourId)); + + label->setColour (TextEditor::textColourId, findColour (ComboBox::textColourId)); + label->setColour (TextEditor::backgroundColourId, Colours::transparentBlack); + label->setColour (TextEditor::highlightColourId, findColour (TextEditor::highlightColourId)); + label->setColour (TextEditor::outlineColourId, Colours::transparentBlack); + repaint(); } void ComboBox::parentHierarchyChanged() @@ -431,14 +438,7 @@ void ComboBox::lookAndFeelChanged() label->addMouseListener (this, false); label->setAccessible (labelEditableState == labelIsEditable); - label->setColour (Label::backgroundColourId, Colours::transparentBlack); - label->setColour (Label::textColourId, findColour (ComboBox::textColourId)); - - label->setColour (TextEditor::textColourId, findColour (ComboBox::textColourId)); - label->setColour (TextEditor::backgroundColourId, Colours::transparentBlack); - label->setColour (TextEditor::highlightColourId, findColour (TextEditor::highlightColourId)); - label->setColour (TextEditor::outlineColourId, Colours::transparentBlack); - + colourChanged(); resized(); } diff --git a/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp b/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp index 7c956e1cf4..05ff6eab34 100644 --- a/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp +++ b/modules/juce_gui_basics/widgets/juce_ProgressBar.cpp @@ -59,6 +59,7 @@ void ProgressBar::lookAndFeelChanged() void ProgressBar::colourChanged() { lookAndFeelChanged(); + repaint(); } void ProgressBar::paint (Graphics& g) diff --git a/modules/juce_gui_basics/widgets/juce_Slider.cpp b/modules/juce_gui_basics/widgets/juce_Slider.cpp index 58e593182d..8b699f6edb 100644 --- a/modules/juce_gui_basics/widgets/juce_Slider.cpp +++ b/modules/juce_gui_basics/widgets/juce_Slider.cpp @@ -1573,7 +1573,7 @@ void Slider::setPopupDisplayEnabled (bool showOnDrag, bool showOnHover, Componen Component* Slider::getCurrentPopupDisplay() const noexcept { return pimpl->popupDisplay.get(); } //============================================================================== -void Slider::colourChanged() { lookAndFeelChanged(); } +void Slider::colourChanged() { repaint(); } void Slider::lookAndFeelChanged() { pimpl->lookAndFeelChanged (getLookAndFeel()); } void Slider::enablementChanged() { repaint(); pimpl->updateTextBoxEnablement(); }