Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::gui::actions::UndoableAction Class Referenceabstract

Base class to be inherited by implementing undoable actions. More...

#include <src/gui/backend/backend/legacy_actions/undoable_action.h>

Inheritance diagram for zrythm::gui::actions::UndoableAction:

Public Types

enum class  Type {
  TracklistSelections , ChannelSend , MixerSelections , ArrangerSelections ,
  MidiMapping , PortConnection , Port , Range ,
  Transport , Chord
}
 Type of UndoableAction. More...
using PortConnectionsManager = dsp::PortConnectionsManager

Public Member Functions

 UndoableAction (Type type)
 UndoableAction (Type type, dsp::FramesPerTick frames_per_tick, units::sample_rate_t sample_rate)
void init_loaded (sample_rate_t engine_sample_rate)
 Non virtual function following the NVI pattern.
virtual bool needs_pause () const
 Returns whether the action requires pausing the engine.
virtual bool needs_transport_total_bar_update (bool perform) const
 Returns whether the total transport bars need to be recalculated.
virtual bool affects_audio_region_internal_positions () const
 Whether audio region loop/fade/etc.
virtual void get_plugins (std::vector< plugins::Plugin * > &plugins)
 Get the plugins referenced in this action.
auto get_frames_per_tick () const
auto get_ticks_per_frame () const
void set_num_actions (int num_actions)
 Sets the number of actions for this action.
void save_or_load_port_connections (bool performing)
 To be used by actions that save/load port connections.
void perform ()
 Performs the action.
void undo ()
 Undoes the action.
virtual QString to_string () const =0
 Stringizes the action to be used in Undo/Redo buttons.

Data Fields

Type undoable_action_type_ {}
 Undoable action type.
dsp::FramesPerTick frames_per_tick_
 A snapshot of AudioEngine.frames_per_tick when the action is executed.
units::sample_rate_t sample_rate_ = 0
 Sample rate of this action.
int num_actions_ = 1
 Number of actions to perform.
std::unique_ptr< dsp::PortConnectionsManagerport_connections_before_
 An (optional) clone of the port connections at the start of the action, used for reverting port connections when undoing.
std::unique_ptr< dsp::PortConnectionsManagerport_connections_after_

Friends

void init_from (UndoableAction &obj, const UndoableAction &other, utils::ObjectCloneType clone_type)

Detailed Description

Base class to be inherited by implementing undoable actions.

Definition at line 26 of file undoable_action.h.

Member Typedef Documentation

◆ PortConnectionsManager

using zrythm::gui::actions::UndoableAction::PortConnectionsManager = dsp::PortConnectionsManager

Definition at line 29 of file undoable_action.h.

Member Enumeration Documentation

◆ Type

Type of UndoableAction.

Definition at line 34 of file undoable_action.h.

Member Function Documentation

◆ affects_audio_region_internal_positions()

virtual bool zrythm::gui::actions::UndoableAction::affects_audio_region_internal_positions ( ) const
inlinevirtual

Whether audio region loop/fade/etc.

positions are affected by this undoable action.

Used to correct off-by-one errors when changing BPM or resampling or something that causes position conversions.

Definition at line 103 of file undoable_action.h.

◆ get_frames_per_tick()

auto zrythm::gui::actions::UndoableAction::get_frames_per_tick ( ) const
inline

Definition at line 112 of file undoable_action.h.

◆ get_plugins()

virtual void zrythm::gui::actions::UndoableAction::get_plugins ( std::vector< plugins::Plugin * > & plugins)
inlinevirtual

Get the plugins referenced in this action.

Parameters
plugins

Definition at line 110 of file undoable_action.h.

◆ get_ticks_per_frame()

auto zrythm::gui::actions::UndoableAction::get_ticks_per_frame ( ) const
inline

Definition at line 113 of file undoable_action.h.

◆ init_loaded()

void zrythm::gui::actions::UndoableAction::init_loaded ( sample_rate_t engine_sample_rate)

Non virtual function following the NVI pattern.

See also
init_loaded_impl().

◆ needs_pause()

virtual bool zrythm::gui::actions::UndoableAction::needs_pause ( ) const
inlinevirtual

Returns whether the action requires pausing the engine.

Reimplemented in zrythm::gui::actions::ArrangerSelectionsAction, and zrythm::gui::actions::TracklistSelectionsAction.

Definition at line 83 of file undoable_action.h.

◆ needs_transport_total_bar_update()

virtual bool zrythm::gui::actions::UndoableAction::needs_transport_total_bar_update ( bool perform) const
inlinevirtual

Returns whether the total transport bars need to be recalculated.

Note
Some actions already handle this logic so return false here to avoid unnecessary calculations.

Reimplemented in zrythm::gui::actions::ArrangerSelectionsAction, and zrythm::gui::actions::TracklistSelectionsAction.

Definition at line 91 of file undoable_action.h.

◆ perform()

void zrythm::gui::actions::UndoableAction::perform ( )

Performs the action.

Note
Only to be called by undo manager.
Exceptions
ZrythmExceptionon error.

◆ save_or_load_port_connections()

void zrythm::gui::actions::UndoableAction::save_or_load_port_connections ( bool performing)

To be used by actions that save/load port connections.

Parameters
performingTrue if doing/performing, false if undoing.

◆ set_num_actions()

void zrythm::gui::actions::UndoableAction::set_num_actions ( int num_actions)

Sets the number of actions for this action.

This should be set on the last action to be performed.

◆ to_string()

◆ undo()

void zrythm::gui::actions::UndoableAction::undo ( )

Undoes the action.

Exceptions
ZrythmExceptionon error.

Field Documentation

◆ frames_per_tick_

dsp::FramesPerTick zrythm::gui::actions::UndoableAction::frames_per_tick_

A snapshot of AudioEngine.frames_per_tick when the action is executed.

Definition at line 173 of file undoable_action.h.

◆ num_actions_

int zrythm::gui::actions::UndoableAction::num_actions_ = 1

Number of actions to perform.

This is used to group multiple actions into one logical action (eg, create a group track and route multiple tracks to it).

To be set on the last action being performed.

Definition at line 191 of file undoable_action.h.

◆ port_connections_after_

std::unique_ptr<dsp::PortConnectionsManager> zrythm::gui::actions::UndoableAction::port_connections_after_
See also
port_connections_before_.

Definition at line 200 of file undoable_action.h.

◆ port_connections_before_

std::unique_ptr<dsp::PortConnectionsManager> zrythm::gui::actions::UndoableAction::port_connections_before_

An (optional) clone of the port connections at the start of the action, used for reverting port connections when undoing.

Definition at line 197 of file undoable_action.h.

◆ sample_rate_

units::sample_rate_t zrythm::gui::actions::UndoableAction::sample_rate_ = 0

Sample rate of this action.

Used to recalculate UndoableAction.frames_per_tick when the project is loaded under a new samplerate.

Definition at line 181 of file undoable_action.h.

◆ undoable_action_type_

Type zrythm::gui::actions::UndoableAction::undoable_action_type_ {}

Undoable action type.

Definition at line 170 of file undoable_action.h.


The documentation for this class was generated from the following file: