Skip to content

Commit

Permalink
Default tearouts to pinned in plugins; separate pref (#6821)
Browse files Browse the repository at this point in the history
This defaults tearout windows to pin on top in plugin contexts
which solves problems in reaper, logic, live and more. To avoid
confusion with the standalone we also separate the user default
parameters by plugin and standalone, making this a really big diff
for a very small change (basically changing the default of alwaysOnTop
in a plugin only)

Closes #6633
  • Loading branch information
baconpaul authored Jan 25, 2023
1 parent a311725 commit 3e1820b
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 39 deletions.
22 changes: 22 additions & 0 deletions src/common/UserDefaults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,28 @@ std::string defaultKeyToString(DefaultKey k)
r = "oscilloscopeOverlayTearOutAlwaysOnTop";
break;

case TuningOverlayTearOutAlwaysOnTop_Plugin:
r = "tuningOverlayTearOutAlwaysOnTop_Plugin";
break;
case ModlistOverlayTearOutAlwaysOnTop_Plugin:
r = "modlistOverlayTearOutAlwaysOnTop_Plugin";
break;
case MSEGOverlayTearOutAlwaysOnTop_Plugin:
r = "msegOverlayTearOutAlwaysOnTop_Plugin";
break;
case FormulaOverlayTearOutAlwaysOnTop_Plugin:
r = "formulaOverlayTearOutAlwaysOnTop_Plugin";
break;
case WSAnalysisOverlayTearOutAlwaysOnTop_Plugin:
r = "wsAnalysisOverlayTearOutAlwaysOnTop_Plugin";
break;
case FilterAnalysisOverlayTearOutAlwaysOnTop_Plugin:
r = "filterAnalysisOverlayTearOutAlwaysOnTop_Plugin";
break;
case OscilloscopeOverlayTearOutAlwaysOnTop_Plugin:
r = "oscilloscopeOverlayTearOutAlwaysOnTop_Plugin";
break;

case ModListValueDisplay:
r = "modListValueDisplay";
break;
Expand Down
8 changes: 8 additions & 0 deletions src/common/UserDefaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ enum DefaultKey
FilterAnalysisOverlayTearOutAlwaysOnTop,
OscilloscopeOverlayTearOutAlwaysOnTop,

TuningOverlayTearOutAlwaysOnTop_Plugin,
ModlistOverlayTearOutAlwaysOnTop_Plugin,
MSEGOverlayTearOutAlwaysOnTop_Plugin,
FormulaOverlayTearOutAlwaysOnTop_Plugin,
WSAnalysisOverlayTearOutAlwaysOnTop_Plugin,
FilterAnalysisOverlayTearOutAlwaysOnTop_Plugin,
OscilloscopeOverlayTearOutAlwaysOnTop_Plugin,

// Surge XT Effects specific defaults
FXUnitAssumeFixedBlock,
FXUnitDefaultZoom,
Expand Down
10 changes: 0 additions & 10 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,6 @@ class DroppedUserDataHandler
};

Surge::GUI::ModulationGrid *Surge::GUI::ModulationGrid::grid = nullptr;
/*
* See the comment in SurgeGUIUtils.cpp
*/
namespace Surge
{
namespace GUI
{
extern void setIsStandalone(bool b);
}
} // namespace Surge

SurgeGUIEditor::SurgeGUIEditor(SurgeSynthEditor *jEd, SurgeSynthesizer *synth)
{
Expand Down
24 changes: 16 additions & 8 deletions src/surge-xt/gui/SurgeGUIEditorOverlays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay

jassert(false); // Make a key for me please!

pt->setCanTearOut({true, Surge::Storage::nKeys, Surge::Storage::nKeys});
pt->setCanTearOut(
{true, Surge::Storage::nKeys, Surge::Storage::nKeys, Surge::Storage::nKeys});

return pt;
}
Expand Down Expand Up @@ -209,7 +210,8 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay

