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 DeviceListener;
28class SCORE_PLUGIN_JS_EXPORT EditJsContext : public QObject
29{
30 W_OBJECT(EditJsContext)
32
33 std::unique_ptr<Macro> m_macro;
34 struct MacroClear
35 {
37 std::unique_ptr<Macro>& macro;
38 bool clearOnDelete{};
39 ~MacroClear();
40 };
41
42 MacroClear macro(const score::DocumentContext& doc);
43
44public:
47
48 const score::DocumentContext* ctx();
49 W_INVOKABLE(ctx);
50
54 QObject* device(QString name);
55 W_SLOT(device)
56
57 QString deviceToJson(QString addr);
58 W_SLOT(deviceToJson)
59
60 QString deviceToOSCQuery(QString addr);
61 W_SLOT(deviceToOSCQuery)
62
63 void createDevice(QString name, QString uuid, QJSValue obj);
64 W_SLOT(createDevice)
65
66 void createOSCDevice(QString name, QString host, int in, int out);
67 W_SLOT(createOSCDevice)
68
69 void connectOSCQueryDevice(QString name, QString host);
70 W_SLOT(connectOSCQueryDevice)
71
72 void removeDevice(QString name);
73 W_SLOT(removeDevice)
74
75 void createQMLWebSocketDevice(QString name, QString text);
76 W_SLOT(createQMLWebSocketDevice)
77
78 void createQMLSerialDevice(QString name, QString port, QString text);
79 W_SLOT(createQMLSerialDevice)
80
81 GlobalDeviceEnumerator* enumerateDevices();
82 W_SLOT(enumerateDevices, ())
83
84 GlobalDeviceEnumerator* enumerateDevices(const QString& uuid);
85 W_SLOT(enumerateDevices, (const QString&))
86
87 DeviceListener* listenDevice(const QString& name);
88 W_SLOT(listenDevice, (const QString&))
89
90 void iterateDevice(const QString& name, const QJSValue& op);
91 W_SLOT(iterateDevice, (const QString&, const QJSValue&))
92
93 void setDeviceLearn(const QString& name, bool learn);
94 W_SLOT(setDeviceLearn, (const QString&, bool))
98 void createAddress(QString addr, QString type);
99 W_SLOT(createAddress)
100
101 QObject* createProcess(QObject* interval, QString name, QString data);
102 W_SLOT(createProcess)
103
104 void setName(QObject* sel, QString new_name);
105 W_SLOT(setName)
106
107 QObject* createBox(QObject* obj, QString startTime, QString duration, double y);
108 W_SLOT(createBox, (QObject*, QString, QString, double))
109
110 QObject*
111 createBox(QObject* obj, double startTimeFlicks, double durationFlicks, double y);
112 W_SLOT(createBox, (QObject*, double, double, double))
113
114 QObject* createState(QObject* ev, double y);
115 W_SLOT(createState)
116
117 QObject* createIntervalAfter(QObject* obj, QString duration, double y);
118 W_SLOT(createIntervalAfter)
119
120 QObject* createIntervalBetween(QObject* startState, QObject* endState);
121 W_SLOT(createIntervalBetween)
122
123 QObject* port(QObject* obj, QString name);
124 W_SLOT(port)
125
126 QObject* inlet(QObject* obj, int index);
127 W_SLOT(inlet)
128
129 int inlets(QObject* obj);
130 W_SLOT(inlets)
131
132 QObject* outlet(QObject* obj, int index);
133 W_SLOT(outlet)
134
135 int outlets(QObject* obj);
136 W_SLOT(outlets)
137
138 QObject* createCable(QObject* outlet, QObject* inlet);
139 W_SLOT(createCable)
140
141 void setAddress(QObject* obj, QString addr);
142 W_SLOT(setAddress)
143
144 void setValue(QObject* obj, double value);
145 W_SLOT(setValue, (QObject*, double))
146
147 void setValue(QObject* obj, QVector2D value);
148 W_SLOT(setValue, (QObject*, QVector2D))
149
150 void setValue(QObject* obj, QVector3D value);
151 W_SLOT(setValue, (QObject*, QVector3D))
152
153 void setValue(QObject* obj, QVector4D value);
154 W_SLOT(setValue, (QObject*, QVector4D))
155
156 void setValue(QObject* obj, QString value);
157 W_SLOT(setValue, (QObject*, QString))
158
159 void setValue(QObject* obj, bool value);
160 W_SLOT(setValue, (QObject*, bool))
161
162 void setValue(QObject* obj, int value);
163 W_SLOT(setValue, (QObject*, int))
164
165 void setValue(QObject* obj, QList<QString> value);
166 W_SLOT(setValue, (QObject*, QList<QString>))
167
168 void setValue(QObject* obj, QList<qreal> value);
169 W_SLOT(setValue, (QObject*, QList<qreal>))
170
171 void setValue(QObject* obj, QList<QVariant> value);
172 W_SLOT(setValue, (QObject*, QList<QVariant>))
173
174 QString valueType(QObject* obj);
175 W_SLOT(valueType)
176
177 double min(QObject* obj);
178 W_SLOT(min)
179
180 double max(QObject* obj);
181 W_SLOT(max)
182
183 QVector<QVariant> enumValues(QObject* obj);
184 W_SLOT(enumValues)
185
186 QObject* metadata(QObject* obj) const noexcept;
187 W_SLOT(metadata)
188
189 QObject* startState(QObject* obj);
190 W_SLOT(startState)
191
192 QObject* startEvent(QObject* obj);
193 W_SLOT(startEvent)
194
195 QObject* startSync(QObject* obj);
196 W_SLOT(startSync)
197
198 QObject* endState(QObject* obj);
199 W_SLOT(endState)
200
201 QObject* endEvent(QObject* obj);
202 W_SLOT(endEvent)
203
204 QObject* endSync(QObject* obj);
205 W_SLOT(endSync)
206
207 void remove(QObject* obj);
208 W_SLOT(remove)
209
210 void setCurvePoints(QObject* process, QVector<QVariantList> points);
211 W_SLOT(setCurvePoints)
212
213 void setSteps(QObject* process, QVector<double> points);
214 W_SLOT(setSteps)
215
216 QVariantList messages(QObject* state);
217 W_SLOT(messages)
218
219 void setMessages(QObject* state, QVariantList msgs);
220 W_SLOT(setMessages)
221
222 void replaceAddress(QObjectList objects, QString before, QString after);
223 W_SLOT(replaceAddress)
224
225 void automate(QObject* interval, QString addr);
226 W_SLOT(automate, (QObject*, QString))
227
228 void automate(QObject* interval, QObject* port);
229 W_SLOT(automate, (QObject*, QObject*))
230
231
234 void startMacro();
235 W_SLOT(startMacro)
236
237 void endMacro();
238 W_SLOT(endMacro)
239
240 void undo();
241 W_SLOT(undo)
242
243 void redo();
244 W_SLOT(redo)
245
246 void load(QString path);
247 W_SLOT(load)
248
249 void save();
250 W_SLOT(save)
251
252 void saveAs(QString path);
253 W_SLOT(saveAs)
254
255
258 QObject* find(QString p);
259 W_SLOT(find)
260
261 QObject* findByLabel(QString p);
262 W_SLOT(findByLabel)
263
264 QObject* document();
265 W_SLOT(document)
266
267 QObject* rootInterval();
268 W_SLOT(rootInterval)
269
270 QObject* documentPlugin(QString key);
271 W_SLOT(documentPlugin)
272
273
276 void play();
277 W_SLOT(play, ())
278
279 void play(QObject* obj);
280 W_SLOT(play, (QObject*))
281
282 void pause();
283 W_SLOT(pause, ())
284
285 void resume();
286 W_SLOT(resume, ())
287
288 void stop();
289 W_SLOT(stop)
290
291 void scrub(double z);
292 W_SLOT(scrub)
293
294
296 QString readFile(QString path);
297 W_SLOT(readFile)
298
299
302 QObject* selectedObject();
303 W_SLOT(selectedObject)
304
305 QVariantList selectedObjects();
306 W_SLOT(selectedObjects)
307
308 void zoom(double zx, double zy);
309 W_SLOT(zoom, (double, double));
310
311 void scroll(double zx, double zy);
312 W_SLOT(scroll, (double, double));
313
315 QVariant prompt(QVariant v);
316 W_SLOT(prompt)
317
318
321 QVariant availableProcesses() const noexcept;
322 W_SLOT(availableProcesses)
323 QVariant availableProcessesAndPresets() const noexcept;
324 W_SLOT(availableProcessesAndPresets)
325 QVariant availableProtocols() const noexcept;
326 W_SLOT(availableProtocols)
327
328 QByteArray serializeAsJson() noexcept;
329 W_SLOT(serializeAsJson)
330private:
331 void submit(Macro& m, score::Command* c);
332};
333}
334
335W_REGISTER_ARGTYPE(QVector<QVariantList>)
336W_REGISTER_ARGTYPE(QList<QObject*>)
337W_REGISTER_ARGTYPE(JS::GlobalDeviceEnumerator*)
Definition DeviceEnumerator.hpp:112
Definition EditContext.hpp:29
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:97
Definition DocumentContext.hpp:18