Skip to content

Commit

Permalink
Announce undo actions with Accessible reader
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Apr 23, 2022
1 parent 7d2c606 commit d3bbcab
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,8 @@ void SurgeGUIEditor::controlBeginEdit(Surge::GUI::IComponentTagValue *control)
if (mci)
{
undoManager()->pushModulationChange(
ptag, modsource, current_scene, modsource_index, mci->modValue,
ptag, synth->storage.getPatch().param_ptr[ptag], modsource, current_scene,
modsource_index, mci->modValue,
synth->isModulationMuted(ptag, modsource, current_scene, modsource_index));
}
}
Expand Down Expand Up @@ -2489,7 +2490,8 @@ void SurgeGUIEditor::pushModulationToUndoRedo(int paramId, modsources ms, int sc
Surge::GUI::UndoManager::Target which)
{
undoManager()->pushModulationChange(
paramId, ms, scene, idx, synth->getModDepth01(paramId, ms, scene, idx),
paramId, synth->storage.getPatch().param_ptr[paramId], ms, scene, idx,
synth->getModDepth01(paramId, ms, scene, idx),
synth->isModulationMuted(paramId, modsource, current_scene, modsource_index), which);
}
//------------------------------------------------------------------------------------------------
Expand Down
61 changes: 55 additions & 6 deletions src/surge-xt/gui/UndoManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ struct UndoManagerImpl
int index;
bool muted;
modsources ms;
std::string source_name, target_name;
};
struct UndoOscillator
{
Expand Down Expand Up @@ -429,11 +430,13 @@ struct UndoManagerImpl
else
pushRedo(r);
}
void pushModulationChange(int paramId, modsources modsource, int sc, int idx, float val,
bool muted, UndoManager::Target to)
void pushModulationChange(int paramId, const Parameter *p, modsources modsource, int sc,
int idx, float val, bool muted, UndoManager::Target to)
{
auto r = UndoModulation();
r.paramId = paramId;
r.target_name = p->fullname;
r.source_name = modsource_names[modsource];
r.val = val;
r.ms = modsource;
r.scene = sc;
Expand Down Expand Up @@ -652,6 +655,7 @@ struct UndoManagerImpl
auto dcroug = DontClearRedoOnUndoGuard(this);
auto *currStack = &undoStack;
auto *currStackMem = &undoStackMem;

if (which == UndoManager::REDO)
{
currStack = &redoStack;
Expand All @@ -667,20 +671,26 @@ struct UndoManagerImpl
currStack->pop_back();

auto opposite = (which == UndoManager::UNDO ? UndoManager::REDO : UndoManager::UNDO);

std::string verb = (which == UndoManager::UNDO ? "Undo" : "Redo");
// this would be cleaner with std:visit but visit isn't in macos libc until 10.13
if (auto pa = std::get_if<UndoParam>(&q))
{
editor->pushParamToUndoRedo(pa->paramId, opposite);
auto g = SelfPushGuard(this);
restoreParamToEditor(pa);
auto ann = fmt::format("{} Parameter Value, {}", verb, pa->name);
editor->enqueueAccessibleAnnouncement(ann);
return true;
}
if (auto p = std::get_if<UndoModulation>(&q))
{
editor->pushModulationToUndoRedo(p->paramId, p->ms, p->scene, p->index, opposite);
auto g = SelfPushGuard(this);
editor->setModulationFromUndo(p->paramId, p->ms, p->scene, p->index, p->val, p->muted);

auto ann =
fmt::format("{} Modulation to {} from {}", verb, p->target_name, p->source_name);
editor->enqueueAccessibleAnnouncement(ann);
return true;
}
if (auto p = std::get_if<UndoOscillator>(&q))
Expand All @@ -695,6 +705,9 @@ struct UndoManagerImpl
{
restoreParamToEditor(&qp);
}
auto ann = fmt::format("{} Oscillator Type to {}, Scene {} Oscillator {}", verb,
osc_type_names[p->type], (char)('A' + p->scene), p->oscNum + 1);
editor->enqueueAccessibleAnnouncement(ann);
return true;
}
if (auto p = std::get_if<UndoFullLFO>(&q))
Expand Down Expand Up @@ -731,6 +744,11 @@ struct UndoManagerImpl
editor->setStepSequencerFromUndo(p->scene, p->lfoid, *ms);
}
}

auto ann = fmt::format("{} Full Modulator, Scene {} Modulator {}", verb,
(char)('A' + p->scene), p->lfoid + 1);
editor->enqueueAccessibleAnnouncement(ann);

return true;
}
if (auto p = std::get_if<UndoFX>(&q))
Expand Down Expand Up @@ -764,6 +782,10 @@ struct UndoManagerImpl
pa->set_extend_range(p->undoParamValues[i].extend_range);
pa->deform_type = p->undoParamValues[i].deform_type;
}

