gui2/tchat_log: Use a separate proper label for the page number text

This replaces the page number slider with a "minimal" variant slider and
an adjacent label widget whose text we enter manually.

The label format is "<PAGE>/<COUNT>" and it's untranslatable. Hopefully
this shouldn't cause any localization issues since it's all numbers and
we currently can't use alternative numeral systems anyway.

I'm leaving the page slider's maximum_value_label attribute intact just
in case this needs to be reverted later, since it's going into the 1.12
branch too.
This commit is contained in:
Ignacio R. Morelle 2014-06-19 02:18:41 -04:00
parent 2ffdcb7e45
commit eee57afbd2
2 changed files with 22 additions and 1 deletions

View file

@ -65,13 +65,25 @@
border_size = 5
[slider]
id = "page_number"
definition = "default"
definition = "minimal"
minimum_value = 1
maximum_value = 100
step_size = 1
# Unused, kept for 1.12 i18n in case the default slider
# variant with a label needs to be restored.
maximum_value_label = _"Last"
[/slider]
[/column]
[column]
grow_factor = 0
border = "all"
border_size = 5
[label]
id = "page_label"
definition = "default"
label = ""
[/label]
[/column]
[column]
grow_factor = 0
border = "all"

View file

@ -75,6 +75,7 @@ public:
, chat_log_history(r->build_chat_log())
, page(0)
, page_number()
, page_label()
, previous_page()
, next_page()
, filter()
@ -90,6 +91,7 @@ public:
int page;
static const int COUNT_PER_PAGE = 100;
tslider* page_number;
tcontrol* page_label;
tbutton* previous_page;
tbutton* next_page;
ttext_box* filter;
@ -311,6 +313,11 @@ public:
LOG_CHAT_LOG << "Maximum value of page number slider: "
<< count_of_pages << std::endl;
model_.page_number->set_value(page + 1);
std::ostringstream cur_page_text;
cur_page_text << (page + 1) << '/' << std::max(1, count_of_pages);
model_.page_label->set_label(cur_page_text.str());
LOG_CHAT_LOG << "Exiting tchat_log::controller::update_view_from_model"
<< std::endl;
}
@ -405,6 +412,8 @@ public:
this,
boost::ref(window)));
model_.page_label = &find_widget<tcontrol>(&window, "page_label", false);
LOG_CHAT_LOG << "Exiting tchat_log::view::bind" << std::endl;
}