Loading...
Searching...
No Matches
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>
11namespace score
12{
13struct DocumentContext;
14class SimpleTextItem;
15class QGraphicsPixmapToggle;
16}
17namespace Dataflow
18{
19class PortItem;
20}
21namespace Process
22{
23class ProcessModel;
24class LayerPresenter;
25struct LayerContext;
26struct Context;
27}
28
29namespace Process
30{
31class TitleItem;
32class SCORE_LIB_PROCESS_EXPORT NodeItem
33 : public QObject
34 , public QGraphicsItem
35{
36public:
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
51private:
52 void createWithDecorations();
53 void createContentItem();
54 void updateTooltip();
55
56 void createWithoutDecorations();
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