From 36afd24d19f0c77dcb3c1d7a46b6eb4882b2d0c4 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 5 May 2013 11:00:58 +0100 Subject: [PATCH] Save and re-use last plugin UI pos when possible (runtime) --- source/backend/native/distrho/DistrhoPluginCarla.cpp | 6 ++++++ source/backend/plugin/CarlaPluginGui.cpp | 5 ++++- source/backend/plugin/CarlaPluginGui.hpp | 2 +- source/backend/plugin/CarlaPluginInternal.hpp | 1 + source/backend/plugin/Lv2Plugin.cpp | 4 +++- source/backend/plugin/VstPlugin.cpp | 4 +++- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/source/backend/native/distrho/DistrhoPluginCarla.cpp b/source/backend/native/distrho/DistrhoPluginCarla.cpp index 0887122a4..8124ab3e8 100644 --- a/source/backend/native/distrho/DistrhoPluginCarla.cpp +++ b/source/backend/native/distrho/DistrhoPluginCarla.cpp @@ -401,6 +401,8 @@ protected: { if (show) createUiIfNeeded(); + else if (fUiPtr != nullptr) + fUiGeometry = fUiPtr->saveGeometry(); if (fUiPtr != nullptr) fUiPtr->carla_show(show); @@ -463,6 +465,7 @@ private: #if DISTRHO_PLUGIN_HAS_UI // UI ScopedPointer fUiPtr; + QByteArray fUiGeometry; void createUiIfNeeded() { @@ -470,6 +473,9 @@ private: { d_lastUiSampleRate = getSampleRate(); fUiPtr = new UICarla(getHostHandle(), &fPlugin); + + if (! fUiGeometry.isNull()) + fUiPtr->restoreGeometry(fUiGeometry); } } #endif diff --git a/source/backend/plugin/CarlaPluginGui.cpp b/source/backend/plugin/CarlaPluginGui.cpp index 4d3be115c..234b2ad06 100644 --- a/source/backend/plugin/CarlaPluginGui.cpp +++ b/source/backend/plugin/CarlaPluginGui.cpp @@ -30,7 +30,7 @@ CARLA_BACKEND_START_NAMESPACE // ------------------------------------------------------------------- // CarlaPluginGUI -CarlaPluginGui::CarlaPluginGui(CarlaEngine* const engine, Callback* const callback, const Options& options) +CarlaPluginGui::CarlaPluginGui(CarlaEngine* const engine, Callback* const callback, const Options& options, const QByteArray& lastGeometry) : QMainWindow(nullptr), kCallback(callback), fContainer(nullptr), @@ -61,6 +61,9 @@ CarlaPluginGui::CarlaPluginGui(CarlaEngine* const engine, Callback* const callba if (settings.value("Engine/UIsAlwaysOnTop", true).toBool()) setWindowFlags(windowFlags()|Qt::WindowStaysOnTopHint); + + if (! lastGeometry.isNull()) + restoreGeometry(lastGeometry); } } diff --git a/source/backend/plugin/CarlaPluginGui.hpp b/source/backend/plugin/CarlaPluginGui.hpp index 8943e8365..0dcb19cc5 100644 --- a/source/backend/plugin/CarlaPluginGui.hpp +++ b/source/backend/plugin/CarlaPluginGui.hpp @@ -47,7 +47,7 @@ public: bool resizable; }; - CarlaPluginGui(CarlaEngine* const engine, Callback* const callback, const Options& options); + CarlaPluginGui(CarlaEngine* const engine, Callback* const callback, const Options& options, const QByteArray& lastGeometry); ~CarlaPluginGui(); void setSize(const int width, const int height); diff --git a/source/backend/plugin/CarlaPluginInternal.hpp b/source/backend/plugin/CarlaPluginInternal.hpp index 9801289e9..d110b9fe6 100644 --- a/source/backend/plugin/CarlaPluginInternal.hpp +++ b/source/backend/plugin/CarlaPluginInternal.hpp @@ -394,6 +394,7 @@ struct CarlaPluginProtectedData { CarlaEngine* const engine; CarlaEngineClient* client; CarlaPluginGui* gui; + QByteArray guiGeometry; bool active; bool needsReset; diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index 309cd0a19..33b74a0bc 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -1183,7 +1183,7 @@ public: guiOptions.parented = (fUi.type == PLUGIN_UI_PARENT); guiOptions.resizable = isUiResizable(); - kData->gui = new CarlaPluginGui(kData->engine, this, guiOptions); + kData->gui = new CarlaPluginGui(kData->engine, this, guiOptions, kData->guiGeometry); } if (fUi.type == PLUGIN_UI_PARENT) @@ -1206,6 +1206,7 @@ public: fUi.handle = nullptr; fUi.widget = nullptr; + kData->guiGeometry = kData->gui->saveGeometry(); kData->gui->close(); delete kData->gui; kData->gui = nullptr; @@ -1231,6 +1232,7 @@ public: if (kData->gui != nullptr) { + kData->guiGeometry = kData->gui->saveGeometry(); kData->gui->close(); delete kData->gui; kData->gui = nullptr; diff --git a/source/backend/plugin/VstPlugin.cpp b/source/backend/plugin/VstPlugin.cpp index 6e9b4f28a..61e3ae4d5 100644 --- a/source/backend/plugin/VstPlugin.cpp +++ b/source/backend/plugin/VstPlugin.cpp @@ -405,7 +405,7 @@ public: guiOptions.parented = true; guiOptions.resizable = false; - kData->gui = new CarlaPluginGui(kData->engine, this, guiOptions); + kData->gui = new CarlaPluginGui(kData->engine, this, guiOptions, kData->guiGeometry); } int32_t value = 0; @@ -440,6 +440,7 @@ public: { if (kData->gui != nullptr) { + kData->guiGeometry = kData->gui->saveGeometry(); kData->gui->close(); delete kData->gui; kData->gui = nullptr; @@ -461,6 +462,7 @@ public: fGui.lastWidth = kData->gui->width(); fGui.lastHeight = kData->gui->height(); + kData->guiGeometry = kData->gui->saveGeometry(); kData->gui->close(); delete kData->gui; kData->gui = nullptr;