The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
gui2::event Namespace Reference

Namespaces

 implementation
 Contains the implementation details of the find function.
 

Classes

class  dispatcher
 Base class for event handling. More...
 
struct  dispatcher_implementation
 
class  distributor
 The event handler class for the widget library. More...
 
class  event_in_set
 Helper class to do a runtime test whether an event is in a set. More...
 
class  manager
 
struct  message
 The message callbacks hold a reference to a message. More...
 
struct  message_show_helptip
 The message for MESSAGE_SHOW_HELPTIP. More...
 
struct  message_show_tooltip
 The message for MESSAGE_SHOW_TOOLTIP. More...
 
class  mouse_button
 
struct  mouse_button_event_types_wrapper
 Small helper metastruct to specialize mouse_button with and provide ui_event type aliases without needing to make mouse_button take a million template types. More...
 
class  mouse_motion
 
class  resource_locker
 SDL_AddTimer() callback for the hover event. More...
 
class  sdl_event_handler
 This singleton class handles all events. More...
 

Typedefs

template<typename K , ui_event E>
using has_key = boost::mpl::has_key< K, boost::mpl::int_< E >>
 
typedef std::function< void(widget
&dispatcher, const ui_event
event, bool &handled, bool
&halt)> 
signal_function
 Callback function signature. More...
 
typedef std::function< void(widget
&dispatcher, const ui_event
event, bool &handled, bool
&halt, const point &coordinate)> 
signal_mouse_function
 Callback function signature. More...
 
typedef std::function< void(widget
&dispatcher, const ui_event
event, bool &handled, bool
&halt, const SDL_Keycode key,
const SDL_Keymod modifier,
const utf8::string &unicode)> 
signal_keyboard_function
 Callback function signature. More...
 
typedef std::function< void(widget
&dispatcher, const ui_event
event, bool &handled, bool
&halt, const point &pos, const
point &distance)> 
signal_touch_function
 Callback function signature. More...
 
typedef std::function< void(widget
&dispatcher, const ui_event
event, bool &handled, bool
&halt, void *)> 
signal_notification_function
 Callback function signature. More...
 
typedef std::function< void(widget
&dispatcher, const ui_event
event, bool &handled, bool
&halt, message &message)> 
signal_message_function
 Callback function signature. More...
 
typedef std::function< void(widget
&dispatcher, const ui_event
event, bool &handled, bool
&halt, const SDL_Event
&sdlevent)> 
signal_raw_event_function
 Callback function signature. More...
 
typedef std::function< void(widget
&dispatcher, const ui_event
event, bool &handled, bool
&halt, const std::string &text,
int32_t current_pos, int32_t
select_len)> 
signal_text_input_function
 Callback function signature. More...
 
typedef std::function< bool(widget
&dispatcher,
hotkey::HOTKEY_COMMAND id)> 
hotkey_function
 Hotkey function handler signature. More...
 
using mouse_button_left = mouse_button< mouse_button_event_types_wrapper< SDL_LEFT_BUTTON_DOWN, SDL_LEFT_BUTTON_UP, LEFT_BUTTON_DOWN, LEFT_BUTTON_UP, LEFT_BUTTON_CLICK, LEFT_BUTTON_DOUBLE_CLICK > >
 
using mouse_button_middle = mouse_button< mouse_button_event_types_wrapper< SDL_MIDDLE_BUTTON_DOWN, SDL_MIDDLE_BUTTON_UP, MIDDLE_BUTTON_DOWN, MIDDLE_BUTTON_UP, MIDDLE_BUTTON_CLICK, MIDDLE_BUTTON_DOUBLE_CLICK > >
 
using mouse_button_right = mouse_button< mouse_button_event_types_wrapper< SDL_RIGHT_BUTTON_DOWN, SDL_RIGHT_BUTTON_UP, RIGHT_BUTTON_DOWN, RIGHT_BUTTON_UP, RIGHT_BUTTON_CLICK, RIGHT_BUTTON_DOUBLE_CLICK > >
 
typedef boost::mpl::set
< boost::mpl::int_< DRAW >
, boost::mpl::int_
< CLOSE_WINDOW >
, boost::mpl::int_
< MOUSE_ENTER >
, boost::mpl::int_
< MOUSE_LEAVE >
, boost::mpl::int_
< LEFT_BUTTON_DOWN >
, boost::mpl::int_
< LEFT_BUTTON_UP >
, boost::mpl::int_
< LEFT_BUTTON_CLICK >
, boost::mpl::int_
< LEFT_BUTTON_DOUBLE_CLICK >
, boost::mpl::int_
< MIDDLE_BUTTON_DOWN >
, boost::mpl::int_
< MIDDLE_BUTTON_UP >
, boost::mpl::int_
< MIDDLE_BUTTON_CLICK >
, boost::mpl::int_
< MIDDLE_BUTTON_DOUBLE_CLICK >
, boost::mpl::int_
< RIGHT_BUTTON_DOWN >
, boost::mpl::int_
< RIGHT_BUTTON_UP >
, boost::mpl::int_
< RIGHT_BUTTON_CLICK >
, boost::mpl::int_
< RIGHT_BUTTON_DOUBLE_CLICK > > 
set_event
 Helper for catching use error of dispatcher::connect_signal. More...
 
typedef boost::mpl::set
< boost::mpl::int_
< SDL_VIDEO_RESIZE >
, boost::mpl::int_
< SDL_MOUSE_MOTION >
, boost::mpl::int_
< MOUSE_MOTION >
, boost::mpl::int_
< SDL_LEFT_BUTTON_DOWN >
, boost::mpl::int_
< SDL_LEFT_BUTTON_UP >
, boost::mpl::int_
< SDL_MIDDLE_BUTTON_DOWN >
, boost::mpl::int_
< SDL_MIDDLE_BUTTON_UP >
, boost::mpl::int_
< SDL_RIGHT_BUTTON_DOWN >
, boost::mpl::int_
< SDL_RIGHT_BUTTON_UP >
, boost::mpl::int_
< SHOW_TOOLTIP >
, boost::mpl::int_
< SHOW_HELPTIP >
, boost::mpl::int_
< SDL_WHEEL_UP >
, boost::mpl::int_
< SDL_WHEEL_DOWN >
, boost::mpl::int_
< SDL_WHEEL_LEFT >
, boost::mpl::int_
< SDL_WHEEL_RIGHT > > 
set_event_mouse
 Helper for catching use error of dispatcher::connect_signal. More...
 
typedef boost::mpl::set
< boost::mpl::int_
< SDL_KEY_DOWN > > 
set_event_keyboard
 Helper for catching use error of dispatcher::connect_signal. More...
 
typedef boost::mpl::set
< boost::mpl::int_
< SDL_TOUCH_MOTION >
, boost::mpl::int_
< SDL_TOUCH_UP >
, boost::mpl::int_
< SDL_TOUCH_DOWN > > 
set_event_touch
 Helper for catching use error of dispatcher::connect_signal. More...
 
typedef boost::mpl::set
< boost::mpl::int_
< NOTIFY_REMOVAL >
, boost::mpl::int_
< NOTIFY_MODIFIED >
, boost::mpl::int_
< RECEIVE_KEYBOARD_FOCUS >
, boost::mpl::int_
< LOSE_KEYBOARD_FOCUS >
, boost::mpl::int_
< NOTIFY_REMOVE_TOOLTIP >
, boost::mpl::int_
< SDL_ACTIVATE > > 
set_event_notification
 Helper for catching use error of dispatcher::connect_signal. More...
 
typedef boost::mpl::set
< boost::mpl::int_
< MESSAGE_SHOW_TOOLTIP >
, boost::mpl::int_
< MESSAGE_SHOW_HELPTIP >
, boost::mpl::int_
< REQUEST_PLACEMENT > > 
set_event_message
 Helper for catching use error of dispatcher::connect_signal. More...
 
typedef boost::mpl::set
< boost::mpl::int_
< SDL_RAW_EVENT > > 
set_event_raw_event
 Helper for catching use error of dispatcher::connect_signal. More...
 
typedef boost::mpl::set
< boost::mpl::int_
< SDL_TEXT_INPUT >
, boost::mpl::int_
< SDL_TEXT_EDITING > > 
set_event_text_input
 Helper for catching use error of dispatcher::connect_signal. More...
 

Enumerations

enum  ui_event {
  SDL_ACTIVATE, DRAW, CLOSE_WINDOW, SDL_VIDEO_RESIZE,
  SDL_MOUSE_MOTION, MOUSE_ENTER, MOUSE_MOTION, MOUSE_LEAVE,
  SDL_LEFT_BUTTON_DOWN, SDL_LEFT_BUTTON_UP, LEFT_BUTTON_DOWN, LEFT_BUTTON_UP,
  LEFT_BUTTON_CLICK, LEFT_BUTTON_DOUBLE_CLICK, SDL_MIDDLE_BUTTON_DOWN, SDL_MIDDLE_BUTTON_UP,
  MIDDLE_BUTTON_DOWN, MIDDLE_BUTTON_UP, MIDDLE_BUTTON_CLICK, MIDDLE_BUTTON_DOUBLE_CLICK,
  SDL_RIGHT_BUTTON_DOWN, SDL_RIGHT_BUTTON_UP, RIGHT_BUTTON_DOWN, RIGHT_BUTTON_UP,
  RIGHT_BUTTON_CLICK, RIGHT_BUTTON_DOUBLE_CLICK, SDL_WHEEL_LEFT, SDL_WHEEL_RIGHT,
  SDL_WHEEL_UP, SDL_WHEEL_DOWN, SDL_KEY_DOWN, SDL_TEXT_INPUT,
  SDL_TEXT_EDITING, NOTIFY_REMOVAL, NOTIFY_MODIFIED, REQUEST_PLACEMENT,
  RECEIVE_KEYBOARD_FOCUS, LOSE_KEYBOARD_FOCUS, SHOW_TOOLTIP, NOTIFY_REMOVE_TOOLTIP,
  MESSAGE_SHOW_TOOLTIP, SHOW_HELPTIP, MESSAGE_SHOW_HELPTIP, SDL_TOUCH_MOTION,
  SDL_TOUCH_UP, SDL_TOUCH_DOWN, SDL_RAW_EVENT
}
 The event send to the dispatcher. More...
 

Functions

void connect_signal_pre_key_press (dispatcher &dispatcher, const signal_keyboard_function &signal)
 Connects the signal for 'snooping' on the keypress. More...
 
void connect_signal_mouse_left_click (dispatcher &dispatcher, const signal_function &signal)
 Connects a signal handler for a left mouse button click. More...
 
void disconnect_signal_mouse_left_click (dispatcher &dispatcher, const signal_function &signal)
 Disconnects a signal handler for a left mouse button click. More...
 
void connect_signal_mouse_left_double_click (dispatcher &dispatcher, const signal_function &signal)
 Connects a signal handler for a left mouse button double click. More...
 
void connect_signal_notify_modified (dispatcher &dispatcher, const signal_notification_function &signal)
 Connects a signal handler for getting a notification upon modification. More...
 
template<typename sequence , typename E , typename F >
bool find (E event, F functor)
 Tests whether an event handler is available. More...
 
template<typename T , 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 T , 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...
 
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)
 

Variables

static std::unique_ptr< class
sdl_event_handler
handler_ = nullptr
 
static events::event_contextevent_context = nullptr
 

Typedef Documentation

template<typename K , ui_event E>
using gui2::event::has_key = typedef boost::mpl::has_key<K, boost::mpl::int_<E>>

Definition at line 42 of file dispatcher.hpp.

Hotkey function handler signature.

Definition at line 144 of file dispatcher.hpp.

Definition at line 235 of file distributor.hpp.

Definition at line 245 of file distributor.hpp.

Definition at line 255 of file distributor.hpp.

typedef boost::mpl::set<boost::mpl::int_<DRAW>, boost::mpl::int_<CLOSE_WINDOW>, boost::mpl::int_<MOUSE_ENTER>, boost::mpl::int_<MOUSE_LEAVE>, boost::mpl::int_<LEFT_BUTTON_DOWN>, boost::mpl::int_<LEFT_BUTTON_UP>, boost::mpl::int_<LEFT_BUTTON_CLICK>, boost::mpl::int_<LEFT_BUTTON_DOUBLE_CLICK>, boost::mpl::int_<MIDDLE_BUTTON_DOWN>, boost::mpl::int_<MIDDLE_BUTTON_UP>, boost::mpl::int_<MIDDLE_BUTTON_CLICK>, boost::mpl::int_<MIDDLE_BUTTON_DOUBLE_CLICK>, boost::mpl::int_<RIGHT_BUTTON_DOWN>, boost::mpl::int_<RIGHT_BUTTON_UP>, boost::mpl::int_<RIGHT_BUTTON_CLICK>, boost::mpl::int_<RIGHT_BUTTON_DOUBLE_CLICK> > gui2::event::set_event

Helper for catching use error of dispatcher::connect_signal.

This helper is needed as a user can't supply the wrong kind of callback functions to dispatcher::connect_signal. If a wrong callback would be send it will never get called.

