The event handler class for the widget library. More...
#include <distributor.hpp>
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_ |
twidget * | keyboard_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... | |
twidget * | last_clicked_widget_ |
The widget the last click was on, used for double clicking. More... | |
twidget * | focus_ |
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 | |
twidget * | mouse_focus_ |
The widget that currently has the mouse focus_. More... | |
bool | mouse_captured_ |
Did the current widget capture the focus_? More... | |
twidget & | owner_ |
The widget that owns us. More... | |
size_t | hover_timer_ |
The timer for the hover event. More... | |
twidget * | hover_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... | |
The event handler class for the widget library.
Definition at line 235 of file distributor.hpp.
gui2::event::tdistributor::tdistributor | ( | twidget & | owner, |
const tdispatcher::tposition | queue_position | ||
) |
Definition at line 604 of file distributor.cpp.
References gui2::event::tdispatcher::connect_signal(), initialize_state(), gui2::event::NOTIFY_REMOVAL, gui2::event::tmouse_motion::owner_, gui2::event::SDL_KEY_DOWN, signal_handler_notify_removal(), and signal_handler_sdl_key_down().
gui2::event::tdistributor::~tdistributor | ( | ) |
Definition at line 636 of file distributor.cpp.
References gui2::event::tdispatcher::disconnect_signal(), gui2::event::NOTIFY_REMOVAL, gui2::event::tmouse_motion::owner_, gui2::event::SDL_KEY_DOWN, signal_handler_notify_removal(), and signal_handler_sdl_key_down().
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().
Adds the widget to the keyboard chain.
widget | The 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_.
Captures the keyboard input.
widget | The 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.
Remove the widget from the keyboard chain.
widget | The widget to be removed from the chain. |
Definition at line 685 of file distributor.cpp.
References gui2::event::find(), itor, and keyboard_focus_chain_.
|
private |
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().
|
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.
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().
|
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().
|
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().
|
private |
Definition at line 285 of file distributor.hpp.