16 #define GETTEXT_DOMAIN "wesnoth-lib"
29 , want_keyboard_input_(true)
31 , signal_mouse_queue_()
32 , signal_keyboard_queue_()
33 , signal_touch_motion_queue_()
34 , signal_touch_gesture_queue_()
35 , signal_notification_queue_()
36 , signal_message_queue_()
67 PLAIN_LOG <<
"Event '" <<
event <<
" '" << (res ?
"found" :
"not found") <<
"in queue";
91 return fire_event<event_category::general>(event,
this, &target);
98 return fire_event<event_category::mouse>(event,
this, &target,
coordinate);
103 const SDL_Keycode key,
104 const SDL_Keymod modifier,
105 const std::string& unicode)
108 return fire_event<event_category::keyboard>(event,
this, &target, key, modifier, unicode);
114 return fire_event<event_category::touch_motion>(event,
this, &target, pos, distance);
120 return fire_event<event_category::touch_gesture>(event,
this, &target, center, dTheta, dDist, numFingers);
126 return fire_event<event_category::raw_event>(event,
this, &target, sdlevent);
132 return fire_event<event_category::text_input>(event,
this, &target, text,
start, len);
138 return fire_event<event_category::notification>(event,
this, &target,
nullptr);
144 return fire_event<event_category::message>(event,
this, &target,
msg);
160 itor->second(
dynamic_cast<widget&
>(*
this),
id);
Base class for event handling.
void connect_signal(const F &func, const queue_position position=back_child)
Adds a callback to the appropriate queue based on event type.
void connect()
Connects the dispatcher to the event handler.
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
bool has_event(const ui_event event, const event_queue_type event_type)
mouse_behavior
The behavior of the mouse events.
void disconnect()
Disconnects the dispatcher from the event handler.
void disconnect_signal(const F &func, const queue_position position=back_child)
Removes a callback from the appropriate queue based on event type.
bool connected_
Are we connected to the event handler.
bool execute_hotkey(const hotkey::HOTKEY_COMMAND id)
Executes a hotkey.
void register_hotkey(const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
Registers a hotkey.
std::map< hotkey::HOTKEY_COMMAND, hotkey_function > hotkeys_
The registered hotkeys for this dispatcher.
bool wants_mouse_right_double_click() const
bool wants_mouse_left_double_click() const
bool wants_mouse_middle_double_click() const
std::string id
Text to match against addon_info.tags()
EXIT_STATUS start(bool clear_id, const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
std::function< void(widget &dispatcher, hotkey::HOTKEY_COMMAND id)> hotkey_function
Hotkey function handler signature.
void connect_signal_pre_key_press(dispatcher &dispatcher, const signal_keyboard &signal)
Connects the signal for 'snooping' on the keypress.
ui_event
The event sent to the dispatcher.
@ MIDDLE_BUTTON_DOUBLE_CLICK
@ LEFT_BUTTON_DOUBLE_CLICK
@ RIGHT_BUTTON_DOUBLE_CLICK
void connect_signal_on_draw(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a callback when the widget is drawn.
void disconnect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Disconnects a signal handler for a left mouse button click.
bool fire_event_double_click(dispatcher *dsp, widget *wgt, F &&... params)
dispatcher_callback< void * > signal_notification
Used for events in event_category::notification.
void disconnect_signal_mouse_left_release(dispatcher &dispatcher, const signal &signal)
Disconnects a signal handler for a left mouse button release.
void disconnect_dispatcher(dispatcher *dispatcher)
Disconnects a dispatcher to the event handler.
dispatcher_callback<> signal
Used for events in event_category::general.
@ notification
Callbacks with a sender aka notification messages.
@ keyboard
Callbacks with the keyboard values (these haven't been determined yet).
@ mouse
Callbacks with a coordinate as extra parameter.
@ message
Callbacks with a sender aka notification messages.
@ general
Callbacks without extra parameters.
void connect_signal_mouse_left_release(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button release.
void connect_dispatcher(dispatcher *dispatcher)
Connects a dispatcher to the event handler.
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
dispatcher_callback< const SDL_Keycode, const SDL_Keymod, const std::string & > signal_keyboard
Used for events in event_category::keyboard.
void connect_signal_mouse_left_double_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button double click.
constexpr bool is_in_category(const ui_event event, const event_category mask)
Checks if a given event is in a given category.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
std::string::const_iterator iterator
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
static bool has_handler(dispatcher &dispatcher, const dispatcher::event_queue_type queue_type, ui_event event)
A helper to test whether dispatcher has an handler for a certain event.
The message callbacks hold a reference to a message.