The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Private Attributes | Friends | List of all members
gui2::event::dispatcher Class Referenceabstract

Base class for event handling. More...

#include <dispatcher.hpp>

Inheritance diagram for gui2::event::dispatcher:
Inheritance graph

Classes

struct  signal_queue
 Helper struct to generate the various event queues. More...
 
struct  signal_type
 Helper struct to generate the various signal types. More...
 

Public Types

enum  event_queue_type { pre = 1, child = 2, post = 4 }
 
enum  queue_position {
  front_pre_child, back_pre_child, front_child, back_child,
  front_post_child, back_post_child
}
 The position where to add a new callback in the signal handler. More...
 
enum  mouse_behavior { all, hit, none }
 The behavior of the mouse events. More...
 

Public Member Functions

 dispatcher ()
 
virtual ~dispatcher ()
 
void connect ()
 Connects the dispatcher to the event handler. More...
 
virtual bool is_at (const point &coordinate) const =0
 Determines whether the location is inside an active widget. More...
 
bool has_event (const ui_event event, const event_queue_type event_type)
 
bool fire (const ui_event event, widget &target)
 Fires an event which has no extra parameters. More...
 
bool fire (const ui_event event, widget &target, const point &coordinate)
 Fires an event which takes a coordinate parameter. More...
 
bool fire (const ui_event event, widget &target, const SDL_Keycode key, const SDL_Keymod modifier, const utf8::string &unicode)
 Fires an event which takes keyboard parameters. More...
 
bool fire (const ui_event event, widget &target, const point &pos, const point &distance)
 Fires an event which takes touch parameters. More...
 
bool fire (const ui_event event, widget &target, void *)
 Fires an event which takes notification parameters. More...
 
bool fire (const ui_event event, widget &target, message &msg)
 Fires an event which takes message parameters. More...
 
bool fire (const ui_event event, widget &target, const SDL_Event &sdlevent)
 Fires an event that's a raw SDL event. More...
 
bool fire (const ui_event event, widget &target, const std::string &text, int32_t start, int32_t len)
 Fires an event which takes text input parameters. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event, E >::value > 
