The Battle for Wesnoth  1.19.7+dev
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
gui2::tree_view_node Class Reference

#include <tree_view_node.hpp>

Inheritance diagram for gui2::tree_view_node:

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_nodeadd_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_nodeadd_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_nodeadd_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_vectorchildren ()
 
node_children_vectorsiblings ()
 
virtual widgetfind_at (const point &coordinate, const bool must_be_active) override
 See widget::find_at. More...
 
virtual const widgetfind_at (const point &coordinate, const bool must_be_active) const override
 See widget::find_at. More...
 
widgetfind (const std::string_view id, const bool must_be_active) override
 See widget::find. More...
 
const widgetfind (const std::string_view 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_nodeparent_node ()
 Returns the parent node. More...
 
const tree_view_nodeparent_node () const
 The const version of parent_node. More...
 
tree_viewget_tree_view ()
 
const tree_viewget_tree_view () const
 
tree_view_nodeget_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_nodeget_last_visible_parent_node ()
 
tree_view_nodeget_node_above ()
 
tree_view_nodeget_node_below ()
 
tree_view_nodeget_selectable_node_above ()
 
tree_view_nodeget_selectable_node_below ()
 
void select_node (bool expand_parents=false)
 
gridget_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
 
widgetoperator= (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
 
windowget_window ()
 Get the parent window. More...
 
const windowget_window () const
 The constant version of get_window. More...
 
gridget_parent_grid ()
 Get the parent grid. More...
 
const gridget_parent_grid () const
 
void set_parent (widget *parent)
 
widgetparent ()
 
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)
 
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 &region)
 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 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
 
- 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_executorset_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 &center, 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_nodeadd_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_nodeparent_node_
 Our parent node. More...
 
tree_viewtree_view_
 The tree view that owns us. More...
 
grid grid_
 Grid holding our contents. More...
 
node_children_vector children_
 Our children. More...
 
selectable_itemtoggle_
 The toggle for the folded state. More...
 
selectable_itemlabel_
 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 pointlayout_size () const
 
void clear_layout_size ()
 Throws away layout_size_. More...
 

Detailed Description

Definition at line 29 of file tree_view_node.hpp.

Member Typedef Documentation

◆ node_children_vector

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.

Constructor & Destructor Documentation

◆ tree_view_node()

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 
)

◆ ~tree_view_node()

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_.

Member Function Documentation

◆ add_child() [1/2]

tree_view_node& gui2::tree_view_node::add_child ( const std::string &  id,
const widget_data data,
const int  index = -1 
)
inline

Constructs a new child node.

Parameters
idThe id of the node definition to use for the new node.
dataThe 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.
indexThe 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().

◆ add_child() [2/2]

tree_view_node& gui2::tree_view_node::add_child ( std::shared_ptr< tree_view_node new_node,
const int  index = -1 
)
inline

Adds a previously-constructed node as a child of this node at the given position.

Parameters
new_nodeA smart pointer to the node object to insert.
indexThe 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_.

◆ add_child_impl()

tree_view_node & gui2::tree_view_node::add_child_impl ( std::shared_ptr< tree_view_node > &&  new_node,
const int  index 
)
private

◆ add_sibling()

tree_view_node& gui2::tree_view_node::add_sibling ( const std::string &  id,
const widget_data data 
)
inline

Adds a sibling for a node at the end of the list.

Parameters
idThe id of the node definition to use for the new node.
dataThe 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().

◆ calculate_best_size() [1/2]

point gui2::tree_view_node::calculate_best_size ( ) const
overrideprivatevirtual

See widget::calculate_best_size.

Implements gui2::widget.

Definition at line 471 of file tree_view_node.cpp.

References get_tree_view().

◆ calculate_best_size() [2/2]

point gui2::tree_view_node::calculate_best_size ( const int  indentation_level,
const unsigned  indentation_step_size 
) const
private

◆ calculate_ypos()

int gui2::tree_view_node::calculate_ypos ( )
private

◆ children()

node_children_vector& gui2::tree_view_node::children ( )
inline

Definition at line 174 of file tree_view_node.hpp.

References children_.

Referenced by siblings().

◆ clear()

void gui2::tree_view_node::clear ( )

Removes all child items from the widget.

Todo:
Also try to find the optimal width.

Definition at line 363 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().

◆ clear_before_destruct()

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().

◆ count_children()

std::size_t gui2::tree_view_node::count_children ( ) const
inline

◆ create_walker()

iteration::walker_ptr gui2::tree_view_node::create_walker ( )
overridevirtual

See widget::create_walker.

Todo:
Implement properly.

Implements gui2::widget.

Definition at line 896 of file tree_view_node.cpp.

References children_.

◆ describe_path()

std::vector< int > gui2::tree_view_node::describe_path ( ) const

◆ disable_click_dismiss()

bool gui2::tree_view_node::disable_click_dismiss ( ) const
overrideprivatevirtual

See widget::disable_click_dismiss.

Implements gui2::widget.

Definition at line 476 of file tree_view_node.cpp.

◆ empty()

bool gui2::tree_view_node::empty ( ) const
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().

◆ find() [1/2]

const widget * gui2::tree_view_node::find ( const std::string_view  id,
const bool  must_be_active 
) const
overridevirtual

◆ find() [2/2]

widget * gui2::tree_view_node::find ( const std::string_view  id,
const bool  must_be_active 
)
overridevirtual

◆ find_at() [1/2]

const widget * gui2::tree_view_node::find_at ( const point coordinate,
const bool  must_be_active 
) const
overridevirtual

See widget::find_at.

Reimplemented from gui2::widget.

Definition at line 422 of file tree_view_node.cpp.

◆ find_at() [2/2]

widget * gui2::tree_view_node::find_at ( const point coordinate,
const bool  must_be_active 
)
overridevirtual

See widget::find_at.

Reimplemented from gui2::widget.

Definition at line 417 of file tree_view_node.cpp.

◆ fold()

void gui2::tree_view_node::fold ( const bool  recursive = false)

◆ fold_internal()

void gui2::tree_view_node::fold_internal ( )
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.

  • vultraz, 2024-08-12

Definition at line 320 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().

◆ get_child_at()

tree_view_node & gui2::tree_view_node::get_child_at ( int  index)

Definition at line 732 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().

◆ get_control_type()

const std::string & gui2::tree_view_node::get_control_type ( ) const
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 726 of file tree_view_node.cpp.

◆ get_current_size()

point gui2::tree_view_node::get_current_size ( bool  assume_visible = false) const
private
Parameters
assume_visibleif false (default) it will return 0 if the parent node is folded

Definition at line 481 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().

◆ get_folded_size()

point gui2::tree_view_node::get_folded_size ( ) const
private

◆ get_grid()

grid& gui2::tree_view_node::get_grid ( )
inline

◆ get_indentation_level()

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 258 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().

◆ get_last_visible_parent_node()

tree_view_node * gui2::tree_view_node::get_last_visible_parent_node ( )

◆ get_node_above()

tree_view_node * gui2::tree_view_node::get_node_above ( )

◆ get_node_below()

tree_view_node * gui2::tree_view_node::get_node_below ( )

◆ get_selectable_node_above()

tree_view_node * gui2::tree_view_node::get_selectable_node_above ( )

Definition at line 840 of file tree_view_node.cpp.

References get_node_above(), and label_.

◆ get_selectable_node_below()

tree_view_node * gui2::tree_view_node::get_selectable_node_below ( )

Definition at line 850 of file tree_view_node.cpp.

References get_node_below(), and label_.

◆ get_tree_view() [1/2]

tree_view& gui2::tree_view_node::get_tree_view ( )
inline

◆ get_tree_view() [2/2]

const tree_view& gui2::tree_view_node::get_tree_view ( ) const
inline

Definition at line 229 of file tree_view_node.hpp.

References tree_view_.

◆ get_unfolded_size()

point gui2::tree_view_node::get_unfolded_size ( ) const
private

◆ impl_draw_children()

void gui2::tree_view_node::impl_draw_children ( )
overrideprivatevirtual

See widget::impl_draw_children.

Reimplemented from gui2::widget.

Definition at line 635 of file tree_view_node.cpp.

References children_, gui2::widget::draw_children(), grid_, and is_folded().

◆ init_grid()

void gui2::tree_view_node::init_grid ( grid grid,
const widget_data data 
)
private

Definition at line 693 of file tree_view_node.cpp.

References data, and g.

Referenced by tree_view_node().

◆ is_folded()

bool gui2::tree_view_node::is_folded ( ) const
inline

◆ is_root_node()

bool gui2::tree_view_node::is_root_node ( ) const
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().

