qskinny/src/controls/QskEvent.h

133 lines
3.0 KiB
C
Raw Normal View History

2017-07-21 18:21:34 +02: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 14:10:48 +02:00
#include <qcoreevent.h>
#include <qrect.h>
2017-07-21 18:21:34 +02:00
class QskGesture;
class QskPopup;
2017-07-21 18:21:34 +02:00
class QQuickWindow;
class QQuickItem;
2020-10-25 17:35:50 +01:00
class QMouseEvent;
2020-10-25 17:35:50 +01:00
class QWheelEvent;
class QHoverEvent;
2017-07-21 18:21:34 +02:00
class QSK_EXPORT QskEvent : public QEvent
{
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02: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 18:21:34 +02:00
Gesture,
Animator,
MaxEvent = NoEvent + 50
};
QskEvent( QskEvent::Type type );
};
class QSK_EXPORT QskGeometryChangeEvent : public QskEvent
{
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02: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;
2018-08-03 08:15:28 +02:00
private:
2017-07-21 18:21:34 +02:00
const QRectF m_rect;
const QRectF m_oldRect;
};
class QSK_EXPORT QskWindowChangeEvent : public QskEvent
{
2018-08-03 08:15:28 +02:00
public:
QskWindowChangeEvent( QQuickWindow* oldWindow, QQuickWindow* window );
2017-07-21 18:21:34 +02:00
inline QQuickWindow* window() const { return m_window; }
inline QQuickWindow* oldWindow() const { return m_oldWindow; }
2018-08-03 08:15:28 +02:00
private:
2017-07-21 18:21:34 +02:00
QQuickWindow* const m_oldWindow;
QQuickWindow* const m_window;
};
class QSK_EXPORT QskPopupEvent : public QskEvent
{
public:
QskPopupEvent( Type, QskPopup* );
inline QskPopup* popup() const { return m_popup; }
private:
QskPopup* const m_popup;
};
2017-07-21 18:21:34 +02:00
class QSK_EXPORT QskGestureEvent : public QskEvent
{
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02:00
QskGestureEvent( const QskGesture* gesture, bool ownedByEvent = true );
2018-07-31 17:32:25 +02:00
~QskGestureEvent() override;
2017-07-21 18:21:34 +02:00
inline const QskGesture* gesture() const { return m_gesture; }
2017-12-07 17:04:05 +01:00
inline bool isGestureOwnedByEvent() const { return m_gestureOwnedByEvent; }
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
private:
2017-07-21 18:21:34 +02:00
const QskGesture* m_gesture;
bool m_gestureOwnedByEvent;
};
class QSK_EXPORT QskAnimatorEvent : public QskEvent
{
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02:00
enum State
{
Started,
Terminated
};
QskAnimatorEvent( QskAspect::Aspect aspect, State state );
2018-07-31 17:32:25 +02:00
~QskAnimatorEvent() override;
2017-07-21 18:21:34 +02:00
inline QskAspect::Aspect aspect() const { return m_aspect; }
2017-12-07 17:04:05 +01:00
inline State state() const { return m_state; }
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
private:
2017-07-21 18:21:34 +02:00
const QskAspect::Aspect m_aspect;
const State m_state;
};
2020-07-27 18:03:02 +02:00
QSK_EXPORT int qskFocusChainIncrement( const QEvent* );
2018-02-06 14:57:34 +01:00
// some helper to work around Qt version incompatibilities
QSK_EXPORT QPointF qskMouseScenePosition( const QMouseEvent* );
QSK_EXPORT QPointF qskMousePosition( const QMouseEvent* );
2020-10-25 17:35:50 +01:00
QSK_EXPORT QPointF qskWheelPosition( const QWheelEvent* );
QSK_EXPORT QPointF qskHoverPosition( const QHoverEvent* );
2017-07-21 18:21:34 +02:00
#endif