TimeSyncView.hpp
1 #pragma once
2 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentViewConstants.hpp>
3 #include <Scenario/Document/VerticalExtent.hpp>
4 
5 #include <score/graphics/TextItem.hpp>
6 
7 #include <QGraphicsItem>
8 
9 #include <score_plugin_scenario_export.h>
10 class QGraphicsSceneMouseEvent;
11 class QPainter;
12 class QStyleOptionGraphicsItem;
13 class QWidget;
14 
15 namespace Scenario
16 {
17 class TimeSyncPresenter;
18 
19 class SCORE_PLUGIN_SCENARIO_EXPORT TimeSyncView final : public QGraphicsItem
20 {
21 public:
22  TimeSyncView(TimeSyncPresenter& presenter, QGraphicsItem* parent);
23  ~TimeSyncView();
24 
25  static const constexpr int Type = ItemType::TimeSync;
26  int type() const final override { return Type; }
27 
28  const TimeSyncPresenter& presenter() const { return m_presenter; }
29 
30  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
31  override;
32 
33  // QGraphicsItem interface
34  QRectF boundingRect() const override
35  {
36  return {-3., 0., 6., m_extent.bottom() - m_extent.top()};
37  }
38 
39  void setExtent(const VerticalExtent& extent);
40  void setExtent(VerticalExtent&& extent);
41  void setTriggerActive(bool);
42  void addPoint(int newY);
43 
44  void setMoving(bool);
45  void setSelected(bool selected);
46 
47  bool isSelected() const { return m_selected; }
48 
49  void changeColor(const score::Brush&);
50  void setLabel(const QString& label);
51 
52 protected:
53  void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
54  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
55  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
56 
57 private:
58  const QPixmap& pixmap(const score::Brush& b);
59  TimeSyncPresenter& m_presenter;
60  VerticalExtent m_extent;
61 
62  QPointF m_clickedPoint{};
63  const score::Brush* m_color{};
64  bool m_selected{};
65 
66  score::SimpleTextItem m_text;
67 };
68 }
Definition: TimeSyncPresenter.hpp:29
Definition: TimeSyncView.hpp:20
Definition: TextItem.hpp:28
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
The VerticalExtent struct.
Definition: VerticalExtent.hpp:20
Definition: Skin.hpp:55