lxgui
Classes | Public Member Functions | Public Attributes | Protected Attributes | List of all members
lxgui::input::source Class Referenceabstract

The base class for input source implementation. More...

#include <input_source.hpp>

Inheritance diagram for lxgui::input::source:
lxgui::input::sdl::source lxgui::input::sfml::source

Classes

struct  key_state
 
struct  mouse_state
 

Public Member Functions

 source ()=default
 Constructor. More...
 
virtual ~source ()=default
 Destructor. More...
 
 source (const source &)=delete
 
 source (source &&)=delete
 
sourceoperator= (const source &)=delete
 
sourceoperator= (source &&)=delete
 
const key_stateget_key_state () const
 Returns the keyboard state of this input source. More...
 
const mouse_stateget_mouse_state () const
 Returns the mouse state of this input source. More...
 
const gui::vector2uiget_window_dimensions () const
 Get the window size (in pixels) More...
 
virtual utils::ustring get_clipboard_content ()=0
 Retrieve a copy of the clipboard content. More...
 
virtual void set_clipboard_content (const utils::ustring &content)=0
 Replace the content of the clipboard. More...
 
virtual void set_mouse_cursor (const std::string &file_name, const gui::vector2i &hot_spot)=0
 Sets the mouse cursor to a given image on disk. More...
 
virtual void reset_mouse_cursor ()=0
 Sets the mouse cursor back to the default (arrow). More...
 
virtual float get_interface_scaling_factor_hint () const
 Return the interface scaling factor suggested by the operating system. More...
 

Public Attributes

utils::signal< void(const gui::vector2f &, const gui::vector2f &)> on_mouse_moved
 Signal triggered when the mouse moves. More...
 
utils::signal< void(float, const gui::vector2f &)> on_mouse_wheel
 Signal triggered when the mouse wheel is moved. More...
 
utils::signal< void(input::mouse_button, const gui::vector2f &)> on_mouse_pressed
 Signal triggered when a mouse button is pressed. More...
 
utils::signal< void(input::mouse_button, const gui::vector2f &)> on_mouse_released
 Signal triggered when a mouse button is released. More...
 
utils::signal< void(input::key)> on_key_pressed
 Signal triggered when a keyboard key is pressed. More...
 
utils::signal< void(input::key)> on_key_pressed_repeat
 Signal triggered when a keyboard key is long-pressed and repeats. More...
 
utils::signal< void(input::key)> on_key_released
 Signal triggered when a keyboard key is released. More...
 
utils::signal< void(std::uint32_t)> on_text_entered
 Signal triggered when text is entered. More...
 
utils::signal< void(const gui::vector2ui &)> on_window_resized
 Signal triggered whenever the window is resized or changes resolution. More...
 

Protected Attributes

key_state keyboard_
 
mouse_state mouse_
 
gui::vector2ui window_dimensions_
 

Detailed Description

The base class for input source implementation.

The implementation is responsible for generating the following low-level events:

These events are "raw", straight from the input implementation. They are meant to be consumed by the input::dispatcher, which takes care of transforming them (apply scaling factors, etc.), and generating more complex events (drag, double-click, etc.). Therefore, do not use these events directly unless you are really after the raw input events, and prefer using input::dispatcher instead.

Definition at line 39 of file input_source.hpp.

Constructor & Destructor Documentation

◆ source() [1/3]

lxgui::input::source::source ( )
default

Constructor.

◆ ~source()

virtual lxgui::input::source::~source ( )
virtualdefault

Destructor.

◆ source() [2/3]

lxgui::input::source::source ( const source )
delete

◆ source() [3/3]

lxgui::input::source::source ( source &&  )
delete

Member Function Documentation

◆ get_clipboard_content()

virtual utils::ustring lxgui::input::source::get_clipboard_content ( )
pure virtual

Retrieve a copy of the clipboard content.

Returns
A copy of the clipboard content (empty string if clipboard is empty).

Implemented in lxgui::input::sfml::source, and lxgui::input::sdl::source.

◆ get_interface_scaling_factor_hint()

float lxgui::input::source::get_interface_scaling_factor_hint ( ) const
virtual

Return the interface scaling factor suggested by the operating system.

Returns
The interface scaling factor suggested by the operating system
Note
This is implementation-dependent; not all input implementations are able to produce this hint, in which case the function always returns 1. Consequently, it is recommended to not rely blindly on this hint, and to offer a way for the user to change the scaling factor. But this can be used for a good default value.

Reimplemented in lxgui::input::sdl::source.

Definition at line 17 of file input_source.cpp.

