Make the lobby tree view look like the listbox.
This commit is contained in:
parent
15be552cb1
commit
6a1dd909e1
3 changed files with 49 additions and 13 deletions
|
@ -354,7 +354,7 @@
|
|||
horizontal_scrollbar_mode = "never"
|
||||
vertical_scrollbar_mode = "always"
|
||||
|
||||
indention_step_size = "40"
|
||||
indention_step_size = "0"
|
||||
|
||||
[node]
|
||||
id = "player_group"
|
||||
|
@ -377,6 +377,7 @@
|
|||
|
||||
[label]
|
||||
id = "tree_view_node_label"
|
||||
definition = "default_tiny"
|
||||
label = "group"
|
||||
[/label]
|
||||
|
||||
|
|
|
@ -92,8 +92,16 @@ void tsub_player_list::init(gui2::twindow &w, const std::string &id)
|
|||
tree_group_item["tree_view_node_label"] = tree_group_field;
|
||||
tree = &parent_tree.add_node("player_group", tree_group_item);
|
||||
|
||||
tree_label = find_widget<tlabel>(tree
|
||||
, "tree_view_node_label"
|
||||
, false
|
||||
, true);
|
||||
|
||||
tree_label->set_label(label->label());
|
||||
|
||||
} else {
|
||||
tree = NULL;
|
||||
tree_label = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,19 +118,45 @@ void tsub_player_list::show_toggle_callback(gui2::twidget* /*widget*/)
|
|||
|
||||
void tsub_player_list::auto_hide()
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "(" << list->get_item_count() << ")";
|
||||
count->set_label(ss.str());
|
||||
if (list->get_item_count() == 0) {
|
||||
list->set_visible(twidget::INVISIBLE);
|
||||
show_toggle->set_visible(twidget::INVISIBLE);
|
||||
label->set_visible(twidget::INVISIBLE);
|
||||
count->set_visible(twidget::INVISIBLE);
|
||||
if(gui2::new_widgets) {
|
||||
assert(tree);
|
||||
assert(tree_label);
|
||||
if(tree->empty()) {
|
||||
/**
|
||||
* @todo Make sure setting visible resizes the widget.
|
||||
*
|
||||
* It doesn't work here since invalidate_layout is blocked, but the
|
||||
* widget should also be able to handle it itself. Once done the
|
||||
* setting of the label text can also be removed.
|
||||
*/
|
||||
assert(label);
|
||||
tree_label->set_label(label->label() + " (0)");
|
||||
// tree_label->set_visible(twidget::INVISIBLE);
|
||||
} else {
|
||||
assert(label);
|
||||
std::stringstream ss;
|
||||
ss << label->label() << " (" << tree->size() << ")";
|
||||
tree_label->set_label(ss.str());
|
||||
// tree_label->set_visible(twidget::VISIBLE);
|
||||
}
|
||||
} else {
|
||||
list->set_visible(show_toggle->get_value() ? twidget::INVISIBLE : twidget::VISIBLE);
|
||||
show_toggle->set_visible(twidget::VISIBLE);
|
||||
label->set_visible(twidget::VISIBLE);
|
||||
count->set_visible(twidget::VISIBLE);
|
||||
std::stringstream ss;
|
||||
ss << "(" << list->get_item_count() << ")";
|
||||
count->set_label(ss.str());
|
||||
if (list->get_item_count() == 0) {
|
||||
list->set_visible(twidget::INVISIBLE);
|
||||
show_toggle->set_visible(twidget::INVISIBLE);
|
||||
label->set_visible(twidget::INVISIBLE);
|
||||
count->set_visible(twidget::INVISIBLE);
|
||||
} else {
|
||||
list->set_visible(show_toggle->get_value()
|
||||
? twidget::INVISIBLE
|
||||
: twidget::VISIBLE);
|
||||
show_toggle->set_visible(twidget::VISIBLE);
|
||||
label->set_visible(twidget::VISIBLE);
|
||||
count->set_visible(twidget::VISIBLE);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ struct tsub_player_list
|
|||
ttoggle_button* show_toggle;
|
||||
tlistbox* list;
|
||||
ttree_view::tnode* tree;
|
||||
tlabel* tree_label;
|
||||
};
|
||||
|
||||
struct tplayer_list
|
||||
|
|
Loading…
Add table
Reference in a new issue