From df5170fcf09846e15a194944738e79c7e9668372 Mon Sep 17 00:00:00 2001 From: Roland Rabien Date: Sun, 4 Feb 2024 12:22:49 -0800 Subject: [PATCH] More mseg improvements --- .../gin_plugin/components/gin_modulation.h | 7 +++--- .../components/gin_msegcomponent.cpp | 23 ++++++++++++++++++- .../gin_plugin/components/gin_msegcomponent.h | 3 +++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/modules/gin_plugin/components/gin_modulation.h b/modules/gin_plugin/components/gin_modulation.h index c875137528..727f9a0c5a 100644 --- a/modules/gin_plugin/components/gin_modulation.h +++ b/modules/gin_plugin/components/gin_modulation.h @@ -310,8 +310,8 @@ class ModMatrixBox : public juce::ListBox, private ModMatrix::Listener { public: - ModMatrixBox (gin::Processor& p, ModMatrix& m) - : proc (p), modMatrix (m) + ModMatrixBox (gin::Processor& p, ModMatrix& m, int dw = 50) + : proc (p), modMatrix (m), depthWidth (dw) { setName ("matrix"); setModel (this); @@ -445,7 +445,7 @@ class ModMatrixBox : public juce::ListBox, enableButton.setBounds (rc.removeFromLeft (h)); deleteButton.setBounds (rc.removeFromRight (h)); rc.removeFromLeft (2); - depth.setBounds (rc.removeFromLeft (50)); + depth.setBounds (rc.removeFromLeft (owner.depthWidth)); int w = rc.getWidth() / 2; src.setBounds (rc.removeFromLeft (w)); @@ -473,4 +473,5 @@ class ModMatrixBox : public juce::ListBox, gin::Processor& proc; gin::ModMatrix& modMatrix; juce::Array assignments; + int depthWidth = 50; }; diff --git a/modules/gin_plugin/components/gin_msegcomponent.cpp b/modules/gin_plugin/components/gin_msegcomponent.cpp index 2cb671c8f4..9db8e597f1 100644 --- a/modules/gin_plugin/components/gin_msegcomponent.cpp +++ b/modules/gin_plugin/components/gin_msegcomponent.cpp @@ -387,9 +387,30 @@ void MSEGComponent::mouseDrag (const juce::MouseEvent& e) void MSEGComponent::mouseUp (const juce::MouseEvent& e) { - if (onClick && e.mouseWasClicked()) + if (onClick && e.mouseWasClicked() && ! e.mods.isPopupMenu()) onClick(); + if (e.mods.isPopupMenu() && (! editable || (draggingPoint == -1 && draggingCurve == -1))) + { + juce::PopupMenu m; + if (onLoad) m.addItem ("Load...", [this] { onLoad(); }); + if (onSave) m.addItem ("Save...", [this] { onSave(); }); + m.addSeparator(); + m.addItem ("Clear", [this] + { + data.numPoints = 2; + data.startIndex = 0; + data.endIndex = 1; + data.points.getReference (0) = { 0.0f, 0.0f, 0.0f }; + data.points.getReference (1) = { 1.0f, 0.0f, 0.0f }; + dirty = true; + repaint(); + }); + m.showMenuAsync ({}); + + return; + } + if (! editable) return; diff --git a/modules/gin_plugin/components/gin_msegcomponent.h b/modules/gin_plugin/components/gin_msegcomponent.h index 53eae561de..c742b2893c 100644 --- a/modules/gin_plugin/components/gin_msegcomponent.h +++ b/modules/gin_plugin/components/gin_msegcomponent.h @@ -16,9 +16,12 @@ class MSEGComponent : public MultiParamComponent, Parameter::Ptr ygrid, Parameter::Ptr loop); void setEditable (bool e) { editable = e; } + void markDirty() { dirty = true; repaint(); } std::function()> phaseCallback; std::function onClick; + std::function onLoad; + std::function onSave; void paint (juce::Graphics& g) override; void resized() override;