Loading...
Searching...
No Matches
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
20class QGraphicsView;
21class QObject;
22class QWidget;
23class ProcessGraphicsView;
24class QFocusEvent;
25class QGraphicsScene;
26class QKeyEvent;
27class QPainterPath;
28class QResizeEvent;
29class QSize;
30class QWheelEvent;
31class SceneGraduations;
32
33namespace score
34{
35struct DocumentContext;
36struct GUIApplicationContext;
37}
38
39namespace Scenario
40{
41class Minimap;
42class ScenarioScene;
43class IntervalDurations;
44class IntervalView;
45class TimeRuler;
46class SCORE_PLUGIN_SCENARIO_EXPORT ProcessGraphicsView final : public QGraphicsView
47{
48 W_OBJECT(ProcessGraphicsView)
49public:
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
64public:
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
82private:
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
113class SCORE_PLUGIN_SCENARIO_EXPORT ScenarioDocumentView final
115{
116 W_OBJECT(ScenarioDocumentView)
117
118public:
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 void zoom(double zx, double zy);
145 void scroll(double dx, double dy);
146
147public:
148 void elementsScaleChanged(double arg_1) W_SIGNAL(elementsScaleChanged, arg_1);
149 void setLargeView() W_SIGNAL(setLargeView);
150 void timeRulerChanged() W_SIGNAL(timeRulerChanged);
151
152private:
153 void timerEvent(QTimerEvent* event) override;
154 QWidget* m_widget{};
155 const score::DocumentContext& m_context;
156 ScenarioScene m_scene;
157 ProcessGraphicsView m_view;
158 BaseGraphicsObject m_baseObject;
159
160 QGraphicsScene m_timeRulerScene;
161 TimeRulerGraphicsView m_timeRulerView;
162 TimeRulerBase* m_timeRuler{};
163 QGraphicsScene m_minimapScene;
164 MinimapGraphicsView m_minimapView;
165 Minimap m_minimap;
166
167 int m_timer{};
168};
169}
170
171Q_DECLARE_METATYPE(const QMimeData*)
172W_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:13
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