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 void setAddress(QObject* obj, QString addr);
136 W_SLOT(setAddress)
137
138 void setValue(QObject* obj, double value);
139 W_SLOT(setValue, (QObject*, double))
140
141 void setValue(QObject* obj, QVector2D value);
142 W_SLOT(setValue, (QObject*, QVector2D))
143
144 void setValue(QObject* obj, QVector3D value);
145 W_SLOT(setValue, (QObject*, QVector3D))
146
147 void setValue(QObject* obj, QVector4D value);
148 W_SLOT(setValue, (QObject*, QVector4D))
149
150 void setValue(QObject* obj, QString value);
151 W_SLOT(setValue, (QObject*, QString))
152
153 void setValue(QObject* obj, bool value);
154 W_SLOT(setValue, (QObject*, bool))
155
156 void setValue(QObject* obj, QList<QString> value);
157 W_SLOT(setValue, (QObject*, QList<QString>))
158
159 QString valueType(QObject* obj);
160 W_SLOT(valueType)
161
162 double min(QObject* obj);
163 W_SLOT(min)
164
165 double max(QObject* obj);
166 W_SLOT(max)
167
168 QVector<QString> enumValues(QObject* obj);
169 W_SLOT(enumValues)
170
171 QObject* metadata(QObject* obj) const noexcept;
172 W_SLOT(metadata)
173
174 QObject* startState(QObject* obj);
175 W_SLOT(startState)
176
177 QObject* startEvent(QObject* obj);
178 W_SLOT(startEvent)
179
180 QObject* startSync(QObject* obj);
181 W_SLOT(startSync)
182
183 QObject* endState(QObject* obj);
184 W_SLOT(endState)
185
186 QObject* endEvent(QObject* obj);
187 W_SLOT(endEvent)
188
189 QObject* endSync(QObject* obj);
190 W_SLOT(endSync)
191
192 void remove(QObject* obj);
193 W_SLOT(remove)
194
195 void setCurvePoints(QObject* process, QVector<QVariantList> points);
196 W_SLOT(setCurvePoints)
197
198 void setSteps(QObject* process, QVector<double> points);
199 W_SLOT(setSteps)
200
201 QVariantList messages(QObject* state);
202 W_SLOT(messages)
203
204 void setMessages(QObject* state, QVariantList msgs);
205 W_SLOT(setMessages)
206
207 void replaceAddress(QObjectList objects, QString before, QString after);
208 W_SLOT(replaceAddress)
209
210 void automate(QObject* interval, QString addr);
211 W_SLOT(automate, (QObject*, QString))
212
213 void automate(QObject* interval, QObject* port);
214 W_SLOT(automate, (QObject*, QObject*))
215
216
219 void startMacro();
220 W_SLOT(startMacro)
221
222 void endMacro();
223 W_SLOT(endMacro)
224
225 void undo();
226 W_SLOT(undo)
227
228 void redo();
229 W_SLOT(redo)
230
231
234 QObject* find(QString p);
235 W_SLOT(find)
236
237 QObject* findByLabel(QString p);
238 W_SLOT(findByLabel)
239
240 QObject* document();
241 W_SLOT(document)
242
243 QObject* rootInterval();
244 W_SLOT(rootInterval)
245
246
249 void play();
250 W_SLOT(play, ())
251
252 void play(QObject* obj);
253 W_SLOT(play, (QObject*))
254
255 void pause();
256 W_SLOT(pause, ())
257
258 void resume();
259 W_SLOT(resume, ())
260
261 void stop();
262 W_SLOT(stop)
263
264 void scrub(double z);
265 W_SLOT(scrub)
266
267
269 QString readFile(QString path);
270 W_SLOT(readFile)
271
272
275 QObject* selectedObject();
276 W_SLOT(selectedObject)
277
278 QVariantList selectedObjects();
279 W_SLOT(selectedObjects)
280
281 void zoom(double zx, double zy);
282 W_SLOT(zoom, (double, double));
283
284 void scroll(double zx, double zy);
285 W_SLOT(scroll, (double, double));
286
288 QVariant prompt(QVariant v);
289 W_SLOT(prompt)
290
291
294 QVariant availableProcesses() const noexcept;
295 W_SLOT(availableProcesses)
296 QVariant availableProtocols() const noexcept;
297 W_SLOT(availableProtocols)
298
299 QByteArray serializeAsJson() noexcept;
300 W_SLOT(serializeAsJson)
301private:
302 void submit(Macro& m, score::Command* c);
303};
304}
305
306W_REGISTER_ARGTYPE(QVector<QVariantList>)
307W_REGISTER_ARGTYPE(QList<QObject*>)
308W_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