qskinny/src/controls/QskEvent.h

179 lines
4.0 KiB
C
Raw Normal View History

2017-07-21 16:21:34 +00:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef QSK_EVENT_H
#define QSK_EVENT_H
#include "QskAspect.h"
2018-07-19 12:10:48 +00:00
#include <qcoreevent.h>
#include <qrect.h>
#include <qkeysequence.h>
2020-12-09 13:56:10 +00:00
#include <memory>
2017-07-21 16:21:34 +00:00
class QskGesture;
class QskPopup;
2017-07-21 16:21:34 +00:00
class QQuickWindow;
class QQuickItem;
2020-10-25 16:35:50 +00:00
class QMouseEvent;
2020-10-25 16:35:50 +00:00
class QWheelEvent;
class QHoverEvent;
class QKeyEvent;
2017-07-21 16:21:34 +00:00
#define QSK_EVENT_DISABLE_COPY(Class) \
Class(const Class &) = default; \
Class(Class &&) = delete; \
Class &operator=(const Class &other) = default; \
Class &operator=(Class &&) = delete;
2022-03-25 17:04:41 +00:00
2017-07-21 16:21:34 +00:00
class QSK_EXPORT QskEvent : public QEvent
{
2018-08-03 06:15:28 +00:00
public:
2017-07-21 16:21:34 +00:00
enum Type
{
NoEvent = 53800,
GeometryChange,
WindowChange,
/*
Popups indicate their existence to the owning window
to allow for priority based stacking rules
*/
PopupAdded,
PopupRemoved,
2017-07-21 16:21:34 +00:00
Gesture,
Animator,
MaxEvent = NoEvent + 50
};
QskEvent( QskEvent::Type type );
2020-12-09 13:56:10 +00:00
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
2021-08-04 07:31:16 +00:00
virtual QskEvent* clone() const;
2020-12-09 13:56:10 +00:00
#endif
protected:
2022-03-25 17:04:41 +00:00
QSK_EVENT_DISABLE_COPY( QskEvent )
2017-07-21 16:21:34 +00:00
};
class QSK_EXPORT QskGeometryChangeEvent : public QskEvent
{
2018-08-03 06:15:28 +00:00
public:
2017-07-21 16:21:34 +00:00
QskGeometryChangeEvent( const QRectF& rect, const QRectF& oldRect );
inline const QRectF& rect() const { return m_rect; }
inline const QRectF& oldRect() const { return m_oldRect; }
bool isResized() const;
bool isMoved() const;
2020-12-09 13:56:10 +00:00
QskGeometryChangeEvent* clone() const override;
protected:
2022-03-25 17:04:41 +00:00
QSK_EVENT_DISABLE_COPY( QskGeometryChangeEvent )
private:
QRectF m_rect;
QRectF m_oldRect;
2017-07-21 16:21:34 +00:00
};
class QSK_EXPORT QskWindowChangeEvent : public QskEvent
{
2018-08-03 06:15:28 +00:00
public:
QskWindowChangeEvent( QQuickWindow* oldWindow, QQuickWindow* window );
2017-07-21 16:21:34 +00:00
inline QQuickWindow* window() const { return m_window; }
inline QQuickWindow* oldWindow() const { return m_oldWindow; }
2020-12-09 13:56:10 +00:00
QskWindowChangeEvent* clone() const override;
protected:
2022-03-25 17:04:41 +00:00
QSK_EVENT_DISABLE_COPY( QskWindowChangeEvent )
private:
QQuickWindow* m_oldWindow;
QQuickWindow* m_window;
2017-07-21 16:21:34 +00:00
};
class QSK_EXPORT QskPopupEvent : public QskEvent
{
public:
QskPopupEvent( Type, QskPopup* );
inline QskPopup* popup() const { return m_popup; }
2020-12-09 13:56:10 +00:00
QskPopupEvent* clone() const override;
protected:
2022-03-25 17:04:41 +00:00
QSK_EVENT_DISABLE_COPY( QskPopupEvent )
private:
QskPopup* m_popup;
};
2017-07-21 16:21:34 +00:00
class QSK_EXPORT QskGestureEvent : public QskEvent
{
2018-08-03 06:15:28 +00:00
public:
2020-12-09 14:58:27 +00:00
QskGestureEvent( std::shared_ptr< const QskGesture > );
2017-07-21 16:21:34 +00:00
2020-12-09 14:58:27 +00:00
inline std::shared_ptr< const QskGesture > gesture() const { return m_gesture; }
QskGestureEvent* clone() const override;
2017-07-21 16:21:34 +00:00
protected:
2022-03-25 17:04:41 +00:00
QSK_EVENT_DISABLE_COPY( QskGestureEvent )
private:
2020-12-09 14:58:27 +00:00
std::shared_ptr< const QskGesture > m_gesture;
2017-07-21 16:21:34 +00:00
};
class QSK_EXPORT QskAnimatorEvent : public QskEvent
{
2018-08-03 06:15:28 +00:00
public:
2017-07-21 16:21:34 +00:00
enum State
{
Started,
Terminated
};
2020-12-21 15:06:58 +00:00
QskAnimatorEvent( QskAspect aspect, State state );
2017-07-21 16:21:34 +00:00
2020-12-21 15:06:58 +00:00
inline QskAspect aspect() const { return m_aspect; }
2017-12-07 16:04:05 +00:00
inline State state() const { return m_state; }
2017-07-21 16:21:34 +00:00
2020-12-09 13:56:10 +00:00
QskAnimatorEvent* clone() const override;
protected:
2022-03-25 17:04:41 +00:00
QSK_EVENT_DISABLE_COPY( QskAnimatorEvent )
private:
QskAspect m_aspect;
State m_state;
2017-07-21 16:21:34 +00:00
};
2020-07-27 16:03:02 +00:00
QSK_EXPORT int qskFocusChainIncrement( const QEvent* );
2018-02-06 13:57:34 +00:00
// some helper to work around Qt version incompatibilities
QSK_EXPORT QPointF qskMouseScenePosition( const QMouseEvent* );
QSK_EXPORT QPointF qskMousePosition( const QMouseEvent* );
2020-10-25 16:35:50 +00:00
QSK_EXPORT QPointF qskHoverPosition( const QHoverEvent* );
2022-01-05 10:59:32 +00:00
#ifndef QT_NO_WHEELEVENT
QSK_EXPORT QPointF qskWheelPosition( const QWheelEvent* );
2022-01-10 13:59:22 +00:00
QSK_EXPORT qreal qskWheelSteps( const QWheelEvent* );
QSK_EXPORT qreal qskWheelIncrement( const QWheelEvent* );
2022-01-05 10:59:32 +00:00
#endif
2022-03-11 13:24:10 +00:00
QSK_EXPORT bool qskIsStandardKeyInput( const QKeyEvent*, QKeySequence::StandardKey );
2017-07-21 16:21:34 +00:00
#endif