Skip to content

Commit

Permalink
Add a "Tear-In" to the "Tear-Out" (#5228)
Browse files Browse the repository at this point in the history
You can return them to the urge window if you want

Closes #5220
  • Loading branch information
baconpaul authored Oct 7, 2021
1 parent 9d60a0f commit 71f6e36
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/surge-xt/gui/overlays/OverlayWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ struct TearOutWindow : public juce::DocumentWindow
wrapping->onClose();
}
}
void minimiseButtonPressed()
{
if (wrapping)
{
wrapping->doTearIn();
}
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TearOutWindow);
};

Expand All @@ -151,6 +158,9 @@ void OverlayWrapper::supressInteriorDecoration()

void OverlayWrapper::doTearOut()
{
parentBeforeTearOut = getParentComponent();
locationBeforeTearOut = getBoundsInParent();
childLocationBeforeTearOut = primaryChild->getBounds();
getParentComponent()->removeChildComponent(this);

auto w = getWidth();
Expand All @@ -171,7 +181,8 @@ void OverlayWrapper::doTearOut()
{
t = oc->getEnclosingParentTitle();
}
auto dw = std::make_unique<TearOutWindow>(t, juce::DocumentWindow::closeButton);
auto dw = std::make_unique<TearOutWindow>(t, juce::DocumentWindow::closeButton |
juce::DocumentWindow::minimiseButton);
dw->setContentNonOwned(this, false);
dw->setContentComponentSize(w, h);
dw->setVisible(true);
Expand All @@ -180,5 +191,23 @@ void OverlayWrapper::doTearOut()
supressInteriorDecoration();
tearOutParent = std::move(dw);
}

void OverlayWrapper::doTearIn()
{
if (!isTornOut() || !parentBeforeTearOut)
{
// Should never happen but if it does
onClose();
return;
}
tearOutParent.reset(nullptr);
hasInteriorDec = true;

primaryChild->setTransform(juce::AffineTransform());
primaryChild->setBounds(childLocationBeforeTearOut);
setBounds(locationBeforeTearOut);
parentBeforeTearOut->addAndMakeVisible(*this);
parentBeforeTearOut = nullptr;
}
} // namespace Overlays
} // namespace Surge
3 changes: 3 additions & 0 deletions src/surge-xt/gui/overlays/OverlayWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ struct OverlayWrapper : public juce::Component,
bool canTearOut{false};
void setCanTearOut(bool b) { canTearOut = b; }
void doTearOut();
void doTearIn();
bool isTornOut();
juce::Rectangle<int> locationBeforeTearOut, childLocationBeforeTearOut;
juce::Component *parentBeforeTearOut{nullptr};

bool hasInteriorDec{true};
void supressInteriorDecoration();
Expand Down

0 comments on commit 71f6e36

Please sign in to comment.