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