Skip to content

Commit

Permalink
GUI2/Multimenu Button: store max shown count as an unsigned int
Browse files Browse the repository at this point in the history
A negative count here makes no sense...
  • Loading branch information
Vultraz committed Jun 16, 2018
1 parent ec04992 commit b17ade9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/gui/widgets/multimenu_button.cpp
Expand Up @@ -166,8 +166,8 @@ void multimenu_button::update_label()
if(selected.size() == values_.size()) {
set_label(_("multimenu^All Selected"));
} else {
if(selected.size() > static_cast<size_t>(max_shown_)) {
const int excess = selected.size() - max_shown_;
if(selected.size() > max_shown_) {
const unsigned excess = selected.size() - max_shown_;
selected.resize(max_shown_ + 1);
selected.back() = VNGETTEXT("multimenu^$excess other", "$excess others", excess, {{"excess", std::to_string(excess)}});
}
Expand Down
8 changes: 4 additions & 4 deletions src/gui/widgets/multimenu_button.hpp
Expand Up @@ -62,7 +62,7 @@ class multimenu_button : public styled_widget
*
* @param max The maximum number of elements to show
*/
void set_max_shown(const int max)
void set_max_shown(const unsigned max)
{
max_shown_ = max;
}
Expand All @@ -72,7 +72,7 @@ class multimenu_button : public styled_widget
*
* @returns The maximum number of elements to show
*/
int get_max_shown()
unsigned get_max_shown()
{
return max_shown_;
}
Expand Down Expand Up @@ -150,7 +150,7 @@ class multimenu_button : public styled_widget
/**
* The maximum number of selected states to list in the label
*/
int max_shown_;
unsigned max_shown_;

std::vector<::config> values_;

Expand Down Expand Up @@ -208,7 +208,7 @@ struct builder_multimenu_button : public builder_styled_widget
widget* build() const;

private:
int max_shown_;
unsigned max_shown_;
std::vector<::config> options_;
};

Expand Down

0 comments on commit b17ade9

Please sign in to comment.