Loading...
Searching...
No Matches
UiEdits.hpp
1#pragma once
2#include <Process/Commands/SetControlValue.hpp>
3#include <Process/Dataflow/Port.hpp>
4
5#include <score/document/DocumentContext.hpp>
6
7#include <QObject>
8#include <QPointer>
9
10#include <score_plugin_avnd_export.h>
11
12#include <vector>
13
14namespace score
15{
16class CommandStack;
17}
18
19namespace oscr
20{
40class SCORE_PLUGIN_AVND_EXPORT UiEdits final : public QObject
41{
42public:
43 UiEdits(const score::DocumentContext& ctx, QObject* parent);
44 ~UiEdits() override;
45
46 void set(Process::ControlInlet& port, ossia::value v);
47 void set(Process::ControlOutlet& port, ossia::value v);
48
50 void beginGesture();
51 void endGesture();
53 void rollback();
54
56 void commit();
57
58 bool pending() const noexcept { return !m_cmds.empty(); }
59
61 struct Reacting
62 {
63 explicit Reacting(UiEdits* e) noexcept
64 : edits{e}
65 {
66 if(edits)
67 ++edits->m_reacting;
68 }
69 ~Reacting()
70 {
71 if(edits)
72 --edits->m_reacting;
73 }
74 Reacting(const Reacting&) = delete;
75 Reacting& operator=(const Reacting&) = delete;
76 UiEdits* edits{};
77 };
78
79private:
80 template <typename Command, typename Port>
81 void edit(Port& port, ossia::value v);
82 void open();
83 void close();
84 void scheduleCommit();
85 void stopWaitingForRelease();
86 bool eventFilter(QObject* watched, QEvent* event) override;
87
88 struct Edit
89 {
90 const QObject* port{};
91 score::Command* cmd{};
92 QMetaObject::Connection destroyed;
93 };
94
95 const score::DocumentContext& m_ctx;
96 QPointer<score::CommandStack> m_stack;
97 std::vector<Edit> m_cmds;
98 QMetaObject::Connection m_aboutToChange;
99 int m_reacting{};
100 int m_gestures{};
101 bool m_open{};
102 bool m_scheduled{};
103 bool m_waitingForRelease{};
104};
105}
Definition Port.hpp:247
Definition Port.hpp:481
The edits a custom ui makes to its process's controls.
Definition UiEdits.hpp:41
The Command class.
Definition Command.hpp:34
Definition Controls.hpp:30
Base toolkit upon which the software is built.
Definition Application.cpp:83
Definition score_plugin_avnd.graph.cpp:22
While one is alive, the ui is reacting to a change and set does nothing.
Definition UiEdits.hpp:62
Definition DocumentContext.hpp:18