Skip to content

Commit

Permalink
Final undo gestures on stack
Browse files Browse the repository at this point in the history
1. Parameter temposync etc
2. Full LFO on LFO menu reset

Addresses surge-synthesizer#694
  • Loading branch information
baconpaul committed Apr 23, 2022
1 parent 24bfd69 commit 7cbfde9
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/common/Parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ class Parameter
bool affect_other_parameters{};
float moverate{};
bool per_voice_processing{};
// remember these need to be stashed specially in undo
bool temposync{}, absolute{}, deactivated{};

#define DEBUG_WRITABLE_EXTEND_RANGE 0
Expand Down
9 changes: 8 additions & 1 deletion src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2460,10 +2460,16 @@ void SurgeGUIEditor::setMacroValueFromUndo(int ccid, float val)
void SurgeGUIEditor::pushParamToUndoRedo(int paramId, Surge::GUI::UndoManager::Target which)
{
auto p = synth->storage.getPatch().param_ptr[paramId];
auto id = synth->idForParameter(p);
undoManager()->pushParameterChange(paramId, p, p->val, which);
}

void SurgeGUIEditor::applyToParamForUndo(int paramId, std::function<void(Parameter *)> f)
{
auto p = synth->storage.getPatch().param_ptr[paramId];
f(p);
synth->refresh_editor = true;
}

void SurgeGUIEditor::setModulationFromUndo(int paramId, modsources ms, int scene, int idx,
float val, bool muted)
{
Expand Down Expand Up @@ -2876,6 +2882,7 @@ juce::PopupMenu SurgeGUIEditor::makeLfoMenu(const juce::Point<int> &where)
for (const auto &p : cat.presets)
{
auto action = [this, p, currentLfoId]() {
undoManager()->pushFullLFO(current_scene, currentLfoId);
this->synth->storage.modulatorPreset->loadPresetFrom(
p.path, &(this->synth->storage), current_scene, currentLfoId);

Expand Down
1 change: 1 addition & 0 deletions src/surge-xt/gui/SurgeGUIEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener,
const std::unique_ptr<Surge::GUI::UndoManager> &undoManager();
void setParamFromUndo(int paramId, pdata val);
void pushParamToUndoRedo(int paramId, Surge::GUI::UndoManager::Target which);
void applyToParamForUndo(int paramId, std::function<void(Parameter *)> f);
void setModulationFromUndo(int paramId, modsources ms, int scene, int idx, float val,
bool muted);
void pushModulationToUndoRedo(int paramId, modsources ms, int scene, int idx,
Expand Down
32 changes: 25 additions & 7 deletions src/surge-xt/gui/SurgeGUIEditorValueCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1744,6 +1744,7 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
contextMenu.addItem(
Surge::GUI::toOSCase("Reset Filter Cutoff To Keytrack Root"),
[this, p, control] {
undoManager()->pushParameterChange(p->id, p, p->val);
auto kr = this->synth->storage.getPatch()
.scene[current_scene]
.keytrack_root.val.i;
Expand Down Expand Up @@ -1772,35 +1773,52 @@ int32_t SurgeGUIEditor::controlModifierClicked(Surge::GUI::IComponentTagValue *c
bool isChecked = p->porta_constrate;

contextMenu.addItem(Surge::GUI::toOSCase("Constant Rate"), true, isChecked,
[this, p]() { p->porta_constrate = !p->porta_constrate; });
[this, p]() {
undoManager()->pushParameterChange(p->id, p, p->val);
p->porta_constrate = !p->porta_constrate;
});

isChecked = p->porta_gliss;

contextMenu.addItem(Surge::GUI::toOSCase("Glissando"), true, isChecked,
[this, p]() { p->porta_gliss = !p->porta_gliss; });
[this, p]() {
undoManager()->pushParameterChange(p->id, p, p->val);
p->porta_gliss = !p->porta_gliss;
});

isChecked = p->porta_retrigger;

contextMenu.addItem(Surge::GUI::toOSCase("Retrigger at Scale Degrees"), true,
isChecked,
[this, p]() { p->porta_retrigger = !p->porta_retrigger; });
isChecked, [this, p]() {
undoManager()->pushParameterChange(p->id, p, p->val);
p->porta_retrigger = !p->porta_retrigger;
});

contextMenu.addSectionHeader("CURVE");

isChecked = (p->porta_curve == -1);

contextMenu.addItem(Surge::GUI::toOSCase("Logarithmic"), true, isChecked,
[this, p]() { p->porta_curve = -1; });
[this, p]() {
undoManager()->pushParameterChange(p->id, p, p->val);
p->porta_curve = -1;
});

isChecked = (p->porta_curve == 0);

contextMenu.addItem(Surge::GUI::toOSCase("Linear"), true, isChecked,
[this, p]() { p->porta_curve = 0; });
[this, p]() {
undoManager()->pushParameterChange(p->id, p, p->val);
p->porta_curve = 0;
});

isChecked = (p->porta_curve == 1);

contextMenu.addItem(Surge::GUI::toOSCase("Exponential"), true, isChecked,
[this, p]() { p->porta_curve = 1; });
[this, p]() {
undoManager()->pushParameterChange(p->id, p, p->val);
p->porta_curve = 1;
});
}

if (p->has_deformoptions())
Expand Down
Loading

0 comments on commit 7cbfde9

Please sign in to comment.