Skip to content

Commit

Permalink
Add setValueFromGUIQuantized and use it in the ContEditor (#94)
Browse files Browse the repository at this point in the history
So we can do quantized drags via the interface
  • Loading branch information
baconpaul authored Jun 26, 2024
1 parent 836b0b3 commit e1fbf12
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/sst/jucegui/data/Continuous.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ struct Continuous : public Labeled

virtual float getValue() const = 0;
virtual void setValueFromGUI(const float &f) = 0;
virtual void setValueFromGUIQuantized(const float &f) { setValueFromGUI(f); }
virtual void setValueFromModel(const float &f) = 0;
virtual float getDefaultValue() const = 0;
virtual float getValue01() { return (getValue() - getMin()) / (getMax() - getMin()); }
Expand Down
9 changes: 8 additions & 1 deletion src/sst/jucegui/components/ContinuousParamEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,14 @@ void ContinuousParamEditor::mouseDrag(const juce::MouseEvent &e)
else
{
auto vn = std::clamp(mouseDownV0 + d, continuous()->getMin(), continuous()->getMax());
continuous()->setValueFromGUI(vn);
if (e.mods.isCommandDown())
{
continuous()->setValueFromGUIQuantized(vn);
}
else
{
continuous()->setValueFromGUI(vn);
}
notifyAccessibleChange();
mouseDownV0 = vn;
}
Expand Down

0 comments on commit e1fbf12

Please sign in to comment.