EditContext.hpp
1 #pragma once
2 #include <score/document/DocumentContext.hpp>
3 
4 #include <QList>
5 #include <QObject>
6 #include <QVariant>
7 
8 #include <memory>
9 #include <optional>
10 #include <verdigris>
11 namespace score
12 {
13 struct DocumentContext;
14 class Command;
15 }
16 namespace Scenario::Command
17 {
18 class Macro;
19 }
20 namespace JS
21 {
23 class EditJsContext : public QObject
24 {
25  W_OBJECT(EditJsContext)
27 
28  std::unique_ptr<Macro> m_macro;
29  struct MacroClear
30  {
32  std::unique_ptr<Macro>& macro;
33  bool clearOnDelete{};
34  ~MacroClear();
35  };
36 
37  MacroClear macro(const score::DocumentContext& doc);
38 
39 public:
40  EditJsContext();
41  ~EditJsContext();
42 
43  const score::DocumentContext* ctx();
44  W_INVOKABLE(ctx);
45 
46  QString deviceToJson(QString addr);
47  W_SLOT(deviceToJson)
48 
49  void createOSCDevice(QString name, QString host, int in, int out);
50  W_SLOT(createOSCDevice)
51 
52  void createQMLWebSocketDevice(QString name, QString text);
53  W_SLOT(createQMLWebSocketDevice)
54 
55  void createQMLSerialDevice(QString name, QString port, QString text);
56  W_SLOT(createQMLSerialDevice)
57 
58  GlobalDeviceEnumerator* enumerateDevices();
59  W_SLOT(enumerateDevices)
60 
61  void createAddress(QString addr, QString type);
62  W_SLOT(createAddress)
63 
64  QObject* createProcess(QObject* interval, QString name, QString data);
65  W_SLOT(createProcess)
66 
67  void setName(QObject* sel, QString new_name);
68  W_SLOT(setName)
69 
70  QObject* createBox(QObject* obj, QString startTime, QString duration, double y);
71  W_SLOT(createBox, (QObject*, QString, QString, double))
72 
73  QObject*
74  createBox(QObject* obj, double startTimeFlicks, double durationFlicks, double y);
75  W_SLOT(createBox, (QObject*, double, double, double))
76 
77  QObject* createState(QObject* ev, double y);
78  W_SLOT(createState)
79 
80  QObject* createIntervalAfter(QObject* obj, QString duration, double y);
81  W_SLOT(createIntervalAfter)
82 
83  QObject* createIntervalBetween(QObject* startState, QObject* endState);
84  W_SLOT(createIntervalBetween)
85 
86  QObject* port(QObject* obj, QString name);
87  W_SLOT(port)
88 
89  QObject* inlet(QObject* obj, int index);
90  W_SLOT(inlet)
91 
92  int inlets(QObject* obj);
93  W_SLOT(inlets)
94 
95  QObject* outlet(QObject* obj, int index);
96  W_SLOT(outlet)
97 
98  int outlets(QObject* obj);
99  W_SLOT(outlets)
100 
101  void setAddress(QObject* obj, QString addr);
102  W_SLOT(setAddress)
103 
104  void setValue(QObject* obj, double value);
105  W_SLOT(setValue, (QObject*, double))
106 
107  void setValue(QObject* obj, QString value);
108  W_SLOT(setValue, (QObject*, QString))
109 
110  void setValue(QObject* obj, bool value);
111  W_SLOT(setValue, (QObject*, bool))
112 
113  void setValue(QObject* obj, QList<QString> value);
114  W_SLOT(setValue, (QObject*, QList<QString>))
115 
116  QString valueType(QObject* obj);
117  W_SLOT(valueType)
118 
119  double min(QObject* obj);
120  W_SLOT(min)
121 
122  double max(QObject* obj);
123  W_SLOT(max)
124 
125  QVector<QString> enumValues(QObject* obj);
126  W_SLOT(enumValues)
127 
128  QObject* metadata(QObject* obj) const noexcept;
129  W_SLOT(metadata)
130 
131  QObject* startState(QObject* obj);
132  W_SLOT(startState)
133 
134  QObject* startEvent(QObject* obj);
135  W_SLOT(startEvent)
136 
137  QObject* startSync(QObject* obj);
138  W_SLOT(startSync)
139 
140  QObject* endState(QObject* obj);
141  W_SLOT(endState)
142 
143  QObject* endEvent(QObject* obj);
144  W_SLOT(endEvent)
145 
146  QObject* endSync(QObject* obj);
147  W_SLOT(endSync)
148 
149  void remove(QObject* obj);
150  W_SLOT(remove)
151 
152  void setCurvePoints(QObject* process, QVector<QVariantList> points);
153  W_SLOT(setCurvePoints)
154 
155  void setSteps(QObject* process, QVector<double> points);
156  W_SLOT(setSteps)
157 
158  QVariantList messages(QObject* state);
159  W_SLOT(messages)
160 
161  void setMessages(QObject* state, QVariantList msgs);
162  W_SLOT(setMessages)
163 
164  void replaceAddress(QObjectList objects, QString before, QString after);
165  W_SLOT(replaceAddress)
166 
167  void automate(QObject* interval, QString addr);
168  W_SLOT(automate, (QObject*, QString))
169 
170  void automate(QObject* interval, QObject* port);
171  W_SLOT(automate, (QObject*, QObject*))
172 
173  void startMacro();
174  W_SLOT(startMacro)
175 
176  void endMacro();
177  W_SLOT(endMacro)
178 
179  void undo();
180  W_SLOT(undo)
181 
182  void redo();
183  W_SLOT(redo)
184 
185  QObject* find(QString p);
186  W_SLOT(find)
187 
188  QObject* findByLabel(QString p);
189  W_SLOT(findByLabel)
190 
191  QObject* document();
192  W_SLOT(document)
193 
194 
195  void play();
196  W_SLOT(play, ())
197 
198  void play(QObject* obj);
199  W_SLOT(play, (QObject*))
200 
201  void stop();
202  W_SLOT(stop)
203 
204  // File API
205  QString readFile(QString path);
206  W_SLOT(readFile)
207 
208  QObject* selectedObject();
209  W_SLOT(selectedObject)
210 
211  QVariantList selectedObjects();
212  W_SLOT(selectedObjects)
213 
214 
215  QVariant prompt(QVariant v);
216  W_SLOT(prompt)
217 
218 private:
219  void submit(Macro& m, score::Command* c);
220 };
221 }
222 
223 W_REGISTER_ARGTYPE(QVector<QVariantList>)
224 W_REGISTER_ARGTYPE(QList<QObject*>)
225 W_REGISTER_ARGTYPE(JS::GlobalDeviceEnumerator*)
Definition: DeviceEnumerator.hpp:44
Definition: EditContext.hpp:24
void play()
Execution ///.
Definition: EditContext.ossia.cpp:35
QVariant prompt(QVariant v)
UI ///.
Definition: EditContext.ui.cpp:15
Definition: CommandAPI.hpp:28
The Command class.
Definition: Command.hpp:34
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: DocumentContext.hpp:18