auto ann = fmt::format("{} FX Type to {}, FX Slot {}", verb, fx_type_names[p->type],
fxslot_names[p->fxslot]);
editor->enqueueAccessibleAnnouncement(ann);
return true;
}
if (auto p = std::get_if<UndoStep>(&q))
Expand All @@ -772,13 +794,21 @@ struct UndoManagerImpl
editor->getPatch().stepsequences[p->scene][p->lfoid], opposite);
auto g = SelfPushGuard(this);
editor->setStepSequencerFromUndo(p->scene, p->lfoid, p->storageCopy);
auto ann = fmt::format("{} StepSequencer Setting, Scene {} Modulator {}", verb,
(char)('A' + p->scene), p->lfoid + 1);
editor->enqueueAccessibleAnnouncement(ann);

return true;
}
if (auto p = std::get_if<UndoMSEG>(&q))
{
pushMSEG(p->scene, p->lfoid, editor->getPatch().msegs[p->scene][p->lfoid], opposite);
auto g = SelfPushGuard(this);
editor->setMSEGFromUndo(p->scene, p->lfoid, p->storageCopy);
auto ann = fmt::format("{} MSEG Model, Scene {} Modulator {}", verb,
(char)('A' + p->scene), p->lfoid + 1);
editor->enqueueAccessibleAnnouncement(ann);

return true;
}
if (auto p = std::get_if<UndoFormula>(&q))
Expand All @@ -787,6 +817,10 @@ struct UndoManagerImpl
opposite);
auto g = SelfPushGuard(this);
editor->setFormulaFromUndo(p->scene, p->lfoid, p->storageCopy);
auto ann = fmt::format("{} Formula, Scene {} Modulator {}", verb,
(char)('A' + p->scene), p->lfoid + 1);
editor->enqueueAccessibleAnnouncement(ann);

return true;
}
if (auto p = std::get_if<UndoRename>(&q))
Expand All @@ -796,14 +830,20 @@ struct UndoManagerImpl
auto nm = editor->getPatch().CustomControllerLabel[p->itemid];
pushMacroOrLFORename(true, nm, -1, p->itemid, -1, opposite);
auto g = SelfPushGuard(this);

editor->setMacroNameFromUndo(p->itemid, p->name);
auto ann = fmt::format("{} Macro {} Rename", p->itemid);
editor->enqueueAccessibleAnnouncement(ann);
}
else
{
auto nm = editor->getPatch().LFOBankLabel[p->scene][p->itemid][p->index];
pushMacroOrLFORename(false, nm, p->scene, p->itemid, p->index, opposite);
auto g = SelfPushGuard(this);
editor->setLFONameFromUndo(p->scene, p->itemid, p->index, p->name);

auto ann = fmt::format("{} Modulator Rename", p->itemid);
editor->enqueueAccessibleAnnouncement(ann);
}
return true;
}
Expand All @@ -815,13 +855,19 @@ struct UndoManagerImpl
pushMacroChange(p->macro, cms->get_target01(0), opposite);
auto g = SelfPushGuard(this);
editor->setMacroValueFromUndo(p->macro, p->val);

auto ann = fmt::format("{} Macro {} Value", p->macro);
editor->enqueueAccessibleAnnouncement(ann);
return true;
}
if (auto p = std::get_if<UndoTuning>(&q))
{
pushTuning(editor->getTuningForRedo(), opposite);
auto g = SelfPushGuard(this);
editor->setTuningFromUndo(p->tuning);

auto ann = fmt::format("{} Tuning Change");
editor->enqueueAccessibleAnnouncement(ann);
return true;
}
if (auto p = std::get_if<UndoPatch>(&q))
Expand All @@ -836,6 +882,9 @@ struct UndoManagerImpl
{
editor->setPatchFromUndo(p->data, p->dataSz);
}

auto ann = fmt::format("{} Patch Change");
editor->enqueueAccessibleAnnouncement(ann);
return true;
}

Expand Down Expand Up @@ -875,10 +924,10 @@ void UndoManager::pushParameterChange(int paramId, const Parameter *p, pdata val
impl->pushParameterChange(paramId, p, val, to);
}

void UndoManager::pushModulationChange(int paramId, modsources modsource, int scene, int idx,
float val, bool muted, Target to)
void UndoManager::pushModulationChange(int paramId, const Parameter *p, modsources modsource,
int scene, int idx, float val, bool muted, Target to)
{
impl->pushModulationChange(paramId, modsource, scene, idx, val, muted, to);
impl->pushModulationChange(paramId, p, modsource, scene, idx, val, muted, to);
}

void UndoManager::pushOscillator(int scene, int oscnum) { impl->pushOscillator(scene, oscnum); }
Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/UndoManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct UndoManager
std::unique_ptr<UndoManagerImpl> impl;
void pushParameterChange(int paramId, const Parameter *p, pdata val, Target to = UNDO);
void pushMacroChange(int macroid, float val);
void pushModulationChange(int paramId, modsources modsource, int scene, int index, float val,
bool muted, Target to = UNDO);
void pushModulationChange(int paramId, const Parameter *p, modsources modsource, int scene,
int index, float val, bool muted, Target to = UNDO);
void pushOscillator(int scene, int oscnum);
void pushStepSequencer(int scene, int lfoid, const StepSequencerStorage &pushValue);
void pushMSEG(int scene, int lfoid, const MSEGStorage &pushValue);
Expand Down

0 comments on commit d3bbcab

Please sign in to comment.