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