|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #pragma once
- #include "common.hpp"
- #include "math.hpp"
- #include "plugin/Model.hpp"
- #include <vector>
- #include <jansson.h>
-
-
- namespace rack {
- namespace history {
-
-
- struct Action {
- virtual ~Action() {}
- virtual void undo() {}
- virtual void redo() {}
- };
-
-
- /** Batches multiple actions into one */
- struct ComplexAction : Action {
- /** Ordered by time occurred. Undoing will replay them backwards. */
- std::vector<Action*> actions;
- ~ComplexAction();
- void undo() override;
- void redo() override;
- void push(Action *action);
- };
-
-
- /** An action operating on a module
- Subclass this to create your own custom actions for your module.
- */
- struct ModuleAction : Action {
- int moduleId;
- };
-
-
- struct ModuleAdd : ModuleAction {
- Model *model;
- math::Vec pos;
- void undo() override;
- void redo() override;
- };
-
-
- struct ModuleRemove : ModuleAction {
- Model *model;
- math::Vec pos;
- json_t *moduleJ;
- ~ModuleRemove();
- void undo() override;
- void redo() override;
- };
-
-
- struct ModuleMove : ModuleAction {
- math::Vec oldPos;
- math::Vec newPos;
- void undo() override;
- void redo() override;
- };
-
-
- struct ModuleBypass : ModuleAction {
- bool bypass;
- void undo() override;
- void redo() override;
- };
-
-
- struct ParamChange : ModuleAction {
- int paramId;
- float oldValue;
- float newValue;
- void undo() override;
- void redo() override;
- };
-
-
- struct CableAdd : Action {
- int cableId;
- int outputModuleId;
- int outputId;
- int inputModuleId;
- int inputId;
- void undo() override;
- void redo() override;
- };
-
-
- struct CableRemove : Action {
- int cableId;
- int outputModuleId;
- int outputId;
- int inputModuleId;
- int inputId;
- void undo() override;
- void redo() override;
- };
-
-
- struct State {
- std::vector<Action*> actions;
- int actionIndex = 0;
-
- ~State();
- void push(Action *action);
- void undo();
- void redo();
- };
-
-
- } // namespace history
- } // namespace rack
|