lxgui
Public Member Functions | Public Attributes | Protected Attributes | List of all members
lxgui::input::sfml::source Class Referencefinal

SFML implementation of input::source. More...

#include <input_sfml_source.hpp>

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

Public Member Functions

 source (sf::Window &win)
 Initializes this input source. More...
 
 source (const source &)=delete
 
sourceoperator= (const source &)=delete
 
utils::ustring get_clipboard_content () override
 Retrieve a copy of the clipboard content. More...
 
void set_clipboard_content (const utils::ustring &content) override
 Replace the content of the clipboard. More...
 
void on_sfml_event (const sf::Event &event)
 
void set_mouse_cursor (const std::string &file_name, const gui::vector2i &hot_spot) override
 Sets the mouse cursor to a given image on disk. More...
 
void reset_mouse_cursor () override
 Sets the mouse cursor back to the default (arrow). More...
 
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 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

SFML implementation of input::source.

Definition at line 26 of file input_sfml_source.hpp.

Constructor & Destructor Documentation

◆ source() [1/2]

lxgui::input::sfml::source::source ( sf::Window &  win)
explicit

Initializes this input source.

Parameters
winThe window from which to receive input

◆ source() [2/2]

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

Member Function Documentation

◆ get_clipboard_content()

utils::ustring lxgui::input::sfml::source::get_clipboard_content ( )
overridevirtual

Retrieve a copy of the clipboard content.

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

Implements lxgui::input::source.

◆ get_interface_scaling_factor_hint()

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

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
inherited

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
inherited

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
inherited

Get the window size (in pixels)

Returns
The window size

Definition at line 13 of file input_source.cpp.

◆ on_sfml_event()

void lxgui::input::sfml::source::on_sfml_event ( const sf::Event &  event)

◆ operator=()

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

◆ reset_mouse_cursor()

void lxgui::input::sfml::source::reset_mouse_cursor ( )
overridevirtual

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

Implements lxgui::input::source.

◆ set_clipboard_content()

void lxgui::input::sfml::source::set_clipboard_content ( const utils::ustring &  content)
overridevirtual

Replace the content of the clipboard.

Parameters
contentThe new clipboard content

Implements lxgui::input::source.

◆ set_mouse_cursor()

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

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.

Implements lxgui::input::source.

Member Data Documentation

◆ keyboard_

key_state lxgui::input::source::keyboard_
protectedinherited

Definition at line 178 of file input_source.hpp.

◆ mouse_

mouse_state lxgui::input::source::mouse_
protectedinherited

Definition at line 179 of file input_source.hpp.

◆ on_key_pressed

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

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
inherited

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
inherited

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
inherited

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
inherited

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
inherited

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
inherited

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
inherited

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
inherited

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_
protectedinherited

Definition at line 181 of file input_source.hpp.


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