Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
undo_manager.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2022 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __UNDO_UNDO_MANAGER_H__
11#define __UNDO_UNDO_MANAGER_H__
12
13#include "actions/undo_stack.h"
14
15#include "zix/sem.h"
16
17typedef struct AudioClip AudioClip;
18
25#define UNDO_MANAGER (PROJECT->undo_manager)
26
30typedef struct UndoManager
31{
32 UndoStack * undo_stack;
33 UndoStack * redo_stack;
34
42
44 ZixSem action_sem;
46
51NONNULL void
53
58WARN_UNUSED_RESULT UndoManager *
60
64NONNULL_ARGS (1) int undo_manager_undo (UndoManager * self, GError ** error);
65
69NONNULL_ARGS (1) int undo_manager_redo (UndoManager * self, GError ** error);
70
77NONNULL_ARGS (1, 2)
79 UndoManager * self,
80 UndoableAction * action,
81 GError ** error);
82
87#define UNDO_MANAGER_PERFORM_AND_PROPAGATE_ERR(action, err, ...) \
88 { \
89 g_return_val_if_fail ( \
90 router_is_processing_thread (ROUTER) == false, false); \
91 UndoableAction * ua = action (__VA_ARGS__); \
92 if (ua) \
93 { \
94 int ret = undo_manager_perform (UNDO_MANAGER, ua, err); \
95 if (ret == 0) \
96 return true; \
97 } \
98 return false; \
99 }
100
105NONNULL bool
107
113NONNULL void
114undo_manager_get_plugins (UndoManager * self, GPtrArray * arr);
115
120NONNULL UndoableAction *
122
126NONNULL void
128
129NONNULL UndoManager *
130undo_manager_clone (const UndoManager * src);
131
132NONNULL void
133undo_manager_free (UndoManager * self);
134
139#endif
NONNULL void undo_manager_get_plugins(UndoManager *self, GPtrArray *arr)
Returns all plugins in the undo stacks.
NONNULL bool undo_manager_contains_clip(UndoManager *self, AudioClip *clip)
Returns whether the given clip is used by any stack.
int undo_manager_perform(UndoManager *self, UndoableAction *action, GError **error)
Performs the action and pushes it to the undo stack.
WARN_UNUSED_RESULT UndoManager * undo_manager_new(void)
Inits the undo manager by creating the undo/redo stacks.
NONNULL void undo_manager_clear_stacks(UndoManager *self, bool free)
Clears the undo and redo stacks.
NONNULL UndoableAction * undo_manager_get_last_action(UndoManager *self)
Returns the last performed action, or NULL if the stack is empty.
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
NONNULL void undo_manager_init_loaded(UndoManager *self)
Inits the undo manager by populating the undo/redo stacks.
Audio clips for the pool.
Definition clip.h:33
Undo manager.
bool redo_stack_locked
Whether the redo stack is currently locked.
ZixSem action_sem
Semaphore for performing actions.
Serializable stack for undoable actions.
Definition undo_stack.h:40
Base struct to be inherited by implementing undoable actions.
Undo stack.