◆ get_key_state()

const source::key_state & lxgui::input::source::get_key_state ( ) const

Returns the keyboard state of this input source.

Definition at line 5 of file input_source.cpp.

◆ get_mouse_state()

const source::mouse_state & lxgui::input::source::get_mouse_state ( ) const

Returns the mouse state of this input source.

Definition at line 9 of file input_source.cpp.

◆ get_window_dimensions()

const gui::vector2ui & lxgui::input::source::get_window_dimensions ( ) const

Get the window size (in pixels)

Returns
The window size

Definition at line 13 of file input_source.cpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ reset_mouse_cursor()

virtual void lxgui::input::source::reset_mouse_cursor ( )
pure virtual

Sets the mouse cursor back to the default (arrow).

Implemented in lxgui::input::sfml::source, and lxgui::input::sdl::source.

◆ set_clipboard_content()

virtual void lxgui::input::source::set_clipboard_content ( const utils::ustring &  content)
pure virtual

Replace the content of the clipboard.

Parameters
contentThe new clipboard content

Implemented in lxgui::input::sfml::source, and lxgui::input::sdl::source.

◆ set_mouse_cursor()

virtual void lxgui::input::source::set_mouse_cursor ( const std::string &  file_name,
const gui::vector2i hot_spot 
)
pure virtual

Sets the mouse cursor to a given image on disk.

Parameters
file_nameThe cursor image
hot_spotThe pixel position of the tip of the pointer in the image
Note
Use reset_mouse_cursor() to set the cursor back to the default.

Implemented in lxgui::input::sfml::source, and lxgui::input::sdl::source.

Member Data Documentation

◆ keyboard_

key_state lxgui::input::source::keyboard_
protected

Definition at line 178 of file input_source.hpp.

◆ mouse_

mouse_state lxgui::input::source::mouse_
protected

Definition at line 179 of file input_source.hpp.

◆ on_key_pressed

utils::signal<void(input::key)> lxgui::input::source::on_key_pressed

Signal triggered when a keyboard key is pressed.

Arguments:

  • keyboard key that generated this event

Definition at line 146 of file input_source.hpp.

◆ on_key_pressed_repeat

utils::signal<void(input::key)> lxgui::input::source::on_key_pressed_repeat

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

Arguments:

  • keyboard key that generated this event

Definition at line 153 of file input_source.hpp.

◆ on_key_released

utils::signal<void(input::key)> lxgui::input::source::on_key_released

Signal triggered when a keyboard key is released.

Arguments:

  • keyboard key that generated this event

Definition at line 160 of file input_source.hpp.

◆ on_mouse_moved

utils::signal<void(const gui::vector2f&, const gui::vector2f&)> lxgui::input::source::on_mouse_moved

Signal triggered when the mouse moves.

Arguments:

  • mouse motion that generated this event, in pixels
  • mouse position, in pixels

Definition at line 115 of file input_source.hpp.

◆ on_mouse_pressed

utils::signal<void(input::mouse_button, const gui::vector2f&)> lxgui::input::source::on_mouse_pressed

Signal triggered when a mouse button is pressed.

Arguments:

  • mouse button that generated this event
  • mouse position, in pixels

Definition at line 131 of file input_source.hpp.

◆ on_mouse_released

utils::signal<void(input::mouse_button, const gui::vector2f&)> lxgui::input::source::on_mouse_released

Signal triggered when a mouse button is released.

Arguments:

  • mouse button that generated this event
  • mouse position, in pixels

Definition at line 139 of file input_source.hpp.

◆ on_mouse_wheel

utils::signal<void(float, const gui::vector2f&)> lxgui::input::source::on_mouse_wheel

Signal triggered when the mouse wheel is moved.

Arguments:

  • mouse wheel motion that generated this event
  • mouse position, in pixels

Definition at line 123 of file input_source.hpp.

◆ on_text_entered

utils::signal<void(std::uint32_t)> lxgui::input::source::on_text_entered

Signal triggered when text is entered.

Arguments:

  • Unicode UTF-32 code point of the typed character
    Note
    The event will trigger repeatedly if more than one character is generated.

Definition at line 168 of file input_source.hpp.

◆ on_window_resized

utils::signal<void(const gui::vector2ui&)> lxgui::input::source::on_window_resized

Signal triggered whenever the window is resized or changes resolution.

Arguments:

  • New size of the window, in pixels

Definition at line 175 of file input_source.hpp.

◆ window_dimensions_

gui::vector2ui lxgui::input::source::window_dimensions_
protected

Definition at line 181 of file input_source.hpp.


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