QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskEvent.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_EVENT_H
7#define QSK_EVENT_H
8
9#include "QskAspect.h"
10
11#include <qcoreevent.h>
12#include <qrect.h>
13#include <qkeysequence.h>
14#include <memory>
15
16class QskGesture;
17class QskPopup;
18class QQuickWindow;
19class QQuickItem;
20
21class QMouseEvent;
22class QWheelEvent;
23class QHoverEvent;
24class QKeyEvent;
25
26#define QSK_EVENT_DISABLE_COPY( Class ) \
27 Class( const Class& ) = default; \
28 Class( Class && ) = delete; \
29 Class& operator=( const Class & ) = default; \
30 Class& operator=( Class && ) = delete;
31
32class QSK_EXPORT QskEvent : public QEvent
33{
34 public:
35 enum Type : int
36 {
37 NoEvent = 53800,
38
39 GeometryChange,
40 ViewportChange,
41 WindowChange,
42
43 /*
44 Popups indicate their existence to the owning window
45 to allow for priority based stacking rules
46 */
47 PopupAdded,
48 PopupRemoved,
49
50 Gesture,
51 GestureFilter,
52
53 Animator,
54
55 MaxEvent = NoEvent + 50
56 };
57
58 QskEvent( QskEvent::Type type );
59
60#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
61 virtual QskEvent* clone() const;
62#endif
63
64 protected:
65 QSK_EVENT_DISABLE_COPY( QskEvent )
66};
67
68class QSK_EXPORT QskGeometryChangeEvent : public QskEvent
69{
70 public:
71 QskGeometryChangeEvent( const QRectF& rect, const QRectF& oldRect );
72
73 inline const QRectF& rect() const { return m_rect; }
74 inline const QRectF& oldRect() const { return m_oldRect; }
75
76 bool isResized() const;
77 bool isMoved() const;
78
79 QskGeometryChangeEvent* clone() const override;
80
81 protected:
82 QSK_EVENT_DISABLE_COPY( QskGeometryChangeEvent )
83
84 private:
85 QRectF m_rect;
86 QRectF m_oldRect;
87};
88
89class QSK_EXPORT QskViewportChangeEvent : public QskEvent
90{
91 public:
92 QskViewportChangeEvent( QQuickItem* );
93
94 inline QQuickItem* modifiedParent() const { return m_modifiedParent; }
95
96 QskViewportChangeEvent* clone() const override;
97
98 protected:
99 QSK_EVENT_DISABLE_COPY( QskViewportChangeEvent )
100
101 private:
102 QQuickItem* m_modifiedParent;
103};
104
105class QSK_EXPORT QskWindowChangeEvent : public QskEvent
106{
107 public:
108 QskWindowChangeEvent( QQuickWindow* oldWindow, QQuickWindow* window );
109
110 inline QQuickWindow* window() const { return m_window; }
111 inline QQuickWindow* oldWindow() const { return m_oldWindow; }
112
113 QskWindowChangeEvent* clone() const override;
114
115 protected:
116 QSK_EVENT_DISABLE_COPY( QskWindowChangeEvent )
117
118 private:
119 QQuickWindow* m_oldWindow;
120 QQuickWindow* m_window;
121};
122
123class QSK_EXPORT QskPopupEvent : public QskEvent
124{
125 public:
126 QskPopupEvent( Type, QskPopup* );
127
128 inline QskPopup* popup() const { return m_popup; }
129
130 QskPopupEvent* clone() const override;
131
132 protected:
133 QSK_EVENT_DISABLE_COPY( QskPopupEvent )
134
135 private:
136 QskPopup* m_popup;
137};
138
139class QSK_EXPORT QskGestureFilterEvent : public QskEvent
140{
141 public:
142 QskGestureFilterEvent( const QQuickItem*, const QEvent* );
143
144 inline const QQuickItem* item() const { return m_item; }
145 inline const QEvent* event() const { return m_event; }
146
147 inline void setMaybeGesture( bool on ) { m_maybeGesture = on; }
148 inline bool maybeGesture() const { return m_maybeGesture; }
149
150 QskGestureFilterEvent* clone() const override;
151
152 protected:
153 QSK_EVENT_DISABLE_COPY( QskGestureFilterEvent )
154
155 private:
156 const QQuickItem* m_item;
157 const QEvent* m_event;
158
159 bool m_maybeGesture;
160};
161
162class QSK_EXPORT QskGestureEvent : public QskEvent
163{
164 public:
165 QskGestureEvent( std::shared_ptr< const QskGesture > );
166
167 inline std::shared_ptr< const QskGesture > gesture() const { return m_gesture; }
168
169 QskGestureEvent* clone() const override;
170
171 protected:
172 QSK_EVENT_DISABLE_COPY( QskGestureEvent )
173
174 private:
175 std::shared_ptr< const QskGesture > m_gesture;
176};
177
178class QSK_EXPORT QskAnimatorEvent : public QskEvent
179{
180 public:
181 enum State : quint8
182 {
183 Started,
184 Terminated
185 };
186
187 QskAnimatorEvent( QskAspect aspect, int index, State state );
188
189 inline QskAspect aspect() const { return m_aspect; }
190 inline int index() const { return m_index; }
191 inline State state() const { return m_state; }
192
193 QskAnimatorEvent* clone() const override;
194
195 protected:
196 QSK_EVENT_DISABLE_COPY( QskAnimatorEvent )
197
198 private:
199 QskAspect m_aspect;
200 int m_index;
201 State m_state;
202};
203
204QSK_EXPORT int qskFocusChainIncrement( const QEvent* );
205
206// some helper to work around Qt version incompatibilities
207QSK_EXPORT QPointF qskMouseScenePosition( const QMouseEvent* );
208QSK_EXPORT QPointF qskMousePosition( const QMouseEvent* );
209QSK_EXPORT QPointF qskHoverPosition( const QHoverEvent* );
210
211#ifndef QT_NO_WHEELEVENT
212
213QSK_EXPORT QPointF qskWheelPosition( const QWheelEvent* );
214QSK_EXPORT qreal qskWheelSteps( const QWheelEvent* );
215QSK_EXPORT qreal qskWheelIncrement( const QWheelEvent* );
216
217#endif
218
219QSK_EXPORT bool qskIsStandardKeyInput( const QKeyEvent*, QKeySequence::StandardKey );
220QSK_EXPORT bool qskIsButtonPressKey( const QKeyEvent* );
221
222QSK_EXPORT bool qskIsTouchOrMouseEvent( QEvent::Type );
223
224#endif
Lookup key for a QskSkinHintTable.
Definition QskAspect.h:15