#include <tree_view_node.hpp>
Public Types | |
using | node_children_vector = std::vector< std::shared_ptr< tree_view_node > > |
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... | |
Public Member Functions | |
bool | operator== (const tree_view_node &node) |
tree_view_node (const std::string &id, tree_view_node *parent_node, tree_view &parent_tree_view, const widget_data &data) | |
~tree_view_node () | |
tree_view_node & | add_child (const std::string &id, const widget_data &data, const int index=-1) |
Constructs a new child node. More... | |
std::vector< std::shared_ptr< gui2::tree_view_node > > | replace_children (const std::string &id, const std::vector< widget_data > &data) |
Replaces all children of this tree with new children. More... | |
tree_view_node & | add_child (std::shared_ptr< tree_view_node > new_node, const int index=-1) |
Adds a previously-constructed node as a child of this node at the given position. More... | |
tree_view_node & | add_sibling (const std::string &id, const widget_data &data) |
Adds a sibling for a node at the end of the list. More... | |
bool | is_root_node () const |
Is this node the root node? More... | |
unsigned | get_indentation_level () const |
The indentation level of the node. More... | |
bool | empty () const |
Does the node have children? More... | |
bool | is_folded () const |
Is the node folded? More... | |
void | fold (const bool recursive=false) |
void | unfold (const bool recursive=false) |
virtual iteration::walker_ptr | create_walker () override |
See widget::create_walker. More... | |
node_children_vector & | children () |
node_children_vector & | siblings () |
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... | |
std::size_t | count_children () const |
The number of children in this widget. More... | |
void | clear () |
Removes all child items from the widget. More... | |
tree_view_node & | parent_node () |
Returns the parent node. More... | |
const tree_view_node & | parent_node () const |
The const version of parent_node. More... | |
tree_view & | get_tree_view () |
const tree_view & | get_tree_view () const |
tree_view_node & | get_child_at (int index) |
std::vector< int > | describe_path () const |
Calculates the node indices needed to get from the root node to this node. More... | |
tree_view_node * | get_last_visible_parent_node () |
tree_view_node * | get_node_above () |
tree_view_node * | get_node_below () |
tree_view_node * | get_selectable_node_above () |
tree_view_node * | get_selectable_node_below () |
void | select_node (bool expand_parents=false) |
grid & | get_grid () |
void | layout_initialize (const bool full_initialization) override |
How the layout engine works. More... | |
void | clear_before_destruct () |
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... | |
void | set_parent (widget *parent) |
widget * | parent () |
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_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... | |
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) |
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) |
virtual bool | has_widget (const widget &widget) const |
Does the widget contain the widget. More... | |
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) | |
Private Member Functions | |
tree_view_node & | add_child_impl (std::shared_ptr< tree_view_node > &&new_node, const int index) |
Implementation detail for add_child. More... | |
int | calculate_ypos () |
virtual void | request_reduce_width (const unsigned maximum_width) override |
See widget::request_reduce_width. More... | |
void | fold_internal () |
void | unfold_internal () |
virtual point | calculate_best_size () const override |
See widget::calculate_best_size. More... | |
bool | disable_click_dismiss () const override |
See widget::disable_click_dismiss. More... | |
point | calculate_best_size (const int indentation_level, const unsigned indentation_step_size) const |
point | get_current_size (bool assume_visible=false) const |
point | get_folded_size () const |
point | get_unfolded_size () const |
virtual void | set_origin (const point &origin) override |
See widget::set_origin. More... | |
virtual void | place (const point &origin, const point &size) override |
See widget::place. More... | |
unsigned | place (const unsigned indentation_step_size, point origin, unsigned width) |
virtual void | set_visible_rectangle (const SDL_Rect &rectangle) override |
See widget::set_visible_rectangle. More... | |
virtual void | impl_draw_children () override |
See widget::impl_draw_children. More... | |
void | signal_handler_toggle_left_click (const event::ui_event event) |
void | signal_handler_label_left_button_click (const event::ui_event event, bool &handled, bool &halt) |
void | init_grid (grid *grid, const widget_data &data) |
const std::string & | get_control_type () const |
Returns the control_type of the tree_view_node. More... | |
Private Attributes | |
tree_view_node * | parent_node_ |
Our parent node. More... | |
tree_view * | tree_view_ |
The tree view that owns us. More... | |
grid | grid_ |
Grid holding our contents. More... | |
node_children_vector | children_ |
Our children. More... | |
selectable_item * | toggle_ |
The toggle for the folded state. More... | |
selectable_item * | label_ |
The label to show our selected state. More... | |
bool | unfolded_ |
Friends | |
struct | tree_view_node_implementation |
class | tree_view |
Additional Inherited Members | |
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... | |
Definition at line 29 of file tree_view_node.hpp.
using gui2::tree_view_node::node_children_vector = std::vector<std::shared_ptr<tree_view_node> > |
Definition at line 35 of file tree_view_node.hpp.
gui2::tree_view_node::tree_view_node | ( | const std::string & | id, |
tree_view_node * | parent_node, | ||
tree_view & | parent_tree_view, | ||
const widget_data & | data | ||
) |
Definition at line 35 of file tree_view_node.cpp.
References _(), gui2::event::dispatcher::back_post_child, gui2::event::dispatcher::connect_signal(), data, FAIL_WITH_DEV_MESSAGE, gui2::grid::find(), gui2::event::dispatcher::front_child, gui2::event::dispatcher::front_pre_child, get_tree_view(), grid_, gui2::widget::hidden, init_grid(), label_, gui2::event::LEFT_BUTTON_CLICK, parent_node_, gui2::tree_view::root_node_id, gui2::tree_view::selected_item_, gui2::widget::set_parent(), gui2::selectable_item::set_value(), gui2::widget::set_visible(), signal_handler_label_left_button_click(), signal_handler_toggle_left_click(), toggle_, unfolded_, and gui2::widget::visible.
gui2::tree_view_node::~tree_view_node | ( | ) |
Definition at line 110 of file tree_view_node.cpp.
References get_tree_view(), gui2::tree_view::selected_item_, and tree_view_.
|
inline |
Constructs a new child node.
id | The id of the node definition to use for the new node. |
data | The data to send to the set_members of the widgets. If the member id is not an empty string it is only send to the widget that has the wanted id (if any). If the member id is an empty string, it is send to all members. Having both empty and non-empty id's gives undefined behavior. |
index | The item before which to add the new item, 0 == begin, -1 == end. |
Definition at line 65 of file tree_view_node.hpp.
References add_child_impl(), data, get_tree_view(), and utf8::index().
Referenced by gui2::dialogs::stuff_list_adder::add(), gui2::add_name_tree_node(), gui2::tree_view::add_node(), gui2::dialogs::mp_options_helper::add_node_and_get_widget(), add_sibling(), gui2::dialogs::mp_staging::add_side_to_team_node(), and gui2::dialogs::mp_options_helper::display_custom_options().
|
inline |
Adds a previously-constructed node as a child of this node at the given position.
new_node | A smart pointer to the node object to insert. |
index | The item before which to add the new item, 0 == begin, -1 == end. |
Definition at line 90 of file tree_view_node.hpp.
References add_child_impl(), utf8::index(), and parent_node_.
|
private |
Implementation detail for add_child.
Definition at line 125 of file tree_view_node.cpp.
References calculate_ypos(), children_, gui2::scrollbar_container::content_grid(), gui2::widget::get_best_size(), get_indentation_level(), gui2::widget::get_size(), get_tree_view(), gui2::tree_view::indentation_step_size_, utf8::index(), is_folded(), gui2::scrollbar_container::layout_initialize(), gui2::widget::layout_size(), parent_node_, draw::point(), gui2::tree_view::resize_content(), and tree_view_.
Referenced by add_child().
|
inline |
Adds a sibling for a node at the end of the list.
id | The id of the node definition to use for the new node. |
data | The data to send to the set_members of the widgets. If the member id is not an empty string it is only send to the widget that has the wanted id (if any). If the member id is an empty string, it is send to all members. Having both empty and non-empty id's gives undefined behavior. |
Definition at line 110 of file tree_view_node.hpp.
References add_child(), data, is_root_node(), and parent_node().
Referenced by gui2::dialogs::mp_staging::add_side_to_team_node(), and gui2::dialogs::mp_join_game::generate_side_list().
|
overrideprivatevirtual |
See widget::calculate_best_size.
Implements gui2::widget.
Definition at line 472 of file tree_view_node.cpp.
References get_tree_view().
|
private |
Definition at line 538 of file tree_view_node.cpp.
References children_, DBG_GUI_L, gui2::widget::get_best_size(), grid_, gui2::widget::invisible, is_folded(), gui2::log_gui_layout, LOG_HEADER, log_scope2, and LOG_SCOPE_HEADER.
|
private |
Definition at line 757 of file tree_view_node.cpp.
References calculate_ypos(), children_, and parent_node_.
Referenced by add_child_impl(), calculate_ypos(), clear(), fold_internal(), and unfold_internal().
|
inline |
void gui2::tree_view_node::clear | ( | ) |
Removes all child items from the widget.
Definition at line 364 of file tree_view_node.cpp.
References calculate_ypos(), children_, get_tree_view(), is_folded(), and gui2::tree_view::resize_content().
Referenced by gui2::tree_view::clear(), and replace_children().
void gui2::tree_view_node::clear_before_destruct | ( | ) |
Definition at line 117 of file tree_view_node.cpp.
References gui2::event::dispatcher::child, children_, and tree_view_.
Referenced by gui2::tree_view::~tree_view().
|
inline |
The number of children in this widget.
Definition at line 203 of file tree_view_node.hpp.
References children_.
Referenced by describe_path(), find_child_by_index(), find_widget_impl(), get_node_above(), get_node_below(), gui2::dialogs::team_mode_controller::show_ai(), gui2::dialogs::variable_mode_controller::show_list(), gui2::dialogs::unit_mode_controller::show_list(), gui2::dialogs::event_mode_controller::show_list(), gui2::dialogs::team_mode_controller::show_list(), gui2::dialogs::team_mode_controller::show_recall(), gui2::dialogs::unit_mode_controller::show_unit(), and gui2::dialogs::team_mode_controller::show_vars().
|
overridevirtual |
Implements gui2::widget.
Definition at line 897 of file tree_view_node.cpp.
References children_.
std::vector< int > gui2::tree_view_node::describe_path | ( | ) | const |
Calculates the node indices needed to get from the root node to this node.
Definition at line 739 of file tree_view_node.cpp.
References children_, count_children(), describe_path(), i, is_root_node(), and parent_node_.
Referenced by gui2::dialogs::stuff_list_adder::add(), describe_path(), gui2::dialogs::unit_mode_controller::show_array(), gui2::dialogs::event_mode_controller::show_event(), gui2::dialogs::team_mode_controller::show_recall_unit(), gui2::dialogs::unit_mode_controller::show_unit(), and gui2::dialogs::unit_mode_controller::show_var().
|
overrideprivatevirtual |
See widget::disable_click_dismiss.
Implements gui2::widget.
Definition at line 477 of file tree_view_node.cpp.
|
inline |
Does the node have children?
Definition at line 144 of file tree_view_node.hpp.
References children_.
Referenced by gui2::tree_view::empty(), and gui2::dialogs::mp_staging::on_team_select().
|
overridevirtual |
See widget::find.
Reimplemented from gui2::widget.
Definition at line 450 of file tree_view_node.cpp.
References gui2::event::dispatcher::child, children_, gui2::widget::find(), gui2::grid::find(), and grid_.
|
overridevirtual |
See widget::find.
Reimplemented from gui2::widget.
Definition at line 428 of file tree_view_node.cpp.
References gui2::event::dispatcher::child, children_, gui2::widget::find(), gui2::grid::find(), and grid_.
Referenced by gui2::dialogs::mp_options_helper::add_node_and_get_widget(), find_widget_impl(), gui2::dialogs::team_mode_controller::show_ai_components(), gui2::dialogs::variable_mode_controller::show_array(), gui2::dialogs::unit_mode_controller::show_array(), gui2::dialogs::team_mode_controller::show_array(), gui2::dialogs::variable_mode_controller::show_var(), gui2::dialogs::unit_mode_controller::show_var(), and gui2::dialogs::team_mode_controller::show_var().
|
overridevirtual |
See widget::find_at.
Reimplemented from gui2::widget.
Definition at line 423 of file tree_view_node.cpp.
|
overridevirtual |
See widget::find_at.
Reimplemented from gui2::widget.
Definition at line 418 of file tree_view_node.cpp.
void gui2::tree_view_node::fold | ( | const bool | recursive = false | ) |
Definition at line 289 of file tree_view_node.cpp.
References children_, fold_internal(), is_folded(), gui2::selectable_item::set_value(), and toggle_.
|
private |
Important! Set this first. See issues #8689 and #9146.
For context, when the unfolded_ flag was introduced in 21001bcb3201b46f4c4b15de1388d4bb843a2403, it was set at the end of this function, and of unfold_internal. Commentary in #8689 indicates that there were no folding issues until recently, and it seems possible tha the graphics overhaul was caused a subtly-hidden flaw to reveal itself.
The bugs above technically only involve this function (not unfold_internal), and only if unfolded_ is set after the call to resize_content. My best guess is because tree_view::resize_content calls queue_redraw, and that somehow still being in an "unfolded state" causes things to draw incorrectly.
Definition at line 321 of file tree_view_node.cpp.
References calculate_ypos(), get_current_size(), get_folded_size(), get_tree_view(), get_unfolded_size(), gui2::tree_view::resize_content(), and unfolded_.
Referenced by fold(), and signal_handler_toggle_left_click().
tree_view_node & gui2::tree_view_node::get_child_at | ( | int | index | ) |
Definition at line 733 of file tree_view_node.cpp.
References children_, and utf8::index().
Referenced by find_child_by_index(), find_widget_impl(), get_node_above(), and get_node_below().
|
private |
Returns the control_type of the tree_view_node.
This class does not derive from styled_widget but the function behaves similar as styled_widget::get_control_type.
Definition at line 727 of file tree_view_node.cpp.
|
private |
assume_visible | if false (default) it will return 0 if the parent node is folded |
Definition at line 482 of file tree_view_node.cpp.
References children_, get_folded_size(), gui2::widget::invisible, is_folded(), parent_node_, draw::point(), and utf8::size().
Referenced by fold_internal(), and unfold_internal().
|
private |
Definition at line 507 of file tree_view_node.cpp.
References gui2::widget::get_best_size(), get_indentation_level(), get_tree_view(), grid_, gui2::tree_view::indentation_step_size_, and utf8::size().
Referenced by fold_internal(), get_current_size(), and unfold_internal().
|
inline |
Definition at line 248 of file tree_view_node.hpp.
References grid_.
Referenced by gui2::dialogs::mp_staging::add_side_node(), and gui2::dialogs::mp_join_game::generate_side_list().
unsigned gui2::tree_view_node::get_indentation_level | ( | ) | const |
The indentation level of the node.
The root node starts at level 0.
Definition at line 259 of file tree_view_node.cpp.
References is_root_node(), game_config::images::level, and parent_node().
Referenced by add_child_impl(), get_folded_size(), get_unfolded_size(), and replace_children().
tree_view_node * gui2::tree_view_node::get_last_visible_parent_node | ( | ) |
Definition at line 775 of file tree_view_node.cpp.
References get_last_visible_parent_node(), is_folded(), and parent_node_.
Referenced by get_last_visible_parent_node().
tree_view_node * gui2::tree_view_node::get_node_above | ( | ) |
Definition at line 785 of file tree_view_node.cpp.
References children_, count_children(), get_child_at(), i, is_folded(), is_root_node(), and parent_node_.
Referenced by get_selectable_node_above().
tree_view_node * gui2::tree_view_node::get_node_below | ( | ) |
Definition at line 814 of file tree_view_node.cpp.
References count_children(), get_child_at(), i, is_folded(), is_root_node(), gui2::widget::parent(), and parent_node_.
Referenced by get_selectable_node_below(), and gui2::dialogs::mp_staging::on_team_select().
tree_view_node * gui2::tree_view_node::get_selectable_node_above | ( | ) |
Definition at line 841 of file tree_view_node.cpp.
References get_node_above(), and label_.
tree_view_node * gui2::tree_view_node::get_selectable_node_below | ( | ) |
Definition at line 851 of file tree_view_node.cpp.
References get_node_below(), and label_.
|
inline |
Definition at line 225 of file tree_view_node.hpp.
References tree_view_.
Referenced by add_child(), add_child_impl(), calculate_best_size(), clear(), fold_internal(), get_folded_size(), get_unfolded_size(), place(), replace_children(), select_node(), set_origin(), signal_handler_label_left_button_click(), signal_handler_toggle_left_click(), tree_view_node(), unfold_internal(), and ~tree_view_node().
|
inline |
Definition at line 230 of file tree_view_node.hpp.
References tree_view_.
|
private |
Definition at line 517 of file tree_view_node.cpp.
References children_, gui2::widget::get_best_size(), get_indentation_level(), get_tree_view(), grid_, gui2::tree_view::indentation_step_size_, gui2::widget::invisible, and utf8::size().
Referenced by fold_internal(), and unfold_internal().
|
overrideprivatevirtual |
See widget::impl_draw_children.
Reimplemented from gui2::widget.
Definition at line 636 of file tree_view_node.cpp.
References children_, gui2::widget::draw_children(), grid_, and is_folded().
|
private |
Definition at line 694 of file tree_view_node.cpp.
Referenced by tree_view_node().
|
inline |
Is the node folded?
Definition at line 150 of file tree_view_node.hpp.
References unfolded_.
Referenced by add_child_impl(), calculate_best_size(), clear(), gui2::tree_view_node_implementation::find_at(), fold(), get_current_size(), get_last_visible_parent_node(), get_node_above(), get_node_below(), impl_draw_children(), place(), replace_children(), set_visible_rectangle(), signal_handler_toggle_left_click(), and unfold().
|
inline |
Is this node the root node?
When the parent tree view is created it adds one special node, the root node. This node has no parent node and some other special features so several code paths need to check whether they are the parent node.
This also returns true for a detached node returned with tree_view::remove_node.
Definition at line 131 of file tree_view_node.hpp.
References parent_node_.
Referenced by add_sibling(), describe_path(), get_indentation_level(), get_node_above(), get_node_below(), parent_node(), place(), and siblings().
|
overridevirtual |
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 from gui2::widget.
Definition at line 885 of file tree_view_node.cpp.
References gui2::event::dispatcher::child, children_, grid_, gui2::widget::layout_initialize(), and gui2::grid::layout_initialize().
|
inline |
Definition at line 37 of file tree_view_node.hpp.
tree_view_node & gui2::tree_view_node::parent_node | ( | ) |
Returns the parent node.
Definition at line 272 of file tree_view_node.cpp.
References is_root_node(), and parent_node_.
Referenced by add_sibling(), get_indentation_level(), and siblings().
const tree_view_node & gui2::tree_view_node::parent_node | ( | ) | const |
The const version of parent_node.
Definition at line 278 of file tree_view_node.cpp.
References is_root_node(), and parent_node_.
|
overrideprivatevirtual |
See widget::place.
Reimplemented from gui2::widget.
Definition at line 576 of file tree_view_node.cpp.
References get_tree_view(), gui2::tree_view::layout_children(), gui2::widget::place(), and utf8::size().
Referenced by gui2::tree_view::layout_children(), and set_origin().
|
private |
Definition at line 584 of file tree_view_node.cpp.
References children_, DBG_GUI_L, gui2::widget::get_best_size(), grid_, is_folded(), is_root_node(), gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, gui2::grid::place(), draw::point(), and gui2::widget::set_size().
std::vector< std::shared_ptr< gui2::tree_view_node > > gui2::tree_view_node::replace_children | ( | const std::string & | id, |
const std::vector< widget_data > & | data | ||
) |
Replaces all children of this tree with new children.
The motivation here is to provide a way to add multiple children without calculating the trees size for each child added. This is a waste of time since the results of that resizing will be immediately thrown out except for the final child added.
id | The id of the node definition to use for the new nodes. |
data | A vector of the data to provide to the tree_node_view's constructor. |
Definition at line 185 of file tree_view_node.cpp.
References children_, clear(), gui2::scrollbar_container::content_grid(), d, data, gui2::widget::get_best_size(), get_indentation_level(), gui2::widget::get_size(), get_tree_view(), gui2::tree_view::indentation_step_size_, is_folded(), gui2::scrollbar_container::layout_initialize(), gui2::widget::layout_size(), nodes, draw::point(), gui2::tree_view::resize_content(), and tree_view_.
|
overrideprivatevirtual |
See widget::request_reduce_width.
Implements gui2::widget.
Definition at line 284 of file tree_view_node.cpp.
void gui2::tree_view_node::select_node | ( | bool | expand_parents = false | ) |
Definition at line 861 of file tree_view_node.cpp.
References gui2::event::dispatcher::fire(), gui2::tree_view::get_root_node(), get_tree_view(), gui2::selectable_item::get_value_bool(), gui2::styled_widget::label_, label_, gui2::event::NOTIFY_MODIFIED, parent_node_, gui2::tree_view::selected_item_, gui2::selectable_item::set_value(), gui2::selectable_item::set_value_bool(), and unfold().
Referenced by gui2::dialogs::help_browser::pre_show().
|
overrideprivatevirtual |
See widget::set_origin.
Reimplemented from gui2::widget.
Definition at line 567 of file tree_view_node.cpp.
References gui2::widget::get_size(), get_tree_view(), place(), and gui2::widget::set_origin().
|
overrideprivatevirtual |
See widget::set_visible_rectangle.
Reimplemented from gui2::widget.
Definition at line 620 of file tree_view_node.cpp.
References children_, DBG_GUI_L, grid_, is_folded(), gui2::log_gui_layout, LOG_HEADER, log_scope2, LOG_SCOPE_HEADER, and gui2::grid::set_visible_rectangle().
Referenced by gui2::tree_view::layout_children().
|
inline |
Definition at line 179 of file tree_view_node.hpp.
References children(), is_root_node(), and parent_node().
|
private |
Definition at line 670 of file tree_view_node.cpp.
References DBG_GUI_E, gui2::event::dispatcher::fire(), get_tree_view(), gui2::selectable_item::get_value(), gui2::styled_widget::label_, label_, LOG_HEADER, gui2::event::NOTIFY_MODIFIED, gui2::tree_view::selected_item_, and gui2::selectable_item::set_value().
Referenced by tree_view_node().
|
private |
The code works but feels rather hacky, so better move back to the drawingboard for 1.9.
Definition at line 649 of file tree_view_node.cpp.
References DBG_GUI_E, gui2::event::dispatcher::fire(), fold_internal(), get_tree_view(), gui2::selectable_item::get_value_bool(), is_folded(), LOG_HEADER, gui2::event::NOTIFY_MODIFIED, toggle_, unfold_internal(), and unfolded_.
Referenced by tree_view_node().
void gui2::tree_view_node::unfold | ( | const bool | recursive = false | ) |
Definition at line 305 of file tree_view_node.cpp.
References children_, is_folded(), gui2::selectable_item::set_value(), toggle_, and unfold_internal().
Referenced by select_node(), and gui2::lobby_player_list_helper::sub_list::sub_list().
|
private |
Important! Set this first. See comment in fold_internal
Definition at line 349 of file tree_view_node.cpp.
References calculate_ypos(), get_current_size(), get_folded_size(), get_tree_view(), get_unfolded_size(), gui2::tree_view::resize_content(), and unfolded_.
Referenced by signal_handler_toggle_left_click(), and unfold().
|
friend |
Definition at line 32 of file tree_view_node.hpp.
|
friend |
Definition at line 31 of file tree_view_node.hpp.
|
private |
Our children.
We want the returned child nodes to remain stable so store pointers.
Definition at line 277 of file tree_view_node.hpp.
Referenced by add_child_impl(), calculate_best_size(), calculate_ypos(), children(), clear(), clear_before_destruct(), count_children(), create_walker(), describe_path(), empty(), find(), gui2::tree_view_node_implementation::find_at(), fold(), get_child_at(), get_current_size(), get_node_above(), get_unfolded_size(), impl_draw_children(), layout_initialize(), place(), gui2::tree_view::remove_node(), replace_children(), set_visible_rectangle(), and unfold().
|
private |
Grid holding our contents.
Definition at line 270 of file tree_view_node.hpp.
Referenced by calculate_best_size(), find(), gui2::tree_view_node_implementation::find_at(), get_folded_size(), get_grid(), get_unfolded_size(), impl_draw_children(), layout_initialize(), place(), set_visible_rectangle(), and tree_view_node().
|
private |
The label to show our selected state.
Definition at line 283 of file tree_view_node.hpp.
Referenced by get_selectable_node_above(), get_selectable_node_below(), select_node(), signal_handler_label_left_button_click(), and tree_view_node().
|
private |
Our parent node.
All nodes except the root node have a parent node.
Definition at line 264 of file tree_view_node.hpp.
Referenced by add_child(), add_child_impl(), calculate_ypos(), describe_path(), get_current_size(), get_last_visible_parent_node(), get_node_above(), get_node_below(), is_root_node(), parent_node(), gui2::tree_view::remove_node(), select_node(), and tree_view_node().
|
private |
The toggle for the folded state.
Definition at line 280 of file tree_view_node.hpp.
Referenced by fold(), signal_handler_toggle_left_click(), tree_view_node(), and unfold().
|
private |
The tree view that owns us.
Definition at line 267 of file tree_view_node.hpp.
Referenced by add_child_impl(), clear_before_destruct(), get_tree_view(), replace_children(), and ~tree_view_node().
|
private |
Definition at line 285 of file tree_view_node.hpp.
Referenced by fold_internal(), is_folded(), signal_handler_toggle_left_click(), tree_view_node(), and unfold_internal().