Base class for all widgets. More...
#include <widget.hpp>
Public Types | |
enum | visibility { visibility::visible, visibility::hidden, visibility::invisible } |
Visibility settings done by the user. More... | |
enum | redraw_action { redraw_action::full, redraw_action::partly, redraw_action::none } |
Visibility set by the engine. More... | |
![]() | |
enum | event_queue_type { pre = 1, child = 2, post = 4 } |
enum | queue_position { front_pre_child, back_pre_child, front_child, back_child, front_post_child, back_post_child } |
The position where to add a new callback in the signal handler. More... | |
enum | mouse_behavior { all, hit, none } |
The behavior of the mouse events. More... | |
Public Member Functions | |
widget (const widget &)=delete | |
widget & | operator= (const widget &)=delete |
widget () | |
widget (const builder_widget &builder) | |
Constructor. More... | |
virtual | ~widget () override |
void | set_id (const std::string &id) |
const std::string & | id () const |
window * | get_window () |
Get the parent window. More... | |
const window * | get_window () const |
The constant version of get_window. More... | |
grid * | get_parent_grid () |
Get the parent grid. More... | |
void | set_parent (widget *parent) |
widget * | parent () |
virtual void | layout_initialize (const bool full_initialization) |
How the layout engine works. More... | |
virtual void | request_reduce_width (const unsigned maximum_width)=0 |
Tries to reduce the width of a widget. More... | |
virtual void | demand_reduce_width (const unsigned maximum_width) |
Tries to reduce the width of a widget. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a widget. More... | |
virtual void | demand_reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a widget. More... | |
point | get_best_size () const |
Gets the best size for the widget. More... | |
virtual bool | can_mouse_focus () const |
Whether the mouse move/click event go 'through' this widget. More... | |
virtual bool | can_wrap () const |
Can the widget wrap. More... | |
virtual void | set_origin (const point &origin) |
Sets the origin of the widget. More... | |
virtual void | set_size (const point &size) |
Sets the size of the widget. More... | |
virtual void | place (const point &origin, const point &size) |
Places the widget. More... | |
virtual void | move (const int x_offset, const int y_offset) |
Moves a widget. More... | |
virtual void | set_horizontal_alignment (const std::string &alignment) |
Sets the horizontal alignment of the widget within its parent grid. More... | |
virtual void | set_vertical_alignment (const std::string &alignment) |
Sets the horizontal alignment of the widget within its parent grid. More... | |
virtual void | layout_children () |
Allows a widget to update its children. More... | |
point | get_origin () const |
Returns the screen origin of the widget. More... | |
point | get_size () const |
Returns the size of the widget. More... | |
SDL_Rect | get_rectangle () const |
Gets the bounding rectangle of the widget on the screen. More... | |
int | get_x () const |
int | get_y () const |
unsigned | get_width () const |
unsigned | get_height () const |
void | set_linked_group (const std::string &linked_group) |
SDL_Rect | calculate_blitting_rectangle (const int x_offset, const int y_offset) |
Calculates the blitting rectangle of the widget. More... | |
SDL_Rect | calculate_clipping_rectangle (const int x_offset, const int y_offset) |
Calculates the clipping rectangle of the widget. More... | |
void | draw_background (surface &frame_buffer, int x_offset, int y_offset) |
Draws the background of a widget. More... | |
void | draw_children (surface &frame_buffer, int x_offset, int y_offset) |
Draws the children of a widget. More... | |
void | draw_foreground (surface &frame_buffer, int x_offset, int y_offset) |
Draws the foreground of the widget. More... | |
void | populate_dirty_list (window &caller, std::vector< widget *> &call_stack) |
Adds a widget to the dirty list if it is dirty. More... | |
SDL_Rect | get_dirty_rectangle () const |
Gets the dirty rectangle of the widget. More... | |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) |
Sets the visible rectangle for a widget. More... | |
void | set_is_dirty (const bool is_dirty) |
bool | get_is_dirty () const |
void | set_visible (const visibility visible) |
visibility | get_visible () const |
redraw_action | get_drawing_action () const |
void | set_debug_border_mode (const unsigned debug_border_mode) |
void | set_debug_border_color (const color_t debug_border_color) |
virtual widget * | find_at (const point &coordinate, const bool must_be_active) |
Returns the widget at the wanted coordinates. More... | |
virtual const widget * | find_at (const point &coordinate, const bool must_be_active) const |
The constant version of find_at. More... | |
virtual widget * | find (const std::string &id, const bool must_be_active) |
Returns a widget with the wanted id. More... | |
virtual const widget * | find (const std::string &id, const bool must_be_active) const |
The constant version of find. More... | |
virtual bool | has_widget (const widget &widget) const |
Does the widget contain the widget. More... | |
virtual bool | disable_click_dismiss () const =0 |
Does the widget disable easy close? More... | |
virtual iteration::walker_base * | create_walker ()=0 |
Creates a new walker object on the heap. More... | |
![]() | |
event_executor () | |
virtual | ~event_executor () |
void | set_wants_mouse_hover (const bool hover=true) |
bool | wants_mouse_hover () const |
void | set_wants_mouse_left_double_click (const bool click=true) |
bool | wants_mouse_left_double_click () const |
void | set_wants_mouse_middle_double_click (const bool click=true) |
bool | wants_mouse_middle_double_click () const |
event_executor & | set_wants_mouse_right_double_click (const bool click=true) |
bool | wants_mouse_right_double_click () const |
![]() | |
dispatcher () | |
virtual | ~dispatcher () |
void | connect () |
Connects the dispatcher to the event handler. More... | |
bool | has_event (const ui_event event, const event_queue_type event_type) |
bool | fire (const ui_event event, widget &target) |
Fires an event which has no extra parameters. More... | |
bool | fire (const ui_event event, widget &target, const point &coordinate) |
Fires an event which takes a coordinate parameter. More... | |
bool | fire (const ui_event event, widget &target, const SDL_Keycode key, const SDL_Keymod modifier, const std::string &unicode) |
Fires an event which takes keyboard parameters. More... | |
bool | fire (const ui_event event, widget &target, const point &pos, const point &distance) |
Fires an event which takes touch-motion parameters. More... | |
bool | fire (const ui_event event, widget &target, const point ¢er, float dTheta, float dDist, uint8_t numFingers) |
Fires an event which takes touch-gesture parameters. More... | |
bool | fire (const ui_event event, widget &target, void *) |
Fires an event which takes notification parameters. More... | |
bool | fire (const ui_event event, widget &target, const message &msg) |
Fires an event which takes message parameters. More... | |
bool | fire (const ui_event event, widget &target, const SDL_Event &sdlevent) |
Fires an event that's a raw SDL event. More... | |
bool | fire (const ui_event event, widget &target, const std::string &text, int32_t start, int32_t len) |
Fires an event which takes text input parameters. More... | |
template<ui_event E> | |
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. More... | |
template<ui_event E> | |
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. More... | |
template<ui_event E> | |
std::enable_if_t< is_mouse_event(E)> | connect_signal (const signal_mouse_function &signal, const queue_position position=back_child) |
Connect a signal for callback in set_event_mouse. More... | |
template<ui_event E> | |
std::enable_if_t< is_mouse_event(E)> | disconnect_signal (const signal_mouse_function &signal, const queue_position position=back_child) |
Disconnect a signal for callback in set_event_mouse. More... | |
template<ui_event E> | |
std::enable_if_t< is_keyboard_event(E)> | connect_signal (const signal_keyboard_function &signal, const queue_position position=back_child) |
Connect a signal for callback in set_event_keyboard. More... | |
template<ui_event E> | |
std::enable_if_t< is_keyboard_event(E)> | disconnect_signal (const signal_keyboard_function &signal, const queue_position position=back_child) |
Disconnect a signal for callback in set_event_keyboard. More... | |
template<ui_event E> | |
std::enable_if_t< is_touch_motion_event(E)> | connect_signal (const signal_touch_motion_function &signal, const queue_position position=back_child) |
Connect a signal for callback in set_event_touch_motion. More... | |
template<ui_event E> | |
std::enable_if_t< is_touch_motion_event(E)> | disconnect_signal (const signal_touch_motion_function &signal, const queue_position position=back_child) |
Disconnect a signal for callback in set_event_touch_motion. More... | |
template<ui_event E> | |
std::enable_if_t< is_touch_gesture_event(E)> | connect_signal (const signal_touch_gesture_function &signal, const queue_position position=back_child) |
Connect a signal for callback in set_event_touch_gesture. More... | |
template<ui_event E> | |
std::enable_if_t< is_touch_gesture_event(E)> | disconnect_signal (const signal_touch_gesture_function &signal, const queue_position position=back_child) |
Disconnect a signal for callback in set_event_touch_gesture. More... | |
template<ui_event E> | |
std::enable_if_t< is_notification_event(E)> | connect_signal (const signal_notification_function &signal, const queue_position position=back_child) |
Connect a signal for callback in set_event_notification. More... | |
template<ui_event E> | |
std::enable_if_t< is_notification_event(E)> | disconnect_signal (const signal_notification_function &signal, const queue_position position=back_child) |
Disconnect a signal for callback in set_event_notification. More... | |
template<ui_event E> | |
std::enable_if_t< is_message_event(E)> | connect_signal (const signal_message_function &signal, const queue_position position=back_child) |
Connect a signal for callback in set_event_message. More... | |
template<ui_event E> | |
std::enable_if_t< is_message_event(E)> | disconnect_signal (const signal_message_function &signal, const queue_position position=back_child) |
Disconnect a signal for callback in set_event_message. More... | |
template<ui_event E> | |
std::enable_if_t< is_raw_event_event(E)> | connect_signal (const signal_raw_event_function &signal, const queue_position position=back_child) |
Connect a signal for callback in set_raw_event. More... | |
template<ui_event E> | |
std::enable_if_t< is_raw_event_event(E)> | disconnect_signal (const signal_raw_event_function &signal, const queue_position position=back_child) |
Disconnect a signal for callback in set_raw_event. More... | |
template<ui_event E> | |
std::enable_if_t< is_text_input_event(E)> | connect_signal (const signal_text_input_function &signal, const queue_position position=back_child) |
Connect a signal for callback in set_text_input. More... | |
template<ui_event E> | |
std::enable_if_t< is_text_input_event(E)> | disconnect_signal (const signal_text_input_function &signal, const queue_position position=back_child) |
Disconnect a signal for callback in set_text_input. More... | |
void | capture_mouse () |
Captures the mouse. More... | |
void | release_mouse () |
Releases the mouse capture. More... | |
void | set_mouse_behavior (const mouse_behavior mouse_behavior) |
mouse_behavior | get_mouse_behavior () const |
void | set_want_keyboard_input (const bool want_keyboard_input) |
bool | get_want_keyboard_input () const |
void | register_hotkey (const hotkey::HOTKEY_COMMAND id, const hotkey_function &function) |
Registers a hotkey. More... | |
bool | execute_hotkey (const hotkey::HOTKEY_COMMAND id) |
Executes a hotkey. More... | |
![]() | |
enable_lua_ptr (widget *tp) | |
Protected Member Functions | |
void | set_layout_size (const point &size) |
const point & | layout_size () const |
void | clear_layout_size () |
Throws away layout_size_. More... | |
Private Member Functions | |
virtual point | calculate_best_size () const =0 |
Calculates the best size. More... | |
virtual void | impl_draw_background (surface &) |
See draw_background. More... | |
virtual void | impl_draw_background (surface &, int, int) |
virtual void | impl_draw_children (surface &, int, int) |
See draw_children. More... | |
virtual void | impl_draw_foreground (surface &, int, int) |
See draw_foreground. More... | |
virtual void | child_populate_dirty_list (window &caller, const std::vector< widget *> &call_stack) |
Tries to add all children of a container to the dirty list. More... | |
void | draw_debug_border () |
void | draw_debug_border (int x_offset, int y_offset) |
virtual bool | is_at (const point &coordinate) const override |
See event::dispatcher::is_at. More... | |
bool | is_at (const point &coordinate, const bool must_be_active) const |
Is the coordinate inside our area. More... | |
bool | recursive_is_visible (const widget *widget, const bool must_be_active) const |
Is the widget and every single one of its parents visible? More... | |
Private Attributes | |
std::string | id_ |
The id is the unique name of the widget in a certain context. More... | |
widget * | parent_ |
The parent widget. More... | |
int | x_ |
The x-coordinate of the widget on the screen. More... | |
int | y_ |
The y-coordinate of the widget on the screen. More... | |
unsigned | width_ |
The width of the widget. More... | |
unsigned | height_ |
The height of the widget. More... | |
point | layout_size_ |
The best size for the widget. More... | |
std::string | linked_group_ |
The linked group the widget belongs to. More... | |
bool | is_dirty_ |
Is the widget dirty? More... | |
visibility | visible_ |
Field for the status of the visibility. More... | |
redraw_action | redraw_action_ |
Field for the action to do on a drawing request. More... | |
SDL_Rect | clipping_rectangle_ |
The clipping rectangle if a widget is partly visible. More... | |
unsigned | debug_border_mode_ |
Mode for drawing the debug border. More... | |
color_t | debug_border_color_ |
The color for the debug border. More... | |
Friends | |
class | debug_layout_graph |
class | window |
Base class for all widgets.
From this abstract all other widgets should derive. It contains the minimal info needed for a real widget and some pure abstract functions which need to be implemented by classes deriving from this class.
Definition at line 49 of file widget.hpp.
|
strong |
Visibility set by the engine.
This state only will be used if visible_ is visibility::visible depending on this state the widget might not be visible after all.
Enumerator | |
---|---|
full | The widget is fully visible. The widget should be drawn if dirty_ is |
partly | The widget is partly visible. The should be drawn if dirty_ is |
none | The widget is not visible. The widget should not be drawn if dirty_ is |
Definition at line 104 of file widget.hpp.
|
strong |
Visibility settings done by the user.
Enumerator | |
---|---|
visible | The user sets the widget visible, that means:
|
hidden | The user sets the widget hidden, that means:
|
invisible | The user set the widget invisible, that means:
|
Definition at line 59 of file widget.hpp.
|
delete |
gui2::widget::widget | ( | ) |
Definition at line 30 of file widget.cpp.
References DBG_GUI_LF.
Referenced by gui2::window::add_to_tab_order(), gui2::policy::placement::independent::find(), gui2::policy::placement::horizontal_list::find_at(), gui2::policy::placement::vertical_list::find_at(), gui2::tree_view_node_implementation::find_at(), gui2::policy::placement::table::find_at(), gui2::tree_view_node_implementation::find_at_aux(), gui2::policy::select_action::selection::init(), gui2::listbox::order_by_column(), gui2::grid::set_active(), and set_id().
|
explicit |
Constructor.
builder | The builder object with the settings for the object. |
Definition at line 53 of file widget.cpp.
References DBG_GUI_LF.
|
overridevirtual |
Definition at line 76 of file widget.cpp.
References DBG_GUI_LF, gui2::event::dispatcher::fire(), get_window(), id_, linked_group_, gui2::event::NOTIFY_REMOVAL, p, parent(), and gui2::window::remove_linked_widget().
|
privatepure virtual |
Calculates the best size.
This function calculates the best size and ignores the current values in the layout phase. Note containers can call the get_best_size() of their children since it is meant to update itself.
Implemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::listbox, gui2::tree_view_node, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::grid, gui2::policy::placement::horizontal_list, gui2::styled_widget, gui2::matrix, gui2::pane, gui2::scrollbar_container, gui2::viewport, gui2::container_base, gui2::drawing, gui2::image, gui2::size_lock, gui2::slider, and gui2::spacer.
Referenced by get_best_size().
SDL_Rect gui2::widget::calculate_blitting_rectangle | ( | const int | x_offset, |
const int | y_offset | ||
) |
Calculates the blitting rectangle of the widget.
The blitting rectangle is the entire widget rectangle, but offsetted for drawing position.
x_offset | The offset in the x-direction when drawn. |
y_offset | The offset in the y-direction when drawn. |
Definition at line 351 of file widget.cpp.
References get_rectangle().
Referenced by draw_debug_border(), gui2::panel::impl_draw_background(), gui2::minimap::impl_draw_background(), gui2::styled_widget::impl_draw_background(), and gui2::panel::impl_draw_foreground().
SDL_Rect gui2::widget::calculate_clipping_rectangle | ( | const int | x_offset, |
const int | y_offset | ||
) |
Calculates the clipping rectangle of the widget.
The clipping rectangle is used then the redraw_action_ is redraw_action::partly. Since the drawing can be offsetted it also needs offset parameters.
x_offset | The offset in the x-direction when drawn. |
y_offset | The offset in the y-direction when drawn. |
Definition at line 360 of file widget.cpp.
References clipping_rectangle_.
Referenced by draw_background(), draw_children(), draw_debug_border(), and draw_foreground().
|
inlinevirtual |
Whether the mouse move/click event go 'through' this widget.
Reimplemented in gui2::grid, gui2::label, and gui2::image.
Definition at line 326 of file widget.hpp.
References utf8::size().
Referenced by gui2::event::mouse_motion::signal_handler_sdl_mouse_motion().
|
virtual |
Can the widget wrap.
When a widget can wrap it can reduce its width by increasing its height. When a layout is too wide it should first try to wrap and if that fails it should check the vertical scrollbar status. After wrapping the height might (probably will) change so the layout engine needs to recalculate the height after wrapping.
Reimplemented in gui2::grid, gui2::scrollbar_container, gui2::container_base, gui2::scroll_label, and gui2::label.
Definition at line 215 of file widget.cpp.
Referenced by gui2::container_base::can_wrap(), gui2::grid::can_wrap(), gui2::styled_widget::get_best_text_size(), gui2::styled_widget::request_reduce_width(), and gui2::text_box::update_canvas().
|
privatevirtual |
Tries to add all children of a container to the dirty list.
caller | The parent window, if dirty it should register itself to this window. |
call_stack | The call-stack of widgets traversed to reach this function. |
Reimplemented in gui2::scrollbar_container, gui2::generator_base, gui2::grid, gui2::listbox, gui2::matrix, gui2::container_base, gui2::tree_view, gui2::pane, and gui2::viewport.
Definition at line 439 of file widget.cpp.
Referenced by populate_dirty_list().
|
inlineprotected |
Throws away layout_size_.
Use with care: this function does not recurse to child widgets.
See Layout algorithm for more information.
Definition at line 452 of file widget.hpp.
Referenced by gui2::container_base::container_base().
|
pure virtual |
Creates a new walker object on the heap.
Implemented in gui2::grid, gui2::matrix, gui2::tree_view_node, gui2::container_base, gui2::pane, gui2::styled_widget, and gui2::viewport.
|
virtual |
Tries to reduce the height of a widget.
This function does it more aggressively and should only be used when using scrollbars failed.
See Layout algorithm for more information.
maximum_height | The wanted maximum height. |
Reimplemented in gui2::grid, and gui2::container_base.
Definition at line 187 of file widget.cpp.
|
virtual |
Tries to reduce the width of a widget.
This function does it more aggressively and should only be used when using scrollbars and wrapping failed.
See Layout algorithm for more information.
maximum_width | The wanted maximum width. |
Reimplemented in gui2::grid, and gui2::container_base.
Definition at line 177 of file widget.cpp.
|
pure virtual |
Does the widget disable easy close?
Implemented in gui2::grid, gui2::tree_view_node, gui2::matrix, gui2::container_base, gui2::scrollbar_container, gui2::pane, gui2::styled_widget, gui2::label, gui2::viewport, gui2::drawing, gui2::image, gui2::spacer, gui2::minimap, and gui2::progress_bar.
Referenced by gui2::grid::disable_click_dismiss().
void gui2::widget::draw_background | ( | surface & | frame_buffer, |
int | x_offset, | ||
int | y_offset | ||
) |
Draws the background of a widget.
Derived should override impl_draw_background instead of changing this function.
frame_buffer | The surface to draw upon. |
x_offset | The offset in the x-direction in the frame_buffer to draw. |
y_offset | The offset in the y-direction in the frame_buffer to draw. |
Definition at line 369 of file widget.cpp.
References calculate_clipping_rectangle(), draw_debug_border(), impl_draw_background(), partly, redraw_action_, visible, and visible_.
Referenced by gui2::viewport::impl_draw_children(), and gui2::grid::impl_draw_children().
void gui2::widget::draw_children | ( | surface & | frame_buffer, |
int | x_offset, | ||
int | y_offset | ||
) |
Draws the children of a widget.
Containers should draw their children when they get this request.
Derived should override impl_draw_children instead of changing this function.
frame_buffer | The surface to draw upon. |
x_offset | The offset in the x-direction in the frame_buffer to draw. |
y_offset | The offset in the y-direction in the frame_buffer to draw. |
Definition at line 386 of file widget.cpp.
References calculate_clipping_rectangle(), impl_draw_children(), partly, redraw_action_, visible, and visible_.
Referenced by gui2::viewport::impl_draw_children(), gui2::pane::impl_draw_children(), gui2::container_base::impl_draw_children(), gui2::matrix::impl_draw_children(), gui2::tree_view_node::impl_draw_children(), gui2::grid::impl_draw_children(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children().
|
private |
Definition at line 523 of file widget.cpp.
References clipping_rectangle_, debug_border_color_, debug_border_mode_, sdl::draw_rectangle(), sdl::fill_rectangle(), get_rectangle(), partly, and redraw_action_.
Referenced by draw_background().
|
private |
Definition at line 546 of file widget.cpp.
References calculate_blitting_rectangle(), calculate_clipping_rectangle(), debug_border_color_, debug_border_mode_, sdl::draw_rectangle(), sdl::fill_rectangle(), partly, and redraw_action_.
void gui2::widget::draw_foreground | ( | surface & | frame_buffer, |
int | x_offset, | ||
int | y_offset | ||
) |
Draws the foreground of the widget.
Some widgets e.g. panel and window have a back and foreground layer this function requests the drawing of the foreground.
Derived should override impl_draw_foreground instead of changing this function.
frame_buffer | The surface to draw upon. |
x_offset | The offset in the x-direction in the frame_buffer to draw. |
y_offset | The offset in the y-direction in the frame_buffer to draw. |
Definition at line 401 of file widget.cpp.
References calculate_clipping_rectangle(), impl_draw_foreground(), partly, redraw_action_, visible, and visible_.
Referenced by gui2::viewport::impl_draw_children(), and gui2::grid::impl_draw_children().
|
virtual |
Returns a widget with the wanted id.
id | The id of the widget to find. |
must_be_active | The widget should be active, not all widgets have an active flag, those who don't ignore flag. |
nullptr | No widget with the id found (or not active if must_be_active was set). |
Reimplemented in gui2::policy::placement::independent, gui2::grid, gui2::window, gui2::styled_widget, gui2::tree_view_node, gui2::stacked_widget, gui2::matrix, gui2::container_base, gui2::scrollbar_container, and gui2::viewport.
Definition at line 583 of file widget.cpp.
References id_.
Referenced by gui2::implementation::builder_instance::build(), gui2::policy::placement::independent::create_item(), gui2::grid_implementation::find(), gui2::matrix::find(), gui2::tree_view_node::find(), gui2::styled_widget::find(), find_child_by_name(), find_widget_impl(), and gui2::dialogs::lobby_player_info::pre_show().
|
virtual |
The constant version of find.
Reimplemented in gui2::policy::placement::independent, gui2::grid, gui2::window, gui2::styled_widget, gui2::tree_view_node, gui2::stacked_widget, gui2::matrix, gui2::container_base, gui2::scrollbar_container, and gui2::viewport.
Definition at line 588 of file widget.cpp.
References id_.
Returns the widget at the wanted coordinates.
coordinate | The coordinate which should be inside the widget. |
must_be_active | The widget should be active, not all widgets have an active flag, those who don't ignore flag. |
nullptr | No widget at the wanted coordinate found (or not active if must_be_active was set). |
Reimplemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::generator_base, gui2::policy::placement::vertical_list, gui2::grid, gui2::policy::placement::horizontal_list, gui2::window, gui2::styled_widget, gui2::tree_view_node, gui2::matrix, gui2::scrollbar_container, gui2::container_base, gui2::pane, gui2::toggle_panel, and gui2::viewport.
Definition at line 572 of file widget.cpp.
References is_at().
Referenced by gui2::grid_implementation::find_at(), gui2::scrollbar_container::find_at(), gui2::styled_widget::find_at(), gui2::tree_view_node_implementation::find_at(), gui2::tree_view_node_implementation::find_at_aux(), gui2::event::mouse_button::signal_handler_sdl_button_down(), gui2::event::mouse_button::signal_handler_sdl_button_up(), gui2::event::mouse_motion::signal_handler_sdl_mouse_motion(), gui2::event::mouse_motion::signal_handler_sdl_touch_motion(), gui2::event::mouse_motion::signal_handler_sdl_wheel(), and gui2::event::mouse_motion::signal_handler_show_helptip().
|
virtual |
The constant version of find_at.
Reimplemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::generator_base, gui2::policy::placement::vertical_list, gui2::grid, gui2::policy::placement::horizontal_list, gui2::window, gui2::styled_widget, gui2::tree_view_node, gui2::matrix, gui2::container_base, gui2::scrollbar_container, gui2::pane, gui2::toggle_panel, and gui2::viewport.
Definition at line 577 of file widget.cpp.
References is_at().
point gui2::widget::get_best_size | ( | ) | const |
Gets the best size for the widget.
During the layout phase a best size will be determined, several stages might change the best size. This function will return the currently best size as determined during the layout phase.
Definition at line 192 of file widget.cpp.
References calculate_best_size(), gui2::window::get_linked_size(), get_window(), invisible, layout_size_, linked_group_, visible_, point::x, and point::y.
Referenced by gui2::tree_view_node::add_child_impl(), gui2::container_base::calculate_best_size(), gui2::viewport::calculate_best_size(), gui2::scrollbar_container::calculate_best_size(), gui2::matrix::calculate_best_size(), gui2::policy::placement::horizontal_list::calculate_best_size(), gui2::policy::placement::vertical_list::calculate_best_size(), gui2::tree_view_node::calculate_best_size(), gui2::policy::placement::table::calculate_best_size(), gui2::policy::placement::independent::calculate_best_size(), gui2::tree_view_node::get_folded_size(), gui2::tree_view_node::get_unfolded_size(), gui2::window_implementation::layout(), gui2::window::layout(), gui2::window::layout_linked_widgets(), gui2::viewport::place(), gui2::size_lock::place(), gui2::policy::placement::horizontal_list::place(), gui2::policy::placement::vertical_list::place(), gui2::tree_view_node::place(), gui2::grid::child::place(), gui2::policy::placement::table::place(), gui2::pane::place_children(), gui2::pane::place_or_set_origin_children(), gui2::pane::prepare_placement(), gui2::container_base::reduce_height(), gui2::grid::reduce_height(), gui2::container_base::reduce_width(), gui2::grid::reduce_width(), gui2::grid::request_placement(), gui2::container_base::request_reduce_height(), gui2::scrollbar_container::request_reduce_height(), gui2::styled_widget::request_reduce_height(), gui2::grid::request_reduce_height(), gui2::container_base::request_reduce_width(), gui2::scrollbar_container::request_reduce_width(), gui2::styled_widget::request_reduce_width(), gui2::grid::request_reduce_width(), gui2::listbox::resize_content(), gui2::listbox::set_content_size(), and gui2::pane::signal_handler_request_placement().
SDL_Rect gui2::widget::get_dirty_rectangle | ( | ) | const |
Gets the dirty rectangle of the widget.
Depending on the redraw_action_ it returns the rectangle this widget dirties while redrawing.
Definition at line 446 of file widget.cpp.
References clipping_rectangle_, full, get_rectangle(), and redraw_action_.
widget::redraw_action gui2::widget::get_drawing_action | ( | ) | const |
Definition at line 507 of file widget.cpp.
References height_, none, redraw_action_, and width_.
Referenced by gui2::grid::impl_draw_children(), and populate_dirty_list().
unsigned gui2::widget::get_height | ( | ) | const |
Definition at line 329 of file widget.cpp.
References height_.
Referenced by gui2::scrollbar_container::content_resize_height(), gui2::styled_widget::get_text_maximum_height(), gui2::vertical_scrollbar::in_orthogonal_range(), gui2::vertical_scrollbar::on_bar(), gui2::horizontal_scrollbar::on_bar(), gui2::slider::on_bar(), gui2::horizontal_scrollbar::on_positioner(), gui2::slider::on_positioner(), gui2::scrollbar_container::place(), gui2::listbox::remove_row(), gui2::policy::placement::vertical_list::set_origin(), gui2::policy::placement::table::set_origin(), gui2::scrollbar_container::show_content_rect(), and gui2::text_box::update_offsets().
bool gui2::widget::get_is_dirty | ( | ) | const |
Definition at line 470 of file widget.cpp.
References is_dirty_.
point gui2::widget::get_origin | ( | ) | const |
Returns the screen origin of the widget.
Definition at line 299 of file widget.cpp.
Referenced by gui2::scrollbar_container::content_resize_request(), get_rectangle(), gui2::tree_view::layout_children(), gui2::listbox::layout_children(), gui2::scrollbar_container::place(), gui2::listbox::place(), gui2::grid::request_placement(), gui2::scroll_label::set_label(), gui2::scrollbar_container::set_origin(), gui2::listbox::set_row_shown(), and gui2::dialogs::mp_lobby::update_playerlist().
grid * gui2::widget::get_parent_grid | ( | ) |
Get the parent grid.
nullptr | No parent grid found. |
Definition at line 144 of file widget.cpp.
References parent_.
Referenced by set_horizontal_alignment(), and set_vertical_alignment().
SDL_Rect gui2::widget::get_rectangle | ( | ) | const |
Gets the bounding rectangle of the widget on the screen.
Definition at line 309 of file widget.cpp.
References gui2::create_rect(), get_origin(), and get_size().
Referenced by calculate_blitting_rectangle(), gui2::window::draw(), draw_debug_border(), gui2::container_base::get_client_rect(), gui2::panel::get_client_rect(), gui2::toggle_panel::get_client_rect(), get_dirty_rectangle(), gui2::text_box_base::handle_editing(), gui2::panel::impl_draw_background(), gui2::styled_widget::impl_draw_background(), gui2::panel::impl_draw_foreground(), is_at(), gui2::listbox::list_item_clicked(), gui2::dialogs::drop_down_menu::mouse_up_callback(), gui2::scrollbar_container::place(), gui2::listbox::place(), place(), gui2::scrollbar_container::set_visible_rectangle(), set_visible_rectangle(), gui2::window::show(), gui2::styled_widget::signal_handler_show_helptip(), gui2::styled_widget::signal_handler_show_tooltip(), gui2::window::undraw(), and gui2::listbox::update_visible_area_on_key_event().
point gui2::widget::get_size | ( | ) | const |
Returns the size of the widget.
Definition at line 304 of file widget.cpp.
References height_, and width_.
Referenced by gui2::tree_view_node::add_child_impl(), gui2::tree_view::clear(), gui2::scrollbar_container::content_resize_request(), get_rectangle(), gui2::tree_view::layout_children(), gui2::listbox::layout_children(), gui2::pane::place_or_set_origin_children(), gui2::tree_view::remove_node(), gui2::grid::request_placement(), gui2::tree_view::resize_content(), gui2::listbox::resize_content(), gui2::scroll_label::set_label(), gui2::tree_view_node::set_origin(), set_visible(), and gui2::listbox::update_content_size().
widget::visibility gui2::widget::get_visible | ( | ) | const |
Definition at line 502 of file widget.cpp.
References visible_.
Referenced by gui2::scrollbar_container::calculate_best_size(), gui2::scrollbar_container::content_resize_height(), gui2::scrollbar_container::content_resize_request(), gui2::scrollbar_container::content_resize_width(), gui2::styled_widget::disable_click_dismiss(), gui2::grid::disable_click_dismiss(), gui2::viewport::impl_draw_children(), gui2::pane::impl_draw_children(), gui2::container_base::impl_draw_children(), gui2::scrollbar_container::impl_draw_children(), gui2::grid::impl_draw_children(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children(), gui2::viewport::layout_initialize(), gui2::pane::layout_initialize(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::layout_initialize(), gui2::grid::child::place(), gui2::pane::place_children(), gui2::pane::place_or_set_origin_children(), gui2::pane::prepare_placement(), gui2::listbox::remove_row(), gui2::scrollbar_container::request_reduce_height(), gui2::scrollbar_container::request_reduce_width(), gui2::listbox::resize_content(), gui2::pane::set_origin_children(), gui2::set_scrollbar_mode(), gui2::pane::signal_handler_request_placement(), gui2::scrollbar_container::signal_handler_sdl_touch_motion(), gui2::scrollbar_container::signal_handler_sdl_wheel_down(), gui2::scrollbar_container::signal_handler_sdl_wheel_left(), gui2::scrollbar_container::signal_handler_sdl_wheel_right(), gui2::scrollbar_container::signal_handler_sdl_wheel_up(), and gui2::listbox::update_content_size().
unsigned gui2::widget::get_width | ( | ) | const |
Definition at line 324 of file widget.cpp.
References width_.
Referenced by gui2::scrollbar_container::content_resize_width(), gui2::styled_widget::get_text_maximum_width(), gui2::horizontal_scrollbar::in_orthogonal_range(), gui2::vertical_scrollbar::on_bar(), gui2::horizontal_scrollbar::on_bar(), gui2::slider::on_bar(), gui2::vertical_scrollbar::on_positioner(), gui2::scrollbar_container::place(), gui2::listbox::remove_row(), gui2::policy::placement::horizontal_list::set_origin(), gui2::policy::placement::table::set_origin(), gui2::scrollbar_container::show_content_rect(), and gui2::text_box::update_offsets().
window * gui2::widget::get_window | ( | ) |
Get the parent window.
nullptr | No parent window found. |
Definition at line 116 of file widget.cpp.
References parent_.
Referenced by gui2::addon_list::add_list_to_keyboard_chain(), gui2::scrollbar_container::content_resize_height(), gui2::scrollbar_container::content_resize_request(), gui2::scrollbar_container::content_resize_width(), gui2::text_box_base::cursor_timer_callback(), gui2::policy::placement::horizontal_list::find_at(), gui2::policy::placement::vertical_list::find_at(), gui2::policy::placement::table::find_at(), gui2::policy::placement::independent::find_at(), get_best_size(), gui2::container_base::inject_linked_groups(), intf_remove_dialog_item(), intf_set_dialog_callback(), intf_set_dialog_focus(), layout_initialize(), gui2::listbox::list_item_clicked(), gui2::unit_preview_pane::profile_button_callback(), gui2::scrollbar_base::recalculate(), gui2::grid::request_placement(), gui2::listbox::set_row_shown(), gui2::toggle_button::set_value(), gui2::toggle_panel::set_value(), set_visible(), gui2::button::signal_handler_left_button_click(), gui2::menu_button::signal_handler_left_button_click(), gui2::multimenu_button::signal_handler_left_button_click(), gui2::toggle_button::signal_handler_left_button_double_click(), gui2::toggle_panel::signal_handler_left_button_double_click(), gui2::button::signal_handler_left_button_down(), gui2::repeating_button::signal_handler_left_button_down(), gui2::scroll_label::signal_handler_left_button_down(), gui2::menu_button::signal_handler_left_button_down(), gui2::tree_view::signal_handler_left_button_down(), gui2::multimenu_button::signal_handler_left_button_down(), gui2::text_box::signal_handler_left_button_down(), gui2::slider_base::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_down(), gui2::slider::signal_handler_left_button_up(), gui2::slider_base::signal_handler_left_button_up(), gui2::scrollbar_base::signal_handler_left_button_up(), gui2::chatbox::signal_handler_receive_keyboard_focus(), gui2::pane::signal_handler_request_placement(), gui2::chatbox::switch_to_window(), WIDGET_GETTER(), gui2::window::window_instance(), and ~widget().
const window * gui2::widget::get_window | ( | ) | const |
int gui2::widget::get_x | ( | ) | const |
Definition at line 314 of file widget.cpp.
References x_.
Referenced by gui2::text_box::handle_mouse_selection(), gui2::viewport::impl_draw_children(), place(), gui2::scrollbar_container::scrollbar_moved(), gui2::grid::set_origin(), gui2::scrollbar_container::show_content_rect(), gui2::label::signal_handler_left_button_click(), gui2::slider_base::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_down(), gui2::slider_base::signal_handler_left_button_up(), gui2::scrollbar_base::signal_handler_left_button_up(), gui2::label::signal_handler_mouse_motion(), gui2::slider_base::signal_handler_mouse_motion(), gui2::scrollbar_base::signal_handler_mouse_motion(), and gui2::label::signal_handler_right_button_click().
int gui2::widget::get_y | ( | ) | const |
Definition at line 319 of file widget.cpp.
References y_.
Referenced by gui2::text_box::handle_mouse_selection(), gui2::viewport::impl_draw_children(), place(), gui2::listbox::remove_row(), gui2::scrollbar_container::scrollbar_moved(), gui2::grid::set_origin(), gui2::scrollbar_container::show_content_rect(), gui2::label::signal_handler_left_button_click(), gui2::slider_base::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_down(), gui2::slider_base::signal_handler_left_button_up(), gui2::scrollbar_base::signal_handler_left_button_up(), gui2::label::signal_handler_mouse_motion(), gui2::slider_base::signal_handler_mouse_motion(), gui2::scrollbar_base::signal_handler_mouse_motion(), and gui2::label::signal_handler_right_button_click().
|
virtual |
Does the widget contain the widget.
Widgets can be containers which have more widgets inside them, this function will traverse in those child widgets and tries to find the wanted widget.
widget | Pointer to the widget to find. |
widget
was found. Reimplemented in gui2::grid, and gui2::container_base.
Definition at line 594 of file widget.cpp.
Referenced by gui2::container_base::has_widget(), and gui2::grid::has_widget().
const std::string & gui2::widget::id | ( | ) | const |
Definition at line 109 of file widget.cpp.
References id_.
Referenced by gui2::window::add_linked_widget(), gui2::chatbox::append_to_chatbox(), gui2::iteration::policy::order::bottom_up< VW, VG, VC >::bottom_up(), gui2::dialogs::campaign_selection::campaign_selected(), gui2::window::click_dismiss(), connect_queue(), gui2::scrollbar_container::find(), gui2::stacked_widget::find(), gui2::grid::find(), gui2::policy::select_action::selection::init(), gui2::window::init_linked_size_group(), gui2::iteration::policy::order::bottom_up< VW, VG, VC >::next(), gui2::iteration::policy::order::top_down< VW, VG, VC >::next(), gui2::dialogs::help_browser::on_topic_select(), gui2::grid::place(), place(), gui2::dialogs::campaign_selection::post_show(), gui2::grid::remove_child(), gui2::window::remove_linked_widget(), gui2::styled_widget::request_reduce_height(), gui2::styled_widget::request_reduce_width(), gui2::addon_list::select_addon(), set_id(), gui2::dialogs::select_orb_colors::setup_orb_group(), gui2::text_box::signal_handler_mouse_motion(), gui2::toggle_panel::signal_handler_pre_left_button_click(), gui2::dialogs::campaign_selection::sort_campaigns(), gui2::event::mouse_motion::start_hover_timer(), gui2::event::mouse_motion::stop_hover_timer(), gui2::grid::swap_child(), gui2::chatbox::switch_to_window(), gui2::iteration::policy::order::top_down< VW, VG, VC >::up(), gui2::dialogs::mp_options_helper::update_options_data_map(), and gui2::dialogs::mp_options_helper::update_options_data_map_menu_button().
|
inlineprivatevirtual |
|
inlineprivatevirtual |
Reimplemented in gui2::styled_widget, gui2::multi_page, gui2::toggle_panel, gui2::minimap, gui2::spacer, and gui2::panel.
Definition at line 593 of file widget.hpp.
|
inlineprivatevirtual |
See draw_children.
Reimplemented in gui2::grid, gui2::scrollbar_container, gui2::tree_view_node, gui2::generator_base, gui2::matrix, gui2::container_base, gui2::pane, and gui2::viewport.
Definition at line 602 of file widget.hpp.
Referenced by draw_children().
|
inlineprivatevirtual |
See draw_foreground.
Reimplemented in gui2::styled_widget, gui2::toggle_panel, and gui2::panel.
Definition at line 611 of file widget.hpp.
References wfl::call_stack.
Referenced by draw_foreground().
|
overrideprivatevirtual |
Implements gui2::event::dispatcher.
Definition at line 599 of file widget.cpp.
Referenced by find_at().
|
private |
Is the coordinate inside our area.
Helper for find_at so also looks at our visibility.
coordinate | The coordinate which should be inside the widget. |
must_be_active | The widget should be active, not all widgets have an active flag, those who don't ignore flag. |
Definition at line 618 of file widget.cpp.
References get_rectangle(), sdl::point_in_rect(), and recursive_is_visible().
|
virtual |
Allows a widget to update its children.
Before the window is populating the dirty list the widgets can update their content, which allows delayed initialization. This delayed initialization is only allowed if the widget resizes itself, not when being placed.
Reimplemented in gui2::scrollbar_container, gui2::grid, gui2::listbox, gui2::matrix, gui2::container_base, gui2::tree_view, gui2::size_lock, and gui2::stacked_widget.
Definition at line 294 of file widget.cpp.
Referenced by gui2::size_lock::layout_children(), and gui2::grid::layout_children().
|
virtual |
How the layout engine works.
Every widget has a member layout_size_ which holds the best size in the current layout phase. When the windows starts the layout phase it calls layout_initialize which resets this value.
Every widget has two function to get the best size. get_best_size tests whether layout_size_ is set and if so returns that value otherwise it calls calculate_best_size so the size can be updated.
During the layout phase some functions can modify layout_size_ so the next call to get_best_size returns the currently best size. This means that after the layout phase get_best_size still returns this value. Initialises the layout phase.
Clears the initial best size for the widgets.
See Layout algorithm for more information.
full_initialization | For widgets with scrollbars it hides them unless the mode is scrollbar_mode::ALWAYS_VISIBLE. For other widgets this flag is a NOP. |
Reimplemented in gui2::generator_base, gui2::tree_view_node, gui2::grid, gui2::styled_widget, gui2::matrix, gui2::scrollbar_container, gui2::pane, gui2::viewport, and gui2::container_base.
Definition at line 166 of file widget.cpp.
References gui2::window::add_linked_widget(), get_window(), invisible, layout_size_, linked_group_, and visible_.
Referenced by gui2::viewport::layout_initialize(), gui2::pane::layout_initialize(), gui2::styled_widget::layout_initialize(), gui2::grid::layout_initialize(), and gui2::tree_view_node::layout_initialize().
|
protected |
Definition at line 339 of file widget.cpp.
References layout_size_.
Referenced by gui2::tree_view_node::add_child_impl().
|
virtual |
Moves a widget.
This function can be used to move the widget without dirtying it.
x_offset | The amount of pixels to move the widget in the x-direction. |
y_offset | The amount of pixels to move the widget in the y-direction. |
Definition at line 262 of file widget.cpp.
widget * gui2::widget::parent | ( | ) |
Definition at line 159 of file widget.cpp.
References parent_.
Referenced by gui2::event::implementation::build_event_chain(), gui2::window::click_dismiss(), gui2::event::fire_event_double_click(), gui2::tree_view_node::get_node_below(), gui2::get_parent(), gui2::grid::place(), place(), set_parent(), gui2::event::mouse_motion::signal_handler_sdl_mouse_motion(), and ~widget().
Places the widget.
This function is normally called by a layout function to do the placement of a widget.
origin | The position of top left of the widget. |
size | The size of the widget. |
Reimplemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::tree_view_node, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::grid, gui2::listbox, gui2::policy::placement::horizontal_list, gui2::styled_widget, gui2::text_box, gui2::matrix, gui2::scrollbar_container, gui2::scrollbar_base, gui2::slider_base, gui2::container_base, gui2::pane, gui2::size_lock, and gui2::viewport.
Definition at line 237 of file widget.cpp.
References get_rectangle(), get_x(), get_y(), height_, id(), parent(), set_is_dirty(), width_, point::x, x_, point::y, and y_.
Referenced by gui2::viewport::place(), gui2::pane::place(), gui2::matrix::place(), gui2::styled_widget::place(), gui2::grid::place(), gui2::tree_view_node::place(), gui2::grid::child::place(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::place().
Adds a widget to the dirty list if it is dirty.
See window::dirty_list_ for more information regarding the dirty list.
If the widget is not dirty and has children it should add itself to the call_stack and call child_populate_dirty_list with the new call_stack.
caller | The parent window, if dirty it should register itself to this window. |
call_stack | The call-stack of widgets traversed to reach this function. |
Definition at line 416 of file widget.cpp.
References gui2::window::add_to_dirty_list(), child_populate_dirty_list(), get_drawing_action(), is_dirty_, none, visible, and visible_.
Referenced by gui2::viewport::child_populate_dirty_list(), gui2::pane::child_populate_dirty_list(), gui2::container_base::child_populate_dirty_list(), gui2::matrix::child_populate_dirty_list(), gui2::listbox::child_populate_dirty_list(), gui2::grid::child_populate_dirty_list(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::child_populate_dirty_list(), gui2::window::draw(), and gui2::tree_view_node::impl_populate_dirty_list().
|
private |
Is the widget and every single one of its parents visible?
widget | Widget where to start the check. |
must_be_active | The widget should be active, not all widgets have an active flag, those who don't ignore flag. |
Definition at line 604 of file widget.cpp.
References hidden, invisible, parent_, and visible_.
Referenced by is_at().
|
virtual |
Tries to reduce the height of a widget.
This function tries to do it 'friendly' and only use scrollbars.
See Layout algorithm for more information.
maximum_height | The wanted maximum height. |
Reimplemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::grid, gui2::policy::placement::horizontal_list, gui2::styled_widget, gui2::scrollbar_container, gui2::container_base, gui2::drawing, and gui2::spacer.
Definition at line 182 of file widget.cpp.
|
pure virtual |
Tries to reduce the width of a widget.
This function tries to do it 'friendly' and only use scrollbars or tries to wrap the widget.
See Layout algorithm for more information.
maximum_width | The wanted maximum width. |
Implemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::tree_view_node, gui2::grid, gui2::policy::placement::horizontal_list, gui2::styled_widget, gui2::matrix, gui2::scrollbar_container, gui2::pane, gui2::viewport, gui2::drawing, gui2::container_base, and gui2::spacer.
void gui2::widget::set_debug_border_color | ( | const color_t | debug_border_color | ) |
Definition at line 518 of file widget.cpp.
References debug_border_color_.
void gui2::widget::set_debug_border_mode | ( | const unsigned | debug_border_mode | ) |
Definition at line 513 of file widget.cpp.
References debug_border_mode_.
|
virtual |
Sets the horizontal alignment of the widget within its parent grid.
alignment | The new alignment. |
Definition at line 268 of file widget.cpp.
References gui2::implementation::get_h_align(), get_parent_grid(), gui2::grid::HORIZONTAL_MASK, and gui2::grid::set_child_alignment().
void gui2::widget::set_id | ( | const std::string & | id | ) |
Definition at line 97 of file widget.cpp.
References DBG_GUI_LF, gui2::styled_widget::get_control_type(), id(), id_, name, and widget().
Referenced by gui2::dialogs::campaign_selection::add_campaign_to_tree(), add_widget(), BOOST_AUTO_TEST_CASE(), gui2::build(), gui2::builder_grid::build(), gui2::window::click_dismiss(), gui2::dialogs::preferences_dialog::post_build(), gui2::dialogs::help_browser::pre_show(), gui2::dialogs::drop_down_menu::pre_show(), gui2::styled_widget::set_members(), gui2::swap_grid(), and test_grid().
void gui2::widget::set_is_dirty | ( | const bool | is_dirty | ) |
Definition at line 465 of file widget.cpp.
References is_dirty_.
Referenced by gui2::text_box_base::cursor_timer_callback(), gui2::event::sdl_event_handler::disconnect(), gui2::dialogs::story_viewer::display_part(), gui2::dialogs::outro::draw_callback(), gui2::event::sdl_event_handler::draw_everything(), gui2::dialogs::story_viewer::draw_floating_image(), gui2::text_box_base::handle_editing(), gui2::text_box::handle_mouse_selection(), gui2::viewport::impl_draw_children(), gui2::grid::impl_draw_children(), gui2::dialogs::lua_interpreter::controller::input_keypress_callback(), gui2::text_box_base::insert_char(), intf_set_dialog_canvas(), gui2::listbox::layout_children(), gui2::listbox::order_by(), gui2::text_box_base::paste_selection(), place(), gui2::window::redraw_windows_on_top(), gui2::tree_view::resize_content(), gui2::listbox::resize_content(), gui2::container_base::set_active(), gui2::grid::set_column_grow_factor(), gui2::text_box_base::set_cursor(), gui2::styled_widget::set_label(), gui2::label::set_link_aware(), gui2::label::set_link_color(), gui2::text_box_base::set_maximum_length(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_order(), gui2::progress_bar::set_percentage(), gui2::grid::set_row_grow_factor(), gui2::listbox::set_row_shown(), gui2::menu_button::set_selected(), gui2::text_box_base::set_selection_length(), gui2::text_box_base::set_selection_start(), set_size(), gui2::button::set_state(), gui2::repeating_button::set_state(), gui2::toggle_button::set_state(), gui2::menu_button::set_state(), gui2::label::set_state(), gui2::toggle_panel::set_state(), gui2::multimenu_button::set_state(), gui2::slider_base::set_state(), gui2::scrollbar_base::set_state(), gui2::text_box_base::set_state(), gui2::styled_widget::set_text_alignment(), gui2::label::set_text_alpha(), gui2::styled_widget::set_text_ellipse_mode(), gui2::styled_widget::set_use_markup(), gui2::text_box_base::set_value(), gui2::toggle_button::set_value(), gui2::toggle_panel::set_value(), gui2::menu_button::set_values(), gui2::multimenu_button::set_values(), set_visible(), gui2::toggle_button::update_canvas(), gui2::slider_base::update_canvas(), gui2::scrollbar_base::update_canvas(), gui2::listbox::update_content_size(), gui2::dialogs::debug_clock::update_time(), gui2::dialogs::title_screen::update_tip(), and gui2::dialogs::custom_tod::update_tod_display().
|
protected |
Definition at line 334 of file widget.cpp.
References layout_size_, and utf8::size().
Referenced by gui2::window::layout_linked_widgets(), gui2::policy::placement::table::place(), gui2::grid::recalculate_best_size(), gui2::container_base::reduce_height(), gui2::container_base::reduce_width(), gui2::container_base::request_reduce_height(), gui2::scrollbar_container::request_reduce_height(), gui2::styled_widget::request_reduce_height(), gui2::grid::request_reduce_height(), gui2::container_base::request_reduce_width(), gui2::scrollbar_container::request_reduce_width(), gui2::styled_widget::request_reduce_width(), gui2::grid::request_reduce_width(), and gui2::styled_widget::set_label().
void gui2::widget::set_linked_group | ( | const std::string & | linked_group | ) |
Definition at line 344 of file widget.cpp.
References linked_group_.
Referenced by gui2::builder_grid::build(), and gui2::styled_widget::set_members().
|
virtual |
Sets the origin of the widget.
This function can be used to move the widget without dirtying it. The location is an absolute position, if a relative more is required use move.
origin | The new origin. |
Reimplemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::tree_view_node, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::grid, gui2::policy::placement::horizontal_list, gui2::scrollbar_container, and gui2::container_base.
Definition at line 220 of file widget.cpp.
References point::x, x_, point::y, and y_.
Referenced by gui2::container_base::set_origin(), gui2::grid::set_origin(), gui2::tree_view_node::set_origin(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_origin().
void gui2::widget::set_parent | ( | widget * | parent | ) |
Definition at line 154 of file widget.cpp.
References parent(), and parent_.
Referenced by gui2::container_base::container_base(), gui2::pane::create_item(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::init(), gui2::matrix::matrix(), gui2::grid::set_child(), gui2::grid::swap_child(), gui2::tree_view_node::tree_view_node(), and gui2::viewport::viewport().
|
virtual |
Sets the size of the widget.
This version is meant to resize a widget, since the origin isn't modified. This can be used if a widget needs to change its size and the layout will be fixed later.
size | The size of the widget. |
Definition at line 226 of file widget.cpp.
References height_, set_is_dirty(), width_, point::x, and point::y.
Referenced by gui2::tree_view_node::place(), gui2::tree_view::resize_content(), and gui2::listbox::resize_content().
|
virtual |
Sets the horizontal alignment of the widget within its parent grid.
alignment | The new alignment. |
Definition at line 281 of file widget.cpp.
References get_parent_grid(), gui2::implementation::get_v_align(), gui2::grid::set_child_alignment(), and gui2::grid::VERTICAL_MASK.
Referenced by gui2::dialogs::story_viewer::display_part().
void gui2::widget::set_visible | ( | const visibility | visible | ) |
Definition at line 475 of file widget.cpp.
References gui2::event::dispatcher::fire(), get_size(), get_window(), gui2::window::invalidate_layout(), invisible, gui2::new_widgets, gui2::event::REQUEST_PLACEMENT, set_is_dirty(), visible, and visible_.
Referenced by gui2::chatbox::active_window_changed(), gui2::dialogs::mp_staging::add_side_node(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), gui2::adjust_scrollbar_mode(), gui2::dialogs::story_viewer::display_part(), gui2::pane::filter(), gui2::chatbox::find_or_create_window(), gui2::chatbox::increment_waiting_messages(), gui2::chatbox::increment_waiting_whispers(), gui2::dialogs::message_implementation::init_button(), gui2::window::layout(), gui2::scrollbar_container::layout_initialize(), gui2::dialogs::mp_staging::on_controller_select(), gui2::dialogs::preferences_dialog::post_build(), gui2::dialogs::transient_message::pre_show(), gui2::dialogs::lobby_player_info::pre_show(), gui2::dialogs::mp_alerts_options::pre_show(), gui2::dialogs::campaign_difficulty::pre_show(), gui2::dialogs::wml_error::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::message::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::scrollbar_container::request_reduce_height(), gui2::scrollbar_container::request_reduce_width(), gui2::policy::select_action::show::select(), gui2::addon_list::set_addons(), gui2::dialogs::game_load::set_save_dir_list(), gui2::set_scrollbar_mode(), gui2::grid::swap_child(), gui2::tree_view_node::tree_view_node(), and gui2::dialogs::mp_options_helper::update_status_label().
|
virtual |
Sets the visible rectangle for a widget.
This function sets the redraw_action_ and the clipping_rectangle_.
rectangle | The visible rectangle in screen coordinates. |
Reimplemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::tree_view_node, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::grid, gui2::policy::placement::horizontal_list, gui2::scrollbar_container, and gui2::container_base.
Definition at line 452 of file widget.cpp.
References clipping_rectangle_, sdl::empty_rect, full, get_rectangle(), sdl::intersect_rects(), none, partly, and redraw_action_.
Referenced by gui2::container_base::set_visible_rectangle(), and gui2::grid::set_visible_rectangle().
|
friend |
Definition at line 51 of file widget.hpp.
|
friend |
Definition at line 52 of file widget.hpp.
|
private |
The clipping rectangle if a widget is partly visible.
Definition at line 709 of file widget.hpp.
Referenced by calculate_clipping_rectangle(), draw_debug_border(), get_dirty_rectangle(), and set_visible_rectangle().
|
private |
The color for the debug border.
Definition at line 725 of file widget.hpp.
Referenced by draw_debug_border(), and set_debug_border_color().
|
private |
Mode for drawing the debug border.
The debug border is a helper border to determine where a widget is placed. It is only intended for debugging purposes.
Possible values:
Definition at line 722 of file widget.hpp.
Referenced by draw_debug_border(), and set_debug_border_mode().
|
private |
The height of the widget.
Definition at line 470 of file widget.hpp.
Referenced by get_drawing_action(), get_height(), get_size(), place(), and set_size().
|
private |
The id is the unique name of the widget in a certain context.
This is needed for certain widgets so the engine knows which widget is which. E.g. it knows which button is pressed and thus which engine action is connected to the button. This doesn't mean that the id is unique in a window, e.g. a listbox can have the same id for every row.
Definition at line 170 of file widget.hpp.
Referenced by gui2::window::draw(), find(), id(), set_id(), and ~widget().
|
private |
Is the widget dirty?
When a widget is dirty it needs to be redrawn at the next drawing cycle.
The top-level window will use populate_dirty_list and child_populate_dirty_list to find al dirty widgets, so the widget doesn't need to inform its parent regarding it being marked dirty.
Definition at line 700 of file widget.hpp.
Referenced by get_is_dirty(), populate_dirty_list(), and set_is_dirty().
|
private |
The best size for the widget.
When 0,0 the real best size is returned, but in the layout phase a wrapping or a scrollbar might change the best size for that widget. This variable holds that best value.
If the widget size hasn't been changed from the default that calculate_best_size() returns, layout_size_ is (0,0).
Definition at line 482 of file widget.hpp.
Referenced by get_best_size(), layout_initialize(), layout_size(), and set_layout_size().
|
private |
The linked group the widget belongs to.
Definition at line 506 of file widget.hpp.
Referenced by get_best_size(), layout_initialize(), set_linked_group(), and ~widget().
|
private |
The parent widget.
If the widget has a parent it contains a pointer to the parent, else it is set to nullptr
.
Definition at line 209 of file widget.hpp.
Referenced by get_parent_grid(), get_window(), parent(), recursive_is_visible(), and set_parent().
|
private |
Field for the action to do on a drawing request.
Definition at line 706 of file widget.hpp.
Referenced by draw_background(), draw_children(), draw_debug_border(), draw_foreground(), get_dirty_rectangle(), get_drawing_action(), and set_visible_rectangle().
|
private |
Field for the status of the visibility.
Definition at line 703 of file widget.hpp.
Referenced by draw_background(), draw_children(), draw_foreground(), get_best_size(), get_visible(), layout_initialize(), populate_dirty_list(), recursive_is_visible(), and set_visible().
|
private |
The width of the widget.
Definition at line 467 of file widget.hpp.
Referenced by get_drawing_action(), get_size(), get_width(), place(), and set_size().
|
private |
The x-coordinate of the widget on the screen.
Definition at line 461 of file widget.hpp.
Referenced by get_origin(), get_x(), move(), place(), and set_origin().
|
private |
The y-coordinate of the widget on the screen.
Definition at line 464 of file widget.hpp.
Referenced by get_origin(), get_y(), move(), place(), and set_origin().