From a8697995add6a383acb37b4f2da2b917ca8c841a Mon Sep 17 00:00:00 2001 From: Timothy Schoen <44585538+timothyschoen@users.noreply.github.com> Date: Mon, 4 Apr 2022 23:42:17 +0200 Subject: [PATCH] Small fixes --- Source/Dialogs.cpp | 6 ++---- Source/GUIObjects.cpp | 5 +++-- Source/Pd/PdInstance.cpp | 4 +++- Source/Pd/PdPatch.cpp | 21 +++++++++++++++------ Source/Pd/PdPatch.h | 6 +++--- Source/Standalone/PlugDataApp.cpp | 2 ++ 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Source/Dialogs.cpp b/Source/Dialogs.cpp index 2a4e54f70..97d521c8c 100644 --- a/Source/Dialogs.cpp +++ b/Source/Dialogs.cpp @@ -467,7 +467,7 @@ struct SettingsComponent : public Component g.fillRoundedRectangle(getLocalBounds().reduced(2).toFloat(), 3.0f); g.setColour(highlightColour); - g.fillRect(2, 42, getWidth() - 4, 4); + g.fillRect(2, 44, getWidth() - 4, 4); if (currentPanel > 0) { @@ -483,7 +483,7 @@ struct SettingsComponent : public Component int toolbarPosition = 2; for (auto& button : toolbarButtons) { - button->setBounds(toolbarPosition, 0, 70, toolbarHeight); + button->setBounds(toolbarPosition, 2, 70, toolbarHeight); toolbarPosition += 70; } @@ -529,8 +529,6 @@ struct SettingsDialog : public Component addAndMakeVisible(closeButton.get()); settingsComponent.addMouseListener(this, false); - - closeButton->onClick = [this]() { diff --git a/Source/GUIObjects.cpp b/Source/GUIObjects.cpp index a5c8dbb21..f8c13f417 100644 --- a/Source/GUIObjects.cpp +++ b/Source/GUIObjects.cpp @@ -1556,7 +1556,7 @@ struct RadioComponent : public GUIComponent if(isVertical) radioButtons[i]->setBounds(0, i * size, size, size); else radioButtons[i]->setBounds(i * size, 0, size, size); } - + // Fix aspect ratio and if(isVertical) { if(getWidth() - Box::doubleMargin != size) { @@ -1608,7 +1608,8 @@ struct RadioComponent : public GUIComponent radioButtons[(int)gui.getValue()]->setToggleState(true, dontSendNotification); - box->updateBounds(false); + resized(); + //box->updateBounds(false); } OwnedArray radioButtons; diff --git a/Source/Pd/PdInstance.cpp b/Source/Pd/PdInstance.cpp index bf2a99896..2972ad0de 100644 --- a/Source/Pd/PdInstance.cpp +++ b/Source/Pd/PdInstance.cpp @@ -111,6 +111,8 @@ extern "C" namespace pd { + + Instance::Instance(std::string const& symbol) { libpd_multi_init(); @@ -155,7 +157,7 @@ Instance::Instance(std::string const& symbol) register_gui_triggers(static_cast(m_instance), this, gui_trigger, panel_trigger, synchronise_trigger); libpd_set_verbose(0); - + setThis(); } diff --git a/Source/Pd/PdPatch.cpp b/Source/Pd/PdPatch.cpp index 4ff33973a..99da7dea2 100644 --- a/Source/Pd/PdPatch.cpp +++ b/Source/Pd/PdPatch.cpp @@ -196,14 +196,17 @@ std::vector Patch::getObjects(bool onlyGui) noexcept std::unique_ptr Patch::createGraphOnParent(int x, int y) { t_pd* pdobject = nullptr; + std::atomic done = false; + instance->enqueueFunction( - [this, x, y, &pdobject]() mutable + [this, x, y, &pdobject, &done]() mutable { setCurrent(); pdobject = libpd_creategraphonparent(getPointer(), x, y); + done = true; }); - while (!pdobject) + while (!done) { instance->waitForStateUpdate(); } @@ -216,14 +219,17 @@ std::unique_ptr Patch::createGraphOnParent(int x, int y) std::unique_ptr Patch::createGraph(const String& name, int size, int x, int y) { t_pd* pdobject = nullptr; + std::atomic done = false; + instance->enqueueFunction( - [this, name, size, x, y, &pdobject]() mutable + [this, name, size, x, y, &pdobject, &done]() mutable { setCurrent(); pdobject = libpd_creategraph(getPointer(), name.toRawUTF8(), size, x, y); + done = true; }); - while (!pdobject) + while (!done) { instance->waitForStateUpdate(); } @@ -304,14 +310,17 @@ std::unique_ptr Patch::createObject(const String& name, int x, int y, bo } t_pd* pdobject = nullptr; + std::atomic done = false; + instance->enqueueFunction( - [this, argc, argv, undoable, typesymbol, &pdobject]() mutable + [this, argc, argv, undoable, typesymbol, &pdobject, &done]() mutable { setCurrent(); pdobject = libpd_createobj(getPointer(), typesymbol, argc, argv.data(), undoable); + done = true; }); - while (!pdobject) + while (!done) { instance->waitForStateUpdate(); } diff --git a/Source/Pd/PdPatch.h b/Source/Pd/PdPatch.h index 4ba7f6465..6c8338f37 100644 --- a/Source/Pd/PdPatch.h +++ b/Source/Pd/PdPatch.h @@ -132,9 +132,9 @@ class Patch {"vsl", "15 128 0 127 0 0 empty empty empty 0 -9 0 10 #171717 #42a2c8 #ffffff 0 1"}, {"bng", "15 250 50 0 empty empty empty 17 7 0 10 #171717 #42a2c8 #ffffff"}, {"nbx", "3 14 -1e+37 1e+37 0 0 empty empty empty 0 -8 0 10 #171717 #42a2c8 #ffffff 0 256"}, - {"hradio", "24 1 0 8 empty empty empty 0 -8 0 10 #171717 #42a2c8 #ffffff 0"}, - {"vradio", "24 1 0 8 empty empty empty 0 -8 0 10 #171717 #42a2c8 #ffffff 0"}, - {"cnv", "15 100 60 empty empty empty 20 12 0 14 #171717 #404040"} + {"hradio", "16 1 0 8 empty empty empty 0 -8 0 10 #171717 #42a2c8 #ffffff 0"}, + {"vradio", "16 1 0 8 empty empty empty 0 -8 0 10 #171717 #42a2c8 #ffffff 0"}, + {"cnv", "15 100 60 empty empty empty 20 12 0 14 #171717 #ffffff"} }; friend class Instance; diff --git a/Source/Standalone/PlugDataApp.cpp b/Source/Standalone/PlugDataApp.cpp index 5c3b23fa9..8c17f16fc 100644 --- a/Source/Standalone/PlugDataApp.cpp +++ b/Source/Standalone/PlugDataApp.cpp @@ -62,6 +62,7 @@ class PlugDataApp : public JUCEApplication // For opening files with PlugData standalone void anotherInstanceStarted(const String& commandLine) override { + auto file = File(commandLine.upToFirstOccurrenceOf(" ", false, false)); if (file.existsAsFile()) { @@ -75,6 +76,7 @@ class PlugDataApp : public JUCEApplication } } } + } virtual PlugDataWindow* createWindow()