reaper_medium/flags.rs
1use enumflags2::BitFlags;
2use reaper_low::raw;
3
4/// When creating an undo point, this defines what parts of the project might have been affected by
5/// the undoable operation.
6#[derive(Copy, Clone, PartialEq, Debug)]
7pub enum UndoScope {
8 /// Everything could have been affected.
9 ///
10 /// This is the safest variant but can lead to very large undo states.
11 All,
12 /// A combination of the given project parts could have been affected.
13 ///
14 /// If you miss some parts, *undo* can behave in weird ways.
15 Scoped(BitFlags<ProjectPart>),
16}
17
18impl UndoScope {
19 /// Converts this value to an integer as expected by the low-level API.
20 pub fn to_raw(&self) -> i32 {
21 use UndoScope::*;
22 match self {
23 All => raw::UNDO_STATE_ALL as i32,
24 Scoped(flags) => flags.bits() as i32,
25 }
26 }
27}
28
29/// Part of a project that could have been affected by an undoable operation.
30#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug, BitFlags)]
31#[repr(u32)]
32pub enum ProjectPart {
33 /// Freeze state.
34 Freeze = raw::UNDO_STATE_FREEZE,
35 /// Track master FX.
36 Fx = raw::UNDO_STATE_FX,
37 /// Track items.
38 Items = raw::UNDO_STATE_ITEMS,
39 /// Loop selection, markers, regions and extensions.
40 MiscCfg = raw::UNDO_STATE_MISCCFG,
41 /// Track/master vol/pan/routing and aLL envelopes (master included).
42 TrackCfg = raw::UNDO_STATE_TRACKCFG,
43}