Base container class. More...
#include <grid.hpp>
Classes | |
class | child |
Child item of the grid. More... | |
class | iterator |
Iterator for the child items. More... | |
Public Member Functions | |
grid (const unsigned rows=0, const unsigned cols=0) | |
grid (const grid &)=delete | |
Delete the copy constructor. More... | |
grid & | operator= (const grid &)=delete |
Delete the move assignment operator. More... | |
virtual | ~grid () |
unsigned | add_row (const unsigned count=1) |
Adds a row to end of the grid. More... | |
void | set_row_grow_factor (const unsigned row, const unsigned factor) |
Sets the grow factor for a row. More... | |
void | set_column_grow_factor (const unsigned column, const unsigned factor) |
Sets the grow factor for a column. More... | |
void | set_child (std::unique_ptr< widget > widget, const unsigned row, const unsigned col, const unsigned flags, const unsigned border_size) |
Sets a child in the grid. More... | |
std::unique_ptr< widget > | swap_child (const std::string &id, std::unique_ptr< widget > w, const bool recurse, widget *new_parent=nullptr) |
Exchanges a child in the grid. More... | |
void | remove_child (const unsigned row, const unsigned col) |
Removes and frees a widget in a cell. More... | |
void | remove_child (const std::string &id, const bool find_all=false) |
Removes and frees a widget in a cell by it's id. More... | |
void | set_active (const bool active) |
Activates all children. More... | |
const widget * | get_widget (const unsigned row, const unsigned col) const |
Returns the widget in the selected cell. More... | |
widget * | get_widget (const unsigned row, const unsigned col) |
Returns the widget in the selected cell. More... | |
virtual bool | can_mouse_focus () const override |
Whether the mouse move/click event go 'through' this widget. More... | |
virtual void | layout_initialize (const bool full_initialization) override |
See widget::layout_initialize. More... | |
void | reduce_width (const unsigned maximum_width) |
Tries to reduce the width of a container. More... | |
virtual void | request_reduce_width (const unsigned maximum_width) override |
See widget::request_reduce_width. More... | |
virtual void | demand_reduce_width (const unsigned maximum_width) override |
See widget::demand_reduce_width. More... | |
void | reduce_height (const unsigned maximum_height) |
Tries to reduce the height of a container. More... | |
virtual void | request_reduce_height (const unsigned maximum_height) override |
See widget::request_reduce_height. More... | |
virtual void | demand_reduce_height (const unsigned maximum_height) override |
See widget::demand_reduce_height. More... | |
point | recalculate_best_size () |
Recalculates the best size. More... | |
void | set_child_alignment (widget *widget, unsigned set_flag, unsigned mode_mask) |
Modifies the widget alignment data of a child cell containing a specific widget. More... | |
virtual bool | can_wrap () const override |
See widget::can_wrap. More... | |
virtual void | place (const point &origin, const point &size) override |
See widget::place. More... | |
virtual void | set_origin (const point &origin) override |
See widget::set_origin. More... | |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) override |
See widget::set_visible_rectangle. More... | |
virtual void | layout_children () override |
See widget::layout_children. More... | |
virtual widget * | find_at (const point &coordinate, const bool must_be_active) override |
See widget::find_at. More... | |
virtual const widget * | find_at (const point &coordinate, const bool must_be_active) const override |
See widget::find_at. More... | |
widget * | find (const std::string &id, const bool must_be_active) override |
See widget::find. More... | |
const widget * | find (const std::string &id, const bool must_be_active) const override |
See widget::find. More... | |
virtual bool | has_widget (const widget &widget) const override |
See widget::has_widget. More... | |
bool | disable_click_dismiss () const override |
See widget::disable_click_dismiss. More... | |
virtual iteration::walker_ptr | create_walker () override |
See widget::create_walker. More... | |
void | set_rows (const unsigned rows) |
unsigned int | get_rows () const |
void | set_cols (const unsigned cols) |
unsigned int | get_cols () const |
void | set_rows_cols (const unsigned rows, const unsigned cols) |
Wrapper to set_rows and set_cols. More... | |
iterator | begin () |
iterator | end () |
Public Member Functions inherited from gui2::widget | |
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 () |
point | get_best_size () const |
Gets the best size for the widget. More... | |
virtual void | set_size (const point &size) |
Sets the size of 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... | |
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... | |
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 |
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) |
template<class T > | |
NOT_DANGLING T * | find_widget (const std::string &id, const bool must_be_active, const bool must_exist) |
Gets a widget with the wanted id. More... | |
template<class T > | |
NOT_DANGLING const T * | find_widget (const std::string &id, const bool must_be_active, const bool must_exist) const |
template<class T > | |
NOT_DANGLING T & | find_widget (const std::string &id, const bool must_be_active=false) |
Gets a widget with the wanted id. More... | |
template<class T > | |
NOT_DANGLING const T & | find_widget (const std::string &id, const bool must_be_active=false) const |
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) | |
Static Public Attributes | |
static const unsigned | VERTICAL_SHIFT = 0 |
static const unsigned | VERTICAL_GROW_SEND_TO_CLIENT = 1 << VERTICAL_SHIFT |
static const unsigned | VERTICAL_ALIGN_TOP = 2 << VERTICAL_SHIFT |
static const unsigned | VERTICAL_ALIGN_CENTER = 3 << VERTICAL_SHIFT |
static const unsigned | VERTICAL_ALIGN_BOTTOM = 4 << VERTICAL_SHIFT |
static const unsigned | VERTICAL_MASK = 7 << VERTICAL_SHIFT |
static const unsigned | HORIZONTAL_SHIFT = 3 |
static const unsigned | HORIZONTAL_GROW_SEND_TO_CLIENT = 1 << HORIZONTAL_SHIFT |
static const unsigned | HORIZONTAL_ALIGN_LEFT = 2 << HORIZONTAL_SHIFT |
static const unsigned | HORIZONTAL_ALIGN_CENTER = 3 << HORIZONTAL_SHIFT |
static const unsigned | HORIZONTAL_ALIGN_RIGHT = 4 << HORIZONTAL_SHIFT |
static const unsigned | HORIZONTAL_MASK = 7 << HORIZONTAL_SHIFT |
static const unsigned | BORDER_TOP = 1 << 6 |
static const unsigned | BORDER_BOTTOM = 1 << 7 |
static const unsigned | BORDER_LEFT = 1 << 8 |
static const unsigned | BORDER_RIGHT = 1 << 9 |
static const unsigned | BORDER_ALL = BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT |
Private Member Functions | |
virtual point | calculate_best_size () const override |
See widget::calculate_best_size. More... | |
void | request_placement (dispatcher &dispatcher, const event::ui_event event, bool &handled, bool &halt) |
Attempts to lay out the grid without laying out the entire window. More... | |
const grid::child & | get_child (const unsigned row, const unsigned col) const |
Gets the grid child in the specified cell. More... | |
grid::child & | get_child (const unsigned row, const unsigned col) |
Gets the grid child in the specified cell. More... | |
grid::child * | get_child (widget *w) |
Gets the grid child containing the specified widget. More... | |
void | layout (const point &origin) |
Layouts the children in the grid. More... | |
virtual void | impl_draw_children () override |
See widget::impl_draw_children. More... | |
Private Attributes | |
unsigned | rows_ |
The number of grid rows. More... | |
unsigned | cols_ |
The number of grid columns. More... | |
std::vector< unsigned > | row_height_ |
The row heights in the grid. More... | |
std::vector< unsigned > | col_width_ |
The column widths in the grid. More... | |
std::vector< unsigned > | row_grow_factor_ |
The grow factor for all rows. More... | |
std::vector< unsigned > | col_grow_factor_ |
The grow factor for all columns. More... | |
std::vector< child > | children_ |
The child items. More... | |
Friends | |
class | debug_layout_graph |
struct | grid_implementation |
Additional Inherited Members | |
Public Types inherited from gui2::widget | |
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... | |
Protected Member Functions inherited from gui2::widget | |
void | set_layout_size (const point &size) |
const point & | layout_size () const |
void | clear_layout_size () |
Throws away layout_size_. More... | |
Base container class.
This class holds a number of widgets and their wanted layout parameters. It also layouts the items in the grid and handles their drawing.
|
explicit |
Definition at line 40 of file grid.cpp.
References gui2::event::dispatcher::back_pre_child, and request_placement().
|
delete |
Delete the copy constructor.
unsigned gui2::grid::add_row | ( | const unsigned | count = 1 | ) |
Adds a row to end of the grid.
count | Number of rows to add, should be > 0. |
Definition at line 60 of file grid.cpp.
References cols_, rows_, and set_rows_cols().
Referenced by gui2::container_base::add_row().
|
inline |
Definition at line 479 of file grid.hpp.
References children_.
Referenced by gui2::container_base::begin(), and gui2::iteration::scrollbar_container::next().
|
overrideprivatevirtual |
See widget::calculate_best_size.
Implements gui2::widget.
Definition at line 427 of file grid.cpp.
References col_width_, cols_, DBG_GUI_L, gui2::grid::child::get_best_size(), get_child(), gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, row_height_, rows_, and utf8::size().
Referenced by place(), recalculate_best_size(), request_placement(), request_reduce_height(), and request_reduce_width().
|
inlineoverridevirtual |
Whether the mouse move/click event go 'through' this widget.
Reimplemented from gui2::widget.
|
overridevirtual |
See widget::can_wrap.
Reimplemented from gui2::widget.
Definition at line 471 of file grid.cpp.
References gui2::grid::child::can_wrap(), gui2::widget::can_wrap(), and children_.
Referenced by gui2::container_base::can_wrap().
|
overridevirtual |
|
overridevirtual |
See widget::demand_reduce_height.
Reimplemented from gui2::widget.
Definition at line 374 of file grid.cpp.
Referenced by gui2::container_base::demand_reduce_height().
|
overridevirtual |
See widget::demand_reduce_width.
Reimplemented from gui2::widget.
Definition at line 276 of file grid.cpp.
Referenced by gui2::container_base::demand_reduce_width().
|
overridevirtual |
See widget::disable_click_dismiss.
Implements gui2::widget.
Definition at line 671 of file grid.cpp.
References children_, gui2::widget::disable_click_dismiss(), gui2::widget::get_visible(), gui2::grid::child::get_widget(), and gui2::widget::visible.
Referenced by gui2::container_base::disable_click_dismiss(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::disable_click_dismiss().
|
inline |
Definition at line 483 of file grid.hpp.
References children_.
Referenced by gui2::iteration::grid::at_end(), gui2::iteration::scrollbar_container::at_end(), gui2::container_base::end(), gui2::iteration::grid::get(), gui2::iteration::scrollbar_container::get(), gui2::iteration::grid::next(), and gui2::iteration::scrollbar_container::next().
|
overridevirtual |
|
overridevirtual |
See widget::find.
Reimplemented from gui2::widget.
Definition at line 645 of file grid.cpp.
Referenced by gui2::dialogs::editor_edit_pbl::create_cfg(), gui2::container_base::find(), gui2::policy::placement::independent::find(), gui2::matrix::find(), gui2::tree_view_node::find(), gui2::scroll_label::get_internal_label(), gui2::scroll_text::get_internal_text_box(), gui2::policy::select_action::show::init(), gui2::dialogs::editor_choose_addon::post_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::log_settings::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::dialogs::unit_recruit::pre_show(), gui2::dialogs::achievements_dialog::set_achievements_row(), gui2::dialogs::achievements_dialog::set_sub_achievements(), gui2::dialogs::mp_match_history::tab_switch_callback(), gui2::tree_view_node::tree_view_node(), and gui2::dialogs::mp_match_history::update_display().
|
overridevirtual |
See widget::find_at.
Reimplemented from gui2::widget.
Definition at line 632 of file grid.cpp.
Referenced by gui2::policy::placement::table::find_at(), gui2::container_base::find_at(), gui2::policy::placement::horizontal_list::find_at(), gui2::policy::placement::vertical_list::find_at(), gui2::policy::placement::independent::find_at(), gui2::matrix::find_at(), and gui2::tree_view_node_implementation::find_at().
|
inlineprivate |
|
inlineprivate |
Gets the grid child in the specified cell.
row | The row of the cell. |
col | The column of the cell. |
Definition at line 525 of file grid.hpp.
References children_, and rows_.
Referenced by calculate_best_size(), gui2::grid_implementation::column_request_reduce_width(), get_widget(), layout(), remove_child(), gui2::grid_implementation::row_request_reduce_height(), set_child(), and set_child_alignment().
|
private |
Gets the grid child containing the specified widget.
w | The widget to search for. |
Definition at line 917 of file grid.cpp.
References gui2::event::dispatcher::child, children_, gui2::grid::child::get_widget(), and w.
|
inline |
Definition at line 309 of file grid.hpp.
References cols_.
Referenced by gui2::container_base::get_cols(), gui2::policy::select_action::show::init(), and gui2::container_base::init_grid().
|
inline |
Definition at line 303 of file grid.hpp.
References rows_.
Referenced by gui2::container_base::get_rows(), gui2::policy::select_action::show::init(), and gui2::container_base::init_grid().
|
inline |
Returns the widget in the selected cell.
Definition at line 187 of file grid.hpp.
References get_child(), and gui2::grid::child::get_widget().
|
inline |
Returns the widget in the selected cell.
Definition at line 181 of file grid.hpp.
References get_child(), and gui2::grid::child::get_widget().
Referenced by gui2::policy::placement::vertical_list::handle_key_down_arrow(), gui2::policy::placement::table::handle_key_down_arrow(), gui2::policy::placement::horizontal_list::handle_key_left_arrow(), gui2::policy::placement::table::handle_key_left_arrow(), gui2::policy::placement::horizontal_list::handle_key_right_arrow(), gui2::policy::placement::table::handle_key_right_arrow(), gui2::policy::placement::vertical_list::handle_key_up_arrow(), gui2::policy::placement::table::handle_key_up_arrow(), gui2::policy::select_action::show::init(), layout(), gui2::grid::child::place(), and gui2::policy::select_action::selection::select().
|
overridevirtual |
See widget::has_widget.
Reimplemented from gui2::widget.
Definition at line 656 of file grid.cpp.
References children_, gui2::grid::child::get_widget(), and gui2::widget::has_widget().
Referenced by gui2::container_base::has_widget(), and gui2::listbox::list_item_clicked().
|
overrideprivatevirtual |
See widget::impl_draw_children.
Reimplemented from gui2::widget.
Definition at line 982 of file grid.cpp.
References children_, gui2::window::defer_region(), gui2::widget::draw_background(), gui2::widget::draw_children(), gui2::widget::draw_foreground(), gui2::widget::get_drawing_action(), gui2::widget::get_rectangle(), gui2::widget::get_visible(), gui2::grid::child::get_widget(), gui2::widget::get_window(), gui2::widget::none, and gui2::widget::visible.
|
private |
Layouts the children in the grid.
Definition at line 960 of file grid.cpp.
References col_width_, cols_, DBG_GUI_L, get_child(), get_widget(), LOG_HEADER, gui2::grid::child::place(), row_height_, rows_, and utf8::size().
Referenced by place().
|
overridevirtual |
Reimplemented from gui2::widget.
Definition at line 623 of file grid.cpp.
References children_, gui2::grid::child::get_widget(), and gui2::widget::layout_children().
Referenced by gui2::container_base::layout_children(), gui2::matrix::layout_children(), and gui2::stacked_widget::layout_children().
|
overridevirtual |
See widget::layout_initialize.
Reimplemented from gui2::widget.
Definition at line 190 of file grid.cpp.
References children_, gui2::grid::child::layout_initialize(), and gui2::widget::layout_initialize().
Referenced by gui2::container_base::layout_initialize(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::layout_initialize(), gui2::matrix::layout_initialize(), gui2::tree_view_node::layout_initialize(), request_placement(), and gui2::set_scrollbar_mode().
See widget::place.
Reimplemented from gui2::widget.
Definition at line 484 of file grid.cpp.
References calculate_best_size(), col_grow_factor_, col_width_, cols_, DBG_GUI_L, ERR_GUI_L, h, i, gui2::widget::id(), layout(), gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, gui2::widget::parent(), gui2::widget::place(), row_grow_factor_, row_height_, rows_, utf8::size(), and w.
Referenced by gui2::policy::placement::table::place(), gui2::container_base::place(), gui2::policy::placement::horizontal_list::place(), gui2::policy::placement::vertical_list::place(), gui2::policy::placement::independent::place(), gui2::matrix::place(), gui2::tree_view_node::place(), request_placement(), gui2::listbox::set_content_size(), and gui2::listbox::update_layout().
point gui2::grid::recalculate_best_size | ( | ) |
Recalculates the best size.
This is used for scrollbar containers when they try to update their contents size before falling back to the 'global' invalidate_layout.
Definition at line 420 of file grid.cpp.
References calculate_best_size(), and gui2::widget::set_layout_size().
Referenced by request_placement().
void gui2::grid::reduce_height | ( | const unsigned | maximum_height | ) |
Tries to reduce the height of a container.
See Layout algorithm for more information.
maximum_height | The wanted maximum height. |
Definition at line 281 of file grid.cpp.
References DBG_GUI_L, gui2::widget::get_best_size(), gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, request_reduce_height(), and utf8::size().
Referenced by gui2::container_base::reduce_height().
void gui2::grid::reduce_width | ( | const unsigned | maximum_width | ) |
Tries to reduce the width of a container.
See Layout algorithm for more information.
maximum_width | The wanted maximum width. |
Definition at line 203 of file grid.cpp.
References DBG_GUI_L, gui2::widget::get_best_size(), gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, request_reduce_width(), and utf8::size().
Referenced by gui2::container_base::reduce_width().
void gui2::grid::remove_child | ( | const std::string & | id, |
const bool | find_all = false |
||
) |
Removes and frees a widget in a cell by it's id.
id | The id of the widget to free. |
find_all | If true if removes all items with the id, otherwise it stops after removing the first item (or once all children have been tested). |
Definition at line 153 of file grid.cpp.
References children_, gui2::grid::child::id(), and gui2::grid::child::set_widget().
void gui2::grid::remove_child | ( | const unsigned | row, |
const unsigned | col | ||
) |
Removes and frees a widget in a cell.
row | The row of the cell. |
col | The column of the cell. |
Definition at line 145 of file grid.cpp.
References cols_, get_child(), rows_, and gui2::grid::child::set_widget().
|
private |
Attempts to lay out the grid without laying out the entire window.
Definition at line 379 of file grid.cpp.
References calculate_best_size(), gui2::widget::get_best_size(), gui2::widget::get_origin(), gui2::widget::get_size(), gui2::widget::get_window(), layout_initialize(), place(), recalculate_best_size(), request_reduce_width(), and utf8::size().
Referenced by grid().
|
overridevirtual |
See widget::request_reduce_height.
Now we try every item to be reduced, maybe items need a flag whether or not to try to reduce and also evaluate whether the force reduction is still needed.
Reimplemented from gui2::widget.
Definition at line 314 of file grid.cpp.
References calculate_best_size(), DBG_GUI_L, gui2::widget::get_best_size(), LOG_HEADER, row_height_, gui2::grid_implementation::row_request_reduce_height(), rows_, gui2::widget::set_layout_size(), and utf8::size().
Referenced by reduce_height(), gui2::container_base::request_reduce_height(), and gui2::policy::placement::independent::request_reduce_height().
|
overridevirtual |
See widget::request_reduce_width.
Implements gui2::widget.
Definition at line 236 of file grid.cpp.
References calculate_best_size(), col_width_, cols_, gui2::grid_implementation::column_request_reduce_width(), DBG_GUI_L, gui2::widget::get_best_size(), LOG_HEADER, gui2::widget::set_layout_size(), and utf8::size().
Referenced by reduce_width(), request_placement(), gui2::container_base::request_reduce_width(), gui2::policy::placement::independent::request_reduce_width(), and gui2::scrollbar_container::request_reduce_width().
void gui2::grid::set_active | ( | const bool | active | ) |
Activates all children.
If a child inherits from styled_widget or is a grid it will call set_active() for the child otherwise it ignores the widget.
active | Parameter for set_active. |
Definition at line 167 of file grid.cpp.
References children_, g, gui2::grid::child::get_widget(), gui2::styled_widget::set_active(), and gui2::widget::widget().
Referenced by gui2::dialogs::editor_edit_pbl::add_translation(), gui2::dialogs::game_load::populate_game_list(), gui2::container_base::set_active(), and gui2::listbox::set_row_active().
void gui2::grid::set_child | ( | std::unique_ptr< widget > | widget, |
const unsigned | row, | ||
const unsigned | col, | ||
const unsigned | flags, | ||
const unsigned | border_size | ||
) |
Sets a child in the grid.
When the child is added to the grid the grid 'owns' the widget. The widget is put in a cell, and every cell can only contain 1 widget if the wanted cell already contains a widget, that widget is freed and removed.
widget | The widget to put in the grid. |
row | The row of the cell. |
col | The column of the cell. |
flags | The flags for the widget in the cell. |
border_size | The size of the border for the cell, how the border is applied depends on the flags. |
Definition at line 71 of file grid.cpp.
References cols_, get_child(), gui2::grid::child::get_widget(), HORIZONTAL_MASK, gui2::grid::child::id(), LOG_HEADER, rows_, gui2::grid::child::set_border_size(), gui2::grid::child::set_flags(), gui2::grid::child::set_widget(), VERTICAL_MASK, w, and WRN_GUI_G.
Referenced by add_widget(), gui2::implementation::builder_scrollbar_panel::build(), gui2::builder_grid::build(), gui2::tree_view::finalize_setup(), gui2::container_base::set_child(), and gui2::set_single_child().
void gui2::grid::set_child_alignment | ( | widget * | widget, |
unsigned | set_flag, | ||
unsigned | mode_mask | ||
) |
Modifies the widget alignment data of a child cell containing a specific widget.
widget | The widget whose cell to modify. |
set_flag | The alignment flag to set. |
mode_mask | Whether to affect horizontal or vertical alignment. Use either HORIZONTAL_MASK or VERTICAL_MASK |
Definition at line 932 of file grid.cpp.
References ERR_GUI_G, gui2::event::dispatcher::fire(), get_child(), gui2::grid::child::get_flags(), HORIZONTAL_GROW_SEND_TO_CLIENT, gui2::event::REQUEST_PLACEMENT, gui2::grid::child::set_flags(), and VERTICAL_GROW_SEND_TO_CLIENT.
Referenced by gui2::widget::set_horizontal_alignment(), and gui2::widget::set_vertical_alignment().
void gui2::grid::set_cols | ( | const unsigned | cols | ) |
Definition at line 703 of file grid.cpp.
References cols_, rows_, and set_rows_cols().
Referenced by gui2::container_base::set_cols().
|
inline |
Sets the grow factor for a column.
column | The column to modify. |
factor | The grow factor. |
Definition at line 102 of file grid.hpp.
References col_grow_factor_, and gui2::widget::queue_redraw().
Referenced by gui2::implementation::builder_scrollbar_panel::build(), gui2::builder_grid::build(), and gui2::container_base::set_column_grow_factor().
|
overridevirtual |
See widget::set_origin.
Reimplemented from gui2::widget.
Definition at line 591 of file grid.cpp.
References children_, gui2::grid::child::get_widget(), gui2::widget::get_x(), gui2::widget::get_y(), draw::point(), and gui2::widget::set_origin().
Referenced by gui2::policy::placement::table::set_origin(), gui2::container_base::set_origin(), gui2::policy::placement::horizontal_list::set_origin(), gui2::policy::placement::vertical_list::set_origin(), and gui2::policy::placement::independent::set_origin().
|
inline |
Sets the grow factor for a row.
row | The row to modify. |
factor | The grow factor. |
Definition at line 87 of file grid.hpp.
References gui2::widget::queue_redraw(), and row_grow_factor_.
Referenced by gui2::implementation::builder_scrollbar_panel::build(), gui2::builder_grid::build(), and gui2::container_base::set_row_grow_factor().
void gui2::grid::set_rows | ( | const unsigned | rows | ) |
Definition at line 694 of file grid.cpp.
References cols_, rows_, and set_rows_cols().
Referenced by gui2::container_base::set_rows().
void gui2::grid::set_rows_cols | ( | const unsigned | rows, |
const unsigned | cols | ||
) |
Wrapper to set_rows and set_cols.
rows | Parameter to call set_rows with. |
cols | Parameter to call set_cols with. |
Definition at line 712 of file grid.cpp.
References children_, col_grow_factor_, cols_, LOG_HEADER, row_grow_factor_, rows_, and WRN_GUI_G.
Referenced by add_row(), gui2::implementation::builder_scrollbar_panel::build(), gui2::builder_grid::build(), gui2::tree_view::finalize_setup(), set_cols(), set_rows(), gui2::container_base::set_rows_cols(), and gui2::set_single_child().
|
overridevirtual |
See widget::set_visible_rectangle.
Reimplemented from gui2::widget.
Definition at line 608 of file grid.cpp.
References children_, gui2::grid::child::get_widget(), and gui2::widget::set_visible_rectangle().
Referenced by gui2::policy::placement::table::set_visible_rectangle(), gui2::container_base::set_visible_rectangle(), gui2::policy::placement::horizontal_list::set_visible_rectangle(), gui2::policy::placement::vertical_list::set_visible_rectangle(), gui2::policy::placement::independent::set_visible_rectangle(), gui2::tree_view_node::set_visible_rectangle(), and gui2::listbox::update_layout().
std::unique_ptr< widget > gui2::grid::swap_child | ( | const std::string & | id, |
std::unique_ptr< widget > | w, | ||
const bool | recurse, | ||
widget * | new_parent = nullptr |
||
) |
Exchanges a child in the grid.
It replaced the child with a certain id with the new widget but doesn't touch the other settings of the child.
id | The id of the widget to free. |
w | The widget to put in the grid. |
recurse | Do we want to decent into the child grids. |
new_parent | The new parent for the swapped out widget. |
Definition at line 101 of file grid.cpp.
References children_, gui2::grid::child::free_widget(), g, gui2::grid::child::get_widget(), gui2::grid::child::id(), gui2::grid::child::set_widget(), and w.
Referenced by gui2::tab_container::finalize(), gui2::dialogs::preferences_dialog::initialize_callbacks(), gui2::dialogs::drop_down_menu::pre_show(), and gui2::swap_grid().
|
friend |
|
static |
Definition at line 66 of file grid.hpp.
Referenced by gui2::implementation::get_border().
|
static |
Definition at line 63 of file grid.hpp.
Referenced by gui2::grid::child::border_space(), gui2::implementation::get_border(), and gui2::grid::child::place().
|
static |
Definition at line 64 of file grid.hpp.
Referenced by gui2::grid::child::border_space(), gui2::implementation::get_border(), and gui2::grid::child::place().
|
static |
Definition at line 65 of file grid.hpp.
Referenced by gui2::grid::child::border_space(), gui2::implementation::get_border(), and gui2::grid::child::place().
|
static |
Definition at line 62 of file grid.hpp.
Referenced by gui2::grid::child::border_space(), gui2::implementation::get_border(), and gui2::grid::child::place().
|
private |
The child items.
All children are stored in a 1D vector and the formula to access a cell is: rows_ * col + row. All other vectors use the same access formula.
Definition at line 515 of file grid.hpp.
Referenced by begin(), can_wrap(), disable_click_dismiss(), end(), gui2::grid_implementation::find(), gui2::grid_implementation::find_at(), get_child(), has_widget(), impl_draw_children(), layout_children(), layout_initialize(), remove_child(), set_active(), set_origin(), set_rows_cols(), set_visible_rectangle(), and swap_child().
|
private |
The grow factor for all columns.
Definition at line 507 of file grid.hpp.
Referenced by place(), set_column_grow_factor(), and set_rows_cols().
|
mutableprivate |
The column widths in the grid.
Definition at line 501 of file grid.hpp.
Referenced by calculate_best_size(), layout(), place(), and request_reduce_width().
|
private |
The number of grid columns.
Definition at line 493 of file grid.hpp.
Referenced by add_row(), calculate_best_size(), get_cols(), layout(), place(), remove_child(), request_reduce_width(), gui2::grid_implementation::row_request_reduce_height(), set_child(), set_cols(), set_rows(), and set_rows_cols().
|
static |
Definition at line 58 of file grid.hpp.
Referenced by gui2::implementation::get_h_align(), gui2::window::layout(), and gui2::grid::child::place().
|
static |
Definition at line 57 of file grid.hpp.
Referenced by gui2::implementation::get_h_align(), gui2::window::layout(), and gui2::grid::child::place().
|
static |
Definition at line 59 of file grid.hpp.
Referenced by gui2::implementation::get_h_align(), gui2::window::layout(), and gui2::grid::child::place().
|
static |
Definition at line 56 of file grid.hpp.
Referenced by add_widget(), gui2::size_lock::finalize(), gui2::tree_view::finalize_setup(), gui2::grid::child::place(), gui2::implementation::read_flags(), set_child_alignment(), and gui2::set_single_child().
|
static |
Definition at line 60 of file grid.hpp.
Referenced by gui2::grid::child::place(), set_child(), and gui2::widget::set_horizontal_alignment().
|
private |
The grow factor for all rows.
Definition at line 504 of file grid.hpp.
Referenced by place(), set_row_grow_factor(), and set_rows_cols().
|
mutableprivate |
The row heights in the grid.
Definition at line 498 of file grid.hpp.
Referenced by calculate_best_size(), layout(), place(), and request_reduce_height().
|
private |
The number of grid rows.
Definition at line 490 of file grid.hpp.
Referenced by add_row(), calculate_best_size(), gui2::grid_implementation::column_request_reduce_width(), get_child(), get_rows(), layout(), place(), remove_child(), request_reduce_height(), set_child(), set_cols(), set_rows(), and set_rows_cols().
|
static |
Definition at line 52 of file grid.hpp.
Referenced by gui2::implementation::get_v_align(), gui2::window::layout(), and gui2::grid::child::place().
|
static |
Definition at line 51 of file grid.hpp.
Referenced by gui2::implementation::get_v_align(), gui2::window::layout(), and gui2::grid::child::place().
|
static |
Definition at line 50 of file grid.hpp.
Referenced by gui2::implementation::get_v_align(), gui2::window::layout(), and gui2::grid::child::place().
|
static |
Definition at line 49 of file grid.hpp.
Referenced by add_widget(), gui2::size_lock::finalize(), gui2::tree_view::finalize_setup(), gui2::grid::child::place(), gui2::implementation::read_flags(), set_child_alignment(), and gui2::set_single_child().
|
static |
Definition at line 53 of file grid.hpp.
Referenced by gui2::grid::child::place(), set_child(), and gui2::widget::set_vertical_alignment().