The Battle for Wesnoth  1.19.8+dev
dispatcher.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
19 
20 
21 namespace gui2
22 {
23 namespace event
24 {
25 /***** dispatcher class. *****/
26 
28  : mouse_behavior_(mouse_behavior::all)
29  , want_keyboard_input_(true)
30  , signal_queue_()
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_()
37  , connected_(false)
38  , hotkeys_()
39 {
40 }
41 
43 {
44  if(connected_) {
45  disconnect();
46  }
47 }
48 
50 {
51  assert(!connected_);
52  connected_ = true;
53  connect_dispatcher(this);
54 }
55 
57 {
58  assert(connected_);
59  connected_ = false;
61 }
62 
63 bool dispatcher::has_event(const ui_event event, const event_queue_type event_type)
64 {
65 #if 0
66  const bool res = dispatcher_implementation::has_handler(*this, event_type, event);
67  PLAIN_LOG << "Event '" << event << " '" << (res ? "found" : "not found") << "in queue";
68  return res;
69 #else
70  return dispatcher_implementation::has_handler(*this, event_type, event);
71 #endif
72 }
73 
74 bool dispatcher::fire(const ui_event event, widget& target)
75 {
77  switch(event) {
81 
85 
89 
90  default:
91  return fire_event<event_category::general>(event, this, &target);
92  }
93 }
94 
95 bool dispatcher::fire(const ui_event event, widget& target, const point& coordinate)
96 {
97  assert(is_in_category(event, event_category::mouse));
98  return fire_event<event_category::mouse>(event, this, &target, coordinate);
99 }
100 
101 bool dispatcher::fire(const ui_event event,
102  widget& target,
103  const SDL_Keycode key,
104  const SDL_Keymod modifier,
105  const std::string& unicode)
106 {
108  return fire_event<event_category::keyboard>(event, this, &target, key, modifier, unicode);
109 }
110 
111 bool dispatcher::fire(const ui_event event, widget& target, const point& pos, const point& distance)
112 {
114  return fire_event<event_category::touch_motion>(event, this, &target, pos, distance);
115 }
116 
117 bool dispatcher::fire(const ui_event event, widget& target, const point& center, float dTheta, float dDist, uint8_t numFingers)
118 {
120  return fire_event<event_category::touch_gesture>(event, this, &target, center, dTheta, dDist, numFingers);
121 }
122 
123 bool dispatcher::fire(const ui_event event, widget& target, const SDL_Event& sdlevent)
124 {
126  return fire_event<event_category::raw_event>(event, this, &target, sdlevent);
127 }
128 
129 bool dispatcher::fire(const ui_event event, widget& target, const std::string& text, int32_t start, int32_t len)
130 {
132  return fire_event<event_category::text_input>(event, this, &target, text, start, len);
133 }
134 
135 bool dispatcher::fire(const ui_event event, widget& target, void*)
136 {
138  return fire_event<event_category::notification>(event, this, &target, nullptr);
139 }
140 
141 bool dispatcher::fire(const ui_event event, widget& target, const message& msg)
142 {
143  assert(is_in_category(event, event_category::message));
144  return fire_event<event_category::message>(event, this, &target, msg);
145 }
146 
148 {
149  hotkeys_[id] = function;
150 }
151 
153 {
155 
156  if(itor == hotkeys_.end()) {
157  return false;
158  }
159 
160  itor->second(dynamic_cast<widget&>(*this), id);
161 
162  /* NOTE: hotkey events used to return bool to indicate was-handled status. However,
163  * every single usecase was returning true and cluttering up the code. I changed
164  * the signature to return void, but if there's ever a need to restore the bool
165  * retval on the hotkey functions, this is where it should be handled.
166  *
167  * -- vultraz, 2017-11-27
168  */
169  return true;
170 }
171 
173 {
175 }
176 
178 {
180 }
181 
183 {
185 }
186 
188 {
190 }
191 
193 {
195 }
196 
197 
199 {
201 }
202 
204 {
206 }
207 
208 } // namespace event
209 
210 } // namespace gui2
211 
212 /**
213  * @page event_dispatching Event dispatching.
214  *
215  * @section introduction-event_dispatching Introduction
216  *
217  * This page describes how the new event handling system works, since the
218  * system is still work in progress it might be out of date with the actual
219  * code. It also contains some ideas that might change later on. Some parts are
220  * explained in the interface and will be integrated in this document later.
221  *
222  * Since the event handling code hasn't been cast in stone yet some scenarios
223  * for solving the problem are discussed first and then the solution that is
224  * chosen in more detail.
225  *
226  * After SDL has generated and event it needs to be turned into an event which
227  * the widgets can use.
228  *
229  * @section handling_solution The implementation solutions.
230  *
231  * For the event handling we use a few use case scenarios and show the possible
232  * solutions.
233  *
234  * @subsection sample The sample window
235  *
236  * In our samples we use this sample window with the following components:
237  * - a window W
238  * - a container C
239  * - a button B
240  *
241  * These are arranged accordingly:
242  * @code
243  *
244  * ---------------------
245  * |W |
246  * | |
247  * | ----------------- |
248  * | |C |^| |
249  * | | |-| |
250  * | | ---------- |#| |
251  * | | |B | | | |
252  * | | ---------- | | |
253  * | | |-| |
254  * | | |v| |
255  * | ----------------- |
256  * | |
257  * ---------------------
258  *
259  * @endcode
260  *
261  * @subsection scenarios Possible scenarios
262  *
263  * The scenarios are:
264  * - An event that is wanted by none.
265  * - A mouse down event that should focus C and set the pressed state in B.
266  * - A mouse wheel event, which first should be offered to B and if not handled
267  * by B should be handled by C.
268  *
269  * @subsection all_queues Pass the event through all queues
270  *
271  * In this solution the event will be passed through all possible queues and
272  * tries sees where the event sticks. This following sections describe how the
273  * events are tried for this usage scenario.
274  *
275  * @subsubsection unhandled-all_queues Unhandled event
276  *
277  * - W pre child
278  * - C pre child
279  * - B pre child
280  * - W child
281  * - C child
282  * - B child
283  * - W post child
284  * - C post child
285  * - B post child
286  *
287  * @subsubsection mouse_down-all_queues Mouse down
288  *
289  * - W pre child
290  * - C pre child -> set focus -> !handled
291  * - B pre child -> set pressed state -> handled
292  *
293  * @subsubsection mouse_wheel-all_queues Mouse wheel
294  *
295  * - W pre child
296  * - C pre child
297  * - B pre child -> We can't scroll so ignore
298  * - W child
299  * - C child
300  * - B child
301  * - W post child
302  * - C post child -> Scroll -> handled
303  *
304  * @subsection chain Pass the events in a chain like fashion
305  *
306  * In this solution the events are send to the pre- and post queue of all but
307  * the last possible widget and to the child of the last widget. The pre queue
308  * will be send from top to bottom, the post queue from bottom to top.
309  *
310  * @subsubsection unhandled-chain Unhandled event
311  *
312  * - W pre child
313  * - C pre child
314  * - B child
315  * - C post child
316  * - W post child
317  *
318  * @subsubsection mouse_down-chain Mouse down
319  *
320  * - W pre child
321  * - C pre child -> set focus -> !handled
322  * - B child -> set pressed state -> handled
323  *
324  * @subsubsection mouse_wheel-chain Mouse wheel
325  *
326  * - W pre child
327  * - C pre child
328  * - B child -> We can't scroll so ignore
329  * - C post child -> Scroll -> handled
330  *
331  * @subsection evaluation Evaluation
332  *
333  * When using the first solution it's possible to drop the child queue since
334  * everything falls in pre or post. But there is a scenario that's a bit ugly
335  * to solve with the first solution:
336  *
337  * Assume there is a listbox with toggle panels and on the panel there are a
338  * few buttons, the wanted behavior is:
339  * - if clicked on the panel it should toggle, which may or may not be allowed.
340  * - if clicked on a button in the panel, we want to make sure the panel is
341  * selected, which again may or may not be allowed.
342  *
343  * With solution 2 it's rather easy:
344  *
345  * Click on panel:
346  * - W pre child
347  * - C child -> Test whether we can toggle -> handled, halt = !toggled
348  *
349  * Click on button in panel:
350  * - W pre child
351  * - C pre child -> Test whether we can select -> handled = halt = !selected
352  * - B child -> do button stuff -> handled
353  *
354  * Since for the different clicks, different queues are triggered it's easy to
355  * add a different handler there.
356  *
357  * With solution 1:
358  *
359  * Click on panel:
360  * - W pre child
361  * - C pre child -> handler 1 -> if last in queue -> solution 2 C child
362  *
363  * Click on button in panel:
364  * - W pre child
365  * - C pre child -> handler 2 -> if !last in queue -> solution 2 C pre child
366  * - B pre child -> do button stuff -> handled
367  *
368  * Not that different from solution 2, the two handlers are installed in the C
369  * pre event. But we need to manually check whether we're really the last,
370  * which means the code to check whether there are more handlers at a lower
371  * level is needed for both solutions. In solution 1 this test needs to be done
372  * twice versus once in solution 2. Also the fact that the queues for the
373  * events are processed in reverse order on the way back sounds more
374  * initiative.
375  *
376  * @section processing_raw_events Processing the raw events.
377  *
378  * This section describes how the events generated by SDL are send as our own
379  * events to the various widgets. The first step in sending an event is to
380  * decode it and send it to a registered dispatcher.
381  *
382  * - gui2::event::sdl_event_handler handles the SDL events.
383  * - gui2::event::dispatcher has the registered dispatchers.
384  *
385  * In general a dispatcher is a window which then needs to send this event to
386  * the widgets. The dispatcher is just a simple part which fires events and
387  * finds a handler for the event. This is not to the liking of most widgets,
388  * they don't want to handle raw events but get a polished and clean event. No
389  * button up and down and then try to figure out whether it needs to act as if
390  * it was clicked upon, no simply op and down to change the appearance and a
391  * click event to do the clicking actions. And don't even try to convince a
392  * widget to determine whether this up event was a single or double click.
393  * Widgets like to sleep with nice dreams and not having nightmares where SDL
394  * events haunt them.
395  *
396  * In order to remedy that problem there's the gui2::event::distributor
397  * class, it's the class to do the dirty job of converting the raw event into
398  * these nice polished events. The distributor is in general linked to a window,
399  * but a widget can install it's own distributor if it needs to know more of the
400  * raw events as still left in the polished events. At the time of this writing
401  * no widget needs this feature, but the toggle panel might need it.
402  *
403  * After the distributor has polished the event and send it on its way to the
404  * widget the dispatcher needs to make sure the event is properly dispatched to
405  * the widget in question and also notify its parents by means of the previously
406  * described event chain.
407  *
408  * @subsection sdl_event Get the SDL events
409  *
410  * The first step in event handling is getting the events in the first place.
411  * Events are generated by SDL and placed in a queue. The Wesnoth code processes
412  * this queue and thus handles the events. The part which does the first
413  * handling isn't described here since it's (secretly) intended to be replaced
414  * by the @ref gui2::event::sdl_event_handler class. Instead we directly jump to this
415  * class and explain what it does.
416  *
417  * The main handling function is @ref gui2::event::sdl_event_handler::handle_event which
418  * as no real surprise handles the events. The function is a simple multiplexer
419  * which lets other subfunctions to the handling of specific events.
420  *
421  * @todo Describe drawing and resizing once the code is stable and working as
422  * wanted in these areas.
423  *
424  * @subsubsection handler_mouse Mouse motion events
425  *
426  * If a dispatcher has captured the mouse it gets the event, no questions asked.
427  * If not it goes through all dispatchers and finds the first one willing to
428  * accept the mouse event.
429  *
430  * This means a mouse event is send to one dispatcher.
431  *
432  * @subsubsection handler_mouse_button_down Mouse button down events
433  *
434  * Turning the mouse wheel on a mouse generates both an down and up event. It
435  * has been decided to handle the wheel event in the button up code so wheel
436  * events are here directly dropped on the floor and forgotten.
437  *
438  * The other buttons are handled as if they're normal mouse events but are
439  * decoded per button so instead of a button_down(id) you get button_down_id.
440  *
441  * @subsubsection handler_mouse_button_up Mouse button up events
442  *
443  * The mouse wheel event is handled as if it's a keyboard event and like the
444  * button_down they are send as wheel_id events.
445  *
446  * The other mouse buttons are handled the same as the down buttons.
447  *
448  * @subsubsection handler_keyboard Keyboard events
449  *
450  * There are three types of keyboard events, the already mentioned mouse wheel
451  * events, the key down and key up event. When a key is pressed for a longer
452  * time several key down events are generated and only one key up, this means
453  * the key up is rather useless. Guess what, the multiplexer already drops that
454  * event so we never get it.
455  *
456  * If the keyboard event is a mouse wheel event it's directly send to the
457  * dispachting queue; either the dispatcher that captured the keyboard or the
458  * last dispatcher in the queue.
459  *
460  * If the event is a real keyboard action it's first tried as hotkey. In order
461  * to do so the target dispatcher is first determined, either the dispatcher
462  * that captured the keyboard or the last dispatcher in the queue. Then it's
463  * tried whether a hotkey and whether the hotkey can be processed. If the
464  * hotkey isn't processed the keyboard event is send to the dispatcher as
465  * normal keyboard event.
466  *
467  * The hotkey processing will have several queues (to be implemented in 1.9):
468  * - global hotkeys that always work eg toggling fullscreen mode.
469  * - main screen hotkeys, these work when one of the dialogs is shown without
470  * other dialogs on top of them. These hotkeys are for example
471  * preferences. The main screens are:
472  * - title screen
473  * - game
474  * - editor
475  * - mp lobby
476  * - map screen hotkeys, these work when a map is shown eg toggle grid. The
477  * screens are:
478  * - game
479  * - editor
480  * - local hotkeys, these are hotkeys that only work in a specific dialog eg
481  * recruit unit only works in the game screen.
482  *
483  * The queues are processed in from bottom to top in the list above, this
484  * allows an item to use a hotkey but have another handler function. Eg
485  * preferences in the editor might open another preferences dialog.
486  *
487  * @todo The hotkeys need to be implemented like above in 1.9.
488  *
489  * @todo This might change in the near future.
490  *
491  * @subsection distributor Event polishing and distribution
492  *
493  * The event distributor has the job to find the widget that should receive the
494  * event and which event(s) to send from a single event. In general an event is
495  * first send to the widget as-is, sending the raw events allows other
496  * distributors to be nested between this distributor and the intended target
497  * widget. Or the intended widget might not really be the intended widget but
498  * another distributor that wants to dispatch the event internally.
499  *
500  * However in the common cases this raw event isn't handled and the distributor
501  * needs to send the polished events. In the following sections the details of
502  * the conversion from raw to polished is described, it intentionally lacks the
503  * part of sending the raw events as well since it adds no value.
504  *
505  * A widget can capture the mouse, which means all mouse events are send to this
506  * widget, regardless where the mouse is. This is normally done in a mouse down
507  * event (for a button) so all events following it are send to that widget.
508  *
509  * @subsection mouse_motion Mouse motion
510  *
511  * This section describes the conversion from a raw mouse motion to the polished
512  * events it can generate:
513  * - @ref gui2::event::MOUSE_ENTER "MOUSE_ENTER"
514  * - @ref gui2::event::MOUSE_LEAVE "MOUSE_LEAVE"
515  * - @ref gui2::event::MOUSE_MOTION "MOUSE_MOTION"
516  *
517  * When the mouse is captured that widget will only receive motion events.
518  *
519  * If not captured the code checks whether the widget underneath the mouse is
520  * the same widget as at the last motion if event. If so that widget gets a
521  * motion event.
522  * If not the widget that before was underneath the mouse pointer (if any) gets
523  * a leave event and the widget newly underneath the mouse pointer (if any) gets
524  * an enter event.
525  *
526  * @subsection mouse_button Mouse buttons
527  *
528  * The mouse button code is a bit more complex and is separated in the various
529  * events to be send.
530  *
531  * @subsubsection mouse_button_down Mouse button down
532  *
533  * Some things start simple, so does the event of pressing down a mouse button.
534  * All it does is send the event to the widget as one of the following events:
535  * - @ref gui2::event::LEFT_BUTTON_DOWN "LEFT_BUTTON_DOWN"
536  * - @ref gui2::event::MIDDLE_BUTTON_DOWN "MIDDLE_BUTTON_DOWN"
537  * - @ref gui2::event::RIGHT_BUTTON_DOWN "RIGHT_BUTTON_DOWN"
538  *
539  * @todo Validate the code it seems a down event with a captured mouse doesn't
540  * really work as wanted. (Rare case but should work properly.) In general the
541  * mouse event handling needs testing to see whether the proper events are send
542  * all the time.
543  *
544  * @subsubsection mouse_button_up Mouse button up
545  *
546  * Simplicity ends here.
547  *
548  * @todo Document further.
549  *
550  * @subsubsection mouse_click Mouse click
551  *
552  * So the button up event has asked for mouse click, now we need to test whether
553  * the click will be a click or a double click. A double click is generated when
554  * the same widget is clicked twice in a short time and causes the following
555  * events:
556  * - @ref gui2::event::LEFT_BUTTON_DOUBLE_CLICK "LEFT_BUTTON_DOUBLE_CLICK"
557  * - @ref gui2::event::MIDDLE_BUTTON_DOUBLE_CLICK "MIDDLE_BUTTON_DOUBLE_CLICK"
558  * - @ref gui2::event::RIGHT_BUTTON_DOUBLE_CLICK "RIGHT_BUTTON_DOUBLE_CLICK"
559  *
560  * Otherwise one of the following single clicks is generated:
561  * - @ref gui2::event::LEFT_BUTTON_CLICK "LEFT_BUTTON_CLICK"
562  * - @ref gui2::event::MIDDLE_BUTTON_CLICK "MIDDLE_BUTTON_CLICK"
563  * - @ref gui2::event::RIGHT_BUTTON_CLICK "RIGHT_BUTTON_CLICK"
564  *
565  * @subsubsection double_click To double click or not to double click
566  *
567  * Wait a second, a widget has a field whether or not it wants a double click
568  * for a certain mouse button and now I see that it's bluntly ignored by the
569  * distributor. Indeed the distributor doesn't care about what the widget wants,
570  * it does what it wants and leaves the sorting out what's wanted to the
571  * dispatcher.
572  *
573  * The problem is that in the chain events are send to one widget that may not
574  * be interested in a double click, but another widget in the chain is. There
575  * are several solutions to this problem:
576  * -# Sending a click followed by a double click.
577  * -# Sending a click with a tag field that it actually is a double click.
578  * -# Send a double click and turn it into a click if the double click is
579  * unwanted.
580  *
581  * The first solution has the disadvantage that a toggle panel likes a click and
582  * double click, the first click selects the second deselects and now the
583  * deselected panel gets a double click. When the panel now checks whether it's
584  * selected it's not and might take the wrong action upon it.
585  *
586  * The second option is possible but would be rather intrusive in the code,
587  * since it would generate another event signature. Adding a signature just for
588  * this special case seemed a bit too much effort vs. gain. Also the widget
589  * needs to check whether a click is a click or a double click and choose a
590  * different code path for it. This in turn would mean a signal handler
591  * secretly might handle two events and lowers the transparency of the code.
592  *
593  * The third option also adds some special case handling but the scope is
594  * limited and only one part knows about the tricks done.
595  *
596  * The last option has been chosen and the dispatcher build the event chain and
597  * while building the chain it looks whether the widget wants the double click
598  * or not. It does this test by looking at the wants double click function and
599  * not test for a handler. The double click test function is made for this
600  * purpose and depending on the handler might again do the wrong thing.
601  * (A certain toggle panel might not want to do something on a double click but
602  * also not being deselected upon a double click. The latter to keep the UI
603  * consistent, a double click on a toggle panel might execute a special function
604  * or not, but always keep the panel selected. (That is if the panel can be
605  * selected.))
606  */
Base class for event handling.
Definition: dispatcher.hpp:150
void connect_signal(const F &func, const queue_position position=back_child)
Adds a callback to the appropriate queue based on event type.
Definition: dispatcher.hpp:351
void connect()
Connects the dispatcher to the event handler.
Definition: dispatcher.cpp:49
bool fire(const ui_event event, widget &target)
Fires an event which has no extra parameters.
Definition: dispatcher.cpp:74
bool has_event(const ui_event event, const event_queue_type event_type)
Definition: dispatcher.cpp:63
mouse_behavior
The behavior of the mouse events.
Definition: dispatcher.hpp:392
void disconnect()
Disconnects the dispatcher from the event handler.
Definition: dispatcher.cpp:56
void disconnect_signal(const F &func, const queue_position position=back_child)
Removes a callback from the appropriate queue based on event type.
Definition: dispatcher.hpp:370
bool connected_
Are we connected to the event handler.
Definition: dispatcher.hpp:608
bool execute_hotkey(const hotkey::HOTKEY_COMMAND id)
Executes a hotkey.
Definition: dispatcher.cpp:152
void register_hotkey(const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
Registers a hotkey.
Definition: dispatcher.cpp:147
std::map< hotkey::HOTKEY_COMMAND, hotkey_function > hotkeys_
The registered hotkeys for this dispatcher.
Definition: dispatcher.hpp:611
bool wants_mouse_right_double_click() const
bool wants_mouse_left_double_click() const
bool wants_mouse_middle_double_click() const
Base class for all widgets.
Definition: widget.hpp:55
std::string id
Text to match against addon_info.tags()
Definition: manager.cpp:199
#define PLAIN_LOG
Definition: log.hpp:297
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.
Definition: dispatcher.hpp:132
void connect_signal_pre_key_press(dispatcher &dispatcher, const signal_keyboard &signal)
Connects the signal for 'snooping' on the keypress.
Definition: dispatcher.cpp:172
ui_event
The event sent to the dispatcher.
Definition: handler.hpp:115
@ MIDDLE_BUTTON_DOUBLE_CLICK
Definition: handler.hpp:127
@ NOTIFY_MODIFIED
Definition: handler.hpp:158
@ MIDDLE_BUTTON_CLICK
Definition: handler.hpp:126
@ LEFT_BUTTON_UP
Definition: handler.hpp:121
@ RIGHT_BUTTON_CLICK
Definition: handler.hpp:130
@ LEFT_BUTTON_DOUBLE_CLICK
Definition: handler.hpp:123
@ LEFT_BUTTON_CLICK
Definition: handler.hpp:122
@ RIGHT_BUTTON_DOUBLE_CLICK
Definition: handler.hpp:131
void disconnect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Disconnects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:182
bool fire_event_double_click(dispatcher *dsp, widget *wgt, F &&... params)
dispatcher_callback< void * > signal_notification
Used for events in event_category::notification.
Definition: dispatcher.hpp:103
void disconnect_signal_mouse_left_release(dispatcher &dispatcher, const signal &signal)
Disconnects a signal handler for a left mouse button release.
Definition: dispatcher.cpp:192
void disconnect_dispatcher(dispatcher *dispatcher)
Disconnects a dispatcher to the event handler.
Definition: handler.cpp:866
dispatcher_callback<> signal
Used for events in event_category::general.
Definition: dispatcher.hpp:56
@ 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.
Definition: dispatcher.cpp:187
void connect_dispatcher(dispatcher *dispatcher)
Connects a dispatcher to the event handler.
Definition: handler.cpp:859
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
Definition: dispatcher.cpp:203
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:177
dispatcher_callback< const SDL_Keycode, const SDL_Keymod, const std::string & > signal_keyboard
Used for events in event_category::keyboard.
Definition: dispatcher.hpp:74
void connect_signal_mouse_left_double_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button double click.
Definition: dispatcher.cpp:198
constexpr bool is_in_category(const ui_event event, const event_category mask)
Checks if a given event is in a given category.
Definition: handler.hpp:180
Generic file dialog.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
std::string::const_iterator iterator
Definition: tokenizer.hpp:25
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
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.
Definition: message.hpp:46
Holds a 2D point.
Definition: point.hpp:25