MeshLib Documentation
Loading...
Searching...
No Matches
MRTouchpadController.h
Go to the documentation of this file.
1#pragma once
2
4#include "MRViewport.h"
6
7#include <functional>
8#include <memory>
9
10struct GLFWwindow;
11
12namespace MR
13{
14
28 TouchpadRotateGestureBeginListener, TouchpadRotateGestureUpdateListener, TouchpadRotateGestureEndListener,
29 TouchpadSwipeGestureBeginListener, TouchpadSwipeGestureUpdateListener, TouchpadSwipeGestureEndListener,
30 TouchpadZoomGestureBeginListener, TouchpadZoomGestureUpdateListener, TouchpadZoomGestureEndListener
31>
32{
33public:
35
37 MRVIEWER_API void initialize( GLFWwindow* window );
39 MRVIEWER_API void reset();
40
41 [[nodiscard]] MRVIEWER_API const TouchpadParameters& getParameters() const;
42 MRVIEWER_API void setParameters( const TouchpadParameters& parameters );
43
48 class Handler
49 {
50 public:
51 virtual ~Handler() = default;
52
54 enum class GestureState
55 {
57 Begin,
59 Update,
61 End,
62 };
63
66 void mouseScroll( float dx, float dy, bool kinetic );
68 void rotate( float angle, GestureState state );
70 void swipe( float dx, float dy, bool kinetic, GestureState state );
72 void zoom( float scale, bool kinetic, GestureState state );
73 };
74
75private:
76 std::unique_ptr<Handler> handler_;
77 TouchpadParameters parameters_;
78
79 Viewport::Parameters initRotateParams_;
80 virtual bool touchpadRotateGestureBegin_() override;
81 virtual bool touchpadRotateGestureUpdate_( float angle ) override;
82 virtual bool touchpadRotateGestureEnd_() override;
83
85 virtual bool touchpadSwipeGestureBegin_() override;
86 virtual bool touchpadSwipeGestureUpdate_( float deltaX, float deltaY, bool kinetic ) override;
87 virtual bool touchpadSwipeGestureEnd_() override;
88
89 Viewport::Parameters initZoomParams_;
90 virtual bool touchpadZoomGestureBegin_() override;
91 virtual bool touchpadZoomGestureUpdate_( float scale, bool kinetic ) override;
92 virtual bool touchpadZoomGestureEnd_() override;
93};
94
95} // namespace MR
Definition MRTouchpadController.h:49
void swipe(float dx, float dy, bool kinetic, GestureState state)
swipe gesture; kinetic flag is set when the event is produced not by a user action but by hardware 'k...
GestureState
gesture state
Definition MRTouchpadController.h:55
void mouseScroll(float dx, float dy, bool kinetic)
void zoom(float scale, bool kinetic, GestureState state)
pitch ('zoom') gesture
void rotate(float angle, GestureState state)
rotate gesture
Definition MRTouchpadController.h:32
MRVIEWER_API const TouchpadParameters & getParameters() const
MRVIEWER_API void reset()
reset event handler
MRVIEWER_API void initialize(GLFWwindow *window)
initialize listening to touchpad events
MR_ADD_CTOR_DELETE_MOVE(TouchpadController)
MRVIEWER_API void setParameters(const TouchpadParameters &parameters)
Definition MRCameraOrientationPlugin.h:8
Definition MRViewerEventsListener.h:29
Definition MRTouchpadParameters.h:9
SwipeMode
swipe processing mode
Definition MRTouchpadParameters.h:15
Definition MRViewport.h:277