connect_signal (const signal_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event, E >::value > 
disconnect_signal (const signal_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_mouse, E >::value > 
connect_signal (const signal_mouse_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_mouse. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_mouse, E >::value > 
disconnect_signal (const signal_mouse_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_mouse. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_keyboard, E >
::value > 
connect_signal (const signal_keyboard_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_keyboard. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_keyboard, E >
::value > 
disconnect_signal (const signal_keyboard_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_keyboard. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_touch, E >::value > 
connect_signal (const signal_touch_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_touch. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_touch, E >::value > 
disconnect_signal (const signal_touch_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_touch. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_notification, E >
::value > 
connect_signal (const signal_notification_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_notification. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_notification, E >
::value > 
disconnect_signal (const signal_notification_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_notification. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_message, E >
::value > 
connect_signal (const signal_message_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_message. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_message, E >
::value > 
disconnect_signal (const signal_message_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_message. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_raw_event, E >
::value > 
connect_signal (const signal_raw_event_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_raw_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_raw_event, E >
::value > 
disconnect_signal (const signal_raw_event_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_raw_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_text_input, E >
::value > 
connect_signal (const signal_text_input_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_text_input. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_text_input, E >
::value > 
disconnect_signal (const signal_text_input_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_text_input. More...
 
void capture_mouse ()
 Captures the mouse. More...
 
void release_mouse ()
 Releases the mouse capture. More...
 
void set_mouse_behavior (const mouse_behavior mouse_behavior)
 
mouse_behavior get_mouse_behavior () const
 
void set_want_keyboard_input (const bool want_keyboard_input)
 
bool get_want_keyboard_input () const
 
void register_hotkey (const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
 Registers a hotkey. More...
 
bool execute_hotkey (const hotkey::HOTKEY_COMMAND id)
 Executes a hotkey. More...
 

Private Attributes

mouse_behavior mouse_behavior_
 The mouse behavior for the dispatcher. More...
 
bool want_keyboard_input_
 Does the dispatcher want to receive keyboard input. More...
 
signal_queue< signal_functionsignal_queue_
 Signal queue for callbacks in set_event. More...
 
signal_queue
< signal_mouse_function
signal_mouse_queue_
 Signal queue for callbacks in set_event_mouse. More...
 
signal_queue
< signal_keyboard_function
signal_keyboard_queue_
 Signal queue for callbacks in set_event_keyboard. More...
 
signal_queue
< signal_touch_function
signal_touch_queue_
 Signal queue for callbacks in set_event_touch. More...
 
signal_queue
< signal_notification_function
signal_notification_queue_
 Signal queue for callbacks in set_event_notification. More...
 
signal_queue
< signal_message_function
signal_message_queue_
 Signal queue for callbacks in set_event_message. More...
 
signal_queue
< signal_raw_event_function
signal_raw_event_queue_
 Signal queue for callbacks in set_raw_event. More...
 
signal_queue
< signal_text_input_function
signal_text_input_queue_
 Signal queue for callbacks in set_event_text_input. More...
 
bool connected_
 Are we connected to the event handler. More...
 
std::map
< hotkey::HOTKEY_COMMAND,
hotkey_function
hotkeys_
 The registered hotkeys for this dispatcher. More...
 

Friends

struct dispatcher_implementation
 

Detailed Description

Base class for event handling.

A dispatcher has slots for events, when an event arrives it looks for the functions that registered themselves for that event and calls their callbacks.

This class is a base class for all widgets[1], what a widget does on a callback can differ greatly, an image might ignore all events a window can track the mouse location and fire MOUSE_ENTER and MOUSE_LEAVE events to the widgets involved.

[1] Not really sure whether it will be a base class for a widget or styled_widget yet.

Definition at line 160 of file dispatcher.hpp.

Member Enumeration Documentation

Enumerator
pre 
child 
post 

Definition at line 193 of file dispatcher.hpp.

The behavior of the mouse events.

Normally for mouse events there's first checked whether a dispatcher has captured the mouse if so it gets the event. If not the dispatcher is searched from the back to the front in the layers and its behavior is checked.

  • none The event is never send to the layer and goes on the the next layer. This is used for tooltips who might cover a button but a click on the tooltips should still click the button.
  • all The event is always send to this layer and stops the search for a next layer.
  • hit If the mouse is inside the dispatcher area the event is send and no longer searched further. If not inside tests the last layer.

If after these tests no dispatcher is found the event is ignored.

Enumerator
all 
hit 
none 

Definition at line 650 of file dispatcher.hpp.

The position where to add a new callback in the signal handler.

The signal handler has three callback queues:

  • pre_child These callbacks are called before a container widget sends it to the child items. Widgets without children should also use this queue.
  • child The callbacks for the proper child widget(s) are called.
  • post_child The callbacks for the parent container to be called after the child.

For every queue it's possible to add a new event in the front or in the back.

Whether all three queues are executed depend on the whether the callbacks modify the handled and halt flag.

  • When the halt flag is set execution of the current queue stops, when doing so the handled flag must be set as well.
  • When the handled flag is set the events in that queue are executed and no more queues afterwards.

Here are some use case examples. A button that plays a sound and executes an optional user callback:

  • The buttons internal click handler is invoked and sets the handled flag
  • The callback installed by the user is in the same queue and gets executed afterwards.

A toggle button may or may not be toggled:

  • The user inserts a callback, that validates whether the action is allowed, if not allowed it sets the halt flag (and handled), else leaves the flags untouched.
  • The normal buttons toggle function then might get invoked and if so sets the handled flag.
  • Optionally there is another user callback invoked at this point.
Enumerator
front_pre_child 
back_pre_child 
front_child 
back_child 
front_post_child 
back_post_child 

Definition at line 334 of file dispatcher.hpp.

Constructor & Destructor Documentation

gui2::event::dispatcher::dispatcher ( )

Definition at line 28 of file dispatcher.cpp.

Referenced by gui2::pane::signal_handler_request_placement().

gui2::event::dispatcher::~dispatcher ( )
virtual

Definition at line 41 of file dispatcher.cpp.

References connected_, and gui2::event::disconnect_dispatcher().

Member Function Documentation

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

Captures the mouse.

Definition at line 657 of file dispatcher.hpp.

References gui2::event::capture_mouse().

void gui2::event::dispatcher::connect ( )

Connects the dispatcher to the event handler.

When a dispatcher is connected to the event handler it will get the events directly from the event handler. This is wanted for top level items like windows but not for most other widgets.

So a window can call connect to register itself, it will automatically disconnect upon destruction.

Definition at line 48 of file dispatcher.cpp.

References gui2::event::connect_dispatcher(), and connected_.

template<ui_event E>
utils::enable_if_t<has_key<set_event, E>::value> gui2::event::dispatcher::connect_signal ( const signal_function signal,
const queue_position  position = back_child 
)
inline

Connect a signal for callback in set_event.

The function uses some enable_if magic to avoid registering the wrong function, but the common way to use this function is: widget->connect_signal<EVENT_ID>( std::bind(&tmy_dialog::my_member, this)); This allows simply adding a member of a dialog to be used as a callback for widget without a lot of magic. Note most widgets probably will get a callback like connect_signal_mouse_left_click(const signal_function& callback) which hides this function for the average use.

Template Parameters
EThe event the callback needs to react to.
Parameters
signalThe callback function.
positionThe position to place the callback.

Definition at line 362 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::connect_signal(), and signal_queue_.

Referenced by gui2::group< SCALING_ALGORITHM >::add_member(), connect_queue(), gui2::event::connect_signal_mouse_left_click(), gui2::event::connect_signal_mouse_left_double_click(), gui2::event::connect_signal_notify_modified(), gui2::event::connect_signal_pre_key_press(), gui2::event::distributor::distributor(), gui2::event::mouse_button< T >::mouse_button(), gui2::event::mouse_motion::mouse_motion(), gui2::dialogs::mp_login::pre_show(), gui2::dialogs::end_credits::pre_show(), gui2::dialogs::outro::pre_show(), gui2::dialogs::hotkey_bind::pre_show(), gui2::dialogs::story_viewer::pre_show(), gui2::dialogs::title_screen::pre_show(), and gui2::tree_view_node::tree_view_node().

template<ui_event E>
utils::enable_if_t<has_key<set_event_mouse, E>::value> gui2::event::dispatcher::connect_signal ( const signal_mouse_function signal,
const queue_position  position = back_child 
)
inline

Connect a signal for callback in set_event_mouse.

Template Parameters
EThe event the callback needs to react to.
Parameters
signalThe callback function.
positionThe position to place the callback.

Definition at line 395 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::connect_signal(), and signal_mouse_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_keyboard, E>::value> gui2::event::dispatcher::connect_signal ( const signal_keyboard_function signal,
const queue_position  position = back_child 
)
inline

Connect a signal for callback in set_event_keyboard.

Template Parameters
EThe event the callback needs to react to.
Parameters
signalThe callback function.
positionThe position to place the callback.

Definition at line 428 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::connect_signal(), and signal_keyboard_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_touch, E>::value> gui2::event::dispatcher::connect_signal ( const signal_touch_function signal,
const queue_position  position = back_child 
)
inline

Connect a signal for callback in set_event_touch.

Template Parameters
EThe event the callback needs to react to.
Parameters
signalThe callback function.
positionThe position to place the callback.

Definition at line 461 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::connect_signal(), and signal_touch_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_notification, E>::value> gui2::event::dispatcher::connect_signal ( const signal_notification_function signal,
const queue_position  position = back_child 
)
inline

Connect a signal for callback in set_event_notification.

Template Parameters
EThe event the callback needs to react to.
Parameters
signalThe callback function.
positionThe position to place the callback. Since the message is send to a widget directly the pre and post positions make no sense and shouldn't be used.

Definition at line 497 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::connect_signal(), and signal_notification_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_message, E>::value> gui2::event::dispatcher::connect_signal ( const signal_message_function signal,
const queue_position  position = back_child 
)
inline

Connect a signal for callback in set_event_message.

Template Parameters
EThe event the callback needs to react to.
Parameters
signalThe callback function.
positionThe position to place the callback. Since the message is send to a widget directly the pre and post positions make no sense and shouldn't be used.

Definition at line 538 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::connect_signal(), and signal_message_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_raw_event, E>::value> gui2::event::dispatcher::connect_signal ( const signal_raw_event_function signal,
const queue_position  position = back_child 
)
inline

Connect a signal for callback in set_raw_event.

Template Parameters
EThe event the callback needs to react to.
Parameters
signalThe callback function.
positionThe position to place the callback.

Definition at line 576 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::connect_signal(), and signal_raw_event_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_text_input, E>::value> gui2::event::dispatcher::connect_signal ( const signal_text_input_function signal,
const queue_position  position = back_child 
)
inline

Connect a signal for callback in set_text_input.

Template Parameters
EThe event the callback needs to react to.
Parameters
signalThe callback function.
positionThe position to place the callback.

Definition at line 609 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::connect_signal(), and signal_text_input_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event, E>::value> gui2::event::dispatcher::disconnect_signal ( const signal_function signal,
const queue_position  position = back_child 
)
inline

Disconnect a signal for callback in set_event.

Template Parameters
EThe event the callback was used for.
Parameters
signalThe callback function.
positionThe place where the function was added. Needed remove the event from the right place. (The function doesn't care whether was added in front or back.)

Definition at line 380 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::disconnect_signal(), and signal_queue_.

Referenced by gui2::event::disconnect_signal_mouse_left_click(), gui2::dialogs::debug_clock::post_show(), and gui2::event::distributor::~distributor().

template<ui_event E>
utils::enable_if_t<has_key<set_event_mouse, E>::value> gui2::event::dispatcher::disconnect_signal ( const signal_mouse_function signal,
const queue_position  position = back_child 
)
inline

Disconnect a signal for callback in set_event_mouse.

Template Parameters
EThe event the callback was used for.
Parameters
signalThe callback function.
positionThe place where the function was added. Needed remove the event from the right place. (The function doesn't care whether was added in front or back.)

Definition at line 413 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::disconnect_signal(), and signal_mouse_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_keyboard, E>::value> gui2::event::dispatcher::disconnect_signal ( const signal_keyboard_function signal,
const queue_position  position = back_child 
)
inline

Disconnect a signal for callback in set_event_keyboard.

Template Parameters
EThe event the callback was used for.
Parameters
signalThe callback function.
positionThe place where the function was added. Needed remove the event from the right place. (The function doesn't care whether was added in front or back.)

Definition at line 446 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::disconnect_signal(), and signal_keyboard_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_touch, E>::value> gui2::event::dispatcher::disconnect_signal ( const signal_touch_function signal,
const queue_position  position = back_child 
)
inline

Disconnect a signal for callback in set_event_touch.

Template Parameters
EThe event the callback was used for.
Parameters
signalThe callback function.
positionThe place where the function was added. Needed remove the event from the right place. (The function doesn't care whether was added in front or back.)

Definition at line 479 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::disconnect_signal(), and signal_touch_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_notification, E>::value> gui2::event::dispatcher::disconnect_signal ( const signal_notification_function signal,
const queue_position  position = back_child 
)
inline

Disconnect a signal for callback in set_event_notification.

Template Parameters
EThe event the callback was used for.
Parameters
signalThe callback function.
positionThe place where the function was added. Needed remove the event from the right place. (The function doesn't care whether was added in front or back, but it needs to know the proper queue so it's save to add with front_child and remove with back_child. But it's not save to add with front_child and remove with front_pre_child)

Definition at line 520 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::disconnect_signal(), and signal_notification_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_message, E>::value> gui2::event::dispatcher::disconnect_signal ( const signal_message_function signal,
const queue_position  position = back_child 
)
inline

Disconnect a signal for callback in set_event_message.

Template Parameters
EThe event the callback was used for.
Parameters
signalThe callback function.
positionThe place where the function was added. Needed remove the event from the right place. (The function doesn't care whether was added in front or back, but it needs to know the proper queue so it's save to add with front_child and remove with back_child. But it's not save to add with front_child and remove with front_pre_child)

Definition at line 561 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::disconnect_signal(), and signal_message_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_raw_event, E>::value> gui2::event::dispatcher::disconnect_signal ( const signal_raw_event_function signal,
const queue_position  position = back_child 
)
inline

Disconnect a signal for callback in set_raw_event.

Template Parameters
EThe event the callback was used for.
Parameters
signalThe callback function.
positionThe place where the function was added. Needed remove the event from the right place. (The function doesn't care whether was added in front or back.)

Definition at line 594 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::disconnect_signal(), and signal_raw_event_queue_.

template<ui_event E>
utils::enable_if_t<has_key<set_event_text_input, E>::value> gui2::event::dispatcher::disconnect_signal ( const signal_text_input_function signal,
const queue_position  position = back_child 
)
inline

Disconnect a signal for callback in set_text_input.

Template Parameters
EThe event the callback was used for.
Parameters
signalThe callback function.
positionThe place where the function was added. Needed remove the event from the right place. (The function doesn't care whether was added in front or back.)

Definition at line 627 of file dispatcher.hpp.

References gui2::event::dispatcher::signal_queue< T >::disconnect_signal(), and signal_text_input_queue_.

bool gui2::event::dispatcher::execute_hotkey ( const hotkey::HOTKEY_COMMAND  id)

Executes a hotkey.

Parameters
idThe hotkey to execute.
Returns
true if the hotkey is handled, false otherwise.

Definition at line 193 of file dispatcher.cpp.

References hotkeys_.

Referenced by gui2::event::sdl_event_handler::hotkey_pressed().

bool gui2::event::dispatcher::fire ( const ui_event  event,
widget target 
)

Fires an event which has no extra parameters.

Definition at line 120 of file dispatcher.cpp.

References gui2::event::fire_event_double_click(), gui2::event::LEFT_BUTTON_CLICK, gui2::event::LEFT_BUTTON_DOUBLE_CLICK, gui2::event::MIDDLE_BUTTON_CLICK, gui2::event::MIDDLE_BUTTON_DOUBLE_CLICK, gui2::event::RIGHT_BUTTON_CLICK, gui2::event::RIGHT_BUTTON_DOUBLE_CLICK, gui2::event_executor::wants_mouse_left_double_click(), gui2::event_executor::wants_mouse_middle_double_click(), and gui2::event_executor::wants_mouse_right_double_click().

Referenced by gui2::event::sdl_event_handler::activate(), BOOST_AUTO_TEST_CASE(), gui2::event::sdl_event_handler::close_window(), gui2::scrollbar_container::content_resize_request(), gui2::pane::create_item(), gui2::event::sdl_event_handler::draw(), gui2::text_box_base::handle_commit(), gui2::text_box_base::handle_key_backspace(), gui2::text_box_base::handle_key_delete(), gui2::event::sdl_event_handler::key_down(), gui2::event::sdl_event_handler::keyboard(), gui2::event::distributor::keyboard_capture(), gui2::listbox::list_item_clicked(), gui2::event::sdl_event_handler::mouse(), gui2::event::mouse_motion::mouse_enter(), gui2::event::mouse_motion::mouse_hover(), gui2::event::mouse_motion::mouse_leave(), gui2::scrollbar_base::move_positioner(), gui2::text_box_base::paste_selection(), gui2::event::sdl_event_handler::raw_event(), gui2::scrollbar_base::scroll(), gui2::slider_base::scroll(), gui2::grid::set_child_alignment(), gui2::scrollbar_base::set_item_position(), gui2::listbox::set_row_shown(), gui2::menu_button::set_selected(), gui2::slider::set_value(), gui2::toggle_button::set_value(), gui2::toggle_panel::set_value(), gui2::widget::set_visible(), gui2::event::mouse_motion::show_tooltip(), gui2::event::distributor::signal_handler_keyboard_internal(), gui2::tree_view_node::signal_handler_left_button_click(), gui2::repeating_button::signal_handler_left_button_down(), gui2::toggle_panel::signal_handler_pre_left_button_click(), gui2::event::mouse_motion::signal_handler_sdl_mouse_motion(), gui2::event::mouse_motion::signal_handler_sdl_wheel(), gui2::event::mouse_motion::signal_handler_show_helptip(), gui2::styled_widget::signal_handler_show_helptip(), gui2::styled_widget::signal_handler_show_tooltip(), gui2::event::sdl_event_handler::text_editing(), gui2::event::sdl_event_handler::text_input(), gui2::multimenu_button::toggle_state_changed(), gui2::event::sdl_event_handler::touch_motion(), gui2::slider_base::update_slider_position(), gui2::listbox::update_visible_area_on_key_event(), gui2::event::sdl_event_handler::video_resize(), and gui2::widget::~widget().

bool gui2::event::dispatcher::fire ( const ui_event  event,
widget target,
const point coordinate 
)

Fires an event which takes a coordinate parameter.

Parameters
eventThe event to fire.
targetThe widget that should receive the event.
coordinateThe mouse position for the event.

Definition at line 141 of file dispatcher.cpp.

bool gui2::event::dispatcher::fire ( const ui_event  event,
widget target,
const SDL_Keycode  key,
const SDL_Keymod  modifier,
const utf8::string unicode 
)

Fires an event which takes keyboard parameters.

Parameters
eventThe event to fire.
targetThe widget that should receive the event.
keyThe SDL key code of the key pressed.
modifierThe SDL key modifiers used.
unicodeThe unicode value for the key pressed.

Definition at line 147 of file dispatcher.cpp.

bool gui2::event::dispatcher::fire ( const ui_event  event,
widget target,
const point pos,
const point distance 
)

Fires an event which takes touch parameters.

Parameters
eventThe event to fire.
targetThe widget that should receive the event.
posThe location touched.
distanceThe distance moved.

Definition at line 169 of file dispatcher.cpp.

bool gui2::event::dispatcher::fire ( const ui_event  event,
widget target,
void *   
)

Fires an event which takes notification parameters.

Note
the void* parameter is a dummy needed for SFINAE.
Parameters
eventThe event to fire.
targetThe widget that should receive the event.

Definition at line 175 of file dispatcher.cpp.

bool gui2::event::dispatcher::fire ( const ui_event  event,
widget target,
message msg 
)

Fires an event which takes message parameters.

Parameters
eventThe event to fire.
targetThe widget that should receive the event. Normally this is the window holding the widget.
msgThe extra information needed for a window (or another widget in the chain) to handle the message.

Definition at line 182 of file dispatcher.cpp.

References wfl::msg().

bool gui2::event::dispatcher::fire ( const ui_event  event,
widget target,
const SDL_Event &  sdlevent 
)

Fires an event that's a raw SDL event.

Parameters
eventThe event to fire.
targetThe widget that should receive the event. Normally this is the window holding the widget.
sdleventThe raw SDL event

Definition at line 157 of file dispatcher.cpp.

bool gui2::event::dispatcher::fire ( const ui_event  event,
widget target,
const std::string &  text,
int32_t  start,
int32_t  len 
)

Fires an event which takes text input parameters.

Parameters
eventThe event to fire.
targetThe widget that should receive the event. Normally this is the window holding the widget.
textThe text involved in the event
startThe start point for IME editing
lenThe selection length for IME editing

Definition at line 163 of file dispatcher.cpp.

References editor::start().

mouse_behavior gui2::event::dispatcher::get_mouse_behavior ( ) const
inline

Definition at line 675 of file dispatcher.hpp.

References mouse_behavior_.

Referenced by gui2::event::sdl_event_handler::mouse().

bool gui2::event::dispatcher::get_want_keyboard_input ( ) const
inline
bool gui2::event::dispatcher::has_event ( const ui_event  event,
const event_queue_type  event_type 
)
virtual bool gui2::event::dispatcher::is_at ( const point coordinate) const
pure virtual

Determines whether the location is inside an active widget.

This is used to see whether a mouse event is inside the widget.

Parameters
coordinateThe coordinate to test whether inside the widget.
Returns
True if inside an active widget, false otherwise.

Implemented in gui2::widget.

Referenced by gui2::event::sdl_event_handler::mouse().

void gui2::event::dispatcher::register_hotkey ( const hotkey::HOTKEY_COMMAND  id,
const hotkey_function function 
)

Registers a hotkey.

Todo:
add a static function register_global_hotkey.

Once that's done execute_hotkey will first try to execute a global hotkey and if that fails tries the hotkeys in this dispatcher.

Parameters
idThe hotkey to register.
functionThe callback function to call.

Definition at line 188 of file dispatcher.cpp.

References hotkeys_.

Referenced by gui2::dialogs::mp_lobby::post_build(), gui2::dialogs::title_screen::pre_show(), and gui2::dialogs::register_button().

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

Releases the mouse capture.

Definition at line 663 of file dispatcher.hpp.

References gui2::event::release_mouse().

void gui2::event::dispatcher::set_mouse_behavior ( const mouse_behavior  mouse_behavior)
inline

Definition at line 670 of file dispatcher.hpp.

References mouse_behavior_.

Referenced by gui2::window::show_non_modal(), and gui2::window::show_tooltip().

void gui2::event::dispatcher::set_want_keyboard_input ( const bool  want_keyboard_input)
inline

Definition at line 680 of file dispatcher.hpp.

References want_keyboard_input_.

Referenced by gui2::window::show_tooltip().

Friends And Related Function Documentation

friend struct dispatcher_implementation
friend

Definition at line 162 of file dispatcher.hpp.

Member Data Documentation

bool gui2::event::dispatcher::connected_
private

Are we connected to the event handler.

Definition at line 844 of file dispatcher.hpp.

Referenced by connect(), and ~dispatcher().

std::map<hotkey::HOTKEY_COMMAND, hotkey_function> gui2::event::dispatcher::hotkeys_
private

The registered hotkeys for this dispatcher.

Definition at line 847 of file dispatcher.hpp.

Referenced by execute_hotkey(), and register_hotkey().

mouse_behavior gui2::event::dispatcher::mouse_behavior_
private

The mouse behavior for the dispatcher.

Definition at line 805 of file dispatcher.hpp.

Referenced by get_mouse_behavior(), and set_mouse_behavior().

signal_queue<signal_keyboard_function> gui2::event::dispatcher::signal_keyboard_queue_
private

Signal queue for callbacks in set_event_keyboard.

Definition at line 826 of file dispatcher.hpp.

Referenced by connect_signal(), and disconnect_signal().

signal_queue<signal_message_function> gui2::event::dispatcher::signal_message_queue_
private

Signal queue for callbacks in set_event_message.

Definition at line 835 of file dispatcher.hpp.

Referenced by connect_signal(), and disconnect_signal().

signal_queue<signal_mouse_function> gui2::event::dispatcher::signal_mouse_queue_
private

Signal queue for callbacks in set_event_mouse.

Definition at line 823 of file dispatcher.hpp.

Referenced by connect_signal(), and disconnect_signal().

signal_queue<signal_notification_function> gui2::event::dispatcher::signal_notification_queue_
private

Signal queue for callbacks in set_event_notification.

Definition at line 832 of file dispatcher.hpp.

Referenced by connect_signal(), and disconnect_signal().

signal_queue<signal_function> gui2::event::dispatcher::signal_queue_
private

Signal queue for callbacks in set_event.

Definition at line 820 of file dispatcher.hpp.

Referenced by connect_signal(), and disconnect_signal().

signal_queue<signal_raw_event_function> gui2::event::dispatcher::signal_raw_event_queue_
private

Signal queue for callbacks in set_raw_event.

Definition at line 838 of file dispatcher.hpp.

Referenced by connect_signal(), and disconnect_signal().

signal_queue<signal_text_input_function> gui2::event::dispatcher::signal_text_input_queue_
private

Signal queue for callbacks in set_event_text_input.

Definition at line 841 of file dispatcher.hpp.

Referenced by connect_signal(), and disconnect_signal().

signal_queue<signal_touch_function> gui2::event::dispatcher::signal_touch_queue_
private

Signal queue for callbacks in set_event_touch.

Definition at line 829 of file dispatcher.hpp.

Referenced by connect_signal(), and disconnect_signal().

bool gui2::event::dispatcher::want_keyboard_input_
private

Does the dispatcher want to receive keyboard input.

Todo:
The entire mouse and keyboard handling can use a code review to seen whether it might be combined in one flag field. At the moment the keyboard doesn't look whether a dialog has the mouse focus before sending the event, so maybe we should add an active dispatcher to keep track of it. But since at the moment there are only non-modal windows and tooltips it's not a problem.

Definition at line 817 of file dispatcher.hpp.

Referenced by get_want_keyboard_input(), and set_want_keyboard_input().


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