The Battle for Wesnoth  1.19.4+dev
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
gui2::event Namespace Reference

Namespaces

 implementation
 

Classes

class  dispatcher
 Base class for event handling. More...
 
struct  dispatcher_implementation
 
class  resource_locker
 Small helper to keep a resource (boolean) locked. More...
 
class  mouse_motion
 
class  mouse_button
 
class  distributor
 The event handler class for the widget library. More...
 
class  sdl_event_handler
 This singleton class handles all events. More...
 
class  manager
 
struct  message
 The message callbacks hold a reference to a message. More...
 
struct  message_show_tooltip
 The message for MESSAGE_SHOW_TOOLTIP. More...
 
struct  message_show_helptip
 The message for MESSAGE_SHOW_HELPTIP. More...
 

Typedefs

template<typename... T>
using dispatcher_callback = std::function< void(widget &, const ui_event, bool &, bool &, T...)>
 Callback function signature alias template. More...
 
using signal = dispatcher_callback<>
 Used for events in event_category::general. More...
 
using signal_mouse = dispatcher_callback< const point & >
 Used for events in event_category::mouse. More...
 
using signal_keyboard = dispatcher_callback< const SDL_Keycode, const SDL_Keymod, const std::string & >
 Used for events in event_category::keyboard. More...
 
using signal_touch_motion = dispatcher_callback< const point &, const point & >
 Used for events in event_category::touch_motion. More...
 
using signal_touch_gesture = dispatcher_callback< const point &, float, float, uint8_t >
 Used for events in event_category::touch_gesture. More...
 
using signal_notification = dispatcher_callback< void * >
 Used for events in event_category::notification. More...
 
using signal_message = dispatcher_callback< const message & >
 Used for events in event_category::message. More...
 
using signal_raw_event = dispatcher_callback< const SDL_Event & >
 Used for events in event_category::raw_event. More...
 
using signal_text_input = dispatcher_callback< const std::string &, int32_t, int32_t >
 Used for eventsin event_category::text_input. More...
 
using hotkey_function = std::function< void(widget &dispatcher, hotkey::HOTKEY_COMMAND id)>
 Hotkey function handler signature. More...
 
using mouse_button_left = mouse_button< 0 >
 
using mouse_button_middle = mouse_button< 1 >
 
using mouse_button_right = mouse_button< 2 >
 

Enumerations

enum class  event_category : uint32_t {
  general = 1u << 8 , mouse = 1u << 9 , keyboard = 1u << 10 , touch_motion = 1u << 11 ,
  touch_gesture = 1u << 12 , notification = 1u << 13 , message = 1u << 14 , raw_event = 1u << 15 ,
  text_input = 1u << 16
}
 Event category masks. More...
 
