The Battle for Wesnoth  1.19.5+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 
209 {
210  // TODO: evaluate whether draw events need go in this queue position.
212 }
213 
214 } // namespace event
215 
216 } // namespace gui2
217 
218 /**
219  * @page event_dispatching Event dispatching.
220  *
221  * @section introduction-event_dispatching Introduction
222  *
223  * This page describes how the new event handling system works, since the
224  * system is still work in progress it might be out of date with the actual
225  * code. It also contains some ideas that might change later on. Some parts are
226  * explained in the interface and will be integrated in this document later.
227  *
228  * Since the event handling code hasn't been cast in stone yet some scenarios
229  * for solving the problem are discussed first and then the solution that is
230  * chosen in more detail.
231  *
232  * After SDL has generated and event it needs to be turned into an event which
233  * the widgets can use.
234  *
235  * @section handling_solution The implementation solutions.
236  *
237  * For the event handling we use a few use case scenarios and show the possible
238  * solutions.
239  *
240  * @subsection sample The sample window
241  *
242  * In our samples we use this sample window with the following components:
243  * - a window W
244  * - a container C
245  * - a button B
246  *
247  * These are arranged accordingly:
248  * @code
249  *
250  * ---------------------
251  * |W |
252  * | |
253  * | ----------------- |
254  * | |C |^| |
255  * | | |-| |
256  * | | ---------- |#| |
257  * | | |B | | | |
258  * | | ---------- | | |
259  * | | |-| |
260  * | | |v| |
261  * | ----------------- |
262  * | |
263  * ---------------------
264  *
265  * @endcode
266  *
267  * @subsection scenarios Possible scenarios
268  *
269  * The scenarios are:
270  * - An event that is wanted by none.
271  * - A mouse down event that should focus C and set the pressed state in B.
272  * - A mouse wheel event, which first should be offered to B and if not handled
273  * by B should be handled by C.
274  *
275  * @subsection all_queues Pass the event through all queues
276  *
277  * In this solution the event will be passed through all possible queues and
278  * tries sees where the event sticks. This following sections describe how the
279  * events are tried for this usage scenario.
280  *
281  * @subsubsection unhandled-all_queues Unhandled event
282  *
283  * - W pre child
284  * - C pre child
285  * - B pre child
286  * - W child
287  * - C child
288  * - B child
289  * - W post child
290  * - C post child
291  * - B post child
292  *
293  * @subsubsection mouse_down-all_queues Mouse down
294  *
295  * - W pre child
296  * - C pre child -> set focus -> !handled
297  * - B pre child -> set pressed state -> handled
298  *
299  * @subsubsection mouse_wheel-all_queues Mouse wheel
300  *
301  * - W pre child
302  * - C pre child
303  * - B pre child -> We can't scroll so ignore
304  * - W child
305  * - C child
306  * - B child
307  * - W post child
308  * - C post child -> Scroll -> handled
309  *
310  * @subsection chain Pass the events in a chain like fashion
311  *
312  * In this solution the events are send to the pre- and post queue of all but
313  * the last possible widget and to the child of the last widget. The pre queue
314  * will be send from top to bottom, the post queue from bottom to top.
315  *
316  * @subsubsection unhandled-chain Unhandled event
317  *
318  * - W pre child
319  * - C pre child
320  * - B child
321  * - C post child
322  * - W post child
323  *
324  * @subsubsection mouse_down-chain Mouse down
325  *
326  * - W pre child
327  * - C pre child -> set focus -> !handled
328  * - B child -> set pressed state -> handled
329  *
330  * @subsubsection mouse_wheel-chain Mouse wheel
331  *
332  * - W pre child
333  * - C pre child
334  * - B child -> We can't scroll so ignore
335  * - C post child -> Scroll -> handled
336  *
337  * @subsection evaluation Evaluation
338  *
339  * When using the first solution it's possible to drop the child queue since
340  * everything falls in pre or post. But there is a scenario that's a bit ugly
341  * to solve with the first solution:
342  *
343  * Assume there is a listbox with toggle panels and on the panel there are a
344  * few buttons, the wanted behavior is:
345  * - if clicked on the panel it should toggle, which may or may not be allowed.
346  * - if clicked on a button in the panel, we want to make sure the panel is
347  * selected, which again may or may not be allowed.
348  *
349  * With solution 2 it's rather easy:
350  *
351  * Click on panel:
352  * - W pre child
353  * - C child -> Test whether we can toggle -> handled, halt = !toggled
354  *
355  * Click on button in panel:
356  * - W pre child
357  * - C pre child -> Test whether we can select -> handled = halt = !selected
358  * - B child -> do button stuff -> handled
359  *
360  * Since for the different clicks, different queues are triggered it's easy to
361  * add a different handler there.
362  *
363  * With solution 1:
364  *
365  * Click on panel:
366  * - W pre child
367  * - C pre child -> handler 1 -> if last in queue -> solution 2 C child
368  *
369  * Click on button in panel:
370  * - W pre child
371  * - C pre child -> handler 2 -> if !last in queue -> solution 2 C pre child
372  * - B pre child -> do button stuff -> handled
373  *
374  * Not that different from solution 2, the two handlers are installed in the C
375  * pre event. But we need to manually check whether we're really the last,
376  * which means the code to check whether there are more handlers at a lower
377  * level is needed for both solutions. In solution 1 this test needs to be done
378  * twice versus once in solution 2. Also the fact that the queues for the
379  * events are processed in reverse order on the way back sounds more
380  * initiative.
381  *
382  * @section processing_raw_events Processing the raw events.
383  *
384  * This section describes how the events generated by SDL are send as our own
385  * events to the various widgets. The first step in sending an event is to
386  * decode it and send it to a registered dispatcher.
387  *
388  * - gui2::event::sdl_event_handler handles the SDL events.
389  * - gui2::event::dispatcher has the registered dispatchers.
390  *
391  * In general a dispatcher is a window which then needs to send this event to
392  * the widgets. The dispatcher is just a simple part which fires events and
393  * finds a handler for the event. This is not to the liking of most widgets,
394  * they don't want to handle raw events but get a polished and clean event. No
395  * button up and down and then try to figure out whether it needs to act as if
396  * it was clicked upon, no simply op and down to change the appearance and a
397  * click event to do the clicking actions. And don't even try to convince a
398  * widget to determine whether this up event was a single or double click.
399  * Widgets like to sleep with nice dreams and not having nightmares where SDL
400  * events haunt them.
401  *
402  * In order to remedy that problem there's the gui2::event::distributor
403  * class, it's the class to do the dirty job of converting the raw event into
404  * these nice polished events. The distributor is in general linked to a window,
405  * but a widget can install it's own distributor if it needs to know more of the
406  * raw events as still left in the polished events. At the time of this writing
407  * no widget needs this feature, but the toggle panel might need it.
408  *
409  * After the distributor has polished the event and send it on its way to the
410  * widget the dispatcher needs to make sure the event is properly dispatched to
411  * the widget in question and also notify its parents by means of the previously
412  * described event chain.
413  *
414  * @subsection sdl_event Get the SDL events
415  *
416  * The first step in event handling is getting the events in the first place.
417  * Events are generated by SDL and placed in a queue. The Wesnoth code processes
418  * this queue and thus handles the events. The part which does the first
419  * handling isn't described here since it's (secretly) intended to be replaced
420  * by the @ref gui2::event::sdl_event_handler class. Instead we directly jump to this
421  * class and explain what it does.
422  *
423  * The main handling function is @ref gui2::event::sdl_event_handler::handle_event which
424  * as no real surprise handles the events. The function is a simple multiplexer
425  * which lets other subfunctions to the handling of specific events.
426  *
427  * @todo Describe drawing and resizing once the code is stable and working as
428  * wanted in these areas.
429  *
430  * @subsubsection handler_mouse Mouse motion events
431  *
432  * If a dispatcher has captured the mouse it gets the event, no questions asked.
433  * If not it goes through all dispatchers and finds the first one willing to
434  * accept the mouse event.
435  *
436  * This means a mouse event is send to one dispatcher.
437  *
438  * @subsubsection handler_mouse_button_down Mouse button down events
439  *
440  * Turning the mouse wheel on a mouse generates both an down and up event. It
441  * has been decided to handle the wheel event in the button up code so wheel
442  * events are here directly dropped on the floor and forgotten.
443  *
444  * The other buttons are handled as if they're normal mouse events but are
445  * decoded per button so instead of a button_down(id) you get button_down_id.
446  *
447  * @subsubsection handler_mouse_button_up Mouse button up events
448  *
449  * The mouse wheel event is handled as if it's a keyboard event and like the
450  * button_down they are send as wheel_id events.
451  *
452  * The other mouse buttons are handled the same as the down buttons.
453  *
454  * @subsubsection handler_keyboard Keyboard events
455  *
456  * There are three types of keyboard events, the already mentioned mouse wheel
457  * events, the key down and key up event. When a key is pressed for a longer
458  * time several key down events are generated and only one key up, this means
459  * the key up is rather useless. Guess what, the multiplexer already drops that
460  * event so we never get it.
461  *
462  * If the keyboard event is a mouse wheel event it's directly send to the
463  * dispachting queue; either the dispatcher that captured the keyboard or the
464  * last dispatcher in the queue.
465  *
466  * If the event is a real keyboard action it's first tried as hotkey. In order
467  * to do so the target dispatcher is first determined, either the dispatcher
468  * that captured the keyboard or the last dispatcher in the queue. Then it's
469  * tried whether a hotkey and whether the hotkey can be processed. If the
470  * hotkey isn't processed the keyboard event is send to the dispatcher as
471  * normal keyboard event.
472  *
473  * The hotkey processing will have several queues (to be implemented in 1.9):
474  * - global hotkeys that always work eg toggling fullscreen mode.
475  * - main screen hotkeys, these work when one of the dialogs is shown without
476  * other dialogs on top of them. These hotkeys are for example
477  * preferences. The main screens are:
478  * - title screen
479  * - game
480  * - editor
481  * - mp lobby
482  * - map screen hotkeys, these work when a map is shown eg toggle grid. The
483  * screens are:
484  * - game
485  * - editor
486  * - local hotkeys, these are hotkeys that only work in a specific dialog eg
487  * recruit unit only works in the game screen.
488  *
489  * The queues are processed in from bottom to top in the list above, this
490  * allows an item to use a hotkey but have another handler function. Eg
491  * preferences in the editor might open another preferences dialog.
492  *
493  * @todo The hotkeys need to be implemented like above in 1.9.
494  *
495  * @todo This might change in the near future.
496  *
497  * @subsection distributor Event polishing and distribution
498  *
499  * The event distributor has the job to find the widget that should receive the
500  * event and which event(s) to send from a single event. In general an event is
501  * first send to the widget as-is, sending the raw events allows other
502  * distributors to be nested between this distributor and the intended target
503  * widget. Or the intended widget might not really be the intended widget but
504  * another distributor that wants to dispatch the event internally.
505  *
506  * However in the common cases this raw event isn't handled and the distributor
507  * needs to send the polished events. In the following sections the details of
508  * the conversion from raw to polished is described, it intentionally lacks the
509  * part of sending the raw events as well since it adds no value.
510  *
511  * A widget can capture the mouse, which means all mouse events are send to this
512  * widget, regardless where the mouse is. This is normally done in a mouse down
513  * event (for a button) so all events following it are send to that widget.
514  *
515  * @subsection mouse_motion Mouse motion
516  *
517  * This section describes the conversion from a raw mouse motion to the polished
518  * events it can generate:
519  * - @ref gui2::event::MOUSE_ENTER "MOUSE_ENTER"
520  * - @ref gui2::event::MOUSE_LEAVE "MOUSE_LEAVE"
521  * - @ref gui2::event::MOUSE_MOTION "MOUSE_MOTION"
522  *
523  * When the mouse is captured that widget will only receive motion events.
524  *
525  * If not captured the code checks whether the widget underneath the mouse is
526  * the same widget as at the last motion if event. If so that widget gets a
527  * motion event.
528  * If not the widget that before was underneath the mouse pointer (if any) gets
529  * a leave event and the widget newly underneath the mouse pointer (if any) gets
530  * an enter event.
531  *
532  * @subsection mouse_button Mouse buttons
533  *
534  * The mouse button code is a bit more complex and is separated in the various
535  * events to be send.
536  *
537  * @subsubsection mouse_button_down Mouse button down
538  *
539  * Some things start simple, so does the event of pressing down a mouse button.
540  * All it does is send the event to the widget as one of the following events:
541  * - @ref gui2::event::LEFT_BUTTON_DOWN "LEFT_BUTTON_DOWN"
542  * - @ref gui2::event::MIDDLE_BUTTON_DOWN "MIDDLE_BUTTON_DOWN"
543  * - @ref gui2::event::RIGHT_BUTTON_DOWN "RIGHT_BUTTON_DOWN"
544  *
545  * @todo Validate the code it seems a down event with a captured mouse doesn't
546  * really work as wanted. (Rare case but should work properly.) In general the
547  * mouse event handling needs testing to see whether the proper events are send
548  * all the time.
549  *
550  * @subsubsection mouse_button_up Mouse button up
551  *
552  * Simplicity ends here.
553  *
554  * @todo Document further.
555  *
556  * @subsubsection mouse_click Mouse click
557  *
558  * So the button up event has asked for mouse click, now we need to test whether
559  * the click will be a click or a double click. A double click is generated when
560  * the same widget is clicked twice in a short time and causes the following
561  * events:
562  * - @ref gui2::event::LEFT_BUTTON_DOUBLE_CLICK "LEFT_BUTTON_DOUBLE_CLICK"
563  * - @ref gui2::event::MIDDLE_BUTTON_DOUBLE_CLICK "MIDDLE_BUTTON_DOUBLE_CLICK"
564  * - @ref gui2::event::RIGHT_BUTTON_DOUBLE_CLICK "RIGHT_BUTTON_DOUBLE_CLICK"
565  *
566  * Otherwise one of the following single clicks is generated:
567  * - @ref gui2::event::LEFT_BUTTON_CLICK "LEFT_BUTTON_CLICK"
568  * - @ref gui2::event::MIDDLE_BUTTON_CLICK "MIDDLE_BUTTON_CLICK"
569  * - @ref gui2::event::RIGHT_BUTTON_CLICK "RIGHT_BUTTON_CLICK"
570  *
571  * @subsubsection double_click To double click or not to double click
572  *
573  * Wait a second, a widget has a field whether or not it wants a double click
574  * for a certain mouse button and now I see that it's bluntly ignored by the
575  * distributor. Indeed the distributor doesn't care about what the widget wants,
576  * it does what it wants and leaves the sorting out what's wanted to the
577  * dispatcher.
578  *
579  * The problem is that in the chain events are send to one widget that may not
580  * be interested in a double click, but another widget in the chain is. There
581  * are several solutions to this problem:
582  * -# Sending a click followed by a double click.
583  * -# Sending a click with a tag field that it actually is a double click.
584  * -# Send a double click and turn it into a click if the double click is
585  * unwanted.
586  *
587  * The first solution has the disadvantage that a toggle panel likes a click and
588  * double click, the first click selects the second deselects and now the
589  * deselected panel gets a double click. When the panel now checks whether it's
590  * selected it's not and might take the wrong action upon it.
591  *
592  * The second option is possible but would be rather intrusive in the code,
593  * since it would generate another event signature. Adding a signature just for
594  * this special case seemed a bit too much effort vs. gain. Also the widget
595  * needs to check whether a click is a click or a double click and choose a
596  * different code path for it. This in turn would mean a signal handler
597  * secretly might handle two events and lowers the transparency of the code.
598  *
599  * The third option also adds some special case handling but the scope is
600  * limited and only one part knows about the tricks done.
601  *
602  * The last option has been chosen and the dispatcher build the event chain and
603  * while building the chain it looks whether the widget wants the double click
604  * or not. It does this test by looking at the wants double click function and
605  * not test for a handler. The double click test function is made for this
606  * purpose and depending on the handler might again do the wrong thing.
607  * (A certain toggle panel might not want to do something on a double click but
608  * also not being deselected upon a double click. The latter to keep the UI
609  * consistent, a double click on a toggle panel might execute a special function
610  * or not, but always keep the panel selected. (That is if the panel can be
611  * selected.))
612  */
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:198
#define PLAIN_LOG
Definition: log.hpp:299
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 connect_signal_on_draw(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a callback when the widget is drawn.
Definition: dispatcher.cpp:208
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