Skip to content

Commit

Permalink
Added option to place builder into a rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
ffAudio committed May 21, 2024
1 parent 597c09f commit ba4f5ad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Examples/PlayerExample/Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,5 @@ void MainComponent::paint (juce::Graphics& g)

void MainComponent::resized()
{
magicBuilder.updateLayout();
magicBuilder.updateLayout (getLocalBounds());
}
16 changes: 8 additions & 8 deletions modules/foleys_gui_magic/General/foleys_MagicGUIBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void MagicGUIBuilder::showOverlayDialog (std::unique_ptr<juce::Component> dialog
overlayDialog = std::move (dialog);
parent->addAndMakeVisible (overlayDialog.get());

updateLayout();
parent->resized();
}

void MagicGUIBuilder::closeOverlayDialog()
Expand Down Expand Up @@ -171,31 +171,31 @@ void MagicGUIBuilder::updateComponents()
root->setEditMode (editMode);
}

void MagicGUIBuilder::updateLayout()
void MagicGUIBuilder::updateLayout (juce::Rectangle<int> bounds)
{
if (parent == nullptr)
return;

if (root.get() != nullptr)
{
if (!stylesheet.setMediaSize (parent->getWidth(), parent->getHeight()))
if (!stylesheet.setMediaSize (bounds.getWidth(), bounds.getHeight()))
{
stylesheet.updateValidRanges();
root->updateInternal();
}

if (root->getBounds() == parent->getLocalBounds())
if (root->getBounds() == bounds)
root->updateLayout();
else
root->setBounds (parent->getLocalBounds());
root->setBounds (bounds);
}

if (overlayDialog)
{
if (overlayDialog->getBounds() == parent->getLocalBounds())
if (overlayDialog->getBounds() == bounds)
overlayDialog->resized();
else
overlayDialog->setBounds (parent->getLocalBounds());
overlayDialog->setBounds (bounds);
}

parent->repaint();
Expand Down Expand Up @@ -365,7 +365,7 @@ void MagicGUIBuilder::changeListenerCallback (juce::ChangeBroadcaster*)
if (root.get() != nullptr)
root->updateInternal();

updateLayout();
root->resized();
}

void MagicGUIBuilder::valueTreeRedirected (juce::ValueTree& treeWhichHasBeenChanged)
Expand Down
2 changes: 1 addition & 1 deletion modules/foleys_gui_magic/General/foleys_MagicGUIBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class MagicGUIBuilder
/**
Recalculates the layout of all components
*/
void updateLayout();
void updateLayout (juce::Rectangle<int> bounds);

/**
Resolve all colours fresh, in case the palette has changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void MagicPluginEditor::paint (juce::Graphics& g)

void MagicPluginEditor::resized()
{
builder->updateLayout();
builder->updateLayout (getLocalBounds());

processorState.setLastEditorSize (getWidth(), getHeight());
}
Expand Down

0 comments on commit ba4f5ad

Please sign in to comment.