enum  ui_event : uint32_t {
  DRAW = encode_category(1 , event_category::general) , CLOSE_WINDOW = encode_category(2 , event_category::general) , MOUSE_ENTER = encode_category(3 , event_category::general) , MOUSE_LEAVE = encode_category(4 , event_category::general) ,
  LEFT_BUTTON_DOWN = encode_category(5 , event_category::general) , LEFT_BUTTON_UP = encode_category(6 , event_category::general) , LEFT_BUTTON_CLICK = encode_category(7 , event_category::general) , LEFT_BUTTON_DOUBLE_CLICK = encode_category(8 , event_category::general) ,
  MIDDLE_BUTTON_DOWN = encode_category(9 , event_category::general) , MIDDLE_BUTTON_UP = encode_category(10, event_category::general) , MIDDLE_BUTTON_CLICK = encode_category(11, event_category::general) , MIDDLE_BUTTON_DOUBLE_CLICK = encode_category(12, event_category::general) ,
  RIGHT_BUTTON_DOWN = encode_category(13, event_category::general) , RIGHT_BUTTON_UP = encode_category(14, event_category::general) , RIGHT_BUTTON_CLICK = encode_category(15, event_category::general) , RIGHT_BUTTON_DOUBLE_CLICK = encode_category(16, event_category::general) ,
  SDL_VIDEO_RESIZE = encode_category(17, event_category::mouse) , SDL_MOUSE_MOTION = encode_category(18, event_category::mouse) , MOUSE_MOTION = encode_category(19, event_category::mouse) , SDL_LEFT_BUTTON_DOWN = encode_category(20, event_category::mouse) ,
  SDL_LEFT_BUTTON_UP = encode_category(21, event_category::mouse) , SDL_MIDDLE_BUTTON_DOWN = encode_category(22, event_category::mouse) , SDL_MIDDLE_BUTTON_UP = encode_category(23, event_category::mouse) , SDL_RIGHT_BUTTON_DOWN = encode_category(24, event_category::mouse) ,
  SDL_RIGHT_BUTTON_UP = encode_category(25, event_category::mouse) , SDL_WHEEL_LEFT = encode_category(26, event_category::mouse) , SDL_WHEEL_RIGHT = encode_category(27, event_category::mouse) , SDL_WHEEL_UP = encode_category(28, event_category::mouse) ,
  SDL_WHEEL_DOWN = encode_category(29, event_category::mouse) , SHOW_TOOLTIP = encode_category(30, event_category::mouse) , SHOW_HELPTIP = encode_category(31, event_category::mouse) , SDL_TOUCH_UP = encode_category(32, event_category::mouse) ,
  SDL_TOUCH_DOWN = encode_category(33, event_category::mouse) , SDL_KEY_DOWN = encode_category(34, event_category::keyboard) , SDL_TEXT_INPUT = encode_category(35, event_category::text_input) , SDL_TEXT_EDITING = encode_category(36, event_category::text_input) ,
  SDL_ACTIVATE = encode_category(37, event_category::notification) , NOTIFY_REMOVAL = encode_category(38, event_category::notification) , NOTIFY_MODIFIED = encode_category(39, event_category::notification) , NOTIFY_REMOVE_TOOLTIP = encode_category(40, event_category::notification) ,
  RECEIVE_KEYBOARD_FOCUS = encode_category(41, event_category::notification) , LOSE_KEYBOARD_FOCUS = encode_category(42, event_category::notification) , REQUEST_PLACEMENT = encode_category(43, event_category::message) , MESSAGE_SHOW_TOOLTIP = encode_category(44, event_category::message) ,
  MESSAGE_SHOW_HELPTIP = encode_category(45, event_category::message) , SDL_TOUCH_MOTION = encode_category(46, event_category::touch_motion) , SDL_TOUCH_MULTI_GESTURE = encode_category(47, event_category::touch_gesture) , SDL_RAW_EVENT = encode_category(48, event_category::raw_event)
}
 The event sent to the dispatcher. More...
 

Functions

void connect_signal_pre_key_press (dispatcher &dispatcher, const signal_keyboard &signal)
 Connects the signal for 'snooping' on the keypress. More...
 
void connect_signal_mouse_left_click (dispatcher &dispatcher, const signal &signal)
 Connects a signal handler for a left mouse button click. More...
 
void disconnect_signal_mouse_left_click (dispatcher &dispatcher, const signal &signal)
 Disconnects a signal handler for a left mouse button click. More...
 
void connect_signal_mouse_left_release (dispatcher &dispatcher, const signal &signal)
 Connects a signal handler for a left mouse button release. More...
 
void disconnect_signal_mouse_left_release (dispatcher &dispatcher, const signal &signal)
 Disconnects a signal handler for a left mouse button release. More...
 
void connect_signal_mouse_left_double_click (dispatcher &dispatcher, const signal &signal)
 Connects a signal handler for a left mouse button double click. More...
 
void connect_signal_notify_modified (dispatcher &dispatcher, const signal_notification &signal)
 Connects a signal handler for getting a notification upon modification. More...
 
void connect_signal_on_draw (dispatcher &dispatcher, const signal &signal)
 Connects a signal handler for a callback when the widget is drawn. More...
 
template<event_category C, typename... F>
bool fire_event (const ui_event event, dispatcher *d, widget *w, F &&... params)
 Fires an event. More...
 
template<ui_event click, ui_event double_click, bool(event_executor::*)() const wants_double_click, typename... F>
bool fire_event_double_click (dispatcher *dsp, widget *wgt, F &&... params)
 