◆ layout_initialize()

void gui2::tree_view_node::layout_initialize ( const bool  full_initialization)
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.

Parameters
full_initializationFor 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 884 of file tree_view_node.cpp.

References gui2::event::dispatcher::child, children_, grid_, gui2::widget::layout_initialize(), and gui2::grid::layout_initialize().

◆ operator==()

bool gui2::tree_view_node::operator== ( const tree_view_node node)
inline

Definition at line 37 of file tree_view_node.hpp.

◆ parent_node() [1/2]

tree_view_node & gui2::tree_view_node::parent_node ( )

Returns the parent node.

Precondition
is_root_node() == false.

Definition at line 271 of file tree_view_node.cpp.

References is_root_node(), and parent_node_.

Referenced by add_sibling(), get_indentation_level(), and siblings().

◆ parent_node() [2/2]

const tree_view_node & gui2::tree_view_node::parent_node ( ) const

The const version of parent_node.

Definition at line 277 of file tree_view_node.cpp.

References is_root_node(), and parent_node_.

◆ place() [1/2]

void gui2::tree_view_node::place ( const point origin,
const point size 
)
overrideprivatevirtual

◆ place() [2/2]

unsigned gui2::tree_view_node::place ( const unsigned  indentation_step_size,
point  origin,
unsigned  width 
)
private

◆ replace_children()

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.

Parameters
idThe id of the node definition to use for the new nodes.
dataA vector of the data to provide to the tree_node_view's constructor.
Returns
A vector of pointers to the newly created nodes.

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_.

◆ request_reduce_width()

void gui2::tree_view_node::request_reduce_width ( const unsigned  maximum_width)
overrideprivatevirtual

See widget::request_reduce_width.

Implements gui2::widget.

Definition at line 283 of file tree_view_node.cpp.

◆ select_node()

void gui2::tree_view_node::select_node ( bool  expand_parents = false)

◆ set_origin()

void gui2::tree_view_node::set_origin ( const point origin)
overrideprivatevirtual

◆ set_visible_rectangle()

void gui2::tree_view_node::set_visible_rectangle ( const SDL_Rect &  rectangle)
overrideprivatevirtual

◆ siblings()

node_children_vector& gui2::tree_view_node::siblings ( )
inline

Definition at line 179 of file tree_view_node.hpp.

References children(), is_root_node(), and parent_node().

◆ signal_handler_label_left_button_click()

void gui2::tree_view_node::signal_handler_label_left_button_click ( const event::ui_event  event,
bool &  handled,
bool &  halt 
)
private

◆ signal_handler_toggle_left_click()

void gui2::tree_view_node::signal_handler_toggle_left_click ( const event::ui_event  event)
private
Todo:
Rewrite this sizing code for the folding/unfolding.

The code works but feels rather hacky, so better move back to the drawingboard for 1.9.

Definition at line 648 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().

◆ unfold()

void gui2::tree_view_node::unfold ( const bool  recursive = false)

◆ unfold_internal()

void gui2::tree_view_node::unfold_internal ( )
private

Friends And Related Function Documentation

◆ tree_view

friend class tree_view
friend

Definition at line 32 of file tree_view_node.hpp.

◆ tree_view_node_implementation

friend struct tree_view_node_implementation
friend

Definition at line 31 of file tree_view_node.hpp.

Member Data Documentation

◆ children_

node_children_vector gui2::tree_view_node::children_
private

◆ grid_

grid gui2::tree_view_node::grid_
private

◆ label_

selectable_item* gui2::tree_view_node::label_
private

The label to show our selected state.

Definition at line 282 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().

◆ parent_node_

tree_view_node* gui2::tree_view_node::parent_node_
private

◆ toggle_

selectable_item* gui2::tree_view_node::toggle_
private

The toggle for the folded state.

Definition at line 279 of file tree_view_node.hpp.

Referenced by fold(), signal_handler_toggle_left_click(), tree_view_node(), and unfold().

◆ tree_view_

tree_view* gui2::tree_view_node::tree_view_
private

The tree view that owns us.

Definition at line 266 of file tree_view_node.hpp.

Referenced by add_child_impl(), clear_before_destruct(), get_tree_view(), replace_children(), and ~tree_view_node().

◆ unfolded_

bool gui2::tree_view_node::unfolded_
private

The documentation for this class was generated from the following files: