The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
gui2::event::tdistributor Class Reference

The event handler class for the widget library. More...

#include <distributor.hpp>

Inheritance diagram for gui2::event::tdistributor:
Inheritance graph

Classes

class  layer
 

Public Member Functions

 tdistributor (twidget &owner, const tdispatcher::tposition queue_position)
 
 ~tdistributor ()
 
void initialize_state ()
 Initializes the state of the keyboard and mouse. More...
 
void keyboard_capture (twidget *widget)
 Captures the keyboard input. More...
 
void keyboard_add_to_chain (twidget *widget)
 Adds the widget to the keyboard chain. More...
 
void keyboard_remove_from_chain (twidget *widget)
 Remove the widget from the keyboard chain. More...
 
- Public Member Functions inherited from gui2::event::tmouse_button< sdl_button_down, sdl_button_up, button_down, button_up, button_click, button_double_click >
 tmouse_button (const std::string &name_, twidget &owner, const tdispatcher::tposition queue_position)
 
void initialize_state (const bool is_down)
 Initializes the state of the button. More...
 
- Public Member Functions inherited from gui2::event::tmouse_motion
 tmouse_motion (twidget &owner, const tdispatcher::tposition queue_position)
 
 ~tmouse_motion ()
 
void capture_mouse (const bool capture=true)
 Captures the mouse input. More...
 

Private Member Functions

void signal_handler_sdl_key_down (const SDLKey key, const SDLMod modifier, const utf8::string &unicode)
 Set of functions that handle certain events and sends them to the proper widget. More...
 
void signal_handler_notify_removal (tdispatcher &widget, const tevent event)
 

Private Attributes

layer layer_
 
twidgetkeyboard_focus_
 The widget that holds the keyboard focus_. More...
 
std::vector< twidget * > keyboard_focus_chain_
 Fall back keyboard focus_ items. More...
 

Additional Inherited Members

- Protected Member Functions inherited from gui2::event::tmouse_motion
void start_hover_timer (twidget *widget, const tpoint &coordinate)
 Starts the hover timer. More...
 
void stop_hover_timer ()
 Stops the current hover timer. More...
 
void mouse_enter (twidget *mouse_over)
 Called when the mouse enters a widget. More...
 
void mouse_leave ()
 Called when the mouse leaves the current widget. More...
 
- Protected Attributes inherited from gui2::event::tmouse_button< sdl_button_down, sdl_button_up, button_down, button_up, button_click, button_double_click >
Uint32 last_click_stamp_
 The time of the last click used for double clicking. More...
 
twidgetlast_clicked_widget_
 The widget the last click was on, used for double clicking. More...
 
twidgetfocus_
 If the mouse isn't captured we need to verify the up is on the same widget as the down so we send a proper click, also needed to send the up to the right widget. More...
 
- Protected Attributes inherited from gui2::event::tmouse_motion
twidgetmouse_focus_
 The widget that currently has the mouse focus_. More...
 
bool mouse_captured_
 Did the current widget capture the focus_? More...
 
twidgetowner_
 The widget that owns us. More...
 
size_t hover_timer_
 The timer for the hover event. More...
 
twidgethover_widget_
 The widget which should get the hover event. More...
 
tpoint hover_position_
 The anchor point of the hover event. More...
 
bool hover_shown_
 Has the hover been shown for the widget? More...
 

Detailed Description

The event handler class for the widget library.

Definition at line 235 of file distributor.hpp.

Constructor & Destructor Documentation

gui2::event::tdistributor::tdistributor ( twidget owner,
const tdispatcher::tposition  queue_position 
)
gui2::event::tdistributor::~tdistributor ( )

Member Function Documentation

void gui2::event::tdistributor::initialize_state ( )

Initializes the state of the keyboard and mouse.

Needed after initialization and reactivation.

Definition at line 645 of file distributor.cpp.

References gui2::event::init_mouse_location().

Referenced by tdistributor(), and gui2::twindow::twindow().

void gui2::event::tdistributor::keyboard_add_to_chain ( twidget widget)

Adds the widget to the keyboard chain.

Parameters
widgetThe widget to add to the chain. The widget should be valid widget, which hasn't been added to the chain yet.

Definition at line 675 of file distributor.cpp.

References gui2::event::find(), and keyboard_focus_chain_.

void gui2::event::tdistributor::keyboard_capture ( twidget widget)

Captures the keyboard input.

Parameters
widgetThe widget which should capture the keyboard. Sending nullptr releases the capturing.

Definition at line 656 of file distributor.cpp.

References DBG_GUI_E, gui2::event::tdispatcher::fire(), keyboard_focus_, LOG_HEADER, gui2::event::LOSE_KEYBOARD_FOCUS, gui2::event::tmouse_motion::owner_, and gui2::event::RECEIVE_KEYBOARD_FOCUS.

void gui2::event::tdistributor::keyboard_remove_from_chain ( twidget widget)

Remove the widget from the keyboard chain.

Parameters
widgetThe widget to be removed from the chain.

Definition at line 685 of file distributor.cpp.

References gui2::event::find(), itor, and keyboard_focus_chain_.

void gui2::event::tdistributor::signal_handler_notify_removal ( tdispatcher widget,
const tevent  event 
)
private
Todo:
Evaluate whether moving the cleanup parts in the subclasses.

It might be cleaner to do it that way, but creates extra small functions...

Definition at line 761 of file distributor.cpp.

References DBG_GUI_E, gui2::event::find(), gui2::event::tmouse_motion::hover_widget_, itor, keyboard_focus_, keyboard_focus_chain_, LOG_HEADER, gui2::event::tmouse_motion::mouse_focus_, and gui2::event::tmouse_motion::stop_hover_timer().

Referenced by tdistributor(), and ~tdistributor().

void gui2::event::tdistributor::signal_handler_sdl_key_down ( const SDLKey  key,
const SDLMod  modifier,
const utf8::string unicode 
)
private

Set of functions that handle certain events and sends them to the proper widget.

These functions are called by the SDL event handling functions.

Todo:
Test whether recursion protection is needed.
Todo:
Make sure we're not in the event chain.

No idea why we're here, but needs to be fixed, otherwise we keep calling this function recursively upon unhandled events...

Probably added to make sure the window can grab the events and handle + block them when needed, this is no longer needed with the chain.

Definition at line 696 of file distributor.cpp.

References DBG_GUI_E, gui2::event::tdispatcher::fire(), gui2::tcontrol::get_active(), keyboard_focus_, keyboard_focus_chain_, LOG_HEADER, gui2::event::tmouse_motion::owner_, and gui2::event::SDL_KEY_DOWN.

Referenced by tdistributor(), and ~tdistributor().

Member Data Documentation

twidget* gui2::event::tdistributor::keyboard_focus_
private

The widget that holds the keyboard focus_.

Definition at line 306 of file distributor.hpp.

Referenced by keyboard_capture(), signal_handler_notify_removal(), and signal_handler_sdl_key_down().

std::vector<twidget*> gui2::event::tdistributor::keyboard_focus_chain_
private

Fall back keyboard focus_ items.

When the focused widget didn't handle the keyboard event (or no handler for the keyboard focus_) it is send all widgets in this vector. The order is from rbegin() to rend(). If the keyboard_focus_ is in the vector it won't get the event twice. The first item added to the vector should be the window, so it will be the last handler and can dispatch the hotkeys registered.

Definition at line 318 of file distributor.hpp.

Referenced by keyboard_add_to_chain(), keyboard_remove_from_chain(), signal_handler_notify_removal(), and signal_handler_sdl_key_down().

layer gui2::event::tdistributor::layer_
private

Definition at line 285 of file distributor.hpp.


The documentation for this class was generated from the following files: