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 loadPreset(QObject* process, QString json);
110 W_SLOT(loadPreset)
111 QString savePreset(QObject* process);
112 W_SLOT(savePreset)
113
114 void setName(QObject* sel, QString new_name);
115 W_SLOT(setName)
116
117 QObject* createBox(QObject* obj, QString startTime, QString duration, double y);
118 W_SLOT(createBox, (QObject*, QString, QString, double))
119
120 QObject*
121 createBox(QObject* obj, double startTimeFlicks, double durationFlicks, double y);
122 W_SLOT(createBox, (QObject*, double, double, double))
123
124 QObject* createState(QObject* ev, double y);
125 W_SLOT(createState)
126
127 QObject* createIntervalAfter(QObject* obj, QString duration, double y);
128 W_SLOT(createIntervalAfter)
129
130 QObject* createIntervalBetween(QObject* startState, QObject* endState);
131 W_SLOT(createIntervalBetween)
132
133 void setIntervalDuration(QObject* object, TimeVal flicks);
134 W_SLOT(setIntervalDuration)
135 void setIntervalMinDuration(QObject* object, TimeVal flicks);
136 W_SLOT(setIntervalMinDuration)
137 void setIntervalMaxDuration(QObject* object, TimeVal flicks);
138 W_SLOT(setIntervalMaxDuration)
139 void setIntervalMaxInfinite(QObject* object, bool);
140 W_SLOT(setIntervalMaxInfinite)
141 void setIntervalSpeed(QObject* object, double);
142 W_SLOT(setIntervalSpeed)
143
144 QObject* port(QObject* obj, QString name);
145 W_SLOT(port)
146
147 QObject* inlet(QObject* obj, int index);
148 W_SLOT(inlet)
149
150 int inlets(QObject* obj);
151 W_SLOT(inlets)
152
153 QObject* outlet(QObject* obj, int index);
154 W_SLOT(outlet)
155
156 int outlets(QObject* obj);
157 W_SLOT(outlets)
158
159 QObject* createCable(QObject* outlet, QObject* inlet);
160 W_SLOT(createCable)
161
162 void setAddress(QObject* obj, QString addr);
163 W_SLOT(setAddress)
164
165 void setValue(QObject* obj, double value);
166 W_SLOT(setValue, (QObject*, double))
167
168 void setValue(QObject* obj, QVector2D value);
169 W_SLOT(setValue, (QObject*, QVector2D))
170
171 void setValue(QObject* obj, QVector3D value);
172 W_SLOT(setValue, (QObject*, QVector3D))
173
174 void setValue(QObject* obj, QVector4D value);
175 W_SLOT(setValue, (QObject*, QVector4D))
176
177 void setValue(QObject* obj, QString value);
178 W_SLOT(setValue, (QObject*, QString))
179
180 void setValue(QObject* obj, bool value);
181 W_SLOT(setValue, (QObject*, bool))
182
183 void setValue(QObject* obj, int value);
184 W_SLOT(setValue, (QObject*, int))
185
186 void setValue(QObject* obj, QList<QString> value);
187 W_SLOT(setValue, (QObject*, QList<QString>))
188
189 void setValue(QObject* obj, QList<qreal> value);
190 W_SLOT(setValue, (QObject*, QList<qreal>))
191
192 void setValue(QObject* obj, QList<QVariant> value);
193 W_SLOT(setValue, (QObject*, QList<QVariant>))
194
195 QString valueType(QObject* obj);
196 W_SLOT(valueType)
197
198 double min(QObject* obj);
199 W_SLOT(min)
200
201 double max(QObject* obj);
202 W_SLOT(max)
203
204 QVector<QVariant> enumValues(QObject* obj);
205 W_SLOT(enumValues)
206
207 QObject* metadata(QObject* obj) const noexcept;
208 W_SLOT(metadata)
209
210 QObject* startState(QObject* obj);
211 W_SLOT(startState)
212
213 QObject* startEvent(QObject* obj);
214 W_SLOT(startEvent)
215
216 QObject* startSync(QObject* obj);
217 W_SLOT(startSync)
218
219 QObject* endState(QObject* obj);
220 W_SLOT(endState)
221
222 QObject* endEvent(QObject* obj);
223 W_SLOT(endEvent)
224
225 QObject* endSync(QObject* obj);
226 W_SLOT(endSync)
227
228 void remove(QObject* obj);
229 W_SLOT(remove)
230
231 void setCurvePoints(QObject* process, QVector<QVariantList> points);
232 W_SLOT(setCurvePoints)
233
234 void setSteps(QObject* process, QVector<double> points);
235 W_SLOT(setSteps)
236
237 QVariantList messages(QObject* state);
238 W_SLOT(messages)
239
240 void setMessages(QObject* state, QVariantList msgs);
241 W_SLOT(setMessages)
242
243 void replaceAddress(QObjectList objects, QString before, QString after);
244 W_SLOT(replaceAddress)
245
246 void automate(QObject* interval, QString addr);
247 W_SLOT(automate, (QObject*, QString))
248
249 void automate(QObject* interval, QObject* port);
250 W_SLOT(automate, (QObject*, QObject*))
251
252
255 void startMacro();
256 W_SLOT(startMacro)
257
258 void endMacro();
259 W_SLOT(endMacro)
260
261 void undo();
262 W_SLOT(undo)
263
264 void redo();
265 W_SLOT(redo)
266
267 void load(QString path);
268 W_SLOT(load)
269
270 void save();
271 W_SLOT(save)
272
273 void saveAs(QString path);
274 W_SLOT(saveAs)
275
276
279 QObject* find(QString p);
280 W_SLOT(find)
281
282 QObject* findByLabel(QString p);
283 W_SLOT(findByLabel)
284
285 QObject* document();
286 W_SLOT(document)
287
288 QObject* rootInterval();
289 W_SLOT(rootInterval)
290
291 QObject* documentPlugin(QString key);
292 W_SLOT(documentPlugin)
293
294
297 void play();
298 W_SLOT(play, ())
299
300 void play(QObject* obj);
301 W_SLOT(play, (QObject*))
302
303 void pause();
304 W_SLOT(pause, ())
305
306 void resume();
307 W_SLOT(resume, ())
308
309 void stop();
310 W_SLOT(stop)
311
312 void reinitialize();
313 W_SLOT(reinitialize)
314
315 void scrub(double z);
316 W_SLOT(scrub)
317
318 QObject* transport();
319 W_INVOKABLE(transport)
320
321
323 QString readFile(QString path);
324 W_SLOT(readFile)
325
326 QString relativizeFilePath(QString path);
327 W_SLOT(relativizeFilePath)
328
329 QString locateFilePath(QString path);
330 W_SLOT(locateFilePath)
331
332
335 QObject* selectedObject();
336 W_SLOT(selectedObject)
337
338 QVariantList selectedObjects();
339 W_SLOT(selectedObjects)
340
341 void zoom(double zx, double zy);
342 W_SLOT(zoom, (double, double));
343
344 void scroll(double zx, double zy);
345 W_SLOT(scroll, (double, double));
346
348 QVariant prompt(QVariant v);
349 W_SLOT(prompt)
350
351
354 QVariantMap availableProcesses() const noexcept;
355 W_SLOT(availableProcesses)
356 QVariant availableProcessesAndPresets() const noexcept;
357 W_SLOT(availableProcessesAndPresets)
358 QVariant availableProtocols() const noexcept;
359 W_SLOT(availableProtocols)
360
361 QByteArray serializeAsJson() noexcept;
362 W_SLOT(serializeAsJson)
363private:
364 void submit(Macro& m, score::Command* c);
365};
366}
367
368W_REGISTER_ARGTYPE(QVector<QVariantList>)
369W_REGISTER_ARGTYPE(QList<QObject*>)
370W_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:113
Definition TimeValue.hpp:21
Definition DocumentContext.hpp:18