Vuo  2.0.3
VuoPublishedPortSidebar.hh
Go to the documentation of this file.
1 
10 #pragma once
11 
12 class VuoCable;
14 class VuoPort;
15 class VuoPublishedPort;
16 class VuoRendererCable;
17 class VuoRendererPort;
19 
20 namespace Ui
21 {
23 }
24 
28 class VuoPublishedPortSidebar : public QDockWidget
29 {
30  Q_OBJECT
31 public:
32  explicit VuoPublishedPortSidebar(QWidget *parent, VuoEditorComposition *composition, bool isInput, bool enableProtocolChanges=true);
33  void updateActiveProtocol();
34  void concludePublishedCableDrag(QMouseEvent *event, VuoCable *cableInProgress, bool cableInProgressWasNew);
35  QMenu * getProtocolsContextMenu();
36  QAction * getRemoveProtocolAction();
37  VuoRendererPublishedPort * getPublishedPortUnderCursorForEvent(QMouseEvent *event, qreal tolerance=0, bool limitPortCollisionRange=false);
40  static QColor getActiveProtocolPortColor(int protocolIndex, bool isInput);
42  void limitAllowedPortTypes(const set<string> &allowedPortTypes);
43 
44 signals:
45  void newPublishedPortRequested(string typeName, bool isInput);
46  void publishedPortNameEditorRequested(VuoRendererPublishedPort *port, bool useUndoStack);
50  void portPublicationRequestedViaDropBox(VuoPort *port, bool forceEventOnlyPublication, bool useUndoStackMacro);
51  void portPublicationRequestedViaSidebarPort(VuoPort *internalPort, VuoPublishedPort *externalPort, bool forceEventOnlyPublication, VuoPort *portToSpecialize, string specializedTypeName, string typecastToInsert, bool useUndoStackMacro);
52  void componentsRemoved(QList<QGraphicsItem *> removedComponents, string commandDescription="Remove");
54  void publishedPortsReordered(vector<VuoPublishedPort *> publishedPorts, bool isInput);
55  void undoStackMacroBeginRequested(QString commandName);
57  void closed();
58 
59 public slots:
60  void updatePortList();
61  void highlightEligibleDropLocations(VuoRendererPort *internalFixedPort, bool eventOnlyConnection);
63  void externalMoveEvent();
64  void updateHoverHighlighting(QMouseEvent *event, qreal tolerance=0);
66 
67 private slots:
68  void populatePortTypeMenus();
69  void newPublishedPortTypeSelected();
70  void updateColor(bool isDark);
71 
72 protected:
73  void contextMenuEvent(QContextMenuEvent *event);
74  void mouseMoveEvent(QMouseEvent *event);
75  void mousePressEvent(QMouseEvent *event);
76  void dragEnterEvent(QDragEnterEvent *event);
77  void dropEvent(QDropEvent *event);
78  void closeEvent(QCloseEvent *event);
79 
80 private:
81  Ui::VuoPublishedPortSidebar *ui;
82  VuoEditorComposition *composition;
83 
84  QMenu *contextMenuPortOptions;
85  QMenu *menuChangeProtocol;
86  QMenu *menuAddPort;
87 
88  QMenu *contextMenuRemoveProtocol;
89  QAction *contextMenuActionRemoveProtocol;
90 
91  bool isInput;
92  bool portTypeMenusPopulated;
93  set<string> allowedPortTypes;
94 
95  bool canListPublishedPortAliasFor(VuoRendererPort *port);
96  bool isPublishedPortDropBoxUnderCursorForEvent(QMouseEvent *event);
97  bool isActiveProtocolLabelUnderCursorForEvent(QContextMenuEvent *event);
98  void appendPublishedPortToList(VuoPublishedPort *port, bool select);
99  static QColor getActiveProtocolHeadingColor(int protocolIndex, bool isInput);
100  void showPublishedPortDetailsEditor(VuoRendererPublishedPort *port);
101 
102 #ifdef VUO_PRO
103 #include "pro/VuoPublishedPortSidebar_Pro.hh"
104 #endif
105 };
106