mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
GUI: Ensure components refresh correctly when their look and feel changes
This commit is contained in:
parent
68e0e0e329
commit
39b5c22a29
10 changed files with 48 additions and 14 deletions
|
|
@ -105,16 +105,15 @@ FileBrowserComponent::FileBrowserComponent (int flags_,
|
|||
addAndMakeVisible (fileLabel);
|
||||
fileLabel.attachToComponent (&filenameBox, true);
|
||||
|
||||
goUpButton.reset (getLookAndFeel().createFileBrowserGoUpButton());
|
||||
addAndMakeVisible (goUpButton.get());
|
||||
goUpButton->onClick = [this] { goUp(); };
|
||||
goUpButton->setTooltip (TRANS ("Go up to parent directory"));
|
||||
|
||||
if (previewComp != nullptr)
|
||||
addAndMakeVisible (previewComp);
|
||||
|
||||
lookAndFeelChanged();
|
||||
|
||||
addAndMakeVisible (goUpButton.get());
|
||||
goUpButton->onClick = [this] { goUp(); };
|
||||
goUpButton->setTooltip (TRANS ("Go up to parent directory"));
|
||||
|
||||
setRoot (currentRoot);
|
||||
|
||||
if (filename.isNotEmpty())
|
||||
|
|
@ -351,12 +350,17 @@ void FileBrowserComponent::resized()
|
|||
//==============================================================================
|
||||
void FileBrowserComponent::lookAndFeelChanged()
|
||||
{
|
||||
goUpButton.reset (getLookAndFeel().createFileBrowserGoUpButton());
|
||||
|
||||
currentPathBox.setColour (ComboBox::backgroundColourId, findColour (currentPathBoxBackgroundColourId));
|
||||
currentPathBox.setColour (ComboBox::textColourId, findColour (currentPathBoxTextColourId));
|
||||
currentPathBox.setColour (ComboBox::arrowColourId, findColour (currentPathBoxArrowColourId));
|
||||
|
||||
filenameBox.setColour (TextEditor::backgroundColourId, findColour (filenameBoxBackgroundColourId));
|
||||
filenameBox.setColour (TextEditor::textColourId, findColour (filenameBoxTextColourId));
|
||||
|
||||
resized();
|
||||
repaint();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -56,9 +56,7 @@ struct CustomMenuBarItemHolder : public Component
|
|||
//==============================================================================
|
||||
BurgerMenuComponent::BurgerMenuComponent (MenuBarModel* modelToUse)
|
||||
{
|
||||
auto& lf = getLookAndFeel();
|
||||
|
||||
listBox.setRowHeight (roundToInt (lf.getPopupMenuFont().getHeight() * 2.0f));
|
||||
lookAndFeelChanged();
|
||||
listBox.addMouseListener (this, true);
|
||||
|
||||
setModel (modelToUse);
|
||||
|
|
@ -283,4 +281,9 @@ void BurgerMenuComponent::handleCommandMessage (int commandID)
|
|||
}
|
||||
}
|
||||
|
||||
void BurgerMenuComponent::lookAndFeelChanged()
|
||||
{
|
||||
listBox.setRowHeight (roundToInt (getLookAndFeel().getPopupMenuFont().getHeight() * 2.0f));
|
||||
}
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
|
|
@ -62,6 +62,9 @@ public:
|
|||
/** Returns the current burger menu model being used. */
|
||||
MenuBarModel* getModel() const noexcept;
|
||||
|
||||
/** @internal */
|
||||
void lookAndFeelChanged() override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
struct Row
|
||||
|
|
|
|||
|
|
@ -25,9 +25,10 @@ struct PropertyPanel::SectionComponent : public Component
|
|||
const Array<PropertyComponent*>& newProperties,
|
||||
bool sectionIsOpen)
|
||||
: Component (sectionTitle),
|
||||
titleHeight (getLookAndFeel().getPropertyPanelSectionHeaderHeight (sectionTitle)),
|
||||
isOpen (sectionIsOpen)
|
||||
{
|
||||
lookAndFeelChanged();
|
||||
|
||||
propertyComps.addArray (newProperties);
|
||||
|
||||
for (auto* propertyComponent : propertyComps)
|
||||
|
|
@ -59,6 +60,13 @@ struct PropertyPanel::SectionComponent : public Component
|
|||
}
|
||||
}
|
||||
|
||||
void lookAndFeelChanged() override
|
||||
{
|
||||
titleHeight = getLookAndFeel().getPropertyPanelSectionHeaderHeight (getName());
|
||||
resized();
|
||||
repaint();
|
||||
}
|
||||
|
||||
int getPreferredHeight() const
|
||||
{
|
||||
auto y = titleHeight;
|
||||
|
|
|
|||
|
|
@ -235,7 +235,7 @@ private:
|
|||
//==============================================================================
|
||||
Toolbar::Toolbar()
|
||||
{
|
||||
missingItemsButton.reset (getLookAndFeel().createToolbarMissingItemsButton (*this));
|
||||
lookAndFeelChanged();
|
||||
addChildComponent (missingItemsButton.get());
|
||||
|
||||
missingItemsButton->setAlwaysOnTop (true);
|
||||
|
|
@ -633,6 +633,11 @@ void Toolbar::itemDropped (const SourceDetails& dragSourceDetails)
|
|||
tc->setState (Button::buttonNormal);
|
||||
}
|
||||
|
||||
void Toolbar::lookAndFeelChanged()
|
||||
{
|
||||
missingItemsButton.reset (getLookAndFeel().createToolbarMissingItemsButton (*this));
|
||||
}
|
||||
|
||||
void Toolbar::mouseDown (const MouseEvent&) {}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -296,6 +296,8 @@ public:
|
|||
/** @internal */
|
||||
void itemDropped (const SourceDetails&) override;
|
||||
/** @internal */
|
||||
void lookAndFeelChanged() override;
|
||||
/** @internal */
|
||||
void updateAllItemPositions (bool animate);
|
||||
/** @internal */
|
||||
static ToolbarItemComponent* createItem (ToolbarItemFactory&, int itemId);
|
||||
|
|
|
|||
|
|
@ -44,9 +44,7 @@ CallOutBox::CallOutBox (Component& c, Rectangle<int> area, Component* const pare
|
|||
creationTime = Time::getCurrentTime();
|
||||
}
|
||||
|
||||
CallOutBox::~CallOutBox()
|
||||
{
|
||||
}
|
||||
CallOutBox::~CallOutBox() = default;
|
||||
|
||||
//==============================================================================
|
||||
class CallOutBoxCallback : public ModalComponentManager::Callback,
|
||||
|
|
@ -94,6 +92,8 @@ int CallOutBox::getBorderSize() const noexcept
|
|||
return jmax (getLookAndFeel().getCallOutBoxBorderSize (*this), (int) arrowSize);
|
||||
}
|
||||
|
||||
void CallOutBox::lookAndFeelChanged() { resized(); repaint(); }
|
||||
|
||||
void CallOutBox::paint (Graphics& g)
|
||||
{
|
||||
getLookAndFeel().drawCallOutBoxBackground (*this, g, outline, background);
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ public:
|
|||
void handleCommandMessage (int) override;
|
||||
/** @internal */
|
||||
int getBorderSize() const noexcept;
|
||||
/** @internal */
|
||||
void lookAndFeelChanged() override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ CodeEditorComponent::CodeEditorComponent (CodeDocument& doc, CodeTokeniser* cons
|
|||
setMouseCursor (MouseCursor::IBeamCursor);
|
||||
setWantsKeyboardFocus (true);
|
||||
|
||||
caret.reset (getLookAndFeel().createCaretComponent (this));
|
||||
lookAndFeelChanged();
|
||||
addAndMakeVisible (caret.get());
|
||||
|
||||
addAndMakeVisible (verticalScrollBar);
|
||||
|
|
@ -1308,6 +1308,11 @@ bool CodeEditorComponent::perform (const InvocationInfo& info)
|
|||
return performCommand (info.commandID);
|
||||
}
|
||||
|
||||
void CodeEditorComponent::lookAndFeelChanged()
|
||||
{
|
||||
caret.reset (getLookAndFeel().createCaretComponent (this));
|
||||
}
|
||||
|
||||
bool CodeEditorComponent::performCommand (const CommandID commandID)
|
||||
{
|
||||
switch (commandID)
|
||||
|
|
|
|||
|
|
@ -371,6 +371,8 @@ public:
|
|||
void getCommandInfo (CommandID, ApplicationCommandInfo&) override;
|
||||
/** @internal */
|
||||
bool perform (const InvocationInfo&) override;
|
||||
/** @internal */
|
||||
void lookAndFeelChanged() override;
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue