Use listboxs sorting feature in experinemtal gui2 addon_list
Also fixes the toggle panels that show the addons description and the filter textbox in the non new-widgets codepath. These changes mostly effect the non new-wigets codepath. The new-widgets codepath (which already had a sorting feature) still works like before except that it was adjusted to the changes to the cfg file.
This commit is contained in:
parent
32342a5fc4
commit
de1eaa30f7
3 changed files with 341 additions and 236 deletions
|
@ -44,6 +44,16 @@
|
|||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[linked_group]
|
||||
id = "toggle"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[linked_group]
|
||||
id = "list_item"
|
||||
fixed_width = "true"
|
||||
[/linked_group]
|
||||
|
||||
[tooltip]
|
||||
id = "tooltip_large"
|
||||
[/tooltip]
|
||||
|
@ -141,6 +151,144 @@
|
|||
[/column]
|
||||
|
||||
[/row]
|
||||
###
|
||||
### The header using listbox own [header] doesn't work becsue of http://gna.org/bugs/?23752
|
||||
###
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
[column]
|
||||
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
[column]
|
||||
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
[grid]
|
||||
## linked_group = "list_item"
|
||||
[row]
|
||||
[column]
|
||||
|
||||
grow_factor = 0
|
||||
border = "all"
|
||||
border_size = 5
|
||||
[spacer]
|
||||
linked_group = "icon"
|
||||
[/spacer]
|
||||
[/column]
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_name"
|
||||
definition = "listbox_header"
|
||||
linked_group = "name"
|
||||
|
||||
label = _ "Name"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
linked_group = "version"
|
||||
label = _ "Version"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_author"
|
||||
definition = "listbox_header"
|
||||
linked_group = "author"
|
||||
|
||||
label = _ "Author"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_downloads"
|
||||
definition = "listbox_header"
|
||||
linked_group = "downloads"
|
||||
|
||||
label = _ "Downloads"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[toggle_button]
|
||||
id = "sort_size"
|
||||
definition = "listbox_header"
|
||||
linked_group = "size"
|
||||
|
||||
label = _ "Size"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
[spacer]
|
||||
linked_group = "toggle"
|
||||
[/spacer]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[column]
|
||||
grow_factor = 0
|
||||
## For the scrollbar
|
||||
[spacer]
|
||||
width=25
|
||||
[/spacer]
|
||||
[/column]
|
||||
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
@ -154,115 +302,10 @@
|
|||
[listbox]
|
||||
id = "addons"
|
||||
definition = "default"
|
||||
[header]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "icon"
|
||||
definition = "default"
|
||||
linked_group = "icon"
|
||||
|
||||
label = ""
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "name"
|
||||
definition = "default"
|
||||
linked_group = "name"
|
||||
|
||||
label = "Name"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "version"
|
||||
definition = "default"
|
||||
linked_group = "version"
|
||||
|
||||
label = "Version"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "author"
|
||||
definition = "default"
|
||||
linked_group = "author"
|
||||
|
||||
label = "Author"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "downloads"
|
||||
definition = "default"
|
||||
linked_group = "downloads"
|
||||
|
||||
label = "Downloads"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
||||
[label]
|
||||
id = "size"
|
||||
definition = "default"
|
||||
linked_group = "size"
|
||||
|
||||
label = "Size"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/header]
|
||||
###
|
||||
### We need the scrollbar becase otherwise the size of the header wouldnt match the size of the content.
|
||||
###
|
||||
vertical_scrollbar_mode = "always"
|
||||
|
||||
[list_definition]
|
||||
|
||||
|
@ -273,6 +316,7 @@
|
|||
horizontal_grow = "true"
|
||||
|
||||
[toggle_panel]
|
||||
## linked_group = "list_item"
|
||||
definition = "default"
|
||||
|
||||
return_value_id = "ok"
|
||||
|
@ -289,8 +333,8 @@
|
|||
[row]
|
||||
|
||||
[column]
|
||||
grow_factor = 1
|
||||
horizontal_grow = "true"
|
||||
## grow_factor = 1
|
||||
horizontal_grow = "false"
|
||||
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
@ -303,6 +347,9 @@
|
|||
width = 72
|
||||
height = 72
|
||||
|
||||
debug_border_mode = 1
|
||||
debug_border_color = "255,128,128,128"
|
||||
|
||||
[draw]
|
||||
|
||||
[image]
|
||||
|
@ -401,19 +448,18 @@
|
|||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
horizontal_alignment = "right"
|
||||
vertical_alignment = "bottom"
|
||||
[toggle_button]
|
||||
linked_group = "toggle"
|
||||
id = "expand"
|
||||
definition = "default"
|
||||
definition = "tree_view_node"
|
||||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
@ -429,7 +475,7 @@
|
|||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
id = "description_grid"
|
||||
[row]
|
||||
|
||||
[column]
|
||||
|
@ -449,6 +495,7 @@
|
|||
|
||||
[/column]
|
||||
|
||||
#ifdef __unused__
|
||||
[column]
|
||||
grow_factor = 0
|
||||
|
||||
|
@ -460,6 +507,7 @@
|
|||
[/toggle_button]
|
||||
|
||||
[/column]
|
||||
#endif
|
||||
|
||||
[/row]
|
||||
|
||||
|
@ -496,62 +544,6 @@
|
|||
[row]
|
||||
grow_factor = 0
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "sort_name_ascending"
|
||||
definition = "default"
|
||||
|
||||
label = "Sort name ascending"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "sort_name_descending"
|
||||
definition = "default"
|
||||
|
||||
label = "Sort name descending"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "sort_size_ascending"
|
||||
definition = "default"
|
||||
|
||||
label = "Sort size ascending"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "sort_size_descending"
|
||||
definition = "default"
|
||||
|
||||
label = "Sort size descending"
|
||||
[/button]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "gui/widgets/pane.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/toggle_button.hpp"
|
||||
#include "gui/widgets/text_box.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "utils/foreach.tpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
@ -72,28 +73,153 @@ namespace gui2
|
|||
|
||||
REGISTER_DIALOG(addon_list)
|
||||
|
||||
void taddon_list::collapse(tgrid& grid)
|
||||
struct filter_transform
|
||||
{
|
||||
find_widget<ttoggle_button>(&grid, "expand", false)
|
||||
.set_visible(twidget::tvisible::visible);
|
||||
filter_transform(const std::vector<std::string>& filtertext) : filtertext_(filtertext) {}
|
||||
bool operator()(const config& cfg) const
|
||||
{
|
||||
FOREACH(const AUTO& filter, filtertext_)
|
||||
{
|
||||
bool found = false;
|
||||
FOREACH(const AUTO& attribute, cfg.attribute_range())
|
||||
{
|
||||
std::string val = attribute.second.str();
|
||||
if(std::search(val.begin(),
|
||||
val.end(),
|
||||
filter.begin(),
|
||||
filter.end(),
|
||||
chars_equal_insensitive)
|
||||
!= val.end())
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const std::vector<std::string> filtertext_;
|
||||
};
|
||||
|
||||
find_widget<ttoggle_button>(&grid, "collapse", false)
|
||||
.set_visible(twidget::tvisible::invisible);
|
||||
|
||||
find_widget<tlabel>(&grid, "description", false)
|
||||
.set_visible(twidget::tvisible::invisible);
|
||||
void taddon_list::on_filtertext_changed(ttext_* textbox, const std::string& text)
|
||||
{
|
||||
tlistbox& listbox = find_widget<tlistbox>(textbox->get_window(), "addons", true);
|
||||
filter_transform filter(utils::split(text, ' '));
|
||||
std::vector<bool> res;
|
||||
res.reserve(cfg_.child_count("campaign"));
|
||||
FOREACH(const AUTO& child, cfg_.child_range("campaign"))
|
||||
{
|
||||
res.push_back(filter(child));
|
||||
}
|
||||
listbox.set_row_shown(res);
|
||||
}
|
||||
|
||||
void taddon_list::expand(tgrid& grid)
|
||||
void taddon_list::on_order_button_click(twindow& window, const tgenerator_::torder_func& up, const tgenerator_::torder_func& down, twidget& w)
|
||||
{
|
||||
find_widget<ttoggle_button>(&grid, "expand", false)
|
||||
.set_visible(twidget::tvisible::hidden);
|
||||
tselectable_& selectable = dynamic_cast<tselectable_&>(w);
|
||||
FOREACH(AUTO& other, orders_)
|
||||
{
|
||||
if(other != &selectable) {
|
||||
other->set_value(0);
|
||||
}
|
||||
}
|
||||
tlistbox& listbox = find_widget<tlistbox>(&window, "addons", true);
|
||||
switch(selectable.get_value())
|
||||
{
|
||||
case 0:
|
||||
listbox.order_by(std::less<unsigned>());
|
||||
break;
|
||||
case 1:
|
||||
listbox.order_by(up);
|
||||
break;
|
||||
case 2:
|
||||
listbox.order_by(down);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
find_widget<ttoggle_button>(&grid, "collapse", false)
|
||||
.set_visible(twidget::tvisible::visible);
|
||||
void taddon_list::register_sort_button(twindow& window, const std::string& id, const tgenerator_::torder_func& up, const tgenerator_::torder_func& down)
|
||||
{
|
||||
tselectable_& selectable = find_widget<tselectable_>(&window, id, true);
|
||||
orders_.push_back(&selectable);
|
||||
selectable.set_callback_state_change(boost::bind(&taddon_list::on_order_button_click, this, boost::ref(window), up, down, _1));
|
||||
}
|
||||
namespace {
|
||||
/// TODO: it would be better if we didnt have to parse the config every time.
|
||||
bool str_up(const config* cfg, const std::string& prop_id, unsigned i1, unsigned i2)
|
||||
{
|
||||
return cfg->child("campaign", i1)[prop_id].str() < cfg->child("campaign", i2)[prop_id].str();
|
||||
}
|
||||
bool str_down(const config* cfg, const std::string& prop_id, unsigned i1, unsigned i2)
|
||||
{
|
||||
return cfg->child("campaign", i1)[prop_id].str() > cfg->child("campaign", i2)[prop_id].str();
|
||||
}
|
||||
bool num_up(const config* cfg, const std::string& prop_id, unsigned i1, unsigned i2)
|
||||
{
|
||||
return cfg->child("campaign", i1)[prop_id].to_int() < cfg->child("campaign", i2)[prop_id].to_int();
|
||||
}
|
||||
bool num_down(const config* cfg, const std::string& prop_id, unsigned i1, unsigned i2)
|
||||
{
|
||||
return cfg->child("campaign", i1)[prop_id].to_int() > cfg->child("campaign", i2)[prop_id].to_int();
|
||||
}
|
||||
|
||||
find_widget<tlabel>(&grid, "description", false)
|
||||
void show_desc_impl(unsigned index, tlistbox& list, tgrid &lower_grid,twidget& w)
|
||||
{
|
||||
// showing teh description ona seperate multipage woudo be better specially on large screens.
|
||||
tselectable_& selectable = dynamic_cast<tselectable_ &>(w);
|
||||
list.select_row(index);
|
||||
lower_grid.set_visible(!selectable.get_value_bool() ? twidget::tvisible::invisible : twidget::tvisible::visible);
|
||||
}
|
||||
|
||||
}
|
||||
void taddon_list::register_sort_button_alphabetical(twindow& window, const std::string& id, const std::string& prop_id)
|
||||
{
|
||||
register_sort_button(window, id, boost::bind(&str_up, &cfg_, prop_id, _1, _2), boost::bind(&str_down, &cfg_, prop_id, _1, _2));
|
||||
}
|
||||
|
||||
void taddon_list::register_sort_button_numeric(twindow& window, const std::string& id, const std::string& prop_id)
|
||||
{
|
||||
|
||||
register_sort_button(window, id, boost::bind(&num_up, &cfg_, prop_id, _1, _2), boost::bind(&num_down, &cfg_, prop_id, _1, _2));
|
||||
}
|
||||
|
||||
|
||||
void taddon_list::expand(tgrid& grid, twidget& w)
|
||||
{
|
||||
tselectable_& selectable = dynamic_cast<tselectable_&>(w);
|
||||
if(selectable.get_value_bool())
|
||||
{
|
||||
find_widget<tlabel>(&grid, "description", false)
|
||||
.set_visible(twidget::tvisible::visible);
|
||||
}
|
||||
else
|
||||
{
|
||||
find_widget<tlabel>(&grid, "description", false)
|
||||
.set_visible(twidget::tvisible::invisible);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool default_sort(const tpane::titem& i1, const tpane::titem& i2)
|
||||
{
|
||||
return i1.id < i2.id;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void sort_callback(twidget& w, tpane* pane, const std::string& name_prop)
|
||||
{
|
||||
tselectable_& selectable = dynamic_cast<tselectable_&>(w);
|
||||
if(selectable.get_value() == 0) {
|
||||
pane->sort(&default_sort);
|
||||
}
|
||||
else {
|
||||
pane->sort(boost::bind(&sort<T>, _1, _2, name_prop, (selectable.get_value() == 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void taddon_list::pre_show(CVideo& /*video*/, twindow& window)
|
||||
|
@ -104,35 +230,9 @@ void taddon_list::pre_show(CVideo& /*video*/, twindow& window)
|
|||
|
||||
tpane& pane = find_widget<tpane>(&window, "addons", false);
|
||||
|
||||
find_widget<tselectable_>(&window, "sort_name", false).set_callback_state_change(boost::bind(&sort_callback<std::string>, _1, &pane, "name"));
|
||||
find_widget<tselectable_>(&window, "sort_size", false).set_callback_state_change(boost::bind(&sort_callback<std::string>, _1, &pane, "size"));
|
||||
|
||||
tpane::tcompare_functor ascending_name_functor
|
||||
= boost::bind(&sort<std::string>, _1, _2, "name", true);
|
||||
|
||||
tpane::tcompare_functor descending_name_functor
|
||||
= boost::bind(&sort<std::string>, _1, _2, "name", false);
|
||||
|
||||
tpane::tcompare_functor ascending_size_functor
|
||||
= boost::bind(&sort<int>, _1, _2, "size", true);
|
||||
|
||||
tpane::tcompare_functor descending_size_functor
|
||||
= boost::bind(&sort<int>, _1, _2, "size", false);
|
||||
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "sort_name_ascending", false),
|
||||
boost::bind(&tpane::sort, &pane, ascending_name_functor));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "sort_name_descending", false),
|
||||
boost::bind(&tpane::sort, &pane, descending_name_functor));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "sort_size_ascending", false),
|
||||
boost::bind(&tpane::sort, &pane, ascending_size_functor));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<tbutton>(&window, "sort_size_descending", false),
|
||||
boost::bind(&tpane::sort, &pane, descending_size_functor));
|
||||
|
||||
/***** ***** Init the filter text box. ***** *****/
|
||||
|
||||
|
@ -194,8 +294,26 @@ void taddon_list::pre_show(CVideo& /*video*/, twindow& window)
|
|||
item["label"] = c["size"];
|
||||
data.insert(std::make_pair("size", item));
|
||||
|
||||
item["label"] = c["description"];
|
||||
data.insert(std::make_pair("description", item));
|
||||
|
||||
list.add_row(data);
|
||||
unsigned index = list.get_item_count() - 1;
|
||||
ttoggle_button& button = find_widget<ttoggle_button>(list.get_row_grid(list.get_item_count() - 1), "expand", true);
|
||||
tgrid& lower_grid = find_widget<tgrid>(list.get_row_grid(list.get_item_count() - 1), "description_grid", false);
|
||||
lower_grid.set_visible(twidget::tvisible::invisible);
|
||||
button.set_callback_state_change(boost::bind(show_desc_impl, index, boost::ref(list), boost::ref(lower_grid), _1));
|
||||
}
|
||||
register_sort_button_alphabetical(window, "sort_name", "name");
|
||||
register_sort_button_alphabetical(window, "sort_author", "author");
|
||||
register_sort_button_numeric(window, "sort_downloads", "downloads");
|
||||
register_sort_button_numeric(window, "sort_size", "size");
|
||||
|
||||
ttext_box& filter_box
|
||||
= find_widget<ttext_box>(&window, "filter", false);
|
||||
|
||||
filter_box.set_text_changed_callback(
|
||||
boost::bind(&taddon_list::on_filtertext_changed, this, _1, _2));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,18 +368,12 @@ void taddon_list::create_campaign(tpane& pane, const config& campaign)
|
|||
tgrid* grid = pane.grid(id);
|
||||
assert(grid);
|
||||
|
||||
ttoggle_button* collapse
|
||||
= find_widget<ttoggle_button>(grid, "collapse", false, false);
|
||||
|
||||
if(collapse) {
|
||||
collapse->set_visible(twidget::tvisible::invisible);
|
||||
collapse->set_callback_state_change(
|
||||
boost::bind(&taddon_list::collapse, this, boost::ref(*grid)));
|
||||
|
||||
find_widget<ttoggle_button>(grid, "expand", false)
|
||||
.set_callback_state_change(boost::bind(
|
||||
&taddon_list::expand, this, boost::ref(*grid)));
|
||||
ttoggle_button* expand
|
||||
= find_widget<ttoggle_button>(grid, "expand", false, false);
|
||||
|
||||
if(expand) {
|
||||
expand->set_callback_state_change(
|
||||
boost::bind(&taddon_list::expand, this, boost::ref(*grid), _1));
|
||||
find_widget<tlabel>(grid, "description", false)
|
||||
.set_visible(twidget::tvisible::invisible);
|
||||
}
|
||||
|
@ -269,7 +381,7 @@ void taddon_list::create_campaign(tpane& pane, const config& campaign)
|
|||
|
||||
void taddon_list::load(tpane& pane)
|
||||
{
|
||||
if(cfg_iterators_.first != cfg_iterators_.second) {
|
||||
while(cfg_iterators_.first != cfg_iterators_.second) {
|
||||
create_campaign(pane, *cfg_iterators_.first);
|
||||
++cfg_iterators_.first;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#define GUI_DIALOGS_ADDON_LIST_HPP_INCLUDED
|
||||
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
#include "../widgets/generator.hpp"
|
||||
#include "gui/widgets/pane.hpp"
|
||||
|
||||
class config;
|
||||
|
@ -24,34 +24,35 @@ class config;
|
|||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
class ttext_;
|
||||
class pane;
|
||||
class tselectable_;
|
||||
|
||||
/** Shows the list of addons on the server. */
|
||||
class taddon_list : public tdialog
|
||||
{
|
||||
public:
|
||||
explicit taddon_list(const config& cfg)
|
||||
: cfg_(cfg), cfg_iterators_(cfg_.child_range("campaign"))
|
||||
: orders_(), cfg_(cfg), cfg_iterators_(cfg_.child_range("campaign"))
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Collapses the description of an addon.
|
||||
*
|
||||
* @param grid The grid of the item whose description to
|
||||
* collapse.
|
||||
*/
|
||||
void collapse(tgrid& grid);
|
||||
void register_sort_button(twindow& window, const std::string& id, const tgenerator_::torder_func& up, const tgenerator_::torder_func& down);
|
||||
void register_sort_button_alphabetical(twindow& window, const std::string& id, const std::string& prop_id);
|
||||
void register_sort_button_numeric(twindow& window, const std::string& id, const std::string& prop_id);
|
||||
|
||||
void on_order_button_click(twindow& window, const tgenerator_::torder_func& up, const tgenerator_::torder_func& down, twidget& w);
|
||||
void on_filtertext_changed(ttext_* textbox, const std::string& text);
|
||||
|
||||
std::vector<tselectable_*> orders_;
|
||||
/**
|
||||
* Expands the description of an addon.
|
||||
*
|
||||
* @param grid The grid of the item whose description to
|
||||
* expand.
|
||||
*/
|
||||
void expand(tgrid& grid);
|
||||
void expand(tgrid& grid, twidget& w);
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue