The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Functions
gui2::event::implementation Namespace Reference

Contains the implementation details of the find function. More...

Classes

struct  find
 Specialized class when itor == end. More...
 
struct  find< false >
 Specialized class when itor != end. More...
 

Functions

template<typename T >
std::vector< std::pair< widget
*, ui_event > > 
build_event_chain (const ui_event event, widget *dispatcher, widget *w)
 Build the event chain. More...
 
template<>
std::vector< std::pair< widget
*, ui_event > > 
build_event_chain< signal_notification_function > (const ui_event event, widget *dispatcher, widget *w)
 Build the event chain for signal_notification_function. More...
 
template<>
std::vector< std::pair< widget
*, ui_event > > 
build_event_chain< signal_message_function > (const ui_event event, widget *dispatcher, widget *w)
 Build the event chain for signal_message_function. More...
 
template<typename T , typename... F>
bool fire_event (const ui_event event, std::vector< std::pair< widget *, ui_event >> &event_chain, widget *dispatcher, widget *w, F &&...params)
 Helper function for fire_event. More...
 

Detailed Description

Contains the implementation details of the find function.

Function Documentation

template<typename T >
std::vector<std::pair<widget*, ui_event> > gui2::event::implementation::build_event_chain ( const ui_event  event,
widget *  dispatcher,
widget *  w 
)
inline

Build the event chain.

The event chain is a chain of events starting from the first parent of the widget until (and including) the wanted parent. For all these widgets it will be tested whether they have either a pre or post handler for the event. This ways there will be list of widgets to try to send the events to. If there's no line from widget to parent the result is undefined. (If widget == dispatcher the result will always be empty.)

Precondition
dispatcher != nullptr
widget != nullptr
Parameters
eventThe event to test.
dispatcherThe final widget to test, this is also the dispatcher the sends the event.
wThe widget should parent(s) to check.
Returns
The list of widgets with a handler. The order will be (assuming all have a handler):
  • container 2
  • container 1
  • dispatcher

Definition at line 302 of file dispatcher_private.hpp.

References gui2::event::dispatcher::has_event(), gui2::widget::parent(), gui2::event::dispatcher::post, and gui2::event::dispatcher::pre.

template<>
std::vector<std::pair<widget*, ui_event> > gui2::event::implementation::build_event_chain< signal_message_function > ( const ui_event  event,
widget *  dispatcher,
widget *  w 
)
inline

Build the event chain for signal_message_function.

This function expects that the widget sending it is also the receiver. This assumption might change, but is valid for now. The function doesn't build an event chain from dispatcher to widget but from widget to its toplevel item (the first one without a parent) which we call window.

Precondition
dispatcher == widget
Returns
The list of widgets with a handler. The order will be (assuming all have a handler):
  • window
  • container 1
  • container 2

Definition at line 369 of file dispatcher_private.hpp.

References gui2::event::dispatcher::post, gui2::event::dispatcher::pre, and w.

template<>
std::vector<std::pair<widget*, ui_event> > gui2::event::implementation::build_event_chain< signal_notification_function > ( const ui_event  event,
widget *  dispatcher,
widget *  w 
)
inline

Build the event chain for signal_notification_function.

The notification is only send to the receiver it returns an empty chain. Since the pre and post queues are unused, it validates whether they are empty (using asserts).

Returns
An empty vector.

Definition at line 336 of file dispatcher_private.hpp.

References gui2::event::dispatcher::post, gui2::event::dispatcher::pre, and w.

template<typename T , typename... F>
bool gui2::event::implementation::fire_event ( const ui_event  event,
std::vector< std::pair< widget *, ui_event >> &  event_chain,
widget *  dispatcher,
widget *  w,
F &&...  params 
)
inline

Helper function for fire_event.

This is called with the same parameters as fire_event except for the event_chain, which contains the widgets with the events to call for them.

Definition at line 399 of file dispatcher_private.hpp.

References gui2::event::dispatcher::child, gui2::event::dispatcher::signal_type< T >::child, gui2::event::dispatcher::has_event(), gui2::event::dispatcher::signal_type< T >::post_child, gui2::event::dispatcher::signal_type< T >::pre_child, reverse(), and w.

Referenced by unit_creator::add_unit(), and game_lua_kernel::intf_select_unit().