tilde~
Puredata Qt-based GUI
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
UIObject.h
Go to the documentation of this file.
1 // (c) 2017 Alex Nadzharov
2 // License: GPL3
3 
4 #ifndef CM_OBJECTITEM_H
5 #define CM_OBJECTITEM_H
6 
7 #include "UIItem.h"
8 
9 #include "../../xpd-transition/xpd-headers.h"
10 #include "objectObserver.h"
11 
12 //namespace ceammc {
13 //class AtomList;
14 //}
15 
16 //using namespace ceammc;
17 
18 using namespace xpd;
19 
20 //namespace xpd {
21 //typedef void t_cpd_list;
22 //}
23 
24 class QAction;
25 class QMenu;
26 
27 //class ServerObject;
28 
29 namespace tilde {
30 
31 class CanvasView;
32 class CanvasData;
33 //class ObjectObserver;
34 class PropertyList;
35 class Port;
36 class SizeBox;
37 
38 typedef std::vector<Port*> portItemVec;
39 
40 class UIObject;
41 class PatchWindowController;
42 class UIObjectData;
43 
44 class UIObject : public UIItem {
45 
46  Q_OBJECT
47 
48 private:
49  portItemVec* _inlets;
50  portItemVec* _outlets;
51 
52  UIObjectData* _objectData;
53 
54  SizeBox* _sizeBox;
55 
56  QMenu* _popupMenu; //TODO pointer
57 
58  QAction* _pmProperties;
59  QAction* _pmHelp;
60  QAction* _pmOpen; //TODO move to UIBox
61 
62  CanvasView* _parentCanvasView;
63  PatchWindowController* _parentController;
64 
65  ObjectId _serverObjectId;
66 
67  ObjectObserverPtr _observer;
68 
69 protected:
70  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent*);
71  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
72 
73 public:
74  explicit UIObject(UIItem* parent = 0);
75 
76  // ----------------------
77 
78  CanvasView* parentCanvasView();
79  virtual void setParentCanvasView(CanvasView* v);
80 
81  PatchWindowController* parentController();
82  void setParentController(PatchWindowController* p);
83 
84  void setObjectData(UIObjectData* m);
85  UIObjectData* objectData();
86 
87  virtual ObjectId serverObjectId();
88  virtual void setServerObjectId(ObjectId o);
89 
90  ObjectObserverPtr observer();
91 
92  virtual void initProperties();
93  PropertyList* properties();
94 
95  // ----------------------
96 
97  virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*){};
98 
99  // ----------------------
100 
101  virtual void fromQString(QString objData);
102  QString toQString();
103 
104  QString objectClass();
105 
106  // ----------------------
107 
108  //UIObjectData _objectDataModel;
109 
110  void createPopupMenu();
111  void showPopupMenu(QPoint pos);
112 
113  void doSetSize(QSize size);
114  virtual void resizeEvent();
115  virtual void autoResize();
116 
117  virtual std::string asPdFileString();
118 
119  void setEditModeRef(t_editMode* canvasEditMode);
120 
121  SizeBox* sizeBox();
122  void hideSizeBox();
123 
124  virtual void sync();
125 
126  bool errorBox();
127  void setErrorBox(bool val);
128 
129  void setHelpName(QString name);
130 
131  QString fullHelpName();
132 
133  // -----------------------------------------------------------------
134 
135  virtual void setInletsPos();
136  virtual void setOutletsPos();
137 
138  virtual void addInlet();
139  virtual void addInlet(int _portClass_);
140 
141  virtual void addOutlet();
142  virtual void addOutlet(int _portClass_);
143 
144  Port* inletAt(int idx);
145  Port* outletAt(int idx);
146 
147  int inletCount();
148  int outletCount();
149 
150  int pdInletClass(int idx);
151  int pdOutletClass(int idx);
152 
153  void removeXLets();
154 
155  // -----------------------------------------
156 
157  virtual void objectPressEvent(QGraphicsSceneMouseEvent*);
158  virtual void objectMoveEvent(QGraphicsSceneMouseEvent*);
159  virtual void objectReleaseEvent(QGraphicsSceneMouseEvent*);
160 
161  virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
162  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
163  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
164 
165  // -----------------------------------------
166 
167  virtual void updateUI(t_cpd_list*){};
168 
169  // XPD
170  PdObject* serverObjectPtr();
171 
172 private slots:
173  void openPropertiesWindow();
174  void openHelpWindow();
175 
176  void propertySize();
177  virtual void propertyFontSize();
178 
179  void propertyPosition();
180  void propertyReceiveSymbol();
181 
182  void propertyUpdate();
183 
184 signals:
185  void signalEditObject(void* box);
186 
189  void signalCallRepaint();
190 
191  void signalSendMessage(ObjectId obj, QString msg);
192 
193  void signalOpenPropertiesWindow();
194  void signalOpenHelpWindow();
195 
196  void signalObjectHoverEnter();
197  void signalObjectHoverLeave();
198 
199 public slots:
200  void slotResizeDeselectedBox(int dx, int dy);
201  void slotRepaint();
202 
207  // void propertyChanged(QString pname);
208 };
209 }
210 
211 #endif // CM_OBJECT_H
std::shared_ptr< ObjectObserver > ObjectObserverPtr
Definition: objectObserver.h:31
SizeBox QGraphicsObject class.
Definition: SizeBox.h:14
virtual void updateUI(t_cpd_list *)
Definition: UIObject.h:167
std::vector< Port * > portItemVec
Definition: UIObjectData.h:13
UIItem QGraphicsObject class.
Definition: UIItem.h:15
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)
UIObject properties
Definition: UIObject.h:97
The Patch window controller.
Definition: PatchWindowController.h:48
Property handling class for ui object - property list.
Definition: PropertyList.h:34
t_editMode
edit mode types
Definition: CommonTypes.h:13
Port QGraphicsItem class.
Definition: Port.h:18
Data model for UIObject.
Definition: UIObjectData.h:20
Definition: UIObject.h:44
Canvas View - used by Patch window controller.
Definition: CanvasView.h:36