tilde~
Puredata Qt-based GUI
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
UIScriptBox.h
Go to the documentation of this file.
1 // (c) 2017 Alex Nadzharov
2 // License: GPL3
3 
4 #ifndef cmo_scriptbox_H
5 #define cmo_scriptbox_H
6 
7 #include <QPlainTextEdit>
8 
9 #include "Port.h"
10 #include "UIObject.h"
11 
12 #include <QFileDialog>
13 
14 #include "UIScriptCommon.h"
15 #include "UIScriptEditor.h"
16 
17 #include "UIBox.h"
18 
19 class QGraphicsView;
20 
21 namespace tilde {
22 
25 class UIScriptBox : public UIBox {
26  Q_OBJECT
27 
28 private:
29  bool _clicked;
31 
32  //temporary
33  UIScriptCommon* _scriptCommon;
34 
35 public:
36  explicit UIScriptBox();
37 
38  static UIObject* createObj(QString data);
39  //static UIObject* createObject(QString, t_canvas*, QGraphicsView*);
40  /*
41 
42  {
43  qDebug() << "ui.scriptbox";
44 
45  UIScriptBox* b = new UIScriptBox();
46  //b->setCanvas((void*)parent);
47 
48  b->_editor->textEdit()->setContext(pyWrapper::inst().withCanvas((QObject*)parent));
49 
50  QString data1 = b->properties()->extractFromPdFileString(objectData);
51  if (data1 != "") {
52  QStringList l = data1.split(" ");
53  if (l.size() > 1) {
54  l.removeAt(0);
55  b->properties()->get("ScriptFile")->set(l.at(0));
56  }
57  }
58 
59  b->setObjectData("ui.scriptbox");
60 
61  // the zoo lol
62  //QString data = b->properties()->get("Script")->asQString().split("\\n ").join("\n");
63  QString data = "";
64 
65  b->_editor->textEdit()->document()->setPlainText(data);
66 
67  // pd object
68  std::string message = "ui.script";
69 
70  //temp
71  t_object* new_obj = 0;
72  if (!pdCanvas) {
73  qDebug("bad pd canvas instance");
74  } else {
75  QPoint pos = QPoint(0, 0);
76  new_obj = cmp_create_object(pdCanvas, message, pos.x(), pos.y());
77  }
78 
79  if (new_obj) {
80  qDebug("created ui.script %s | ptr %lu\n", message.c_str(), (long)new_obj);
81  //b->setPdObject(new_obj);
82 
83  b->_editor->textEdit()->setContext(pyWrapper::inst().withCanvasPdObjectAndInput((UIObject*)parent, new_obj, &b->_scriptCommon->scriptData()->inputList));
84 
85  b->addInlet();
86  b->addOutlet();
87 
88  } else {
89  qDebug("Error: no such object %s", message.c_str());
90  }
91 
92  b->resizeEvent();
93 
94  return (UIObject*)b;
95  };
96 */
97  void initProperties();
98 
99  virtual void paint(QPainter* p, const QStyleOptionGraphicsItem* option, QWidget*);
100 
101  // ------------------------
102 
103  virtual void objectPressEvent(QGraphicsSceneMouseEvent* event);
104 
105  // ----------------------
106 
107  void setPdMessage(QString message);
108 
109  virtual void sync();
110 
111  virtual void updateUI(t_cpd_list* list);
112 
113 private slots:
114  void editorChanged();
115 };
116 }
117 #endif // cmo_text_H
void initProperties()
Definition: UIScriptBox.cpp:129
virtual void updateUI(t_cpd_list *list)
Definition: UIScriptBox.cpp:190
static UIObject * createObj(QString data)
Definition: UIScriptBox.cpp:64
virtual void objectPressEvent(QGraphicsSceneMouseEvent *event)
mouse down
Definition: UIScriptBox.cpp:164
Sort of view controller for UIScript/UISCriptBox.
Definition: UIScriptCommon.h:37
virtual void paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *)
UIObject properties
Definition: UIScriptBox.cpp:136
void setPdMessage(QString message)
Definition: UIScriptBox.cpp:173
Script editor QWidget.
Definition: UIScriptEditor.h:18
Definition: UIObject.h:44
UIScriptBox()
Definition: UIScriptBox.cpp:22
gui object: script box (ui.scriptbox)
Definition: UIScriptBox.h:25
virtual void sync()
Definition: UIScriptBox.cpp:180
Definition: g_canvas.h:89
gui object: standard object box
Definition: UIBox.h:46