Merge branch 'gesture-events'
Integrate GSoC 2017 work by Prashant Kumar implementing support for gesture events. Closes https://github.com/wxWidgets/wxWidgets/pull/551 Closes https://github.com/wxWidgets/wxWidgets/pull/565
This commit is contained in:
@@ -3644,6 +3644,251 @@ public:
|
||||
void SetPosition(int pos);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** @class wxGestureEvent
|
||||
This is the base class for all supported gesture events.
|
||||
|
||||
@note Gesture events are not generated by default, you must call
|
||||
wxWindow::EnableTouchEvents() with the appropriate parameter to
|
||||
request their generation.
|
||||
|
||||
@library{wxcore}
|
||||
@category{events}
|
||||
|
||||
@see wxPanGestureEvent, wxZoomGestureEvent, wxRotateGestureEvent
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
class wxGestureEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
*/
|
||||
wxGestureEvent(wxWindowID winid = 0, wxEventType type = wxEVT_NULL);
|
||||
|
||||
/**
|
||||
Returns the position where the event took effect, in client coordinates: position of Pan event,
|
||||
center of zoom for Zoom event, center of rotation for Rotate event, center of box formed by 2 fingers
|
||||
for Two Finger Tap event and position of the pressed finger for Press and Tap Event.
|
||||
*/
|
||||
const wxPoint& GetPosition() const;
|
||||
|
||||
/**
|
||||
Returns true if the event was the first in a gesture sequence.
|
||||
*/
|
||||
bool IsGestureStart() const;
|
||||
|
||||
/**
|
||||
Returns true if the event was the last in a gesture sequence.
|
||||
*/
|
||||
bool IsGestureEnd() const;
|
||||
|
||||
/**
|
||||
Sets the position where the event took effect, in client coordinates: position of Pan event,
|
||||
center of zoom for Zoom event, center of rotation for Rotate event.
|
||||
*/
|
||||
void SetPosition(const wxPoint& pos);
|
||||
|
||||
/**
|
||||
Sets the event to be the first in a gesture sequence.
|
||||
*/
|
||||
void SetGestureStart(bool isStart = true);
|
||||
|
||||
/**
|
||||
Sets the event to be the last in a gesture sequence.
|
||||
*/
|
||||
void SetGestureEnd(bool isEnd = true);
|
||||
};
|
||||
|
||||
|
||||
/** @class wxPanGestureEvent
|
||||
|
||||
This event is generated when the user moves a finger on the surface.
|
||||
|
||||
wxGTK also generates this event during mouse dragging (mouse motion while a left mouse button is depressed).
|
||||
|
||||
Note that OSX requires the primary mouse button to be pressed while performing the finger movement.
|
||||
|
||||
@beginEventTable{wxPanGestureEvent}
|
||||
@event{EVT_GESTURE_PAN(id, func)}
|
||||
Process a @c wxEVT_GESTURE_PAN.
|
||||
@endEventTable
|
||||
|
||||
@library{wxcore}
|
||||
@category{events}
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
class wxPanGestureEvent : class wxGestureEvent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
*/
|
||||
wxPanGestureEvent(wxWindowID winid = 0);
|
||||
|
||||
/**
|
||||
Returns the distance covered since the previous panning event.
|
||||
*/
|
||||
wxPoint GetDelta() const;
|
||||
|
||||
/**
|
||||
Sets the distance covered since the previous panning event.
|
||||
*/
|
||||
void SetDelta(const wxPoint& delta);
|
||||
};
|
||||
|
||||
|
||||
/** @class wxZoomGestureEvent
|
||||
|
||||
This event is generated when two fingers pinch the surface to zoom in or out.
|
||||
|
||||
@beginEventTable{wxZoomGestureEvent}
|
||||
@event{EVT_GESTURE_ZOOM(id, func)}
|
||||
Process a @c wxEVT_GESTURE_ZOOM.
|
||||
@endEventTable
|
||||
|
||||
@library{wxcore}
|
||||
@category{events}
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
class wxZoomGestureEvent : public wxGestureEvent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
*/
|
||||
wxZoomGestureEvent(wxWindowID windid = 0);
|
||||
|
||||
/**
|
||||
Returns the zoom Factor since the gesture started. Hence, starting of the gesture
|
||||
is considered as 1:1. A value greater than 1.0 means we should enlarge
|
||||
(or zoom in), a value less than 1.0 means we should shrink (or zoom out).
|
||||
*/
|
||||
double GetZoomFactor() const;
|
||||
|
||||
/**
|
||||
Sets the zoom Factor.
|
||||
*/
|
||||
double SetZoomFactor() const;
|
||||
};
|
||||
|
||||
|
||||
/** @class wxRotateGestureEvent
|
||||
|
||||
This event is generated when two fingers move in opposite directions on the surface.
|
||||
|
||||
@beginEventTable{wxRotateGestureEvent}
|
||||
@event{EVT_GESTURE_ROTATE(id, func)}
|
||||
Process a @c wxEVT_GESTURE_ROTATE.
|
||||
@endEventTable
|
||||
|
||||
@library{wxcore}
|
||||
@category{events}
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
class wxRotateGestureEvent : public wxGestureEvent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
*/
|
||||
wxRotateGestureEvent(wxWindowID windid = 0);
|
||||
|
||||
/**
|
||||
Returns the total angle of rotation in radians in clockwise direction since the
|
||||
gesture was first started i.e. when IsGestureStart() returned true. This value is always
|
||||
greater than or equal to zero.
|
||||
*/
|
||||
double GetRotationAngle() const;
|
||||
|
||||
/**
|
||||
Sets the total angle of rotation in radians in clockwise direction since the
|
||||
gesture was first started i.e. when IsGestureStart() returned true. This value is always
|
||||
greater than or equal to zero.
|
||||
*/
|
||||
void SetRotationAngle(double rotationAngle);
|
||||
};
|
||||
|
||||
/** @class wxTwoFingerTapEvent
|
||||
|
||||
This event is generated when two fingers touch the surface at the same time.
|
||||
|
||||
@beginEventTable{wxTwoFingerTapEvent}
|
||||
@event{EVT_TWO_FINGER_TAP(id, func)}
|
||||
Process a @c wxEVT_TWO_FINGER_TAP.
|
||||
@endEventTable
|
||||
|
||||
@library{wxcore}
|
||||
@category{events}
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
class wxTwoFingerTapEvent : public wxGestureEvent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
*/
|
||||
wxTwoFingerTapEvent(wxWindowID windid = 0);
|
||||
};
|
||||
|
||||
/** @class wxLongPressEvent
|
||||
|
||||
This event is generated when one finger touches the surface and remains stationary.
|
||||
|
||||
Note that currently it is only generated under wxGTK and wxOSX.
|
||||
|
||||
wxGTK also generates this event when left mouse button is being pressed for some minimum duration of time.
|
||||
|
||||
@beginEventTable{wxLongPressEvent}
|
||||
@event{EVT_LONG_PRESS(id, func)}
|
||||
Process a @c wxEVT_LONG_PRESS.
|
||||
@endEventTable
|
||||
|
||||
@library{wxcore}
|
||||
@category{events}
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
class wxLongPressEvent : public wxGestureEvent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
*/
|
||||
wxLongPressEvent(wxWindowID windid = 0);
|
||||
};
|
||||
|
||||
/** @class wxPressAndTapEvent
|
||||
|
||||
This event is generated when the user press the surface with one finger and taps with another.
|
||||
|
||||
Note that once started the event will also be generated when the finger that was pressed moves on surface.
|
||||
|
||||
@beginEventTable{wxPressAndTapEvent}
|
||||
@event{EVT_PRESS_AND_TAP(id, func)}
|
||||
Process a @c wxEVT_PRESS_AND_TAP.
|
||||
@endEventTable
|
||||
|
||||
@library{wxcore}
|
||||
@category{events}
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
class wxPressAndTapEvent : public wxGestureEvent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Constructor.
|
||||
*/
|
||||
wxPressAndTapEvent(wxWindowID windid = 0);
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
#if wxUSE_BASE
|
||||
|
@@ -52,6 +52,68 @@ enum wxShowEffect
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Values for wxWindow::EnableTouchEvents() mask.
|
||||
|
||||
The values other than ::wxTOUCH_NONE and ::wxTOUCH_ALL_GESTURES can be
|
||||
combined together to request enabling events for the specified gestures and
|
||||
for them only.
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
enum
|
||||
{
|
||||
/**
|
||||
Don't generate any touch events.
|
||||
*/
|
||||
wxTOUCH_NONE,
|
||||
|
||||
/**
|
||||
Generate wxPanGestureEvent for vertical pans.
|
||||
|
||||
Note that under macOS horizontal pan events are also enabled when this
|
||||
flag is specified.
|
||||
*/
|
||||
wxTOUCH_VERTICAL_PAN_GESTURE,
|
||||
|
||||
/**
|
||||
Generate wxPanGestureEvent for horizontal pans.
|
||||
|
||||
Note that under macOS vertical pan events are also enabled when this
|
||||
flag is specified.
|
||||
*/
|
||||
wxTOUCH_HORIZONTAL_PAN_GESTURE,
|
||||
|
||||
/**
|
||||
Generate wxPanGestureEvent for any pans.
|
||||
|
||||
This is just a convenient combination of wxTOUCH_VERTICAL_PAN_GESTURE
|
||||
and wxTOUCH_HORIZONTAL_PAN_GESTURE.
|
||||
*/
|
||||
wxTOUCH_PAN_GESTURES,
|
||||
|
||||
/**
|
||||
Generate wxZoomGestureEvent.
|
||||
*/
|
||||
wxTOUCH_ZOOM_GESTURE,
|
||||
|
||||
/**
|
||||
Generate wxRotateGestureEvent.
|
||||
*/
|
||||
wxTOUCH_ROTATE_GESTURE,
|
||||
|
||||
/**
|
||||
Generate events for press or tap gestures such as wxTwoFingerTapEvent,
|
||||
wxLongPressEvent and wxPressAndTapEvent.
|
||||
*/
|
||||
wxTOUCH_PRESS_GESTURES,
|
||||
|
||||
/**
|
||||
Enable all supported gesture events.
|
||||
*/
|
||||
wxTOUCH_ALL_GESTURES
|
||||
};
|
||||
|
||||
/**
|
||||
flags for SendSizeEvent()
|
||||
*/
|
||||
@@ -3424,6 +3486,28 @@ public:
|
||||
*/
|
||||
virtual void WarpPointer(int x, int y);
|
||||
|
||||
/**
|
||||
Request generation of touch events for this window.
|
||||
|
||||
Each call to this function supersedes the previous ones, i.e. if you
|
||||
want to receive events for both zoom and rotate gestures, you need to
|
||||
call
|
||||
@code
|
||||
EnableTouchEvents(wxTOUCH_ZOOM_GESTURE | wxTOUCH_ROTATE_GESTURE);
|
||||
@endcode
|
||||
instead of calling it twice in a row as the second call would disable
|
||||
the first gesture.
|
||||
|
||||
@param eventsMask Either wxTOUCH_NONE or wxTOUCH_ALL_GESTURES to
|
||||
disable or enable gesture events for this window.
|
||||
|
||||
@return @true if the specified events were enabled or @false if the
|
||||
current platform doesn't support touch events.
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
virtual bool EnableTouchEvents(int eventsMask);
|
||||
|
||||
//@}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user