mse->setEnclosingParentTitle(title);
mse->setCanTearOut({true, Surge::Storage::MSEGOverlayLocationTearOut,
Surge::Storage::MSEGOverlayTearOutAlwaysOnTop});
Surge::Storage::MSEGOverlayTearOutAlwaysOnTop,
Surge::Storage::MSEGOverlayTearOutAlwaysOnTop_Plugin});
mse->setCanTearOutResize({true, Surge::Storage::MSEGOverlaySizeTearOut});
mse->setMinimumSize(600, 250);
locationGet(mse.get(), Surge::Skin::Connector::NonParameterConnection::MSEG_EDITOR_WINDOW,
Expand Down Expand Up @@ -259,7 +261,8 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay
fme->setSkin(currentSkin, bitmapStore);
fme->setEnclosingParentTitle(title);
fme->setCanTearOut({true, Surge::Storage::FormulaOverlayLocationTearOut,
Surge::Storage::FormulaOverlayTearOutAlwaysOnTop});
Surge::Storage::FormulaOverlayTearOutAlwaysOnTop,
Surge::Storage::FormulaOverlayTearOutAlwaysOnTop_Plugin});
fme->setCanTearOutResize({true, Surge::Storage::FormulaOverlaySizeTearOut});
fme->setMinimumSize(500, 250);
locationGet(fme.get(),
Expand All @@ -284,7 +287,8 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay
te->setTuning(synth->storage.currentTuning);
te->setEnclosingParentTitle("Tuning Editor");
te->setCanTearOut({true, Surge::Storage::TuningOverlayLocationTearOut,
Surge::Storage::TuningOverlayTearOutAlwaysOnTop});
Surge::Storage::TuningOverlayTearOutAlwaysOnTop,
Surge::Storage::TuningOverlayTearOutAlwaysOnTop_Plugin});
te->setCanTearOutResize({true, Surge::Storage::TuningOverlaySizeTearOut});
te->setMinimumSize(730, 400);
locationGet(te.get(), Surge::Skin::Connector::NonParameterConnection::TUNING_EDITOR_WINDOW,
Expand Down Expand Up @@ -325,7 +329,8 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay
wsa->setEnclosingParentTitle("Waveshaper Analysis");
wsa->setWSType(synth->storage.getPatch().scene[current_scene].wsunit.type.val.i);
wsa->setCanTearOut({true, Surge::Storage::WSAnalysisOverlayLocationTearOut,
Surge::Storage::WSAnalysisOverlayTearOutAlwaysOnTop});
Surge::Storage::WSAnalysisOverlayTearOutAlwaysOnTop,
Surge::Storage::WSAnalysisOverlayTearOutAlwaysOnTop_Plugin});
wsa->setCanTearOutResize({true, Surge::Storage::WSAnalysisOverlaySizeTearOut});
wsa->setMinimumSize(300, 160);

Expand All @@ -343,7 +348,8 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay
fa->setSkin(currentSkin, bitmapStore);
fa->setEnclosingParentTitle("Filter Analysis");
fa->setCanTearOut({true, Surge::Storage::FilterAnalysisOverlayLocationTearOut,
Surge::Storage::FilterAnalysisOverlayTearOutAlwaysOnTop});
Surge::Storage::FilterAnalysisOverlayTearOutAlwaysOnTop,
Surge::Storage::FilterAnalysisOverlayTearOutAlwaysOnTop_Plugin});
fa->setCanTearOutResize({true, Surge::Storage::FilterAnalysisOverlaySizeTearOut});
fa->setMinimumSize(300, 200);

Expand All @@ -361,7 +367,8 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay
scope->setSkin(currentSkin, bitmapStore);
scope->setEnclosingParentTitle("Oscilloscope");
scope->setCanTearOut({true, Surge::Storage::OscilloscopeOverlayLocationTearOut,
Surge::Storage::OscilloscopeOverlayTearOutAlwaysOnTop});
Surge::Storage::OscilloscopeOverlayTearOutAlwaysOnTop,
Surge::Storage::OscilloscopeOverlayTearOutAlwaysOnTop_Plugin});
scope->setCanTearOutResize({true, Surge::Storage::OscilloscopeOverlaySizeTearOut});
scope->setMinimumSize(500, 300);

Expand All @@ -373,7 +380,8 @@ std::unique_ptr<Surge::Overlays::OverlayComponent> SurgeGUIEditor::createOverlay
auto me = std::make_unique<Surge::Overlays::ModulationEditor>(this, this->synth);
me->setEnclosingParentTitle("Modulation List");
me->setCanTearOut({true, Surge::Storage::ModlistOverlayLocationTearOut,
Surge::Storage::ModlistOverlayTearOutAlwaysOnTop});
Surge::Storage::ModlistOverlayTearOutAlwaysOnTop,
Surge::Storage::ModlistOverlayTearOutAlwaysOnTop_Plugin});
me->setCanTearOutResize({true, Surge::Storage::ModlistOverlaySizeTearOut});
me->setMinimumSize(600, 300);
me->setSkin(currentSkin, bitmapStore);
Expand Down
1 change: 1 addition & 0 deletions src/surge-xt/gui/SurgeGUIUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ bool isTouchMode(SurgeStorage *storage)
*/
static bool isStandalone{false};
void setIsStandalone(bool b) { isStandalone = b; }
bool getIsStandalone() { return isStandalone; }