void connect_dispatcher (dispatcher *dispatcher)
 Connects a dispatcher to the event handler. More...
 
void disconnect_dispatcher (dispatcher *dispatcher)
 Disconnects a dispatcher to the event handler. More...
 
std::vector< dispatcher * > & get_all_dispatchers ()
 Gets all event dispatchers in the Z order. More...
 
void init_mouse_location ()
 Initializes the location of the mouse. More...
 
void capture_mouse (dispatcher *dispatcher)
 Captures the mouse. More...
 
void release_mouse (dispatcher *dispatcher)
 Releases a captured mouse. More...
 
void capture_keyboard (dispatcher *dispatcher)
 Captures the keyboard. More...
 
std::ostream & operator<< (std::ostream &stream, const ui_event event)
 
constexpr uint32_t encode_category (const uint32_t input, const event_category mask)
 
constexpr bool is_in_category (const ui_event event, const event_category mask)
 Checks if a given event is in a given category. More...
 
constexpr event_category get_event_category (const ui_event event)
 Returns the category of a given event. More...
 

Variables

static std::unique_ptr< class sdl_event_handlerhandler_ = nullptr
 
static events::event_contextevent_context = nullptr
 

Typedef Documentation

◆ dispatcher_callback

template<typename... T>
using gui2::event::dispatcher_callback = typedef std::function<void(widget&, const ui_event, bool&, bool&, T...)>

Callback function signature alias template.

All callbacks take these four arguments in addition to any arguments specified by the parameter pack.

Parameters:

  1. The widget handling this event.
  2. The event type.
  3. Reference to the flag controlling whether this event has been handled.
  4. Reference to the flag controlling whether to halt execution of this event.

Definition at line 51 of file dispatcher.hpp.

◆ hotkey_function

Hotkey function handler signature.

Definition at line 132 of file dispatcher.hpp.

◆ mouse_button_left

Definition at line 190 of file distributor.hpp.

◆ mouse_button_middle

Definition at line 191 of file distributor.hpp.

◆ mouse_button_right

Definition at line 192 of file distributor.hpp.

◆ signal

Used for events in event_category::general.

Definition at line 56 of file dispatcher.hpp.

◆ signal_keyboard

using gui2::event::signal_keyboard = typedef dispatcher_callback<const SDL_Keycode, const SDL_Keymod, const std::string&>

Used for events in event_category::keyboard.

Extra parameters:

  1. The keycode of the key that triggered this event.
  2. Any applicable active modifer key.
  3. Any applicable text associated with the key.

Definition at line 74 of file dispatcher.hpp.

◆ signal_message

Used for events in event_category::message.

Extra parameters:

  1. The applicable data this event requires.

Definition at line 111 of file dispatcher.hpp.

◆ signal_mouse

Used for events in event_category::mouse.

Extra parameters:

  1. The x,y coordinate of the mouse when this event is fired.

Definition at line 64 of file dispatcher.hpp.

◆ signal_notification

Used for events in event_category::notification.

Extra parameters:

  1. A dummy void* parameter which will always be nullptr, used to differentiate this function from signal.

Definition at line 103 of file dispatcher.hpp.

◆ signal_raw_event

using gui2::event::signal_raw_event = typedef dispatcher_callback<const SDL_Event&>

Used for events in event_category::raw_event.

Extra parameters:

  1. The raw SDL_Event.

Definition at line 119 of file dispatcher.hpp.

◆ signal_text_input

using gui2::event::signal_text_input = typedef dispatcher_callback<const std::string&, int32_t, int32_t>

Used for eventsin event_category::text_input.

Extra parameters:

  1. The text entered.
  2. The current input position.
  3. The current text selection length.

Definition at line 129 of file dispatcher.hpp.

◆ signal_touch_gesture

using gui2::event::signal_touch_gesture = typedef dispatcher_callback<const point&, float, float, uint8_t>

Used for events in event_category::touch_gesture.

Extra parameters: (TODO: document what these actually are)

  1. center
  2. dTheta
  3. dDist
  4. numFingers

