LayerView.hpp
1 #pragma once
2 #include <score/widgets/MimeData.hpp>
3 
4 #include <QGraphicsItem>
5 #include <QGraphicsSceneDragDropEvent>
6 #include <QRect>
7 
8 #include <score_lib_process_export.h>
9 
10 #include <verdigris>
11 
12 class QPainter;
13 class QStyleOptionGraphicsItem;
14 class QWidget;
15 class QMimeData;
16 namespace Process
17 {
18 class SCORE_LIB_PROCESS_EXPORT LayerView
19  : public QObject
20  , public QGraphicsItem
21 {
22  W_OBJECT(LayerView)
23  Q_INTERFACES(QGraphicsItem)
24 public:
25  LayerView(QGraphicsItem* parent);
26 
27  virtual ~LayerView() override;
28 
29  QRectF boundingRect() const final override;
30  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
31  final override;
32 
33  void setHeight(qreal height) noexcept;
34  qreal height() const noexcept { return m_height; }
35 
36  void setWidth(qreal width) noexcept;
37  qreal width() const noexcept { return m_width; }
38 
39  virtual QPixmap pixmap() noexcept;
40 
41  void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
42  void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
43  void dropEvent(QGraphicsSceneDragDropEvent* event) override;
44 
45  void clearPressed() E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, clearPressed)
46 
47  void escPressed() E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, escPressed)
48 
49  void pressed(QPointF arg_1) E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, pressed, arg_1)
50  void released(QPointF arg_1) E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, released, arg_1)
51  void moved(QPointF arg_1) E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, moved, arg_1)
52  void doubleClicked(QPointF arg_1)
53  E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, doubleClicked, arg_1)
54 
55  // Screen pos, scene pos
56  void askContextMenu(const QPoint& arg_1, const QPointF& arg_2)
57  E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, askContextMenu, arg_1, arg_2)
58  void dropReceived(const QPointF& pos, const QMimeData& arg_2)
59  E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, dropReceived, pos, arg_2)
60  void presetDropReceived(const QPointF& pos, const QMimeData& arg_2)
61  E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, presetDropReceived, pos, arg_2)
62 
63  void keyPressed(int arg_1) E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, keyPressed, arg_1)
64  void keyReleased(int arg_1) E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, keyReleased, arg_1)
65 
66  // Screen pos, scene pos
67  void dragEnter(const QPointF& pos, const QMimeData& arg_2)
68  E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, dragEnter, pos, arg_2)
69  void dragMove(const QPointF& pos, const QMimeData& arg_2)
70  E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, dragMove, pos, arg_2)
71  void dragLeave(const QPointF& pos, const QMimeData& arg_2)
72  E_SIGNAL(SCORE_LIB_PROCESS_EXPORT, dragLeave, pos, arg_2)
73 
74 protected:
75  virtual void paint_impl(QPainter*) const = 0;
76  virtual void heightChanged(qreal);
77  virtual void widthChanged(qreal);
78 
79  void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
80  void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
81 
82  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
83  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
84  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
85 
86  void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
87 
88 private:
89  qreal m_height{};
90  qreal m_width{};
91  bool m_dropPresetOverlay{false};
92 };
93 
94 class SCORE_LIB_PROCESS_EXPORT MiniLayer : public QGraphicsItem
95 {
96  Q_INTERFACES(QGraphicsItem)
97 public:
98  MiniLayer(QGraphicsItem* parent);
99 
100  ~MiniLayer() override;
101 
102  QRectF boundingRect() const final override;
103  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
104  final override;
105 
106  void setHeight(qreal height);
107  qreal height() const;
108 
109  void setWidth(qreal width);
110  qreal width() const;
111 
112  void setZoomRatio(qreal);
113  qreal zoom() const;
114 
115 protected:
116  virtual void paint_impl(QPainter*) const = 0;
117 
118 private:
119  qreal m_height{};
120  qreal m_width{};
121  qreal m_zoom{};
122 };
123 }
Definition: LayerView.hpp:21
Definition: LayerView.hpp:95
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324