bool allowKeyboardEdits(SurgeStorage *storage)
{
Expand Down
5 changes: 5 additions & 0 deletions src/surge-xt/gui/SurgeGUIUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@ void constrainPointOnLineWithinRectangle(const juce::Rectangle<float> rect,

void openFileOrFolder(const std::string &f);
inline void openFileOrFolder(const fs::path &f) { openFileOrFolder(path_to_string(f)); }

// Are we standalone exe vs a plugin (clap, vst, au, etc...)
void setIsStandalone(bool);
bool getIsStandalone();

} // namespace GUI
} // namespace Surge
17 changes: 7 additions & 10 deletions src/surge-xt/gui/overlays/OverlayComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,13 @@ struct OverlayComponent : juce::Component
*/
virtual void shownInParent() {}

std::tuple<bool, Surge::Storage::DefaultKey, Surge::Storage::DefaultKey> canTearOut{
false, Surge::Storage::nKeys, Surge::Storage::nKeys};
void setCanTearOut(std::tuple<bool, Surge::Storage::DefaultKey, Surge::Storage::DefaultKey> t)
{
canTearOut = t;
}
std::tuple<bool, Surge::Storage::DefaultKey, Surge::Storage::DefaultKey> getCanTearOut()
{
return canTearOut;
}
typedef std::tuple<bool, Surge::Storage::DefaultKey, Surge::Storage::DefaultKey,
Surge::Storage::DefaultKey>
tearoutTuple_t;
tearoutTuple_t canTearOut{false, Surge::Storage::nKeys, Surge::Storage::nKeys,
Surge::Storage::nKeys};
void setCanTearOut(tearoutTuple_t t) { canTearOut = t; }
tearoutTuple_t getCanTearOut() { return canTearOut; }
virtual void onTearOutChanged(bool isTornOut) {}

std::pair<bool, Surge::Storage::DefaultKey> canTearOutResize{false, Surge::Storage::nKeys};
Expand Down
13 changes: 10 additions & 3 deletions src/surge-xt/gui/overlays/OverlayWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,16 @@ struct TearOutWindow : public juce::DocumentWindow, public Surge::GUI::SkinConsu
{
isPinned = !isPinned;

Surge::Storage::updateUserDefaultValue(wrapping->storage,
std::get<2>(wrapping->canTearOutData), isPinned);

if (Surge::GUI::getIsStandalone())
{
Surge::Storage::updateUserDefaultValue(wrapping->storage,
std::get<2>(wrapping->canTearOutData), isPinned);
}
else
{
Surge::Storage::updateUserDefaultValue(wrapping->storage,
std::get<3>(wrapping->canTearOutData), isPinned);
}
setAlwaysOnTop(isPinned);
repaint();
}
Expand Down
22 changes: 14 additions & 8 deletions src/surge-xt/gui/overlays/OverlayWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "UserDefaults.h"

#include "juce_gui_basics/juce_gui_basics.h"
#include "SurgeGUIUtils.h"

class SurgeGUIEditor;
class SurgeImage;
Expand Down Expand Up @@ -77,19 +78,24 @@ struct OverlayWrapper : public juce::Component,
SurgeImage *icon{nullptr};
void setIcon(SurgeImage *d) { icon = d; }

std::tuple<bool, Surge::Storage::DefaultKey, Surge::Storage::DefaultKey> canTearOutData{
false, Surge::Storage::nKeys, Surge::Storage::nKeys};
// this is can, size key, standalone pin key, plugin pin key
typedef std::tuple<bool, Surge::Storage::DefaultKey, Surge::Storage::DefaultKey,
Surge::Storage::DefaultKey>
tearoutTuple_t;
tearoutTuple_t canTearOutData{false, Surge::Storage::nKeys, Surge::Storage::nKeys,
Surge::Storage::nKeys};
bool canTearOut, isAlwaysOnTop;
void setCanTearOut(std::tuple<bool, Surge::Storage::DefaultKey, Surge::Storage::DefaultKey> t)
// this tuple is can: the sie key,
void setCanTearOut(tearoutTuple_t t)
{
canTearOutData = t;
canTearOut = std::get<0>(t);
isAlwaysOnTop = Surge::Storage::getUserDefaultValue(storage, std::get<2>(t), false);
}
std::tuple<bool, Surge::Storage::DefaultKey, Surge::Storage::DefaultKey> getCanTearOut()
{
return canTearOutData;
if (Surge::GUI::getIsStandalone())
isAlwaysOnTop = Surge::Storage::getUserDefaultValue(storage, std::get<2>(t), false);
else
isAlwaysOnTop = Surge::Storage::getUserDefaultValue(storage, std::get<3>(t), true);
}
tearoutTuple_t getCanTearOut() { return canTearOutData; }

std::pair<bool, Surge::Storage::DefaultKey> canTearOutResizePair{false, Surge::Storage::nKeys};
bool canTearOutResize;
Expand Down

0 comments on commit 3e1820b

Please sign in to comment.