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