ScenarioDocumentView.hpp
1 #pragma once
2 #include <Scenario/Document/Minimap/Minimap.hpp>
3 #include <Scenario/Document/ScenarioDocument/ScenarioScene.hpp>
4 #include <Scenario/Document/TimeRuler/TimeRuler.hpp>
5 #include <Scenario/Document/TimeRuler/TimeRulerGraphicsView.hpp>
6 
7 #include <score/graphics/ArrowDialog.hpp>
8 #include <score/graphics/GraphicsProxyObject.hpp>
9 #include <score/plugins/documentdelegate/DocumentDelegateView.hpp>
10 
11 #include <QGraphicsView>
12 #include <QMimeData>
13 #include <QPoint>
14 #include <QPointer>
15 
16 #include <score_plugin_scenario_export.h>
17 
18 #include <verdigris>
19 
20 class QGraphicsView;
21 class QObject;
22 class QWidget;
23 class ProcessGraphicsView;
24 class QFocusEvent;
25 class QGraphicsScene;
26 class QKeyEvent;
27 class QPainterPath;
28 class QResizeEvent;
29 class QSize;
30 class QWheelEvent;
31 class SceneGraduations;
32 
33 namespace score
34 {
35 struct DocumentContext;
36 struct GUIApplicationContext;
37 }
38 
39 namespace Scenario
40 {
41 class Minimap;
42 class ScenarioScene;
43 class IntervalDurations;
44 class IntervalView;
45 class TimeRuler;
46 class SCORE_PLUGIN_SCENARIO_EXPORT ProcessGraphicsView final : public QGraphicsView
47 {
48  W_OBJECT(ProcessGraphicsView)
49 public:
51  const score::GUIApplicationContext& ctx, QGraphicsScene* scene, QWidget* parent);
52  ~ProcessGraphicsView() override;
53 
54  void scrollHorizontal(double dx);
55  QRectF visibleRect() const noexcept;
56 
57  QPointer<score::ArrowDialog> currentPopup{};
58 
59  IntervalDurations* currentTimebar{};
60  IntervalView* currentView{};
61  bool timebarPlaying{};
62  bool timebarVisible{};
63 
64 public:
65  void drawForeground(QPainter* painter, const QRectF& rect) override;
66  void sizeChanged(const QSize& arg_1)
67  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, sizeChanged, arg_1)
68  void scrolled(int arg_1) E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, scrolled, arg_1)
69  void focusedOut() E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, focusedOut)
70  void horizontalZoom(QPointF pixDelta, QPointF pos)
71  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, horizontalZoom, pixDelta, pos)
72  void verticalZoom(QPointF pixDelta, QPointF pos)
73  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, verticalZoom, pixDelta, pos)
74 
75  void visibleRectChanged(QRectF r)
76  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, visibleRectChanged, r)
77  void dropRequested(QPoint pos, const QMimeData* mime)
78  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, dropRequested, pos, mime)
79  void emptyContextMenuRequested(QPoint pos)
80  E_SIGNAL(SCORE_PLUGIN_SCENARIO_EXPORT, emptyContextMenuRequested, pos)
81 
82 private:
83  void resizeEvent(QResizeEvent* ev) override;
84  void scrollContentsBy(int dx, int dy) override;
85  void wheelEvent(QWheelEvent* event) override;
86  void keyPressEvent(QKeyEvent* event) override;
87  void keyReleaseEvent(QKeyEvent* event) override;
88  void focusOutEvent(QFocusEvent* event) override;
89  void leaveEvent(QEvent* event) override;
90  void mousePressEvent(QMouseEvent* event) override;
91  void mouseMoveEvent(QMouseEvent* event) override;
92  void mouseReleaseEvent(QMouseEvent* event) override;
93  void dragEnterEvent(QDragEnterEvent* event) override;
94  void dragMoveEvent(QDragMoveEvent* event) override;
95  void dragLeaveEvent(QDragLeaveEvent* event) override;
96  void dropEvent(QDropEvent* event) override;
97  void contextMenuEvent(QContextMenuEvent* event) override;
98  bool event(QEvent*) override;
99 
100  void hoverEnterEvent(QHoverEvent* event);
101  void hoverMoveEvent(QHoverEvent* event);
102  void hoverLeaveEvent(QHoverEvent* event);
103 
104  void checkAndRemoveCurrentDialog(QPoint pos);
105  // void drawBackground(QPainter* painter, const QRectF& rect) override;
106 
107  const score::GUIApplicationContext& m_app;
108 
109  std::chrono::steady_clock::time_point m_lastwheel;
110  bool m_opengl{false};
111 };
112 
113 class SCORE_PLUGIN_SCENARIO_EXPORT ScenarioDocumentView final
115 {
116  W_OBJECT(ScenarioDocumentView)
117 
118 public:
119  ScenarioDocumentView(const score::DocumentContext& ctx, QObject* parent);
120  ~ScenarioDocumentView() override;
121 
122  QWidget* getWidget() override;
123 
124  BaseGraphicsObject& baseItem() { return m_baseObject; }
125 
126  ScenarioScene& scene() { return m_scene; }
127 
128  ProcessGraphicsView& view() { return m_view; }
129 
130  qreal viewWidth() const;
131 
132  QGraphicsView& rulerView() { return m_timeRulerView; }
133 
134  TimeRulerBase& timeRuler() { return *m_timeRuler; }
135 
136  Minimap& minimap() { return m_minimap; }
137 
138  QRectF viewportRect() const;
139  QRectF visibleSceneRect() const;
140 
141  void showRulers(bool);
142  void ready() override;
143 
144 public:
145  void elementsScaleChanged(double arg_1) W_SIGNAL(elementsScaleChanged, arg_1);
146  void setLargeView() W_SIGNAL(setLargeView);
147  void timeRulerChanged() W_SIGNAL(timeRulerChanged);
148 
149 private:
150  void timerEvent(QTimerEvent* event) override;
151  QWidget* m_widget{};
152  const score::DocumentContext& m_context;
153  ScenarioScene m_scene;
154  ProcessGraphicsView m_view;
155  BaseGraphicsObject m_baseObject;
156 
157  QGraphicsScene m_timeRulerScene;
158  TimeRulerGraphicsView m_timeRulerView;
159  TimeRulerBase* m_timeRuler{};
160  QGraphicsScene m_minimapScene;
161  MinimapGraphicsView m_minimapView;
162  Minimap m_minimap;
163 
164  int m_timer{};
165 };
166 }
167 
168 Q_DECLARE_METATYPE(const QMimeData*)
169 W_REGISTER_ARGTYPE(const QMimeData*)
Definition: GraphicsProxyObject.hpp:8
Definition: IntervalDurations.hpp:23
Definition: IntervalView.hpp:34
Definition: TimeRulerGraphicsView.hpp:11
Definition: Minimap.hpp:16
Definition: ScenarioDocumentView.hpp:47
Definition: ScenarioDocumentView.hpp:115
Definition: ScenarioScene.hpp:9
Definition: TimeRuler.hpp:36
Definition: TimeRulerGraphicsView.hpp:6
Definition: DocumentDelegateView.hpp:10
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: DocumentContext.hpp:18
Specializes ApplicationContext with the QMainWindow.
Definition: GUIApplicationContext.hpp:15