Loading...
Searching...
No Matches
EditContext.hpp
1#pragma once
2#include <score/document/DocumentContext.hpp>
3
4#include <ossia-qt/js_utilities.hpp>
5
6#include <QJSValue>
7#include <QList>
8#include <QObject>
9#include <QVariant>
10
11#include <score_plugin_js_export.h>
12
13#include <memory>
14#include <verdigris>
15namespace score
16{
17struct DocumentContext;
18class Command;
19}
20namespace Scenario::Command
21{
22class Macro;
23}
24namespace JS
25{
26class GlobalDeviceEnumerator;
27class SCORE_PLUGIN_JS_EXPORT EditJsContext : public QObject
28{
29 W_OBJECT(EditJsContext)
31
32 std::unique_ptr<Macro> m_macro;
33 struct MacroClear
34 {
36 std::unique_ptr<Macro>& macro;
37 bool clearOnDelete{};
38 ~MacroClear();
39 };
40
41 MacroClear macro(const score::DocumentContext& doc);
42
43public:
46
47 const score::DocumentContext* ctx();
48 W_INVOKABLE(ctx);
49
50 QString deviceToJson(QString addr);
51 W_SLOT(deviceToJson)
52
53 QString deviceToOSCQuery(QString addr);
54 W_SLOT(deviceToOSCQuery)
55
56 void createDevice(QString name, QString uuid, QJSValue obj);
57 W_SLOT(createDevice)
58
59 void createOSCDevice(QString name, QString host, int in, int out);
60 W_SLOT(createOSCDevice)
61
62 void removeDevice(QString name);
63 W_SLOT(removeDevice)
64
65 void createQMLWebSocketDevice(QString name, QString text);
66 W_SLOT(createQMLWebSocketDevice)
67
68 void createQMLSerialDevice(QString name, QString port, QString text);
69 W_SLOT(createQMLSerialDevice)
70
71 GlobalDeviceEnumerator* enumerateDevices();
72 W_SLOT(enumerateDevices, ())
73
74 GlobalDeviceEnumerator* enumerateDevices(const QString& uuid);
75 W_SLOT(enumerateDevices, (const QString&))
76
77 void createAddress(QString addr, QString type);
78 W_SLOT(createAddress)
79
80 QObject* createProcess(QObject* interval, QString name, QString data);
81 W_SLOT(createProcess)
82
83 void setName(QObject* sel, QString new_name);
84 W_SLOT(setName)
85
86 QObject* createBox(QObject* obj, QString startTime, QString duration, double y);
87 W_SLOT(createBox, (QObject*, QString, QString, double))
88
89 QObject*
90 createBox(QObject* obj, double startTimeFlicks, double durationFlicks, double y);
91 W_SLOT(createBox, (QObject*, double, double, double))
92
93 QObject* createState(QObject* ev, double y);
94 W_SLOT(createState)
95
96 QObject* createIntervalAfter(QObject* obj, QString duration, double y);
97 W_SLOT(createIntervalAfter)
98
99 QObject* createIntervalBetween(QObject* startState, QObject* endState);
100 W_SLOT(createIntervalBetween)
101
102 QObject* port(QObject* obj, QString name);
103 W_SLOT(port)
104
105 QObject* inlet(QObject* obj, int index);
106 W_SLOT(inlet)
107
108 int inlets(QObject* obj);
109 W_SLOT(inlets)
110
111 QObject* outlet(QObject* obj, int index);
112 W_SLOT(outlet)
113
114 int outlets(QObject* obj);
115 W_SLOT(outlets)
116
117 void setAddress(QObject* obj, QString addr);
118 W_SLOT(setAddress)
119
120 void setValue(QObject* obj, double value);
121 W_SLOT(setValue, (QObject*, double))
122
123 void setValue(QObject* obj, QString value);
124 W_SLOT(setValue, (QObject*, QString))
125
126 void setValue(QObject* obj, bool value);
127 W_SLOT(setValue, (QObject*, bool))
128
129 void setValue(QObject* obj, QList<QString> value);
130 W_SLOT(setValue, (QObject*, QList<QString>))
131
132 QString valueType(QObject* obj);
133 W_SLOT(valueType)
134
135 double min(QObject* obj);
136 W_SLOT(min)
137
138 double max(QObject* obj);
139 W_SLOT(max)
140
141 QVector<QString> enumValues(QObject* obj);
142 W_SLOT(enumValues)
143
144 QObject* metadata(QObject* obj) const noexcept;
145 W_SLOT(metadata)
146
147 QObject* startState(QObject* obj);
148 W_SLOT(startState)
149
150 QObject* startEvent(QObject* obj);
151 W_SLOT(startEvent)
152
153 QObject* startSync(QObject* obj);
154 W_SLOT(startSync)
155
156 QObject* endState(QObject* obj);
157 W_SLOT(endState)
158
159 QObject* endEvent(QObject* obj);
160 W_SLOT(endEvent)
161
162 QObject* endSync(QObject* obj);
163 W_SLOT(endSync)
164
165 void remove(QObject* obj);
166 W_SLOT(remove)
167
168 void setCurvePoints(QObject* process, QVector<QVariantList> points);
169 W_SLOT(setCurvePoints)
170
171 void setSteps(QObject* process, QVector<double> points);
172 W_SLOT(setSteps)
173
174 QVariantList messages(QObject* state);
175 W_SLOT(messages)
176
177 void setMessages(QObject* state, QVariantList msgs);
178 W_SLOT(setMessages)
179
180 void replaceAddress(QObjectList objects, QString before, QString after);
181 W_SLOT(replaceAddress)
182
183 void automate(QObject* interval, QString addr);
184 W_SLOT(automate, (QObject*, QString))
185
186 void automate(QObject* interval, QObject* port);
187 W_SLOT(automate, (QObject*, QObject*))
188
189 void startMacro();
190 W_SLOT(startMacro)
191
192 void endMacro();
193 W_SLOT(endMacro)
194
195 void undo();
196 W_SLOT(undo)
197
198 void redo();
199 W_SLOT(redo)
200
201 QObject* find(QString p);
202 W_SLOT(find)
203
204 QObject* findByLabel(QString p);
205 W_SLOT(findByLabel)
206
207 QObject* document();
208 W_SLOT(document)
209
210 QObject* rootInterval();
211 W_SLOT(rootInterval)
212
213
214 void play();
215 W_SLOT(play, ())
216
217 void play(QObject* obj);
218 W_SLOT(play, (QObject*))
219
220 void pause();
221 W_SLOT(pause, ())
222
223 void resume();
224 W_SLOT(resume, ())
225
226 void stop();
227 W_SLOT(stop)
228
229 void scrub(double z);
230 W_SLOT(scrub)
231
232
233 QString readFile(QString path);
234 W_SLOT(readFile)
235
236
237 QObject* selectedObject();
238 W_SLOT(selectedObject)
239
240 QVariantList selectedObjects();
241 W_SLOT(selectedObjects)
242
243 void zoom(double zx, double zy);
244 W_SLOT(zoom, (double, double));
245
246 void scroll(double zx, double zy);
247 W_SLOT(scroll, (double, double));
248
250 QVariant prompt(QVariant v);
251 W_SLOT(prompt)
252
253private:
254 void submit(Macro& m, score::Command* c);
255};
256}
257
258W_REGISTER_ARGTYPE(QVector<QVariantList>)
259W_REGISTER_ARGTYPE(QList<QObject*>)
260W_REGISTER_ARGTYPE(JS::GlobalDeviceEnumerator*)
Definition EditContext.hpp:28
Definition DeviceEnumerator.hpp:49
Definition CommandAPI.hpp:28
The Command class.
Definition Command.hpp:34
Base toolkit upon which the software is built.
Definition Application.cpp:97
Definition DocumentContext.hpp:18