lxgui
Public Member Functions | Public Attributes | List of all members
lxgui::input::dispatcher Class Reference

Handles inputs (keyboard and mouse) More...

#include <input_dispatcher.hpp>

Inheritance diagram for lxgui::input::dispatcher:
lxgui::input::signals

Public Member Functions

 dispatcher (source &src)
 Initializes this dispatcher with a chosen input source. More...
 
 dispatcher (const dispatcher &)=delete
 
 dispatcher (dispatcher &&)=delete
 
dispatcheroperator= (const dispatcher &)=delete
 
dispatcheroperator= (dispatcher &&)=delete
 
bool any_key_is_down () const
 Checks if any key is being pressed. More...
 
bool key_is_down (key key_id) const
 Checks if a key is being pressed. More...
 
double get_key_down_duration (key key_id) const
 Returns elapsed time since the key has been pressed. More...
 
bool alt_is_pressed () const
 Checks if Alt is being pressed. More...
 
bool shift_is_pressed () const
 Checks if Shift is being pressed. More...
 
bool ctrl_is_pressed () const
 Checks if Control (Ctrl) is being pressed. More...
 
bool mouse_is_down (mouse_button button_id) const
 Checks if a mouse button is being pressed. More...
 
double get_mouse_down_duration (mouse_button key_id) const
 Returns elapsed time since the mouse button has been pressed. More...
 
gui::vector2f get_mouse_position () const
 Returns the position of the mouse in pixels. More...
 
float get_mouse_wheel () const
 Returns the accumulated rolling amount of the mouse wheel. More...
 
void set_doubleclick_time (double double_click_time)
 Sets the double click maximum time. More...
 
double get_doubleclick_time () const
 Returns the double click maximum time. More...
 
void set_interface_scaling_factor (float scaling_factor)
 Sets the scaling factor applied to the interface. More...
 
float get_interface_scaling_factor () const
 Return the current interface scaling factor. More...
 
const sourceget_source () const
 Returns the input source. More...
 
sourceget_source ()
 Returns the input source. More...
 

Public Attributes

utils::signal< void(const mouse_moved_data &)> on_mouse_moved
 Signal triggered when the mouse moves. More...
 
utils::signal< void(const mouse_wheel_data &)> on_mouse_wheel
 Signal triggered when the mouse wheel is moved. More...
 
utils::signal< void(const mouse_pressed_data &)> on_mouse_pressed
 Signal triggered when a mouse button is pressed. More...
 
utils::signal< void(const mouse_released_data &)> on_mouse_released
 Signal triggered when a mouse button is released. More...
 
utils::signal< void(const mouse_double_clicked_data &)> on_mouse_double_clicked
 Signal triggered when a mouse button is double clicked. More...
 
utils::signal< void(const mouse_drag_start_data &)> on_mouse_drag_start
 Signal triggered when the mouse starts a drag operation. More...
 
utils::signal< void(const mouse_drag_stop_data &)> on_mouse_drag_stop
 Signal triggered when the mouse ends a drag operation. More...
 
utils::signal< void(const key_pressed_data &)> on_key_pressed
 Signal triggered when a keyboard key is pressed. More...
 
utils::signal< void(const key_pressed_repeat_data &)> on_key_pressed_repeat
 Signal triggered when a keyboard key is long-pressed and repeats. More...
 
utils::signal< void(const key_released_data &)> on_key_released
 Signal triggered when a keyboard key is released. More...
 
utils::signal< void(const text_entered_data &)> on_text_entered
 Signal triggered when text is entered. More...
 

Detailed Description

Handles inputs (keyboard and mouse)

The implementation is responsible for generating the following events:

These events are "global" and are not restricted by the UI. For example, on_mouse_pressed will trigger whenever a mouse button is pressed, even if the mouse pointer is currently over a UI element that should capture mouse input. Likewise, on_key_pressed will trigger even if a UI element has focus. These global events are meant to be consumed by the gui::root, which takes care of forwarding them to UI elements, and determining if a particular event is allowed to propagate to the elements below the UI. If you need to react only to events that are not captured by the UI, use events from input::world_dispatcher instead.

Definition at line 46 of file input_dispatcher.hpp.

Constructor & Destructor Documentation

◆ dispatcher() [1/3]

lxgui::input::dispatcher::dispatcher ( source src)
explicit

Initializes this dispatcher with a chosen input source.

Parameters
srcThe input source

Definition at line 15 of file input_dispatcher.cpp.

◆ dispatcher() [2/3]

lxgui::input::dispatcher::dispatcher ( const dispatcher )
delete

◆ dispatcher() [3/3]

lxgui::input::dispatcher::dispatcher ( dispatcher &&  )
delete

Member Function Documentation

◆ alt_is_pressed()

bool lxgui::input::dispatcher::alt_is_pressed ( ) const

Checks if Alt is being pressed.

Returns
'true' if Alt is being pressed

Definition at line 149 of file input_dispatcher.cpp.

◆ any_key_is_down()

bool lxgui::input::dispatcher::any_key_is_down ( ) const

Checks if any key is being pressed.

Returns
'true' if any key is being pressed

Definition at line 105 of file input_dispatcher.cpp.

◆ ctrl_is_pressed()

bool lxgui::input::dispatcher::ctrl_is_pressed ( ) const

Checks if Control (Ctrl) is being pressed.

Returns
'true' if Control (Ctrl) is being pressed

Definition at line 157 of file input_dispatcher.cpp.

◆ get_doubleclick_time()

double lxgui::input::dispatcher::get_doubleclick_time ( ) const

Returns the double click maximum time.

Returns
The double click maximum time

Definition at line 145 of file input_dispatcher.cpp.

◆ get_interface_scaling_factor()

float lxgui::input::dispatcher::get_interface_scaling_factor ( ) const

Return the current interface scaling factor.

Returns
The current interface scaling factor

Definition at line 181 of file input_dispatcher.cpp.

◆ get_key_down_duration()

double lxgui::input::dispatcher::get_key_down_duration ( key  key_id) const

Returns elapsed time since the key has been pressed.

Parameters
key_idThe ID code of the key you are interested in
Returns
Elapsed time since the key has been pressed

Definition at line 119 of file input_dispatcher.cpp.

◆ get_mouse_down_duration()

double lxgui::input::dispatcher::get_mouse_down_duration ( mouse_button  key_id) const

Returns elapsed time since the mouse button has been pressed.

Parameters
key_idThe ID code of the mouse button you are interested in
Returns
Elapsed time since the mouse button has been pressed

Definition at line 132 of file input_dispatcher.cpp.

◆ get_mouse_position()

gui::vector2f lxgui::input::dispatcher::get_mouse_position ( ) const

Returns the position of the mouse in pixels.

Returns
The position of the mouse in pixels

Definition at line 161 of file input_dispatcher.cpp.

◆ get_mouse_wheel()

float lxgui::input::dispatcher::get_mouse_wheel ( ) const

Returns the accumulated rolling amount of the mouse wheel.

Returns
The accumulated rolling amount of the mouse wheel

Definition at line 165 of file input_dispatcher.cpp.

◆ get_source() [1/2]

source & lxgui::input::dispatcher::get_source ( )

Returns the input source.

Returns
The input source

Definition at line 173 of file input_dispatcher.cpp.

◆ get_source() [2/2]

const source & lxgui::input::dispatcher::get_source ( ) const

Returns the input source.

Returns
The input source

Definition at line 169 of file input_dispatcher.cpp.

◆ key_is_down()

bool lxgui::input::dispatcher::key_is_down ( key  key_id) const

Checks if a key is being pressed.

Parameters
key_idThe ID code of the key you are interested in
Returns
'true' if the key is being pressed

Definition at line 115 of file input_dispatcher.cpp.

◆ mouse_is_down()

bool lxgui::input::dispatcher::mouse_is_down ( mouse_button  button_id) const

Checks if a mouse button is being pressed.

Parameters
button_idThe ID code of the mouse button you are interested in
Returns
'true' if the mouse button is being pressed

Definition at line 128 of file input_dispatcher.cpp.

◆ operator=() [1/2]

dispatcher& lxgui::input::dispatcher::operator= ( const dispatcher )
delete

◆ operator=() [2/2]

dispatcher& lxgui::input::dispatcher::operator= ( dispatcher &&  )
delete

◆ set_doubleclick_time()

void lxgui::input::dispatcher::set_doubleclick_time ( double  double_click_time)

Sets the double click maximum time.

Parameters
double_click_timeMaximum amount of time between two clicks in a double click

Definition at line 141 of file input_dispatcher.cpp.

◆ set_interface_scaling_factor()

void lxgui::input::dispatcher::set_interface_scaling_factor ( float  scaling_factor)

Sets the scaling factor applied to the interface.

Parameters
scaling_factorThe new scaling factor (default: 1)
Note
This is the conversion factor between UI units and pixels in the display. This factor should match gui::renderer::get_interface_scaling_factor().

Definition at line 177 of file input_dispatcher.cpp.

◆ shift_is_pressed()

bool lxgui::input::dispatcher::shift_is_pressed ( ) const

Checks if Shift is being pressed.

Returns
'true' if Shift is being pressed

Definition at line 153 of file input_dispatcher.cpp.

Member Data Documentation

◆ on_key_pressed

utils::signal<void(const key_pressed_data&)> lxgui::input::signals::on_key_pressed
inherited

Signal triggered when a keyboard key is pressed.

Definition at line 125 of file input_signals.hpp.

◆ on_key_pressed_repeat

utils::signal<void(const key_pressed_repeat_data&)> lxgui::input::signals::on_key_pressed_repeat
inherited

Signal triggered when a keyboard key is long-pressed and repeats.

Definition at line 130 of file input_signals.hpp.

◆ on_key_released

utils::signal<void(const key_released_data&)> lxgui::input::signals::on_key_released
inherited

Signal triggered when a keyboard key is released.

Definition at line 135 of file input_signals.hpp.

◆ on_mouse_double_clicked

utils::signal<void(const mouse_double_clicked_data&)> lxgui::input::signals::on_mouse_double_clicked
inherited

Signal triggered when a mouse button is double clicked.

Definition at line 110 of file input_signals.hpp.

◆ on_mouse_drag_start

utils::signal<void(const mouse_drag_start_data&)> lxgui::input::signals::on_mouse_drag_start
inherited

Signal triggered when the mouse starts a drag operation.

Definition at line 115 of file input_signals.hpp.

◆ on_mouse_drag_stop

utils::signal<void(const mouse_drag_stop_data&)> lxgui::input::signals::on_mouse_drag_stop
inherited

Signal triggered when the mouse ends a drag operation.

Definition at line 120 of file input_signals.hpp.

◆ on_mouse_moved

utils::signal<void(const mouse_moved_data&)> lxgui::input::signals::on_mouse_moved
inherited

Signal triggered when the mouse moves.

Definition at line 90 of file input_signals.hpp.

◆ on_mouse_pressed

utils::signal<void(const mouse_pressed_data&)> lxgui::input::signals::on_mouse_pressed
inherited

Signal triggered when a mouse button is pressed.

Definition at line 100 of file input_signals.hpp.

◆ on_mouse_released

utils::signal<void(const mouse_released_data&)> lxgui::input::signals::on_mouse_released
inherited

Signal triggered when a mouse button is released.

Definition at line 105 of file input_signals.hpp.

◆ on_mouse_wheel

utils::signal<void(const mouse_wheel_data&)> lxgui::input::signals::on_mouse_wheel
inherited

Signal triggered when the mouse wheel is moved.

Definition at line 95 of file input_signals.hpp.

◆ on_text_entered

utils::signal<void(const text_entered_data&)> lxgui::input::signals::on_text_entered
inherited

Signal triggered when text is entered.

Note
The event will trigger repeatedly if more than one character is generated.

Definition at line 141 of file input_signals.hpp.


The documentation for this class was generated from the following files: