AriaSalvatrice / AriaModules

Aria Salvatrice's Signature Series - Cool and Nice virtual synthesizer modules
https://aria.dog/modules/
GNU General Public License v3.0
61 stars 14 forks source link

Randomize knobs on Darius do not get stored in Undo history #14

Closed AriaSalvatrice closed 4 years ago

AriaSalvatrice commented 4 years ago

Haven't looked into how to implement it yet

AriaSalvatrice commented 4 years ago

https://community.vcvrack.com/t/custom-history-actions-for-modules/2575

AriaSalvatrice commented 4 years ago

Pushing back that one for later. Anyone knows of open-source modules that implemented this so I can see what they did?

david-c14 commented 4 years ago

https://github.com/david-c14/SubmarineFree/blob/1f8d55eccb8997ef42551afc9519e7cabb4cbcae/src/LT1.cpp#L427

Adding an Action to the APP-history. However, this example uses anonymous functions, because I prefer them. The EventWidgetAction is defined here and here

If you don't want to be doing anonymous functions, you need a subclass of ModuleAction for each kind of undo that you need, create an instance of your subclass, give it whatever information it needs to undo / redo the action, and then add it to the APP->history.

Don't put a pointer to your module into the action, set the moduleId in the action instead, and then the undo/redo methods should find that module by it's id. That's because your undo might get called after someone has deleted your module and then undone the delete, so your pointer would be invalid, but the id should be good.

AriaSalvatrice commented 4 years ago

Undo support was added to the development branch. Thank you for the example implementation @david-c14 !