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