Loading...
Searching...
No Matches
EditContext.hpp
1#pragma once
2#include <Process/TimeValue.hpp>
3
4#include <score/document/DocumentContext.hpp>
5
6#include <ossia-qt/js_utilities.hpp>
7
8#include <QJSValue>
9#include <QList>
10#include <QObject>
11#include <QVariant>
12
13#include <score_plugin_js_export.h>
14
15#include <memory>
16#include <verdigris>
17namespace score
18{
19struct DocumentContext;
20class Command;
21}
22namespace Scenario::Command
23{
24class Macro;
25}
26namespace JS
27{
28class GlobalDeviceEnumerator;
29class DeviceListener;
30class SCORE_PLUGIN_JS_EXPORT EditJsContext : public QObject
31{
32 W_OBJECT(EditJsContext)
34
35 std::unique_ptr<Macro> m_macro;
36 struct MacroClear
37 {
39 std::unique_ptr<Macro>& macro;
40 bool clearOnDelete{};
41 ~MacroClear();
42 };
43
44 MacroClear macro(const score::DocumentContext& doc);
45
46public:
49
53 const score::DocumentContext* ctx();
54 W_INVOKABLE(ctx);
55
59 QObject* device(QString name);
60 W_SLOT(device)
61
62 QString deviceToJson(QString addr);
63 W_SLOT(deviceToJson)
64
65 QString deviceToOSCQuery(QString addr);
66 W_SLOT(deviceToOSCQuery)
67
68 void createDevice(QString name, QString uuid, QJSValue obj);
69 W_SLOT(createDevice)
70
71 void createOSCDevice(QString name, QString host, int in, int out);
72 W_SLOT(createOSCDevice)
73
74 void connectOSCQueryDevice(QString name, QString host);
75 W_SLOT(connectOSCQueryDevice)
76
77 void removeDevice(QString name);
78 W_SLOT(removeDevice)
79
80 void createQMLWebSocketDevice(QString name, QString text);
81 W_SLOT(createQMLWebSocketDevice)
82
83 void createQMLSerialDevice(QString name, QString port, QString text);
84 W_SLOT(createQMLSerialDevice)
85
86 GlobalDeviceEnumerator* enumerateDevices();
87 W_SLOT(enumerateDevices, ())
88
89 GlobalDeviceEnumerator* enumerateDevices(const QString& uuid);
90 W_SLOT(enumerateDevices, (const QString&))
91
92 DeviceListener* listenDevice(const QString& name);
93 W_SLOT(listenDevice, (const QString&))
94
95 void iterateDevice(const QString& name, const QJSValue& op);
96 W_SLOT(iterateDevice, (const QString&, const QJSValue&))
97
98 void setDeviceLearn(const QString& name, bool learn);
99 W_SLOT(setDeviceLearn, (const QString&, bool))
103 void createAddress(QString addr, QString type);
104 W_SLOT(createAddress)
105
106 QObject* createProcess(QObject* interval, QString name, QString data);
107 W_SLOT(createProcess)
108
109 void setName(QObject* sel, QString new_name);
110 W_SLOT(setName)
111
112 QObject* createBox(QObject* obj, QString startTime, QString duration, double y);
113 W_SLOT(createBox, (QObject*, QString, QString, double))
114
115 QObject*
116 createBox(QObject* obj, double startTimeFlicks, double durationFlicks, double y);
117 W_SLOT(createBox, (QObject*, double, double, double))
118
119 QObject* createState(QObject* ev, double y);
120 W_SLOT(createState)
121
122 QObject* createIntervalAfter(QObject* obj, QString duration, double y);
123 W_SLOT(createIntervalAfter)
124
125 QObject* createIntervalBetween(QObject* startState, QObject* endState);
126 W_SLOT(createIntervalBetween)
127
128 void setIntervalDuration(QObject* object, TimeVal flicks);
129 W_SLOT(setIntervalDuration)
130 void setIntervalMinDuration(QObject* object, TimeVal flicks);
131 W_SLOT(setIntervalMinDuration)
132 void setIntervalMaxDuration(QObject* object, TimeVal flicks);
133 W_SLOT(setIntervalMaxDuration)
134 void setIntervalMaxInfinite(QObject* object, bool);
135 W_SLOT(setIntervalMaxInfinite)
136 void setIntervalSpeed(QObject* object, double);
137 W_SLOT(setIntervalSpeed)
138
139 QObject* port(QObject* obj, QString name);
140 W_SLOT(port)
141
142 QObject* inlet(QObject* obj, int index);
143 W_SLOT(inlet)
144
145 int inlets(QObject* obj);
146 W_SLOT(inlets)
147
148 QObject* outlet(QObject* obj, int index);
149 W_SLOT(outlet)
150
151 int outlets(QObject* obj);
152 W_SLOT(outlets)
153
154 QObject* createCable(QObject* outlet, QObject* inlet);
155 W_SLOT(createCable)
156
157 void setAddress(QObject* obj, QString addr);
158 W_SLOT(setAddress)
159
160 void setValue(QObject* obj, double value);
161 W_SLOT(setValue, (QObject*, double))
162
163 void setValue(QObject* obj, QVector2D value);
164 W_SLOT(setValue, (QObject*, QVector2D))
165
166 void setValue(QObject* obj, QVector3D value);
167 W_SLOT(setValue, (QObject*, QVector3D))
168
169 void setValue(QObject* obj, QVector4D value);
170 W_SLOT(setValue, (QObject*, QVector4D))
171
172 void setValue(QObject* obj, QString value);
173 W_SLOT(setValue, (QObject*, QString))
174
175 void setValue(QObject* obj, bool value);
176 W_SLOT(setValue, (QObject*, bool))
177
178 void setValue(QObject* obj, int value);
179 W_SLOT(setValue, (QObject*, int))
180
181 void setValue(QObject* obj, QList<QString> value);
182 W_SLOT(setValue, (QObject*, QList<QString>))
183
184 void setValue(QObject* obj, QList<qreal> value);
185 W_SLOT(setValue, (QObject*, QList<qreal>))
186
187 void setValue(QObject* obj, QList<QVariant> value);
188 W_SLOT(setValue, (QObject*, QList<QVariant>))
189
190 QString valueType(QObject* obj);
191 W_SLOT(valueType)
192
193 double min(QObject* obj);
194 W_SLOT(min)
195
196 double max(QObject* obj);
197 W_SLOT(max)
198
199 QVector<QVariant> enumValues(QObject* obj);
200 W_SLOT(enumValues)
201
202 QObject* metadata(QObject* obj) const noexcept;
203 W_SLOT(metadata)
204
205 QObject* startState(QObject* obj);
206 W_SLOT(startState)
207
208 QObject* startEvent(QObject* obj);
209 W_SLOT(startEvent)
210
211 QObject* startSync(QObject* obj);
212 W_SLOT(startSync)
213
214 QObject* endState(QObject* obj);
215 W_SLOT(endState)
216
217 QObject* endEvent(QObject* obj);
218 W_SLOT(endEvent)
219
220 QObject* endSync(QObject* obj);
221 W_SLOT(endSync)
222
223 void remove(QObject* obj);
224 W_SLOT(remove)
225
226 void setCurvePoints(QObject* process, QVector<QVariantList> points);
227 W_SLOT(setCurvePoints)
228
229 void setSteps(QObject* process, QVector<double> points);
230 W_SLOT(setSteps)
231
232 QVariantList messages(QObject* state);
233 W_SLOT(messages)
234
235 void setMessages(QObject* state, QVariantList msgs);
236 W_SLOT(setMessages)
237
238 void replaceAddress(QObjectList objects, QString before, QString after);
239 W_SLOT(replaceAddress)
240
241 void automate(QObject* interval, QString addr);
242 W_SLOT(automate, (QObject*, QString))
243
244 void automate(QObject* interval, QObject* port);
245 W_SLOT(automate, (QObject*, QObject*))
246
247
250 void startMacro();
251 W_SLOT(startMacro)
252
253 void endMacro();
254 W_SLOT(endMacro)
255
256 void undo();
257 W_SLOT(undo)
258
259 void redo();
260 W_SLOT(redo)
261
262 void load(QString path);
263 W_SLOT(load)
264
265 void save();
266 W_SLOT(save)
267
268 void saveAs(QString path);
269 W_SLOT(saveAs)
270
271
274 QObject* find(QString p);
275 W_SLOT(find)
276
277 QObject* findByLabel(QString p);
278 W_SLOT(findByLabel)
279
280 QObject* document();
281 W_SLOT(document)
282
283 QObject* rootInterval();
284 W_SLOT(rootInterval)
285
286 QObject* documentPlugin(QString key);
287 W_SLOT(documentPlugin)
288
289
292 void play();
293 W_SLOT(play, ())
294
295 void play(QObject* obj);
296 W_SLOT(play, (QObject*))
297
298 void pause();
299 W_SLOT(pause, ())
300
301 void resume();
302 W_SLOT(resume, ())
303
304 void stop();
305 W_SLOT(stop)
306
307 void reinitialize();
308 W_SLOT(reinitialize)
309
310 void scrub(double z);
311 W_SLOT(scrub)
312
313 QObject* transport();
314 W_INVOKABLE(transport)
315
316
318 QString readFile(QString path);
319 W_SLOT(readFile)
320
321
324 QObject* selectedObject();
325 W_SLOT(selectedObject)
326
327 QVariantList selectedObjects();
328 W_SLOT(selectedObjects)
329
330 void zoom(double zx, double zy);
331 W_SLOT(zoom, (double, double));
332
333 void scroll(double zx, double zy);
334 W_SLOT(scroll, (double, double));
335
337 QVariant prompt(QVariant v);
338 W_SLOT(prompt)
339
340
343 QVariantMap availableProcesses() const noexcept;
344 W_SLOT(availableProcesses)
345 QVariant availableProcessesAndPresets() const noexcept;
346 W_SLOT(availableProcessesAndPresets)
347 QVariant availableProtocols() const noexcept;
348 W_SLOT(availableProtocols)
349
350 QByteArray serializeAsJson() noexcept;
351 W_SLOT(serializeAsJson)
352private:
353 void submit(Macro& m, score::Command* c);
354};
355}
356
357W_REGISTER_ARGTYPE(QVector<QVariantList>)
358W_REGISTER_ARGTYPE(QList<QObject*>)
359W_REGISTER_ARGTYPE(JS::GlobalDeviceEnumerator*)
Definition DeviceEnumerator.hpp:112
Definition EditContext.hpp:31
Definition DeviceEnumerator.hpp:60
Definition CommandAPI.hpp:28
The Command class.
Definition Command.hpp:34
Base toolkit upon which the software is built.
Definition Application.cpp:112
Definition TimeValue.hpp:21
Definition DocumentContext.hpp:18