IntervalView.hpp
1 #pragma once
2 #include <Scenario/Document/Interval/ExecutionState.hpp>
3 #include <Scenario/Document/Interval/Temporal/Braces/LeftBrace.hpp>
4 #include <Scenario/Document/ScenarioDocument/ScenarioDocumentViewConstants.hpp>
5 
6 #include <score/graphics/TextItem.hpp>
7 #include <score/model/ColorInterpolator.hpp>
8 
9 #include <QGraphicsItem>
10 #include <qnamespace.h>
11 
12 #include <score_plugin_scenario_export.h>
13 
14 #include <verdigris>
15 class QGraphicsSceneMouseEvent;
16 
17 namespace Process
18 {
19 struct Style;
20 }
21 namespace score
22 {
23 class SimpleTextItem;
24 }
25 namespace Scenario
26 {
27 class IntervalPresenter;
28 class LeftBraceView;
29 class RightBraceView;
30 class IntervalMenuOverlay;
31 class SCORE_PLUGIN_SCENARIO_EXPORT IntervalView
32  : public QObject
33  , public QGraphicsItem
34 {
35  W_OBJECT(IntervalView)
36  Q_INTERFACES(QGraphicsItem)
37 
38 public:
39  IntervalView(IntervalPresenter& presenter, QGraphicsItem* parent);
40  virtual ~IntervalView();
41 
42  static const constexpr int Type = ItemType::Interval;
43  int type() const final override { return Type; }
44 
45  const IntervalPresenter& presenter() const { return m_presenter; }
46 
47  void setInfinite(bool);
48  bool infinite() const { return m_infinite; }
49 
50  void setExecuting(bool);
51  void setDefaultWidth(double width);
52  void setMaxWidth(bool infinite, double max);
53  void setMinWidth(double min);
54  void setRigid(bool r);
55  void setHeight(double height);
56  double setPlayWidth(double width);
57  void setValid(bool val);
58 
59  double height() const { return m_height; }
60 
61  bool isSelected() const { return m_selected; }
62 
63  double defaultWidth() const { return m_defaultWidth; }
64 
65  double minWidth() const { return m_minWidth; }
66 
67  double maxWidth() const { return m_maxWidth; }
68 
69  bool rigid() const { return m_rigid; }
70 
71  double intervalAndRackHeight() const { return m_height; }
72 
73  double playWidth() const { return m_playWidth; }
74 
75  bool isValid() const { return m_validInterval; }
76 
77  bool warning() const;
78  void setWarning(bool warning);
79 
80  void setExecutionState(IntervalExecutionState);
81  const score::Brush& intervalColor(const Process::Style& skin) const;
82  const QPixmap& intervalDashedPixmap(const Process::Style& skin) const;
83 
84  void updateLabelPos();
85  void updateCounterPos();
86  virtual void updatePaths() = 0;
87  virtual void updatePlayPaths() = 0;
88 
89  void mousePressEvent(QGraphicsSceneMouseEvent* event) final override;
90  void mouseMoveEvent(QGraphicsSceneMouseEvent* event) final override;
91  void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) final override;
92 
93  LeftBraceView& leftBrace() { return m_leftBrace; }
94  RightBraceView& rightBrace() { return m_rightBrace; }
95 
96  void setDropTarget(bool b)
97  {
98  m_dropTarget = b;
99  update();
100  }
101 
102 public:
103  void requestOverlayMenu(QPointF arg_1)
104  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, requestOverlayMenu, arg_1)
105  void dropReceived(const QPointF& pos, const QMimeData& arg_2)
106  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, dropReceived, pos, arg_2)
107 
108 protected:
109  friend class TemporalIntervalHeader;
110  friend class FullViewIntervalHeader;
111  void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
112  void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
113  void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
114  void dropEvent(QGraphicsSceneDragDropEvent* event) override;
115 
116  QPainterPath shape() const override;
117  QPainterPath opaqueArea() const override;
118  bool contains(const QPointF&) const override;
119 
120  void setGripCursor();
121  void setUngripCursor();
122 
123  LeftBraceView m_leftBrace;
124  RightBraceView m_rightBrace;
125  score::SimpleTextItem m_counterItem;
126 
127  IntervalPresenter& m_presenter;
128  QPainterPath solidPath, playedSolidPath;
129 
130  double m_defaultWidth{};
131  double m_maxWidth{};
132  double m_minWidth{};
133  double m_playWidth{};
134  double m_height{};
135  score::ColorBang m_execPing;
136 
137  bool m_selected : 1;
138  bool m_infinite : 1;
139  bool m_validInterval : 1; //{true};
140  bool m_warning : 1;
141  bool m_waiting : 1;
142  bool m_dropTarget : 1;
143  bool m_rigid : 1;
144  IntervalExecutionState m_state : 2;
145 };
146 }
Definition: FullViewIntervalHeader.hpp:16
Definition: IntervalPresenter.hpp:30
Definition: IntervalView.hpp:34
Definition: LeftBrace.hpp:12
Definition: LeftBrace.hpp:27
Definition: TemporalIntervalHeader.hpp:25
Definition: ColorInterpolator.hpp:9
Definition: TextItem.hpp:28
Base classes and tools to implement processes and layers.
Definition: JSONVisitor.hpp:1324
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Base toolkit upon which the software is built.
Definition: Application.cpp:90
Definition: ScenarioStyle.hpp:13
Definition: Skin.hpp:55