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
36 {
37 NoEvent = 53800,
38
39 GeometryChange,
40 WindowChange,
41
42 /*
43 Popups indicate their existence to the owning window
44 to allow for priority based stacking rules
45 */
46 PopupAdded,
47 PopupRemoved,
48
49 Gesture,
50 GestureFilter,
51
52 Animator,
53
54 MaxEvent = NoEvent + 50
55 };
56
57 QskEvent( QskEvent::Type type );
58
59#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
60 virtual QskEvent* clone() const;
61#endif
62
63 protected:
64 QSK_EVENT_DISABLE_COPY( QskEvent )
65};
66
67class QSK_EXPORT QskGeometryChangeEvent : public QskEvent
68{
69 public:
70 QskGeometryChangeEvent( const QRectF& rect, const QRectF& oldRect );
71
72 inline const QRectF& rect() const { return m_rect; }
73 inline const QRectF& oldRect() const { return m_oldRect; }
74
75 bool isResized() const;
76 bool isMoved() const;
77
78 QskGeometryChangeEvent* clone() const override;
79
80 protected:
81 QSK_EVENT_DISABLE_COPY( QskGeometryChangeEvent )
82
83 private:
84 QRectF m_rect;
85 QRectF m_oldRect;
86};
87
88class QSK_EXPORT QskWindowChangeEvent : public QskEvent
89{
90 public:
91 QskWindowChangeEvent( QQuickWindow* oldWindow, QQuickWindow* window );
92
93 inline QQuickWindow* window() const { return m_window; }
94 inline QQuickWindow* oldWindow() const { return m_oldWindow; }
95
96 QskWindowChangeEvent* clone() const override;
97
98 protected:
99 QSK_EVENT_DISABLE_COPY( QskWindowChangeEvent )
100
101 private:
102 QQuickWindow* m_oldWindow;
103 QQuickWindow* m_window;
104};
105
106class QSK_EXPORT QskPopupEvent : public QskEvent
107{
108 public:
109 QskPopupEvent( Type, QskPopup* );
110
111 inline QskPopup* popup() const { return m_popup; }
112
113 QskPopupEvent* clone() const override;
114
115 protected:
116 QSK_EVENT_DISABLE_COPY( QskPopupEvent )
117
118 private:
119 QskPopup* m_popup;
120};
121
122class QSK_EXPORT QskGestureFilterEvent : public QskEvent
123{
124 public:
125 QskGestureFilterEvent( const QQuickItem*, const QEvent* );
126
127 inline const QQuickItem* item() const { return m_item; }
128 inline const QEvent* event() const { return m_event; }
129
130 inline void setMaybeGesture( bool on ) { m_maybeGesture = on; }
131 inline bool maybeGesture() const { return m_maybeGesture; }
132
133 QskGestureFilterEvent* clone() const override;
134
135 protected:
136 QSK_EVENT_DISABLE_COPY( QskGestureFilterEvent )
137
138 private:
139 const QQuickItem* m_item;
140 const QEvent* m_event;
141
142 bool m_maybeGesture;
143};
144
145class QSK_EXPORT QskGestureEvent : public QskEvent
146{
147 public:
148 QskGestureEvent( std::shared_ptr< const QskGesture > );
149
150 inline std::shared_ptr< const QskGesture > gesture() const { return m_gesture; }
151
152 QskGestureEvent* clone() const override;
153
154 protected:
155 QSK_EVENT_DISABLE_COPY( QskGestureEvent )
156
157 private:
158 std::shared_ptr< const QskGesture > m_gesture;
159};
160
161class QSK_EXPORT QskAnimatorEvent : public QskEvent
162{
163 public:
164 enum State
165 {
166 Started,
167 Terminated
168 };
169
170 QskAnimatorEvent( QskAspect aspect, int index, State state );
171
172 inline QskAspect aspect() const { return m_aspect; }
173 inline int index() const { return m_index; }
174 inline State state() const { return m_state; }
175
176 QskAnimatorEvent* clone() const override;
177
178 protected:
179 QSK_EVENT_DISABLE_COPY( QskAnimatorEvent )
180
181 private:
182 QskAspect m_aspect;
183 int m_index;
184 State m_state;
185};
186
187QSK_EXPORT int qskFocusChainIncrement( const QEvent* );
188
189// some helper to work around Qt version incompatibilities
190QSK_EXPORT QPointF qskMouseScenePosition( const QMouseEvent* );
191QSK_EXPORT QPointF qskMousePosition( const QMouseEvent* );
192QSK_EXPORT QPointF qskHoverPosition( const QHoverEvent* );
193
194#ifndef QT_NO_WHEELEVENT
195
196QSK_EXPORT QPointF qskWheelPosition( const QWheelEvent* );
197QSK_EXPORT qreal qskWheelSteps( const QWheelEvent* );
198QSK_EXPORT qreal qskWheelIncrement( const QWheelEvent* );
199
200#endif
201
202QSK_EXPORT bool qskIsStandardKeyInput( const QKeyEvent*, QKeySequence::StandardKey );
203QSK_EXPORT bool qskIsButtonPressKey( const QKeyEvent* );
204
205QSK_EXPORT bool qskIsTouchOrMouseEvent( QEvent::Type );
206
207#endif
Lookup key for a QskSkinHintTable.
Definition QskAspect.h:15