Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto develop
  • Loading branch information
timothyschoen committed Nov 8, 2023
2 parents 540df3b + e85a5bf commit 3018a14
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions Source/PluginMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class PluginMode : public Component {
}
#endif
}
if (ProjectInfo::isStandalone) {
auto frameSize = desktopWindow->getFrameSizeIfPresent();
nativeTitleBarHeight = frameSize ? frameSize->getTop() : 0;
}

if(auto* mainWindow = dynamic_cast<PlugDataWindow*>(editor->getTopLevelComponent()))
{
mainWindow->setUsingNativeTitleBar(false);
Expand Down Expand Up @@ -142,18 +147,6 @@ class PluginMode : public Component {

void closePluginMode()
{
if (cnv) {
content.removeChildComponent(cnv);
// Reset the canvas properties to before plugin mode was entered
cnv->viewport->setViewedComponent(cnv, false);
cnv->patch.openInPluginMode = false;
cnv->zoomScale.setValue(originalCanvasScale);
cnv->zoomScale.getValueSource().sendChangeMessage(true);
cnv->setTopLeftPosition(originalCanvasPos);
cnv->locked = originalLockedMode;
cnv->presentationMode = originalPresentationMode;
}

if (auto* mainWindow = dynamic_cast<PlugDataWindow*>(editor->getTopLevelComponent())) {
bool isUsingNativeTitlebar = SettingsFile::getInstance()->getProperty<bool>("native_window");
if(isUsingNativeTitlebar) {
Expand All @@ -162,17 +155,32 @@ class PluginMode : public Component {
mainWindow->setUsingNativeTitleBar(true);
}
editor->constrainer.setSizeLimits(850, 650, 99000, 99000);
mainWindow->setBoundsConstrained(windowBounds);
auto correctedPosition = windowBounds.getTopLeft() - Point<int>(0, nativeTitleBarHeight);
mainWindow->setBoundsConstrained(windowBounds.withPosition(correctedPosition));
} else {
editor->pluginConstrainer.setSizeLimits(850, 650, 99000, 99000);
editor->setBounds(windowBounds);
}

editor->resized();
if (auto* tabbar = editor->getActiveTabbar()) {
tabbar->resized();
}

if (cnv) {
content.removeChildComponent(cnv);
// Reset the canvas properties to before plugin mode was entered
cnv->viewport->setViewedComponent(cnv, false);
cnv->patch.openInPluginMode = false;
cnv->zoomScale.setValue(originalCanvasScale);
cnv->zoomScale.getValueSource().sendChangeMessage(true);
cnv->setTopLeftPosition(originalCanvasPos);
cnv->locked = originalLockedMode;
cnv->presentationMode = originalPresentationMode;
}

editor->parentSizeChanged();
editor->resized();

// Destroy this view
editor->pluginMode.reset(nullptr);
}
Expand Down Expand Up @@ -376,6 +384,7 @@ class PluginMode : public Component {

Component titleBar;
int const titlebarHeight = 40;
int nativeTitleBarHeight = 0;
ComboBox scaleComboBox;
std::unique_ptr<MainToolbarButton> editorButton;

Expand Down

0 comments on commit 3018a14

Please sign in to comment.