Skip to content

Commit

Permalink
More mseg improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
FigBug committed Feb 4, 2024
1 parent f4564da commit df5170f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
7 changes: 4 additions & 3 deletions modules/gin_plugin/components/gin_modulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -473,4 +473,5 @@ class ModMatrixBox : public juce::ListBox,
gin::Processor& proc;
gin::ModMatrix& modMatrix;
juce::Array<Assignment> assignments;
int depthWidth = 50;
};
23 changes: 22 additions & 1 deletion modules/gin_plugin/components/gin_msegcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions modules/gin_plugin/components/gin_msegcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::vector<float>()> phaseCallback;
std::function<void()> onClick;
std::function<void()> onLoad;
std::function<void()> onSave;

void paint (juce::Graphics& g) override;
void resized() override;
Expand Down

0 comments on commit df5170f

Please sign in to comment.