SlotHeader.hpp
1 #pragma once
2 #include <Scenario/Document/Interval/Slot.hpp>
3 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentViewConstants.hpp>
4 
5 #include <QGraphicsItem>
6 
7 #include <verdigris>
8 
9 namespace Scenario
10 {
11 class IntervalPresenter;
12 class SlotHeader final : public QGraphicsItem
13 {
14 public:
15  SlotHeader(const IntervalPresenter& slotView, int slotIndex, QGraphicsItem* parent);
16 
17  const IntervalPresenter& presenter() const { return m_presenter; }
18  static const constexpr int Type = ItemType::SlotHeader;
19  int type() const final override { return Type; }
20 
21  int slotIndex() const;
22  void setSlotIndex(int);
23  static constexpr double headerHeight() { return 16.; }
24  static constexpr double handleWidth() { return 16.; }
25  static constexpr double menuWidth() { return 16.; }
26 
27  QRectF boundingRect() const override;
28  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
29  override;
30 
31  void setWidth(qreal width);
32  void setMini(bool b);
33 
34 private:
35  void mousePressEvent(QGraphicsSceneMouseEvent* event) final override;
36  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) final override;
37  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) final override;
38 
39  void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
40  void hoverMoveEvent(QGraphicsSceneHoverEvent* event) override;
41  void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
42 
43  const IntervalPresenter& m_presenter;
44  qreal m_width{};
45  // double m_menupos{};
46  int m_slotIndex{};
47  QByteArray dragMimeData(bool temporal);
48 };
49 
50 class SlotFooter : public QGraphicsItem
51 {
52 public:
53  SlotFooter(const IntervalPresenter& slotView, int slotIndex, QGraphicsItem* parent);
54 
55  const IntervalPresenter& presenter() const { return m_presenter; }
56  static const constexpr int Type = ItemType::SlotFooter;
57  int type() const final override { return Type; }
58 
59  int slotIndex() const;
60  void setSlotIndex(int);
61  static constexpr double footerHeight() { return 13.; }
62 
63  QRectF boundingRect() const override;
64  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
65  override;
66 
67  void setWidth(qreal width);
68 
69  const IntervalPresenter& m_presenter;
70  qreal m_width{};
71  int m_slotIndex{};
72 };
73 
74 class AmovibleSlotFooter final : public SlotFooter
75 {
76 public:
78  const IntervalPresenter& slotView, int slotIndex, QGraphicsItem* parent);
79 
80 private:
81  void mousePressEvent(QGraphicsSceneMouseEvent* event) final override;
82  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) final override;
83  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) final override;
84 
85  bool m_fullView{};
86 };
87 
88 class FixedSlotFooter final : public SlotFooter
89 {
90 public:
91  using SlotFooter::SlotFooter;
92 
93 private:
94  void mousePressEvent(QGraphicsSceneMouseEvent* event) final override;
95  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) final override;
96  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) final override;
97 };
98 
99 class SlotDragOverlay final
100  : public QObject
101  , public QGraphicsItem
102 {
103  W_OBJECT(SlotDragOverlay)
104 public:
105  SlotDragOverlay(const IntervalPresenter& c, Slot::RackView v);
106 
107  const IntervalPresenter& interval;
108  Slot::RackView view;
109  QRectF boundingRect() const override;
110 
111  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
112  override;
113 
114  void dropBefore(int slot) W_SIGNAL(dropBefore, slot);
115  void dropIn(int slot) W_SIGNAL(dropIn, slot);
116 
117  void onDrag(QPointF pos);
118 
119 private:
120  void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
121  void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
122  void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
123 
124  void dropEvent(QGraphicsSceneDragDropEvent* event) override;
125 
126 private:
127  QRectF m_drawnRect;
128 };
129 }
Definition: IntervalPresenter.hpp:30
Definition: SlotHeader.hpp:102
Definition: SlotHeader.hpp:13
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14