IntervalHeader.hpp
1 #pragma once
2 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentViewConstants.hpp>
3 
4 #include <QGraphicsItem>
5 
6 class QGraphicsSceneMouseEvent;
7 
8 namespace Scenario
9 {
10 class IntervalView;
12  : public QObject
13  , public QGraphicsItem
14 {
15 public:
16  enum class State
17  {
18  Hidden, // No rack, we show nothing
19  RackHidden, // There is at least a hidden rack in the interval
20  RackShown // There is a rack currently shown
21  };
22 
23  using QGraphicsItem::QGraphicsItem;
24 
25  static const constexpr int Type = ItemType::IntervalHeader;
26  int type() const final override { return Type; }
27 
28  void setIntervalView(IntervalView* view) { m_view = view; }
29  IntervalView* intervalView() const noexcept { return m_view; }
30  static constexpr double headerHeight() { return IntervalHeaderHeight; }
31 
32  void setWidth(double width);
33  virtual void setState(State s) = 0;
34  State state() const noexcept { return m_state; }
35 
36  virtual void on_textChanged() { }
37 
38 protected:
39  void mousePressEvent(QGraphicsSceneMouseEvent* event) final override;
40  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) final override;
41  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) final override;
42 
43 protected:
44  IntervalView* m_view{};
45  State m_state{};
46  double m_width{};
47 };
48 }
Definition: IntervalHeader.hpp:14
Definition: IntervalView.hpp:34
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Utilities for OSSIA data structures.
Definition: DeviceInterface.hpp:33