Definition at line 94 of file dispatcher.hpp.

◆ signal_touch_motion

Used for events in event_category::touch_motion.

Extra parameters:

  1. Origin of the touch event, in x,y format.
  2. Number of pixels dragged, in x,y format.

Definition at line 83 of file dispatcher.hpp.

Enumeration Type Documentation

◆ event_category

enum gui2::event::event_category : uint32_t
strong

Event category masks.

These begin at 2^8 to allow for 8 bits for the event identifiers themselves. This means ui_event can have up to 256 unique members. Since each mask needs its own place value, we can have 24 categories since ui_event's underlying type is 32 bits:

              USABLE CATEGORY BITS    NULL
           |------------------------|--------|
MASK        000000000000000000000000 00000000

              ENCODED CATEGORY        EVENT
           |------------------------|--------|
UI_EVENT    000000000000000000000000 00000000
Enumerator
general 

Callbacks without extra parameters.

Note
Some mouse events like MOUSE_ENTER don't send the mouse coordinates to the callback function so they are also in this category.
mouse 

Callbacks with a coordinate as extra parameter.

keyboard 

Callbacks with the keyboard values (these haven't been determined yet).

touch_motion 
touch_gesture 
notification 

Callbacks with a sender aka notification messages.

Like general events it has no extra parameters, but this version is only sent to the target and does not use the pre and post queue.

message 

Callbacks with a sender aka notification messages.

Unlike the notifications this message is send through the chain. The event is sent from a widget all the way up to the window, who is always the receiver of the message (unless somebody grabbed it before).

raw_event 
text_input 

Definition at line 55 of file handler.hpp.

◆ ui_event

enum gui2::event::ui_event : uint32_t

The event sent to the dispatcher.

Events prefixed by SDL are (semi)-real SDL events. The handler does some minor decoding like splitting the button down event to the proper event but nothing more. Events without an SDL prefix are generated by another signal eg the windows signal handler for SDL_MOUSE_MOTION can generate a MOUSE_ENTER, MOUSE_MOTION and MOUSE_LEAVE event and send that to it's children.

Note
When adding a new entry to the enum also add a unit test.
Enumerator
DRAW 
CLOSE_WINDOW 
MOUSE_ENTER 
MOUSE_LEAVE 
LEFT_BUTTON_DOWN 
LEFT_BUTTON_UP 
LEFT_BUTTON_CLICK 
LEFT_BUTTON_DOUBLE_CLICK 
MIDDLE_BUTTON_DOWN 
MIDDLE_BUTTON_UP 
MIDDLE_BUTTON_CLICK 
MIDDLE_BUTTON_DOUBLE_CLICK 
RIGHT_BUTTON_DOWN 
RIGHT_BUTTON_UP 
RIGHT_BUTTON_CLICK 
RIGHT_BUTTON_DOUBLE_CLICK 
SDL_VIDEO_RESIZE 
SDL_MOUSE_MOTION 
MOUSE_MOTION 
SDL_LEFT_BUTTON_DOWN 
SDL_LEFT_BUTTON_UP 
SDL_MIDDLE_BUTTON_DOWN 
SDL_MIDDLE_BUTTON_UP 
SDL_RIGHT_BUTTON_DOWN 
SDL_RIGHT_BUTTON_UP 
SDL_WHEEL_LEFT 
SDL_WHEEL_RIGHT 
SDL_WHEEL_UP 
SDL_WHEEL_DOWN 
SHOW_TOOLTIP 
SHOW_HELPTIP 
SDL_TOUCH_UP 
SDL_TOUCH_DOWN 
SDL_KEY_DOWN 
SDL_TEXT_INPUT 

An SDL text input (commit) event.

SDL_TEXT_EDITING 

An SDL text editing (IME) event.

SDL_ACTIVATE 
NOTIFY_REMOVAL 
NOTIFY_MODIFIED 
NOTIFY_REMOVE_TOOLTIP 
RECEIVE_KEYBOARD_FOCUS 
LOSE_KEYBOARD_FOCUS 
REQUEST_PLACEMENT 
MESSAGE_SHOW_TOOLTIP 
MESSAGE_SHOW_HELPTIP 
SDL_TOUCH_MOTION 
SDL_TOUCH_MULTI_GESTURE 
SDL_RAW_EVENT 

Definition at line 115 of file handler.hpp.

Function Documentation

◆ capture_keyboard()

void gui2::event::capture_keyboard ( dispatcher dispatcher)

Captures the keyboard.

A dispatcher can capture the keyboard, when for example it's pressed on a button, this means all keyboard events after that are send to that widget.

Parameters
dispatcherThe dispatcher which should get the keyboard focus.

Definition at line 909 of file handler.cpp.

◆ capture_mouse()

void gui2::event::capture_mouse ( dispatcher dispatcher)

Captures the mouse.

A dispatcher can capture the mouse, when for example it's pressed on a button, this means all mouse events after that are send to that widget.

Parameters
dispatcherThe dispatcher which should get the mouse focus.

Definition at line 893 of file handler.cpp.

References handler_.

Referenced by gui2::event::dispatcher::capture_mouse().

◆ connect_dispatcher()

void gui2::event::connect_dispatcher ( dispatcher dispatcher)

Connects a dispatcher to the event handler.

Parameters
dispatcherThe dispatcher to connect.

Definition at line 860 of file handler.cpp.

References handler_.

Referenced by gui2::event::dispatcher::connect().

◆ connect_signal_mouse_left_click()

void gui2::event::connect_signal_mouse_left_click ( dispatcher dispatcher,
const signal signal 
)

Connects a signal handler for a left mouse button click.

Definition at line 177 of file dispatcher.cpp.

References gui2::event::dispatcher::connect_signal(), and LEFT_BUTTON_CLICK.

Referenced by gui2::dialogs::mp_staging::add_side_node(), gui2::dialogs::chat_log::view::bind(), gui2::dialogs::gamestate_inspector::controller::bind(), gui2::dialogs::lua_interpreter::controller::bind(), gui2::button::connect_click_handler(), gui2::dialogs::mp_options_helper::display_custom_options(), gui2::dialogs::editor_choose_addon::editor_choose_addon(), gui2::dialogs::editor_edit_pbl::editor_edit_pbl(), gui2::unit_preview_pane::finalize_setup(), gui2::chatbox::find_or_create_window(), gui2::dialogs::mp_join_game::generate_side_list(), gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::window::layout(), gui2::dialogs::addon_connect::pre_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::custom_tod::pre_show(), gui2::dialogs::editor_edit_unit::pre_show(), gui2::dialogs::editor_generate_map::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::dialogs::formula_debugger::pre_show(), gui2::dialogs::game_cache_options::pre_show(), gui2::dialogs::game_load::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::help_browser::pre_show(), gui2::dialogs::language_selection::pre_show(), gui2::dialogs::mp_lobby::pre_show(), gui2::dialogs::mp_match_history::pre_show(), gui2::dialogs::mp_alerts_options::pre_show(), gui2::dialogs::mp_connect::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::mp_method_selection::pre_show(), gui2::dialogs::lobby_player_info::pre_show(), gui2::dialogs::synched_choice_wait::pre_show(), gui2::dialogs::preferences_dialog::pre_show(), gui2::dialogs::screenshot_notification::pre_show(), gui2::dialogs::select_orb_colors::pre_show(), gui2::dialogs::story_viewer::pre_show(), gui2::dialogs::unit_advance::pre_show(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::dialogs::unit_recruit::pre_show(), gui2::dialogs::wml_error::pre_show(), gui2::dialogs::title_screen::register_button(), gui2::addon_list::set_addons(), gui2::dialogs::select_orb_colors::setup_orb_group_two_color(), gui2::dialogs::select_orb_colors::setup_orb_toggle(), and gui2::dialogs::mp_match_history::update_display().

◆ connect_signal_mouse_left_double_click()

void gui2::event::connect_signal_mouse_left_double_click ( dispatcher dispatcher,
const signal signal 
)

Connects a signal handler for a left mouse button double click.

I'm not exactly sure why this works in this queue position with toggle panels, but it does. Will revisit if it becomes an issue later (ie, if this is used with other widgets and doesn't work).

  • vultraz, 2017-08-23

Definition at line 198 of file dispatcher.cpp.

References gui2::event::dispatcher::back_post_child, gui2::event::dispatcher::connect_signal(), and LEFT_BUTTON_DOUBLE_CLICK.

Referenced by gui2::dialogs::mp_lobby::adjust_game_row_contents(), and gui2::lobby_player_list_helper::update().

◆ connect_signal_mouse_left_release()

void gui2::event::connect_signal_mouse_left_release ( dispatcher dispatcher,
const signal signal 
)

Connects a signal handler for a left mouse button release.

Definition at line 187 of file dispatcher.cpp.

References gui2::event::dispatcher::connect_signal(), and LEFT_BUTTON_UP.

Referenced by gui2::dialogs::preferences_dialog::initialize_callbacks().

◆ connect_signal_notify_modified()

void gui2::event::connect_signal_notify_modified ( dispatcher dispatcher,
const signal_notification signal 
)

Connects a signal handler for getting a notification upon modification.

Definition at line 203 of file dispatcher.cpp.

References gui2::event::dispatcher::connect_signal(), and NOTIFY_MODIFIED.

Referenced by gui2::dialogs::mp_staging::add_side_node(), gui2::dialogs::chat_log::view::bind(), gui2::dialogs::gamestate_inspector::controller::bind(), gui2::bind_status_label(), gui2::dialogs::mp_options_helper::display_custom_options(), gui2::dialogs::editor_edit_pbl::editor_edit_pbl(), gui2::listbox::finalize(), gui2::chatbox::finalize_setup(), gui2::scrollbar_container::finalize_setup(), gui2::policy::select_action::selection::init(), gui2::field_bool::init_specialized(), gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::dialogs::preferences_dialog::initialize_sound_option_group(), gui2::dialogs::preferences_dialog::initialize_tabs(), intf_set_dialog_callback(), gui2::dialogs::achievements_dialog::pre_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::core_selection::pre_show(), gui2::dialogs::drop_down_menu::pre_show(), gui2::dialogs::edit_text::pre_show(), gui2::dialogs::custom_tod::pre_show(), gui2::dialogs::editor_edit_unit::pre_show(), gui2::dialogs::editor_generate_map::pre_show(), gui2::dialogs::generator_settings::pre_show(), gui2::dialogs::editor_resize_map::pre_show(), gui2::dialogs::tod_new_schedule::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::dialogs::game_load::pre_show(), gui2::dialogs::game_stats::pre_show(), gui2::dialogs::help_browser::pre_show(), gui2::dialogs::label_settings::pre_show(), gui2::dialogs::faction_select::pre_show(), gui2::dialogs::mp_lobby::pre_show(), gui2::dialogs::mp_change_control::pre_show(), gui2::dialogs::mp_connect::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::preferences_dialog::pre_show(), gui2::dialogs::server_info::pre_show(), gui2::dialogs::statistics_dialog::pre_show(), gui2::dialogs::unit_advance::pre_show(), gui2::dialogs::unit_create::pre_show(), gui2::dialogs::unit_list::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::dialogs::unit_recruit::pre_show(), gui2::group< T >::set_callback_on_value_change(), gui2::addon_list::set_modified_signal_handler(), and gui2::dialogs::mp_match_history::update_display().

◆ connect_signal_on_draw()

void gui2::event::connect_signal_on_draw ( dispatcher dispatcher,
const signal signal 
)

Connects a signal handler for a callback when the widget is drawn.

Definition at line 208 of file dispatcher.cpp.

References gui2::event::dispatcher::connect_signal(), DRAW, and gui2::event::dispatcher::front_child.

◆ connect_signal_pre_key_press()

void gui2::event::connect_signal_pre_key_press ( dispatcher dispatcher,
const signal_keyboard signal 
)

◆ disconnect_dispatcher()

void gui2::event::disconnect_dispatcher ( dispatcher dispatcher)

Disconnects a dispatcher to the event handler.

Parameters
dispatcherThe dispatcher to disconnect.

Definition at line 867 of file handler.cpp.

References handler_.

Referenced by gui2::event::dispatcher::disconnect().

◆ disconnect_signal_mouse_left_click()

void gui2::event::disconnect_signal_mouse_left_click ( dispatcher dispatcher,
const signal signal 
)

Disconnects a signal handler for a left mouse button click.

Definition at line 182 of file dispatcher.cpp.

References gui2::event::dispatcher::disconnect_signal(), and LEFT_BUTTON_CLICK.

Referenced by gui2::button::disconnect_click_handler().

◆ disconnect_signal_mouse_left_release()

void gui2::event::disconnect_signal_mouse_left_release ( dispatcher dispatcher,
const signal signal 
)

Disconnects a signal handler for a left mouse button release.

Definition at line 192 of file dispatcher.cpp.

References gui2::event::dispatcher::disconnect_signal(), and LEFT_BUTTON_UP.

◆ encode_category()

constexpr uint32_t gui2::event::encode_category ( const uint32_t  input,
const event_category  mask 
)
constexpr

Definition at line 96 of file handler.hpp.

◆ fire_event()

template<event_category C, typename... F>
bool gui2::event::fire_event ( const ui_event  event,
dispatcher d,
widget w,
F &&...  params 
)

Fires an event.

A helper to allow the common event firing code to be shared between the different signal function types.

Precondition
d != nullptr
w != nullptr
Template Parameters
CThe category of the event to handle.
FThe parameter pack type.
Parameters
eventThe event to fire.
dThe dispatcher that handles the event.
wThe widget that should receive the event.
paramsZero or more additional arguments to pass to the signal function when it's executed.
Returns
Whether or not the event was handled.

Definition at line 322 of file dispatcher_private.hpp.

References d, and w.

◆ fire_event_double_click()

template<ui_event click, ui_event double_click, bool(event_executor::*)() const wants_double_click, typename... F>
bool gui2::event::fire_event_double_click ( dispatcher dsp,
widget wgt,
F &&...  params 
)

◆ get_all_dispatchers()

std::vector< dispatcher * > & gui2::event::get_all_dispatchers ( )

Gets all event dispatchers in the Z order.

Definition at line 874 of file handler.cpp.

References handler_.

◆ get_event_category()

constexpr event_category gui2::event::get_event_category ( const ui_event  event)
constexpr

Returns the category of a given event.

Note
Since each event has only one category flag set, it is safe to simply do an equality check with this result, which would return the same as is_in_category.

Definition at line 192 of file handler.hpp.

Referenced by fire_event_double_click(), and gui2::event::dispatcher_implementation::has_handler().

◆ init_mouse_location()

void gui2::event::init_mouse_location ( )

Initializes the location of the mouse.

After a layout of the window the mouse location needs to be updated to test whether it entered or left a widget. Also after closing a window it's needed to send a dummy mouse move.

Definition at line 880 of file handler.cpp.

References gui2::get_mouse_position(), and mouse.

Referenced by gui2::event::distributor::initialize_state(), and gui2::window::layout().

◆ is_in_category()

constexpr bool gui2::event::is_in_category ( const ui_event  event,
const event_category  mask 
)
constexpr

Checks if a given event is in a given category.

Note
Even though all events currently have only one category bitflag set, this function works correctly if they ever have multiple flags set, unlike get_event_category.

Definition at line 180 of file handler.hpp.

Referenced by gui2::event::dispatcher::fire().

◆ operator<<()

std::ostream & gui2::event::operator<< ( std::ostream &  stream,
const ui_event  event 
)

◆ release_mouse()

void gui2::event::release_mouse ( dispatcher dispatcher)

Releases a captured mouse.

Parameters
dispatcherThe dispatcher which should release the mouse capture.

Definition at line 900 of file handler.cpp.

References handler_.

Referenced by gui2::event::dispatcher::release_mouse().

Variable Documentation

◆ event_context

events::event_context* gui2::event::event_context = nullptr
static

◆ handler_

std::unique_ptr<class sdl_event_handler> gui2::event::handler_ = nullptr
static