Base class for all widgets. More...
#include <widget.hpp>
Public Types | |
enum class | visibility { visible , hidden , invisible } |
Visibility settings done by the user. More... | |
enum class | redraw_action { full , partly , none } |
Visibility set by the engine. More... | |
enum class | debug_border { none , outline , fill } |
Public Types inherited from gui2::event::dispatcher | |
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 class | 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... | |
const grid * | get_parent_grid () const |
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... | |
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) |
std::string | get_linked_group () const |
SDL_Rect | calculate_blitting_rectangle () const |
Calculates the blitting rectangle of the widget. More... | |
SDL_Rect | calculate_clipping_rectangle () const |
Calculates the clipping rectangle of the widget. More... | |
bool | draw_background () |
Draws the background of a widget. More... | |
void | draw_children () |
Draws the children of a widget. More... | |
bool | draw_foreground () |
Draws the foreground of the widget. 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 | queue_redraw () |
Indicates that this widget should be redrawn. More... | |
void | queue_redraw (const rect ®ion) |
Indicate that specific region of the screen should be redrawn. More... | |
void | set_visible (const visibility visible) |
visibility | get_visible () const |
void | set_visible (bool visible) |
Sets widget to visible if visible is true, else invisible. More... | |
void | set_hidden (bool hidden) |
Sets widget to visible if hidden is true, else hidden. More... | |
redraw_action | get_drawing_action () const |
void | set_debug_border_mode (const debug_border 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_view id, const bool must_be_active) |
Returns a widget with the wanted id. More... | |
virtual const widget * | find (const std::string_view 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... | |
template<class T > | |
T * | find_widget (const std::string_view id, const bool must_be_active, const bool must_exist) |
Gets a widget with the wanted id. More... | |
template<class T > | |
const T * | find_widget (const std::string_view id, const bool must_be_active, const bool must_exist) const |
template<class T > | |
T & | find_widget (const std::string_view id, const bool must_be_active=false) |
Gets a widget with the wanted id. More... | |
template<class T > | |
const T & | find_widget (const std::string_view id, const bool must_be_active=false) const |
virtual bool | disable_click_dismiss () const =0 |
Does the widget disable easy close? More... | |
virtual iteration::walker_ptr | create_walker ()=0 |
Creates a new walker object on the heap. More... | |
Public Member Functions inherited from gui2::event_executor | |
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 |
Public Member Functions inherited from gui2::event::dispatcher | |
dispatcher () | |
virtual | ~dispatcher () |
void | connect () |
Connects the dispatcher to the event handler. More... | |
void | disconnect () |
Disconnects the dispatcher from the event handler. More... | |
bool | is_connected () const |
Return whether the dispatcher is currently connected. 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, typename F > | |
void | connect_signal (const F &func, const queue_position position=back_child) |
Adds a callback to the appropriate queue based on event type. More... | |
template<ui_event E, typename F > | |
void | disconnect_signal (const F &func, const queue_position position=back_child) |
Removes a callback from the appropriate queue based on event type. 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... | |
Public Member Functions inherited from enable_lua_ptr< widget > | |
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 bool | impl_draw_background () |
See draw_background. More... | |
virtual void | impl_draw_children () |
See draw_children. More... | |
virtual bool | impl_draw_foreground () |
See draw_foreground. More... | |
void | draw_debug_border () |
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... | |
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... | |
rect | clipping_rectangle_ |
The clipping rectangle if a widget is partly visible. More... | |
debug_border | 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 54 of file widget.hpp.
|
strong |
Enumerator | |
---|---|
none | No border. |
outline | Single-pixel outline. |
fill | Flood-filled rectangle. |
Definition at line 129 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. The entire widget's rectangle should be redrawn. |
partly | The widget is partly visible. The should be drawn. The rectangle to redraw in determined by clipping_rectangle_ |
none | The widget is not visible. The widget should not be drawn. |
Definition at line 102 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 64 of file widget.hpp.
|
delete |
gui2::widget::widget | ( | ) |
Definition at line 33 of file widget.cpp.
References DBG_GUI_LF.
Referenced by gui2::policy::placement::independent::find(), gui2::policy::placement::table::find_at(), gui2::policy::placement::horizontal_list::find_at(), gui2::policy::placement::vertical_list::find_at(), gui2::policy::select_action::selection::init(), gui2::dialogs::title_screen::init_callbacks(), 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 55 of file widget.cpp.
References DBG_GUI_LF.
|
overridevirtual |
Definition at line 77 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::generator_base, gui2::viewport, gui2::tree_view_node, gui2::styled_widget, gui2::spacer, gui2::slider, gui2::size_lock, gui2::scrollbar_container, gui2::scroll_text, gui2::rich_label, gui2::pane, gui2::matrix, gui2::listbox, gui2::image, gui2::grid, gui2::policy::placement::independent, gui2::policy::placement::table, gui2::policy::placement::vertical_list, gui2::policy::placement::horizontal_list, gui2::drawing, and gui2::container_base.
Referenced by get_best_size().
SDL_Rect gui2::widget::calculate_blitting_rectangle | ( | ) | const |
Calculates the blitting rectangle of the widget.
The blitting rectangle is the entire widget rectangle.
Definition at line 363 of file widget.cpp.
References get_rectangle().
Referenced by draw_background(), draw_children(), and draw_foreground().
SDL_Rect gui2::widget::calculate_clipping_rectangle | ( | ) | const |
Calculates the clipping rectangle of the widget.
The clipping rectangle is used then the redraw_action_ is redraw_action::partly.
Definition at line 368 of file widget.cpp.
References clipping_rectangle_, sdl::empty_rect, full, get_drawing_action(), get_rectangle(), none, and partly.
Referenced by draw_background(), draw_children(), and draw_foreground().
|
inlinevirtual |
Whether the mouse move/click event go 'through' this widget.
Reimplemented in gui2::rich_label, gui2::label, gui2::image, and gui2::grid.
Definition at line 334 of file widget.hpp.
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::tab_container, gui2::spinner, gui2::scrollbar_container, gui2::scroll_text, gui2::scroll_label, gui2::rich_label, gui2::multiline_text, gui2::label, gui2::grid, and gui2::container_base.
Definition at line 225 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::get_text_ellipse_mode(), gui2::styled_widget::request_reduce_width(), gui2::combobox::update_canvas(), and gui2::text_box::update_canvas().
|
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 459 of file widget.hpp.
References draw::point(), and set_layout_size().
Referenced by gui2::container_base::container_base().
|
pure virtual |
Creates a new walker object on the heap.
Implemented in gui2::viewport, gui2::tree_view_node, gui2::styled_widget, gui2::scrollbar_container, gui2::pane, gui2::matrix, gui2::grid, and gui2::container_base.
|
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 198 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 188 of file widget.cpp.
|
pure virtual |
Does the widget disable easy close?
Implemented in gui2::viewport, gui2::tree_view_node, gui2::styled_widget, gui2::spacer, gui2::scrollbar_container, gui2::rich_label, gui2::progress_bar, gui2::pane, gui2::minimap, gui2::matrix, gui2::label, gui2::image, gui2::grid, gui2::drawing, and gui2::container_base.
Referenced by gui2::grid::disable_click_dismiss().
bool gui2::widget::draw_background | ( | ) |
Draws the background of a widget.
Derived should override impl_draw_background instead of changing this function.
Definition at line 381 of file widget.cpp.
References calculate_blitting_rectangle(), calculate_clipping_rectangle(), get_drawing_action(), get_origin(), get_window(), impl_draw_background(), none, draw::reduce_clip(), draw::set_viewport(), rect::shift(), visible, and visible_.
Referenced by gui2::grid::impl_draw_children().
void gui2::widget::draw_children | ( | ) |
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.
Definition at line 402 of file widget.cpp.
References calculate_blitting_rectangle(), calculate_clipping_rectangle(), get_drawing_action(), get_origin(), get_window(), impl_draw_children(), none, draw::reduce_clip(), draw::set_viewport(), rect::shift(), visible, and visible_.
Referenced by gui2::container_base::impl_draw_children(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children(), gui2::grid::impl_draw_children(), gui2::matrix::impl_draw_children(), and gui2::tree_view_node::impl_draw_children().
|
private |
Definition at line 527 of file widget.cpp.
References debug_border_color_, debug_border_mode_, draw::fill(), fill, get_size(), none, outline, and draw::rect().
Referenced by draw_foreground().
bool gui2::widget::draw_foreground | ( | ) |
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.
Definition at line 423 of file widget.cpp.
References calculate_blitting_rectangle(), calculate_clipping_rectangle(), draw_debug_border(), get_drawing_action(), get_origin(), get_window(), impl_draw_foreground(), none, draw::reduce_clip(), draw::set_viewport(), rect::shift(), visible, and visible_.
Referenced by 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::window, gui2::viewport, gui2::tree_view_node, gui2::styled_widget, gui2::stacked_widget, gui2::scrollbar_container, gui2::matrix, gui2::grid, gui2::policy::placement::independent, and gui2::container_base.
Definition at line 560 of file widget.cpp.
References id_.
Referenced by gui2::matrix::find(), gui2::styled_widget::find(), gui2::tree_view_node::find(), gui2::grid_implementation::find(), and find_widget().
|
virtual |
The constant version of find.
Reimplemented in gui2::window, gui2::viewport, gui2::tree_view_node, gui2::styled_widget, gui2::stacked_widget, gui2::scrollbar_container, gui2::matrix, gui2::grid, gui2::policy::placement::independent, and gui2::container_base.
Definition at line 565 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::generator_base, gui2::window, gui2::viewport, gui2::tree_view_node, gui2::toggle_panel, gui2::styled_widget, gui2::scrollbar_container, gui2::pane, gui2::matrix, gui2::grid, gui2::policy::placement::independent, gui2::policy::placement::vertical_list, gui2::policy::placement::horizontal_list, gui2::container_base, and gui2::policy::placement::table.
Definition at line 549 of file widget.cpp.
References is_at().
Referenced by gui2::scrollbar_container::find_at(), gui2::styled_widget::find_at(), gui2::grid_implementation::find_at(), gui2::tree_view_node_implementation::find_at_aux(), gui2::event::mouse_button< I >::signal_handler_sdl_button_down(), gui2::event::mouse_button< I >::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::generator_base, gui2::window, gui2::viewport, gui2::tree_view_node, gui2::toggle_panel, gui2::styled_widget, gui2::scrollbar_container, gui2::pane, gui2::matrix, gui2::grid, gui2::policy::placement::independent, gui2::policy::placement::vertical_list, gui2::policy::placement::horizontal_list, gui2::container_base, and gui2::policy::placement::table.
Definition at line 554 of file widget.cpp.
References is_at().
|
inline |
Gets a widget with the wanted id.
This template function doesn't return a pointer to a generic widget but returns the wanted type and tests for its existence if required.
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. |
must_exist | The widget should be exist, the function will fail if the widget doesn't exist or is inactive and must be active. Upon failure a wml_error is thrown. |
Definition at line 753 of file widget.hpp.
References find(), gui2::missing_widget(), and VALIDATE.
Referenced by gui2::chatbox::active_window_changed(), gui2::dialogs::preferences_dialog::add_friend_list_entry(), gui2::dialogs::preferences_dialog::add_hotkey_callback(), gui2::add_name_tree_node(), gui2::dialogs::mp_staging::add_side_node(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), gui2::chatbox::append_to_chatbox(), gui2::field_base::attach_to_window(), gui2::dialogs::chat_log::view::bind(), gui2::dialogs::gamestate_inspector::controller::bind(), gui2::dialogs::lua_interpreter::view::bind(), gui2::dialogs::lua_interpreter::controller::bind(), gui2::bind_status_label(), gui2::dialogs::gamestate_inspector::controller::build_stuff_list(), gui2::dialogs::editor_edit_unit::button_state_change(), gui2::chatbox::clear_messages(), gui2::dialogs::mp_options_helper::display_custom_options(), gui2::dialogs::mp_create_game::display_games_of_type(), gui2::dialogs::story_viewer::display_part(), gui2::window::finalize(), gui2::scrollbar_container::finalize_setup(), gui2::chatbox::find_or_create_window(), gui2::dialogs::mp_join_game::generate_side_list(), gui2::dialogs::mp_create_game::get_active_mods(), gui2::tab_container::get_internal_list(), gui2::addon_list::get_listbox(), gui2::addon_list::get_selected_addon(), gui2::dialogs::drop_down_menu::get_toggle_states(), gui2::dialogs::mp_change_control::highlight_side_nick(), gui2::chatbox::increment_waiting_messages(), gui2::chatbox::increment_waiting_whispers(), gui2::dialogs::message_implementation::init_button(), gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::matrix::matrix(), gui2::dialogs::mp_staging::network_handler(), gui2::dialogs::addon_manager::on_addon_select(), gui2::dialogs::preferences_dialog::on_advanced_prefs_list_select(), gui2::dialogs::mp_staging::on_color_select(), gui2::dialogs::mp_staging::on_controller_select(), gui2::dialogs::addon_manager::on_selected_version_change(), gui2::dialogs::campaign_difficulty::pre_show(), gui2::dialogs::drop_down_menu::pre_show(), gui2::dialogs::help_browser::pre_show(), gui2::dialogs::label_settings::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::preferences_dialog::pre_show(), gui2::dialogs::unit_list::pre_show(), gui2::dialogs::file_dialog::push_fileview_row(), gui2::dialogs::preferences_dialog::remove_hotkey_callback(), gui2::dialogs::unit_recall::rename_unit(), gui2::dialogs::editor_edit_unit::save_unit_type(), gui2::addon_list::select_addon(), gui2::dialogs::mp_create_game::set_active_mods(), gui2::addon_list::set_addons(), gui2::scrollbar_container::set_scrollbar_button_status(), gui2::lobby_player_list_helper::sub_list::sub_list(), gui2::swap_grid(), gui2::dialogs::mp_staging::update_leader_display(), and gui2::dialogs::mp_lobby::update_visible_games().
|
inline |
Definition at line 765 of file widget.hpp.
References find(), gui2::missing_widget(), and VALIDATE.
|
inline |
Gets a widget with the wanted id.
This template function doesn't return a reference to a generic widget but returns a reference to the wanted type
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. |
Definition at line 790 of file widget.hpp.
|
inline |
Definition at line 798 of file widget.hpp.
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 203 of file widget.cpp.
References calculate_best_size(), gui2::window::get_linked_size(), get_window(), invisible, layout_size_, linked_group_, draw::point(), and visible_.
Referenced by gui2::tree_view_node::add_child_impl(), gui2::container_base::calculate_best_size(), gui2::policy::placement::horizontal_list::calculate_best_size(), gui2::policy::placement::vertical_list::calculate_best_size(), gui2::policy::placement::table::calculate_best_size(), gui2::policy::placement::independent::calculate_best_size(), gui2::matrix::calculate_best_size(), gui2::scrollbar_container::calculate_best_size(), gui2::tree_view_node::calculate_best_size(), gui2::tree_view_node::get_folded_size(), gui2::tree_view_node::get_unfolded_size(), gui2::window::layout(), gui2::window_implementation::layout(), gui2::window::layout_linked_widgets(), gui2::policy::placement::table::place(), gui2::policy::placement::horizontal_list::place(), gui2::policy::placement::vertical_list::place(), gui2::size_lock::place(), gui2::tree_view_node::place(), gui2::grid::child::place(), gui2::container_base::reduce_height(), gui2::grid::reduce_height(), gui2::container_base::reduce_width(), gui2::grid::reduce_width(), gui2::tree_view_node::replace_children(), gui2::grid::request_placement(), gui2::container_base::request_reduce_height(), gui2::grid::request_reduce_height(), gui2::scrollbar_container::request_reduce_height(), gui2::styled_widget::request_reduce_height(), gui2::container_base::request_reduce_width(), gui2::grid::request_reduce_width(), gui2::scrollbar_container::request_reduce_width(), gui2::styled_widget::request_reduce_width(), gui2::listbox::resize_content(), gui2::listbox::set_content_size(), and gui2::scroll_text::set_max_size().
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 445 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 511 of file widget.cpp.
References height_, none, redraw_action_, and width_.
Referenced by calculate_clipping_rectangle(), draw_background(), draw_children(), draw_foreground(), and gui2::grid::impl_draw_children().
unsigned gui2::widget::get_height | ( | ) | const |
Definition at line 341 of file widget.cpp.
References height_.
Referenced by gui2::scrollbar_container::content_resize_height(), gui2::vertical_scrollbar::get_length(), gui2::styled_widget::get_text_maximum_height(), gui2::vertical_scrollbar::in_orthogonal_range(), gui2::horizontal_scrollbar::on_bar(), gui2::slider::on_bar(), gui2::vertical_scrollbar::on_bar(), gui2::horizontal_scrollbar::on_positioner(), gui2::slider::on_positioner(), gui2::scrollbar_container::place(), gui2::listbox::remove_row(), gui2::policy::placement::table::set_origin(), gui2::policy::placement::vertical_list::set_origin(), gui2::scrollbar_container::show_content_rect(), gui2::dialogs::end_credits::update(), gui2::combobox::update_offsets(), gui2::multiline_text::update_offsets(), and gui2::text_box::update_offsets().
|
inline |
Definition at line 464 of file widget.hpp.
References linked_group_.
point gui2::widget::get_origin | ( | ) | const |
Returns the screen origin of the widget.
Definition at line 311 of file widget.cpp.
References draw::point(), x_, and y_.
Referenced by gui2::tab_container::change_selection(), gui2::scrollbar_container::content_resize_request(), draw_background(), draw_children(), draw_foreground(), get_rectangle(), gui2::multiline_text::handle_mouse_selection(), gui2::tree_view::layout_children(), gui2::listbox::place(), gui2::scrollbar_container::place(), gui2::grid::request_placement(), gui2::scroll_label::set_label(), gui2::scroll_text::set_label(), gui2::scrollbar_container::set_origin(), gui2::listbox::set_row_shown(), gui2::rich_label::signal_handler_left_button_click(), gui2::multiline_text::signal_handler_left_button_down(), gui2::rich_label::signal_handler_mouse_motion(), gui2::multiline_text::signal_handler_mouse_motion(), gui2::lobby_player_list_helper::update(), and gui2::listbox::update_layout().
grid * gui2::widget::get_parent_grid | ( | ) |
Get the parent grid.
nullptr | No parent grid found. |
Definition at line 145 of file widget.cpp.
References parent_.
Referenced by set_horizontal_alignment(), and set_vertical_alignment().
const grid * gui2::widget::get_parent_grid | ( | ) | const |
Definition at line 155 of file widget.cpp.
References parent_.
rect gui2::widget::get_rectangle | ( | ) | const |
Gets the bounding rectangle of the widget on the screen.
Definition at line 321 of file widget.cpp.
References get_origin(), and get_size().
Referenced by calculate_blitting_rectangle(), calculate_clipping_rectangle(), 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::grid::impl_draw_children(), gui2::panel::impl_draw_foreground(), is_at(), gui2::listbox::list_item_clicked(), gui2::dialogs::drop_down_menu::mouse_up_callback(), place(), gui2::listbox::place(), gui2::scrollbar_container::place(), queue_redraw(), set_visible_rectangle(), gui2::styled_widget::signal_handler_show_helptip(), and gui2::listbox::update_visible_area_on_key_event().
point gui2::widget::get_size | ( | ) | const |
Returns the size of the widget.
Definition at line 316 of file widget.cpp.
References height_, draw::point(), and width_.
Referenced by gui2::tree_view_node::add_child_impl(), gui2::tab_container::change_selection(), gui2::tree_view::clear(), gui2::scrollbar_container::content_resize_request(), draw_debug_border(), get_rectangle(), gui2::minimap::impl_draw_background(), gui2::tree_view::layout_children(), gui2::dialogs::terrain_layers::pre_show(), gui2::tree_view::remove_node(), gui2::tree_view_node::replace_children(), gui2::grid::request_placement(), gui2::listbox::resize_content(), gui2::tree_view::resize_content(), gui2::scroll_label::set_label(), gui2::scroll_text::set_label(), gui2::tree_view_node::set_origin(), set_visible(), gui2::combobox::signal_handler_left_button_down(), gui2::listbox::update_content_size(), gui2::listbox::update_layout(), and gui2::combobox::update_mouse_cursor().
widget::visibility gui2::widget::get_visible | ( | ) | const |
Definition at line 506 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::grid::disable_click_dismiss(), gui2::styled_widget::disable_click_dismiss(), gui2::container_base::impl_draw_children(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children(), gui2::grid::impl_draw_children(), gui2::scrollbar_container::impl_draw_children(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::layout_initialize(), gui2::grid::child::place(), gui2::dialogs::help_browser::pre_show(), gui2::listbox::remove_row(), gui2::scrollbar_container::request_reduce_height(), gui2::scrollbar_container::request_reduce_width(), gui2::listbox::resize_content(), gui2::scroll_text::set_max_size(), gui2::set_scrollbar_mode(), 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 336 of file widget.cpp.
References width_.
Referenced by gui2::scrollbar_container::content_resize_width(), gui2::horizontal_scrollbar::get_length(), gui2::slider::get_length(), gui2::styled_widget::get_text_maximum_width(), gui2::horizontal_scrollbar::in_orthogonal_range(), gui2::horizontal_scrollbar::on_bar(), gui2::slider::on_bar(), gui2::vertical_scrollbar::on_bar(), gui2::vertical_scrollbar::on_positioner(), gui2::scrollbar_container::place(), gui2::listbox::remove_row(), gui2::policy::placement::table::set_origin(), gui2::policy::placement::horizontal_list::set_origin(), gui2::scrollbar_container::show_content_rect(), gui2::combobox::update_offsets(), gui2::multiline_text::update_offsets(), and gui2::text_box::update_offsets().
window * gui2::widget::get_window | ( | ) |
Get the parent window.
nullptr | No parent window found. |
Definition at line 117 of file widget.cpp.
References parent_.
Referenced by gui2::addon_list::add_list_to_keyboard_chain(), gui2::dialogs::title_screen::button_callback_cores(), gui2::dialogs::title_screen::button_callback_multiplayer(), gui2::dialogs::tod_new_schedule::button_state_change(), gui2::dialogs::lobby_player_info::check_status_button_callback(), gui2::dialogs::mp_join_game::close_faction_select_dialog_if_open(), 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::dialogs::story_viewer::display_part(), gui2::dialogs::game_load::display_savegame(), draw_background(), draw_children(), gui2::dialogs::story_viewer::draw_floating_image(), draw_foreground(), gui2::policy::placement::table::find_at(), gui2::policy::placement::horizontal_list::find_at(), gui2::policy::placement::vertical_list::find_at(), gui2::policy::placement::independent::find_at(), get_best_size(), gui2::grid::impl_draw_children(), gui2::container_base::inject_linked_groups(), gui2::dialogs::lobby_player_info::kick_ban_button_callback(), gui2::dialogs::lobby_player_info::kick_button_callback(), layout_initialize(), gui2::listbox::list_item_clicked(), gui2::dialogs::story_viewer::nav_button_callback(), gui2::dialogs::file_dialog::on_bookmark_selected(), gui2::dialogs::file_dialog::on_row_selected(), gui2::unit_preview_pane::profile_button_callback(), queue_redraw(), gui2::scrollbar_base::recalculate(), gui2::dialogs::unit_recall::rename_unit(), 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::scroll_label::signal_handler_left_button_down(), gui2::scroll_text::signal_handler_left_button_down(), gui2::spinner::signal_handler_left_button_down(), gui2::tree_view::signal_handler_left_button_down(), gui2::button::signal_handler_left_button_down(), gui2::combobox::signal_handler_left_button_down(), gui2::menu_button::signal_handler_left_button_down(), gui2::multiline_text::signal_handler_left_button_down(), gui2::multimenu_button::signal_handler_left_button_down(), gui2::repeating_button::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_down(), gui2::slider_base::signal_handler_left_button_down(), gui2::text_box::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_up(), gui2::slider::signal_handler_left_button_up(), gui2::slider_base::signal_handler_left_button_up(), gui2::chatbox::signal_handler_receive_keyboard_focus(), gui2::pane::signal_handler_request_placement(), gui2::dialogs::mp_staging::start_game(), gui2::dialogs::lobby_player_info::start_whisper_button_callback(), gui2::dialogs::lobby_player_info::stopgame_button_callback(), gui2::chatbox::switch_to_window(), gui2::dialogs::custom_tod::update_image(), gui2::multiline_text::update_layout(), gui2::dialogs::custom_tod::update_tod_display(), gui2::window::window_instance(), and ~widget().
const window * gui2::widget::get_window | ( | ) | const |
int gui2::widget::get_x | ( | ) | const |
Definition at line 326 of file widget.cpp.
References x_.
Referenced by gui2::viewport_implementation::find_at(), gui2::combobox::handle_mouse_selection(), gui2::text_box::handle_mouse_selection(), gui2::scrollbar_container::move_viewport(), place(), gui2::grid::set_origin(), gui2::scrollbar_container::show_content_rect(), gui2::label::signal_handler_left_button_click(), gui2::combobox::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_down(), gui2::slider_base::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_up(), gui2::slider_base::signal_handler_left_button_up(), gui2::label::signal_handler_mouse_motion(), gui2::scrollbar_base::signal_handler_mouse_motion(), gui2::slider_base::signal_handler_mouse_motion(), gui2::label::signal_handler_right_button_click(), and gui2::combobox::update_mouse_cursor().
int gui2::widget::get_y | ( | ) | const |
Definition at line 331 of file widget.cpp.
References y_.
Referenced by gui2::viewport_implementation::find_at(), gui2::combobox::handle_mouse_selection(), gui2::text_box::handle_mouse_selection(), gui2::scrollbar_container::move_viewport(), place(), gui2::listbox::remove_row(), gui2::grid::set_origin(), gui2::scrollbar_container::show_content_rect(), gui2::label::signal_handler_left_button_click(), gui2::scrollbar_base::signal_handler_left_button_down(), gui2::slider_base::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_up(), gui2::slider_base::signal_handler_left_button_up(), gui2::label::signal_handler_mouse_motion(), gui2::scrollbar_base::signal_handler_mouse_motion(), gui2::slider_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 570 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 110 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(), connect_queue(), gui2::window::finalize(), lua_widget::impl_widget_dir(), gui2::policy::select_action::selection::init(), gui2::window::init_linked_size_group(), gui2::listbox::initialize_sorter(), gui2::dialogs::addon_manager::load_addon_list(), gui2::iteration::policy::order::bottom_up< VW, VG, VC >::next(), gui2::iteration::policy::order::top_down< VW, VG, VC >::next(), place(), gui2::grid::place(), gui2::dialogs::campaign_selection::proceed(), gui2::dialogs::modal_dialog::register_text(), gui2::window::remove_linked_widget(), gui2::styled_widget::request_reduce_height(), gui2::styled_widget::request_reduce_width(), gui2::dialogs::attack_predictions::set_data(), set_id(), gui2::dialogs::select_orb_colors::setup_orb_group(), gui2::combobox::signal_handler_mouse_motion(), gui2::multiline_text::signal_handler_mouse_motion(), gui2::text_box::signal_handler_mouse_motion(), gui2::toggle_panel::signal_handler_pre_left_button_click(), gui2::event::mouse_motion::start_hover_timer(), gui2::event::mouse_motion::stop_hover_timer(), gui2::chatbox::switch_to_window(), gui2::iteration::policy::order::top_down< VW, VG, VC >::up(), gui2::dialogs::mp_options_helper::update_options_data_map(), gui2::dialogs::mp_options_helper::update_options_data_map_menu_button(), and gui2::dialogs::modeless_dialog::window_id().
|
inlineprivatevirtual |
See draw_background.
Reimplemented in gui2::toggle_panel, gui2::styled_widget, gui2::spacer, gui2::panel, gui2::multi_page, and gui2::minimap.
Definition at line 578 of file widget.hpp.
Referenced by draw_background().
|
inlineprivatevirtual |
See draw_children.
Reimplemented in gui2::generator_base, gui2::viewport, gui2::tree_view_node, gui2::scrollbar_container, gui2::pane, gui2::matrix, gui2::grid, and gui2::container_base.
Definition at line 584 of file widget.hpp.
Referenced by draw_children().
|
inlineprivatevirtual |
See draw_foreground.
Reimplemented in gui2::toggle_panel, gui2::styled_widget, and gui2::panel.
Definition at line 589 of file widget.hpp.
Referenced by draw_foreground().
|
overrideprivatevirtual |
Implements gui2::event::dispatcher.
Definition at line 575 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 594 of file widget.cpp.
References rect::contains(), get_rectangle(), 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::tree_view, gui2::stacked_widget, gui2::size_lock, gui2::scrollbar_container, gui2::matrix, gui2::grid, and gui2::container_base.
Definition at line 306 of file widget.cpp.
Referenced by gui2::grid::layout_children(), and gui2::size_lock::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::viewport, gui2::tree_view_node, gui2::styled_widget, gui2::scrollbar_container, gui2::pane, gui2::matrix, gui2::grid, and gui2::container_base.
Definition at line 177 of file widget.cpp.
References gui2::window::add_linked_widget(), get_window(), invisible, layout_size_, linked_group_, draw::point(), and visible_.
Referenced by gui2::grid::layout_initialize(), gui2::pane::layout_initialize(), gui2::styled_widget::layout_initialize(), gui2::tree_view_node::layout_initialize(), and gui2::viewport::layout_initialize().
|
protected |
Definition at line 351 of file widget.cpp.
References layout_size_.
Referenced by gui2::tree_view_node::add_child_impl(), and gui2::tree_view_node::replace_children().
|
virtual |
Moves a widget.
This function can be used to move the widget without queueing a redraw.
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 274 of file widget.cpp.
widget * gui2::widget::parent | ( | ) |
Definition at line 170 of file widget.cpp.
References parent_.
Referenced by gui2::dialogs::help_browser::add_topic(), gui2::tree_view_node::get_node_below(), gui2::dialogs::addon_manager::on_addon_select(), gui2::dialogs::addon_manager::on_selected_version_change(), place(), gui2::grid::place(), set_parent(), gui2::event::mouse_motion::signal_handler_sdl_mouse_motion(), gui2::dialogs::gamestate_inspector::view::stuff_list_entry(), gui2::swap_grid(), 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::generator_base, gui2::viewport, gui2::tree_view_node, gui2::text_box, gui2::styled_widget, gui2::slider_base, gui2::size_lock, gui2::scrollbar_container, gui2::scrollbar_base, gui2::scroll_text, gui2::pane, gui2::multiline_text, gui2::matrix, gui2::listbox, gui2::grid, gui2::policy::placement::independent, gui2::policy::placement::vertical_list, gui2::policy::placement::horizontal_list, gui2::container_base, gui2::combobox, and gui2::policy::placement::table.
Definition at line 248 of file widget.cpp.
References get_rectangle(), get_x(), get_y(), height_, id(), parent(), PLAIN_LOG, queue_redraw(), utf8::size(), width_, x_, and y_.
Referenced by gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::place(), gui2::grid::place(), gui2::matrix::place(), gui2::pane::place(), gui2::styled_widget::place(), gui2::tree_view_node::place(), gui2::viewport::place(), and gui2::grid::child::place().
void gui2::widget::queue_redraw | ( | ) |
Indicates that this widget should be redrawn.
This function should be called by widgets whenever their visible state changes.
Definition at line 464 of file widget.cpp.
References get_rectangle(), height_, and width_.
Referenced by gui2::dialogs::editor_edit_unit::button_state_change(), gui2::dialogs::tod_new_schedule::button_state_change(), gui2::tab_container::change_selection(), gui2::text_box_base::cursor_timer_callback(), gui2::dialogs::story_viewer::display_part(), gui2::dialogs::story_viewer::draw_floating_image(), gui2::text_box_base::handle_editing(), gui2::multiline_text::handle_key_down_arrow(), gui2::multiline_text::handle_key_up_arrow(), gui2::combobox::handle_mouse_selection(), gui2::multiline_text::handle_mouse_selection(), gui2::text_box::handle_mouse_selection(), gui2::dialogs::lua_interpreter::controller::input_keypress_callback(), gui2::text_box_base::insert_char(), gui2::dialogs::loading_screen::layout(), gui2::scrollbar_container::move_viewport(), gui2::text_box_base::paste_selection(), place(), gui2::dialogs::loading_screen::process(), gui2::listbox::resize_content(), gui2::tree_view::resize_content(), gui2::container_base::set_active(), gui2::slider::set_best_slider_length(), gui2::grid::set_column_grow_factor(), gui2::text_box_base::set_cursor(), gui2::styled_widget::set_label(), gui2::label::set_link_aware(), gui2::multiline_text::set_link_aware(), gui2::rich_label::set_link_aware(), gui2::label::set_link_color(), gui2::rich_label::set_link_color(), gui2::minimap::set_map_data(), gui2::text_box_base::set_maximum_length(), gui2::progress_bar::set_percentage(), gui2::grid::set_row_grow_factor(), gui2::listbox::set_row_shown(), gui2::combobox::set_selected(), 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::label::set_state(), gui2::menu_button::set_state(), gui2::multimenu_button::set_state(), gui2::repeating_button::set_state(), gui2::rich_label::set_state(), gui2::scrollbar_base::set_state(), gui2::slider_base::set_state(), gui2::text_box_base::set_state(), gui2::toggle_button::set_state(), gui2::toggle_panel::set_state(), gui2::styled_widget::set_text_alignment(), gui2::label::set_text_alpha(), gui2::rich_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::multimenu_button::set_values(), gui2::combobox::set_values(), gui2::menu_button::set_values(), gui2::window::set_variable(), set_visible(), gui2::dialogs::title_screen::show_preferences(), gui2::scrollbar_base::update_canvas(), gui2::slider_base::update_canvas(), gui2::toggle_button::update_canvas(), gui2::listbox::update_content_size(), gui2::dialogs::editor_edit_unit::update_image(), gui2::listbox::update_layout(), gui2::dialogs::file_progress::update_progress(), and gui2::dialogs::debug_clock::update_time().
void gui2::widget::queue_redraw | ( | const rect & | region | ) |
Indicate that specific region of the screen should be redrawn.
This is in absolute drawing-space coordinates, and not constrained to the current widget.
Definition at line 473 of file widget.cpp.
References get_window(), draw_manager::invalidate_region(), and gui2::window::queue_rerender().
|
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 580 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::table, gui2::policy::placement::vertical_list, gui2::policy::placement::horizontal_list, gui2::generator_base, gui2::styled_widget, gui2::spacer, gui2::scrollbar_container, gui2::grid, gui2::policy::placement::independent, gui2::drawing, and gui2::container_base.
Definition at line 193 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::table, gui2::policy::placement::vertical_list, gui2::policy::placement::horizontal_list, gui2::generator_base, gui2::viewport, gui2::tree_view_node, gui2::styled_widget, gui2::spacer, gui2::scrollbar_container, gui2::pane, gui2::matrix, gui2::grid, gui2::policy::placement::independent, gui2::drawing, and gui2::container_base.
void gui2::widget::set_debug_border_color | ( | const color_t | debug_border_color | ) |
Definition at line 522 of file widget.cpp.
References debug_border_color_.
void gui2::widget::set_debug_border_mode | ( | const debug_border | debug_border_mode | ) |
Definition at line 517 of file widget.cpp.
References debug_border_mode_.
|
inline |
Sets widget to visible if hidden is true, else hidden.
Definition at line 643 of file widget.hpp.
References hidden, set_visible(), and visible.
Referenced by gui2::adjust_scrollbar_mode(), gui2::dialogs::mp_staging::on_controller_select(), gui2::policy::select_action::show::select(), and gui2::set_scrollbar_mode().
|
virtual |
Sets the horizontal alignment of the widget within its parent grid.
alignment | The new alignment. |
Definition at line 280 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 98 of file widget.cpp.
References DBG_GUI_LF, gui2::styled_widget::get_control_type(), id(), id_, and widget().
Referenced by gui2::dialogs::campaign_selection::add_campaign_to_tree(), gui2::dialogs::mp_options_helper::add_node_and_get_widget(), gui2::dialogs::help_browser::add_topic(), BOOST_AUTO_TEST_CASE(), gui2::builder_grid::build(), gui2::window::finalize(), gui2::dialogs::modal_dialog::modal_dialog(), gui2::dialogs::modeless_dialog::modeless_dialog(), gui2::styled_widget::set_members(), gui2::swap_grid(), and test_grid().
|
protected |
Definition at line 346 of file widget.cpp.
References layout_size_, and utf8::size().
Referenced by clear_layout_size(), 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::grid::request_reduce_height(), gui2::scrollbar_container::request_reduce_height(), gui2::styled_widget::request_reduce_height(), gui2::container_base::request_reduce_width(), gui2::grid::request_reduce_width(), gui2::scrollbar_container::request_reduce_width(), gui2::styled_widget::request_reduce_width(), and gui2::styled_widget::set_label().
void gui2::widget::set_linked_group | ( | const std::string & | linked_group | ) |
Definition at line 356 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 triggering a redraw. The location is an absolute position, if a relative move is required use move.
origin | The new origin. |
Reimplemented in gui2::generator_base, gui2::tree_view_node, gui2::scrollbar_container, gui2::grid, gui2::policy::placement::independent, gui2::policy::placement::vertical_list, gui2::policy::placement::horizontal_list, gui2::container_base, and gui2::policy::placement::table.
Definition at line 230 of file widget.cpp.
Referenced by gui2::container_base::set_origin(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_origin(), gui2::grid::set_origin(), and gui2::tree_view_node::set_origin().
void gui2::widget::set_parent | ( | widget * | parent | ) |
Definition at line 165 of file widget.cpp.
References parent(), and parent_.
Referenced by gui2::container_base::container_base(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::init(), gui2::dialogs::addon_manager::install_addon(), gui2::matrix::matrix(), gui2::dialogs::addon_manager::on_selected_version_change(), and gui2::tree_view_node::tree_view_node().
|
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 236 of file widget.cpp.
References height_, queue_redraw(), utf8::size(), and width_.
Referenced by gui2::tree_view_node::place(), gui2::listbox::resize_content(), and gui2::tree_view::resize_content().
|
virtual |
Sets the horizontal alignment of the widget within its parent grid.
alignment | The new alignment. |
Definition at line 293 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().
|
inline |
Sets widget to visible if visible is true, else invisible.
Definition at line 637 of file widget.hpp.
References invisible, set_visible(), and visible.
void gui2::widget::set_visible | ( | const visibility | visible | ) |
Definition at line 479 of file widget.cpp.
References gui2::event::dispatcher::fire(), get_size(), get_window(), gui2::window::invalidate_layout(), invisible, gui2::new_widgets, draw::point(), queue_redraw(), gui2::event::REQUEST_PLACEMENT, 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::gamestate_inspector::controller::bind(), gui2::dialogs::gamestate_inspector::view::clear_stuff_list(), gui2::dialogs::story_viewer::display_part(), gui2::chatbox::find_or_create_window(), gui2::dialogs::mp_join_game::generate_side_list(), gui2::chatbox::increment_waiting_messages(), gui2::chatbox::increment_waiting_whispers(), gui2::dialogs::message_implementation::init_button(), gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::window::layout(), gui2::scrollbar_container::layout_initialize(), gui2::dialogs::preferences_dialog::on_advanced_prefs_list_select(), gui2::dialogs::help_browser::on_topic_select(), gui2::dialogs::campaign_difficulty::pre_show(), gui2::dialogs::end_credits::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::help_browser::pre_show(), gui2::dialogs::message::pre_show(), gui2::dialogs::mp_alerts_options::pre_show(), gui2::dialogs::lobby_player_info::pre_show(), gui2::dialogs::simple_item_selector::pre_show(), gui2::dialogs::transient_message::pre_show(), gui2::dialogs::unit_list::pre_show(), gui2::dialogs::wml_error::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::scrollbar_container::request_reduce_height(), gui2::scrollbar_container::request_reduce_width(), gui2::dialogs::achievements_dialog::set_achievements_row(), gui2::addon_list::set_addons(), gui2::dialogs::attack_predictions::set_data(), set_hidden(), gui2::dialogs::game_load::set_save_dir_list(), gui2::set_scrollbar_mode(), gui2::dialogs::achievements_dialog::set_sub_achievements(), set_visible(), gui2::dialogs::mp_match_history::tab_switch_callback(), gui2::tree_view_node::tree_view_node(), gui2::dialogs::gamestate_inspector::view::update(), gui2::dialogs::mp_match_history::update_display(), 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::generator_base, gui2::tree_view_node, gui2::scrollbar_container, gui2::grid, gui2::policy::placement::independent, gui2::policy::placement::vertical_list, gui2::policy::placement::horizontal_list, gui2::container_base, and gui2::policy::placement::table.
Definition at line 451 of file widget.cpp.
References clipping_rectangle_, rect::empty(), full, get_rectangle(), rect::intersect(), none, partly, and redraw_action_.
Referenced by gui2::container_base::set_visible_rectangle(), and gui2::grid::set_visible_rectangle().
|
friend |
Definition at line 56 of file widget.hpp.
|
friend |
Definition at line 57 of file widget.hpp.
|
private |
The clipping rectangle if a widget is partly visible.
Definition at line 664 of file widget.hpp.
Referenced by calculate_clipping_rectangle(), get_dirty_rectangle(), and set_visible_rectangle().
|
private |
The color for the debug border.
Definition at line 675 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.
Definition at line 672 of file widget.hpp.
Referenced by draw_debug_border(), and set_debug_border_mode().
|
private |
The height of the widget.
Definition at line 482 of file widget.hpp.
Referenced by get_drawing_action(), get_height(), get_size(), place(), queue_redraw(), 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 177 of file widget.hpp.
|
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 494 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 518 of file widget.hpp.
Referenced by get_best_size(), get_linked_group(), 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 217 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 661 of file widget.hpp.
Referenced by get_dirty_rectangle(), get_drawing_action(), and set_visible_rectangle().
|
private |
Field for the status of the visibility.
Definition at line 658 of file widget.hpp.
Referenced by draw_background(), draw_children(), draw_foreground(), get_best_size(), get_visible(), layout_initialize(), recursive_is_visible(), and set_visible().
|
private |
The width of the widget.
Definition at line 479 of file widget.hpp.
Referenced by get_drawing_action(), get_size(), get_width(), place(), queue_redraw(), and set_size().
|
private |
The x-coordinate of the widget on the screen.
Definition at line 473 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 476 of file widget.hpp.
Referenced by get_origin(), get_y(), move(), place(), and set_origin().