mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-18 16:35:40 +00:00
Make the lobby tree view look like the listbox.
This commit is contained in:
parent
15be552cb1
commit
6a1dd909e1
@ -354,7 +354,7 @@
|
|||||||
horizontal_scrollbar_mode = "never"
|
horizontal_scrollbar_mode = "never"
|
||||||
vertical_scrollbar_mode = "always"
|
vertical_scrollbar_mode = "always"
|
||||||
|
|
||||||
indention_step_size = "40"
|
indention_step_size = "0"
|
||||||
|
|
||||||
[node]
|
[node]
|
||||||
id = "player_group"
|
id = "player_group"
|
||||||
@ -377,6 +377,7 @@
|
|||||||
|
|
||||||
[label]
|
[label]
|
||||||
id = "tree_view_node_label"
|
id = "tree_view_node_label"
|
||||||
|
definition = "default_tiny"
|
||||||
label = "group"
|
label = "group"
|
||||||
[/label]
|
[/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_group_item["tree_view_node_label"] = tree_group_field;
|
||||||
tree = &parent_tree.add_node("player_group", tree_group_item);
|
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 {
|
} else {
|
||||||
tree = NULL;
|
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()
|
void tsub_player_list::auto_hide()
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
if(gui2::new_widgets) {
|
||||||
ss << "(" << list->get_item_count() << ")";
|
assert(tree);
|
||||||
count->set_label(ss.str());
|
assert(tree_label);
|
||||||
if (list->get_item_count() == 0) {
|
if(tree->empty()) {
|
||||||
list->set_visible(twidget::INVISIBLE);
|
/**
|
||||||
show_toggle->set_visible(twidget::INVISIBLE);
|
* @todo Make sure setting visible resizes the widget.
|
||||||
label->set_visible(twidget::INVISIBLE);
|
*
|
||||||
count->set_visible(twidget::INVISIBLE);
|
* 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 {
|
} else {
|
||||||
list->set_visible(show_toggle->get_value() ? twidget::INVISIBLE : twidget::VISIBLE);
|
std::stringstream ss;
|
||||||
show_toggle->set_visible(twidget::VISIBLE);
|
ss << "(" << list->get_item_count() << ")";
|
||||||
label->set_visible(twidget::VISIBLE);
|
count->set_label(ss.str());
|
||||||
count->set_visible(twidget::VISIBLE);
|
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;
|
ttoggle_button* show_toggle;
|
||||||
tlistbox* list;
|
tlistbox* list;
|
||||||
ttree_view::tnode* tree;
|
ttree_view::tnode* tree;
|
||||||
|
tlabel* tree_label;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct tplayer_list
|
struct tplayer_list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user