NodeItem.hpp
1 #pragma once
2 #include <Process/TimeValue.hpp>
3 #include <Process/ZoomHelper.hpp>
4 
5 #include <score/model/Identifier.hpp>
6 
7 #include <QGraphicsItem>
8 #include <QObject>
9 
10 #include <score_lib_process_export.h>
11 namespace score
12 {
13 struct DocumentContext;
14 class SimpleTextItem;
15 class QGraphicsPixmapToggle;
16 }
17 namespace Dataflow
18 {
19 class PortItem;
20 }
21 namespace Process
22 {
23 class ProcessModel;
24 class LayerPresenter;
25 struct LayerContext;
26 struct Context;
27 }
28 
29 namespace Process
30 {
31 class TitleItem;
32 class SCORE_LIB_PROCESS_EXPORT NodeItem
33  : public QObject
34  , public QGraphicsItem
35 {
36 public:
37  NodeItem(
38  const Process::ProcessModel& model, const Process::Context& ctx, TimeVal parentDur,
39  QGraphicsItem* parent);
40  const Id<Process::ProcessModel>& id() const noexcept;
41  ~NodeItem();
42 
43  void setParentDuration(TimeVal r);
44  void setPlayPercentage(float f, TimeVal parent_dur);
45 
46  qreal width() const noexcept;
47  qreal height() const;
48 
49  const Process::ProcessModel& model() const noexcept;
50 
51 private:
52  void createWithDecorations();
53  void createContentItem();
54 
55  void createWithoutDecorations();
56  void createCustomContentItem();
57 
58  void updateZoomRatio() const noexcept;
59  void updateSize();
60  void setSize(QSizeF sz);
61 
62  bool isInSelectionCorner(QPointF f, QRectF r) const;
63  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
64  override;
65 
66  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
67  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
68  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
69  void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
70 
71  void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
72  void hoverMoveEvent(QGraphicsSceneHoverEvent* event) override;
73  void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
74 
75  void keyPressEvent(QKeyEvent* event) override;
76  void keyReleaseEvent(QKeyEvent* event) override;
77 
78  void resetInlets();
79  void resetOutlets();
80 
81  QSizeF size() const noexcept;
82 
83  void setSelected(bool s);
84 
85  void updateTitlePos();
86  QRectF boundingRect() const final override;
87 
88  double minimalContentWidth() const noexcept;
89  double minimalContentHeight() const noexcept;
90  static void paintNode(QPainter* painter, bool selected, bool hovered, QRectF rect);
91 
92  // Title
93  QGraphicsItem* m_uiButton{};
94  QGraphicsItem* m_presetButton{};
95  score::SimpleTextItem* m_label{};
96 
97  QSizeF m_contentSize{};
98 
99  const Process::ProcessModel& m_model;
100 
101  // Body
102  QGraphicsItem* m_fx{};
104  Process::LayerPresenter* m_presenter{};
105 
106  std::vector<Dataflow::PortItem*> m_inlets, m_outlets;
107  const Process::Context& m_context;
108 
109  TimeVal m_parentDuration{1};
110  double m_playPercentage{};
111 
112  bool m_hover{false};
113  bool m_selected{false};
114 };
115 }
Definition: LayerPresenter.hpp:34
Definition: NodeItem.hpp:35
The Process class.
Definition: score-lib-process/Process/Process.hpp:61
The id_base_t class.
Definition: Identifier.hpp:57
Definition: QGraphicsPixmapToggle.hpp:18
Definition: TextItem.hpp:28
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: ProcessContext.hpp:12
Definition: TimeValue.hpp:21