mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 22:59:19 +02:00
virtual slider mouse input mode, minor refactoring, minor bug fixes
This commit is contained in:
33
mouseinput.h
33
mouseinput.h
@@ -12,6 +12,36 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <unordered_map>
|
||||
#include "command.h"
|
||||
|
||||
// virtual slider; value determined by position of the mouse
|
||||
class mouse_slider {
|
||||
|
||||
public:
|
||||
// constructors
|
||||
mouse_slider() = default;
|
||||
// methods
|
||||
void
|
||||
bind( user_command const &Command );
|
||||
void
|
||||
release();
|
||||
void
|
||||
on_move( double const Mousex, double const Mousey );
|
||||
inline
|
||||
user_command
|
||||
command() const {
|
||||
return m_command; }
|
||||
double
|
||||
value() const {
|
||||
return m_value; }
|
||||
|
||||
private:
|
||||
// members
|
||||
user_command m_command { user_command::none };
|
||||
double m_value { 0.0 };
|
||||
double m_valuerange { 0.0 };
|
||||
bool m_analogue { false };
|
||||
glm::dvec2 m_cursorposition { 0.0 };
|
||||
};
|
||||
|
||||
class mouse_input {
|
||||
|
||||
public:
|
||||
@@ -27,6 +57,8 @@ public:
|
||||
move( double const Mousex, double const Mousey );
|
||||
void
|
||||
poll();
|
||||
user_command
|
||||
command() const;
|
||||
|
||||
private:
|
||||
// types
|
||||
@@ -44,6 +76,7 @@ private:
|
||||
|
||||
// members
|
||||
command_relay m_relay;
|
||||
mouse_slider m_slider; // virtual control, when active translates intercepted mouse position to a value
|
||||
controlcommands_map m_mousecommands;
|
||||
user_command m_mousecommandleft { user_command::none }; // last if any command issued with left mouse button
|
||||
user_command m_mousecommandright { user_command::none }; // last if any command issued with right mouse button
|
||||
|
||||
Reference in New Issue
Block a user