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