This version is for callbacks without extra parameters. NOTE some mouse functions like MOUSE_ENTER don't send the mouse coordinates to the callback function so they are also in this category.

Definition at line 150 of file handler.hpp.

typedef boost::mpl::set<boost::mpl::int_<SDL_KEY_DOWN> > gui2::event::set_event_keyboard

Helper for catching use error of dispatcher::connect_signal.

This version is for callbacks with the keyboard values (these haven't been determined yet).

Definition at line 179 of file handler.hpp.

typedef boost::mpl::set<boost::mpl::int_<MESSAGE_SHOW_TOOLTIP>, boost::mpl::int_<MESSAGE_SHOW_HELPTIP>, boost::mpl::int_<REQUEST_PLACEMENT> > gui2::event::set_event_message

Helper for catching use error of dispatcher::connect_signal.

This version is for callbacks with a sender aka notification messages. Unlike the notifications this message is send through the chain. The event is send from a widget all the way up to the window, who always is the receiver of the message (unless somebody grabbed it before).

Definition at line 218 of file handler.hpp.

typedef boost::mpl::set<boost::mpl::int_<SDL_VIDEO_RESIZE>, boost::mpl::int_<SDL_MOUSE_MOTION>, boost::mpl::int_<MOUSE_MOTION>, boost::mpl::int_<SDL_LEFT_BUTTON_DOWN>, boost::mpl::int_<SDL_LEFT_BUTTON_UP>, boost::mpl::int_<SDL_MIDDLE_BUTTON_DOWN>, boost::mpl::int_<SDL_MIDDLE_BUTTON_UP>, boost::mpl::int_<SDL_RIGHT_BUTTON_DOWN>, boost::mpl::int_<SDL_RIGHT_BUTTON_UP>, boost::mpl::int_<SHOW_TOOLTIP>, boost::mpl::int_<SHOW_HELPTIP>, boost::mpl::int_<SDL_WHEEL_UP>, boost::mpl::int_<SDL_WHEEL_DOWN>, boost::mpl::int_<SDL_WHEEL_LEFT>, boost::mpl::int_<SDL_WHEEL_RIGHT> > gui2::event::set_event_mouse

Helper for catching use error of dispatcher::connect_signal.

This version is for callbacks with a coordinate as extra parameter.

Definition at line 171 of file handler.hpp.

typedef boost::mpl::set<boost::mpl::int_<NOTIFY_REMOVAL>, boost::mpl::int_<NOTIFY_MODIFIED>, boost::mpl::int_<RECEIVE_KEYBOARD_FOCUS>, boost::mpl::int_<LOSE_KEYBOARD_FOCUS>, boost::mpl::int_<NOTIFY_REMOVE_TOOLTIP>, boost::mpl::int_<SDL_ACTIVATE> > gui2::event::set_event_notification

Helper for catching use error of dispatcher::connect_signal.

This version is for callbacks with a sender aka notification messages. Like the ones in set_event it has no extra parameters, but this version is only send to the target and not using the pre and post queue.

Definition at line 205 of file handler.hpp.

typedef boost::mpl::set<boost::mpl::int_<SDL_RAW_EVENT> > gui2::event::set_event_raw_event

Helper for catching use error of dispatcher::connect_signal.

This version is for callbacks of raw events.

Definition at line 225 of file handler.hpp.

typedef boost::mpl::set<boost::mpl::int_<SDL_TEXT_INPUT>, boost::mpl::int_<SDL_TEXT_EDITING> > gui2::event::set_event_text_input

Helper for catching use error of dispatcher::connect_signal.

This version is for callbacks of text input events.

Definition at line 234 of file handler.hpp.

typedef boost::mpl::set<boost::mpl::int_<SDL_TOUCH_MOTION>, boost::mpl::int_<SDL_TOUCH_UP>, boost::mpl::int_<SDL_TOUCH_DOWN> > gui2::event::set_event_touch

Helper for catching use error of dispatcher::connect_signal.

This version is for callbacks of touch events.

Definition at line 189 of file handler.hpp.

typedef std::function<void(widget& dispatcher, const ui_event event, bool& handled, bool& halt)> gui2::event::signal_function

Callback function signature.

There are several kinds of callback signature, this only has the parameters shared by all callbacks.

This function is used for the callbacks in set_event.

Definition at line 44 of file dispatcher.hpp.

typedef std::function<void(widget& dispatcher, const ui_event event, bool& handled, bool& halt, const SDL_Keycode key, const SDL_Keymod modifier, const utf8::string& unicode)> gui2::event::signal_keyboard_function

Callback function signature.

This function is used for the callbacks in set_event_keyboard.

Definition at line 80 of file dispatcher.hpp.

typedef std::function<void(widget& dispatcher, const ui_event event, bool& handled, bool& halt, message& message)> gui2::event::signal_message_function

Callback function signature.

This function is used for the callbacks in set_event_message.

Definition at line 116 of file dispatcher.hpp.

typedef std::function<void(widget& dispatcher, const ui_event event, bool& handled, bool& halt, const point& coordinate)> gui2::event::signal_mouse_function

Callback function signature.

This function is used for the callbacks in set_event_mouse.

Definition at line 67 of file dispatcher.hpp.

typedef std::function<void(widget& dispatcher, const ui_event event, bool& handled, bool& halt, void*)> gui2::event::signal_notification_function

Callback function signature.

This function is used for the callbacks in set_event_notification. Added the dummy void* parameter which will be nullptr to get a different signature as signal_function's callback.

Definition at line 105 of file dispatcher.hpp.

typedef std::function<void(widget& dispatcher, const ui_event event, bool& handled, bool& halt, const SDL_Event& sdlevent)> gui2::event::signal_raw_event_function

Callback function signature.

This function is used for the callbacks in set_event_raw_event.

Definition at line 127 of file dispatcher.hpp.

typedef std::function<void(widget& dispatcher, const ui_event event, bool& handled, bool& halt, const std::string& text, int32_t current_pos, int32_t select_len)> gui2::event::signal_text_input_function

Callback function signature.

This function is used for the callbacks in set_event_text_input.

Definition at line 140 of file dispatcher.hpp.

typedef std::function<void(widget& dispatcher, const ui_event event, bool& handled, bool& halt, const point& pos, const point& distance)> gui2::event::signal_touch_function

Callback function signature.

This function is used for the callbacks in set_event_touch.

Definition at line 92 of file dispatcher.hpp.

Enumeration Type Documentation

The event send 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
SDL_ACTIVATE 

The main application window is activated.

DRAW 

Periodic redraw request.

CLOSE_WINDOW 

A request to close the current window.

SDL_VIDEO_RESIZE 

An SDL resize request, coordinate is the new window size.

SDL_MOUSE_MOTION 

An SDL mouse motion event.

MOUSE_ENTER 

A mouse enter event for a widget.

MOUSE_MOTION 

A mouse motion event for a widget.

MOUSE_LEAVE 

A mouse leave event for a widget.

SDL_LEFT_BUTTON_DOWN 

An SDL left mouse button down event.

SDL_LEFT_BUTTON_UP 

An SDL left mouse button up event.

LEFT_BUTTON_DOWN 

A left mouse button down event for a widget.

LEFT_BUTTON_UP 

A left mouse button up event for a widget.

LEFT_BUTTON_CLICK 

A left mouse button click event for a widget.

LEFT_BUTTON_DOUBLE_CLICK 

A left mouse button double click event for a widget.

SDL_MIDDLE_BUTTON_DOWN 

An SDL middle mouse button down event.

SDL_MIDDLE_BUTTON_UP 

An SDL middle mouse button up event.

MIDDLE_BUTTON_DOWN 

See LEFT_BUTTON_DOWN.

MIDDLE_BUTTON_UP 

See LEFT_BUTTON_UP.

MIDDLE_BUTTON_CLICK 

See LEFT_BUTTON_CLICK.

MIDDLE_BUTTON_DOUBLE_CLICK 

See LEFT_BUTTON_DOUBLE_CLICK.

SDL_RIGHT_BUTTON_DOWN 

An SDL right mouse button down event.

SDL_RIGHT_BUTTON_UP 

An SDL right mouse button up event.

RIGHT_BUTTON_DOWN 

See LEFT_BUTTON_DOWN.

RIGHT_BUTTON_UP 

See LEFT_BUTTON_UP.

RIGHT_BUTTON_CLICK 

See LEFT_BUTTON_CLICK.

RIGHT_BUTTON_DOUBLE_CLICK 

See LEFT_BUTTON_DOUBLE_CLICK.

SDL_WHEEL_LEFT 

An SDL wheel left event.

SDL_WHEEL_RIGHT 

An SDL wheel right event.

SDL_WHEEL_UP 

An SDL wheel up event.

SDL_WHEEL_DOWN 

An SDL wheel down event.

SDL_KEY_DOWN 

An SDL key down event.

SDL_TEXT_INPUT 

An SDL text input (commit) event.

SDL_TEXT_EDITING 

An SDL text editing (IME) event.

NOTIFY_REMOVAL 

Sent by a widget to notify others it's being destroyed.

NOTIFY_MODIFIED 

Sent by a widget to notify others its contents or state are modified.

What modified means is documented per widget. If not documented the request means nothing.

REQUEST_PLACEMENT 

Request to place the widget.

This may also trigger an update of other layout components.

RECEIVE_KEYBOARD_FOCUS 

Widget gains keyboard focus.

LOSE_KEYBOARD_FOCUS 

Widget loses keyboard focus.

SHOW_TOOLTIP 

Request the widget to show its hover tooltip.

NOTIFY_REMOVE_TOOLTIP 

Request the widget to remove its hover tooltip.

MESSAGE_SHOW_TOOLTIP 

Request to show a tooltip based on the data sent.

SHOW_HELPTIP 

Request the widget to show its hover helptip.

MESSAGE_SHOW_HELPTIP 

Request to show a helptip based on the data sent.

SDL_TOUCH_MOTION 
SDL_TOUCH_UP 
SDL_TOUCH_DOWN 
SDL_RAW_EVENT 

Raw SDL event.

Definition at line 55 of file handler.hpp.

Function Documentation

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 866 of file handler.cpp.

References gui2::event::dispatcher::get_want_keyboard_input(), and gui2::event::sdl_event_handler::keyboard_focus_.

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 850 of file handler.cpp.

References gui2::event::sdl_event_handler::mouse_focus.

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

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

Connects a dispatcher to the event handler.

Parameters
dispatcherThe dispatcher to connect.

Definition at line 823 of file handler.cpp.

References gui2::event::sdl_event_handler::connect().

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

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

Connects a signal handler for a left mouse button click.

Definition at line 209 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::mp_lobby::adjust_game_row_contents(), gui2::dialogs::chat_log::view::bind(), gui2::dialogs::lua_interpreter::controller::bind(), gui2::dialogs::gamestate_inspector::controller::bind(), gui2::button::connect_click_handler(), gui2::menu_button::connect_click_handler(), gui2::multimenu_button::connect_click_handler(), gui2::dialogs::mp_options_helper::display_custom_options(), gui2::unit_preview_pane::finalize_setup(), gui2::window::layout(), gui2::dialogs::preferences_dialog::post_build(), gui2::dialogs::mp_connect::pre_show(), gui2::dialogs::formula_debugger::pre_show(), gui2::dialogs::synched_choice_wait::pre_show(), gui2::dialogs::unit_advance::pre_show(), gui2::dialogs::unit_recruit::pre_show(), gui2::dialogs::mp_alerts_options::pre_show(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::lobby_player_info::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::custom_tod::pre_show(), gui2::dialogs::game_load::pre_show(), gui2::dialogs::select_orb_colors::pre_show(), gui2::dialogs::story_viewer::pre_show(), gui2::dialogs::addon_connect::pre_show(), gui2::dialogs::screenshot_notification::pre_show(), gui2::dialogs::editor_generate_map::pre_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::game_cache_options::pre_show(), gui2::dialogs::wml_error::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::mp_lobby::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::dialogs::register_button(), gui2::chatbox::search_create_window(), gui2::addon_list::set_addons(), gui2::dialogs::select_orb_colors::setup_orb_group(), and gui2::dialogs::setup_pref_toggle_button().

void gui2::event::connect_signal_mouse_left_double_click ( dispatcher &  dispatcher,
const signal_function &  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 219 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::dialogs::mp_lobby::update_playerlist().

void gui2::event::connect_signal_notify_modified ( dispatcher &  dispatcher,
const signal_notification_function &  signal 
)

Connects a signal handler for getting a notification upon modification.

Definition at line 224 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::bind_status_label(), gui2::dialogs::mp_options_helper::display_custom_options(), 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_tabs(), lua_gui2::intf_set_dialog_callback(), gui2::dialogs::preferences_dialog::post_build(), gui2::dialogs::generator_settings::pre_show(), gui2::dialogs::unit_advance::pre_show(), gui2::dialogs::unit_recruit::pre_show(), gui2::dialogs::mp_change_control::pre_show(), gui2::dialogs::label_settings::pre_show(), gui2::dialogs::statistics_dialog::pre_show(), gui2::dialogs::faction_select::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::core_selection::pre_show(), gui2::dialogs::custom_tod::pre_show(), gui2::dialogs::game_load::pre_show(), gui2::dialogs::editor_generate_map::pre_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::unit_list::pre_show(), gui2::dialogs::game_stats::pre_show(), gui2::dialogs::unit_create::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::drop_down_menu::pre_show(), gui2::dialogs::preferences_dialog::pre_show(), gui2::dialogs::editor_resize_map::pre_show(), gui2::dialogs::mp_lobby::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::group< SCALING_ALGORITHM >::set_callback_on_value_change(), and gui2::addon_list::set_modified_signal_handler().

void gui2::event::connect_signal_pre_key_press ( dispatcher &  dispatcher,
const signal_keyboard_function &  signal 
)

Connects the signal for 'snooping' on the keypress.

This callback is called before the widget itself allowing you to either snoop on the input or filter it.

Definition at line 204 of file dispatcher.cpp.

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

Referenced by gui2::dialogs::lua_interpreter::controller::bind(), gui2::chatbox::finalize_setup(), gui2::dialogs::end_credits::pre_show(), gui2::dialogs::game_load::pre_show(), gui2::dialogs::story_viewer::pre_show(), and gui2::dialogs::mp_lobby::pre_show().

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

Disconnects a dispatcher to the event handler.

Parameters
dispatcherThe dispatcher to disconnect.

Definition at line 830 of file handler.cpp.

References gui2::event::sdl_event_handler::disconnect().

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

void gui2::event::disconnect_signal_mouse_left_click ( dispatcher &  dispatcher,
const signal_function &  signal 
)
template<typename sequence , typename E , typename F >
bool gui2::event::find ( event,
functor 
)
inline

Tests whether an event handler is available.

The code is based on boost::mpl_for_each, which doesn't allow to call a template function with the dereferred iterator as template parameter.

The function first tries to match whether the value in the sequence matches event, once that matched it will execute the functor with the key found as template parameter and the event as parameter.

Template Parameters
sequenceThe sequence to test upon.
EThe value type of the item in the sequence
FType of the functor.
Parameters
eventThe event to look for.
functorThe predicate which should is executed if the event is matched.
Returns
Whether or not the function found a result.

Definition at line 240 of file dispatcher_private.hpp.

Referenced by pathfind::a_star_search(), unit::ability_affects_adjacent(), game_data::activate_scope_variable(), unit_type::add_advancement(), replay::add_chat_message_location(), game_events::manager::add_events(), syncmp_registry::add_handler(), editor::location_palette::add_item(), gui2::window::add_linked_widget(), gui2::add_timer(), gui2::window::add_to_tab_order(), unit::apply_builtin_effect(), attack_type::apply_modification(), events::generic_event::attach_handler(), wesnothd::server::ban_handler(), wesnothd::server::bans_handler(), team::calculate_is_enemy(), gui2::dialogs::campaign_selection::campaign_selected(), events::chat_handler::change_logging(), wb::attack::check_validity(), wb::recall::check_validity(), wb::recruit::check_validity(), wesnothd::server::cleanup_game(), persist_file_context::clear_var(), gui2::event::sdl_event_handler::connect(), ng::connect_engine::connect_engine(), pathfind::paths::dest_vect::contains(), gui2::dialogs::mp_create_game::convert_to_game_filtered_index(), gui::menu::create_help_strings(), default_map_generator_job::default_generate_map(), wesnothd::server::delete_game(), events::generic_event::detach_handler(), gui2::event::sdl_event_handler::disconnect(), ai::ai_default_rca::get_villages_phase::dispatch_complex(), display::display(), gui2::dialogs::mp_options_helper::display_custom_options(), ai::move_result::do_execute(), events::console_handler::do_set_alias(), events::console_handler::do_set_var(), font::draw_text(), wb::side_actions_container::erase(), utils::detail::contains_impl< Container, Value >::eval(), ai::lua_sticky_candidate_action_wrapper::evaluate(), ai::ai_default_rca::retreat_phase::evaluate(), ng::flg_manager::faction_index(), unit_filter_impl::unit_filter_compound::fill(), terrain_filterimpl::filter_xy(), font::text_cache::find(), utils::basic_string_view< charT, traits >::find_not_of(), ng::flg_manager::find_suitable_faction(), wesnothd::game::find_user(), ai::ai_default_rca::get_villages_phase::find_villages(), footsteps_images(), mp::game_info::game_info(), wesnothd::server::gban_handler(), ng::flg_manager::gender_index(), help::generate_terrain_sections(), CVideo::get_available_resolutions(), wfl::function_symbol_table::get_builtins(), wfl::variant_callable::get_debug_string(), gui2::dialogs::mp_lobby::get_game_index_from_id(), pathfind::paths::dest_vect::get_path(), wb::side_actions::get_position_of(), wesnothd::server::handle_join_game(), wesnothd::server::handle_login(), wesnothd::server::handle_whisper(), unit_type::has_gender_variation(), terrain_label::hidden(), game_lua_kernel::intf_set_time_of_day(), ai::stage_factory::is_duplicate(), ai::engine_factory::is_duplicate(), ai::candidate_action_factory::is_duplicate(), ai::goal_factory::is_duplicate(), ai::aspect_factory::is_duplicate(), wesnothd::server::is_ip_banned(), wesnothd::game::is_muted_observer(), wesnothd::game::is_observer(), wesnothd::game::is_player(), sound::is_sound_playing(), events::sdl_handler::join_same(), gui2::event::distributor::keyboard_add_to_chain(), gui2::event::distributor::keyboard_remove_from_chain(), wesnothd::server::kick_handler(), wesnothd::server::kickban_handler(), ng::flg_manager::leader_index(), ai::default_recruitment::recruitment::leader_matches_job(), sound::load_chunk(), ng::connect_engine::load_previous_sides_users(), gui2::gui_definition::load_widget_definitions(), ai::lua_sticky_candidate_action_wrapper::lua_sticky_candidate_action_wrapper(), wesnothd::make_change_diff(), wesnothd::make_delete_diff(), markov_generate_name(), side_filter::match_internal(), terrain_filter::match_internal(), unit_animation::matches(), game_events::event_handler::matches_name(), map_location::matches_range(), matches_simple_filter(), ai::ai_default_rca::move_to_targets_phase::move_group(), unit_type::musthave_status(), gui2::dialogs::faction_select::on_leader_select(), utils::parse_range(), fake_unit_manager::place_temporary_unit(), wesnothd::game::player_is_banned(), wesnothd::server::pm_handler(), gui2::dialogs::preferences_dialog::post_build(), gui2::dialogs::campaign_selection::post_show(), ai::readonly_context_impl::power_projection(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::campaign_selection::pre_show(), wesnothd::server::process_command(), ng::connect_engine::process_network_data(), wesnothd::game::process_turn(), unit::remove_attack(), syncmp_registry::remove_handler(), events::context::remove_handler(), gui2::window::remove_linked_widget(), wesnothd::server::remove_player(), unit_type::resistance_filter_matches(), unit::resistance_filter_matches(), lua_fileops::resolve_filename(), ng::flg_manager::resolve_random(), wesnothd::server::searchlog_handler(), help::section_is_referenced(), help::help_menu::select_topic_internal(), events::context::set_focus(), gui::button::set_label(), gui2::dialogs::preferences_dialog::set_resolution_list(), ng::side_engine::side_engine(), gui2::event::distributor::signal_handler_notify_removal(), gui2::window::signal_handler_sdl_key_down(), wfl::string_expression::string_expression(), ai::readonly_context_impl::suitable_keep(), gui2::dialogs::file_dialog::sync_bookmarks_bar(), synced_command::synced_command(), SYNCED_COMMAND_HANDLER_FUNCTION(), help::topic_is_referenced(), wesnothd::game::transfer_side_control(), wb::side_actions::unit_has_actions(), ng::flg_manager::update_choosable_genders(), ng::flg_manager::update_choosable_leaders(), and unit::~unit().

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

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
TThe signal type of the event to handle.
FThe paramater 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 495 of file dispatcher_private.hpp.

References d, and w.

template<ui_event click, ui_event double_click, bool(event_executor::*)() const wants_double_click, typename T , typename... F>
bool gui2::event::fire_event_double_click ( dispatcher *  dsp,
widget *  wgt,
F &&...  params 
)
inline
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 837 of file handler.cpp.

References gui2::get_mouse_position(), gui2::point::x, and gui2::point::y.

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

std::ostream & gui2::event::operator<< ( std::ostream &  stream,
const ui_event  event 
)
void gui2::event::release_mouse ( dispatcher *  dispatcher)

Releases a captured mouse.

Parameters
dispatcherThe dispatcher which should release the mouse capture.

Definition at line 857 of file handler.cpp.

References gui2::event::sdl_event_handler::mouse_focus.

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

Variable Documentation

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

Definition at line 62 of file handler.cpp.