Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
port_action.h
1// SPDX-FileCopyrightText: © 2020-2021, 2024 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "gui/backend/backend/actions/undoable_action.h"
7#include "utils/icloneable.h"
8
9namespace zrythm::gui::actions
10{
11
12class PortAction : public QObject, public UndoableAction
13{
14 Q_OBJECT
15 QML_ELEMENT
16 DEFINE_UNDOABLE_ACTION_QML_PROPERTIES (PortAction)
17
18public:
19 enum class Type
20 {
23 };
24
25public:
26 PortAction (QObject * parent = nullptr);
27 ~PortAction () override = default;
28
33 Type type,
34 dsp::ProcessorParameter::Uuid port_id,
35 float normalized_val);
36
37 QString to_string () const override;
38
39 friend void init_from (
40 PortAction &obj,
41 const PortAction &other,
42 utils::ObjectCloneType clone_type);
43
44private:
45 void init_loaded_impl () override { }
46 void perform_impl () override;
47 void undo_impl () override;
48 void do_or_undo (bool do_it);
49
50public:
52
53 std::optional<dsp::ProcessorParameter::Uuid> port_id_;
54
60 float normalized_val_ = 0.0f;
61};
62
66class PortActionResetControl : public PortAction
67{
68public:
69 PortActionResetControl (const dsp::ProcessorParameter &port)
70 : PortAction (
72 port.get_uuid (),
73 port.range ().convertTo0To1 (port.range ().deff_))
74 {
75 }
76};
77
78}; // namespace zrythm::gui::actions
float deff_
Default value.
Definition parameter.h:204
Processor parameter that accepts automation and modulation sources and integrates with QML and the DS...
Definition parameter.h:225
PortAction(Type type, dsp::ProcessorParameter::Uuid port_id, float normalized_val)
Construct a new action for setting a control.
@ SetControlValue
Set control port value.
Definition port_action.h:22
float normalized_val_
Normalized value before/after the change.
Definition port_action.h:60
QString to_string() const override
Stringizes the action to be used in Undo/Redo buttons.