The Battle for Wesnoth  1.13.4+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<class T >
std::vector< std::pair
< twidget *, tevent > > 
build_event_chain (const tevent event, twidget *dispatcher, twidget *widget)
 Build the event chain. More...
 
template<>
std::vector< std::pair
< twidget *, tevent > > 
build_event_chain< tsignal_notification_function > (const tevent event, twidget *dispatcher, twidget *widget)
 Build the event chain for tsignal_notification_function. More...
 
template<>
std::vector< std::pair
< twidget *, tevent > > 
build_event_chain< tsignal_message_function > (const tevent event, twidget *dispatcher, twidget *widget)
 Build the event chain for tsignal_message_function. More...
 
template<class T , class F >
bool fire_event (const tevent event, std::vector< std::pair< twidget *, tevent > > &event_chain, twidget *dispatcher, twidget *widget, F functor)
 Helper function for fire_event. More...
 

Detailed Description

Contains the implementation details of the find function.

Function Documentation

template<class T >
std::vector<std::pair<twidget*, tevent> > gui2::event::implementation::build_event_chain ( const tevent  event,
twidget *  dispatcher,
twidget *  widget 
)
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.
widgetThe 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 299 of file dispatcher_private.hpp.

References gui2::event::tdispatcher::has_event(), gui2::twidget::parent(), gui2::event::tdispatcher::post, and gui2::event::tdispatcher::pre.

template<>
std::vector<std::pair<twidget*, tevent> > gui2::event::implementation::build_event_chain< tsignal_message_function > ( const tevent  event,
twidget *  dispatcher,
twidget *  widget 
)
inline

Build the event chain for tsignal_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::tdispatcher::post, and gui2::event::tdispatcher::pre.

template<>
std::vector<std::pair<twidget*, tevent> > gui2::event::implementation::build_event_chain< tsignal_notification_function > ( const tevent  event,
twidget *  dispatcher,
twidget *  widget 
)
inline

Build the event chain for tsignal_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 332 of file dispatcher_private.hpp.

References gui2::event::tdispatcher::post, and gui2::event::tdispatcher::pre.

template<class T , class F >
bool gui2::event::implementation::fire_event ( const tevent  event,
std::vector< std::pair< twidget *, tevent > > &  event_chain,
twidget *  dispatcher,
twidget *  widget,
functor 
)
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 404 of file dispatcher_private.hpp.

References gui2::event::tdispatcher::child, gui2::event::tdispatcher::tsignal< T >::child, functor(), gui2::event::tdispatcher::has_event(), itor, gui2::event::tdispatcher::tsignal< T >::post_child, and gui2::event::tdispatcher::tsignal< T >::pre_child.

Referenced by game_lua_kernel::intf_kill(), and game_lua_kernel::intf_select_unit().