Fix the off by one error in the range of the slider.

This commit is contained in:
Mark de Wever 2008-07-18 10:42:23 +00:00
parent 3900430f9d
commit b5d48b4ed0
2 changed files with 7 additions and 3 deletions

View file

@ -83,7 +83,8 @@ void tslider::set_minimum_value(const int minimum_value)
const int maximum_value = get_maximum_value();
minimum_value_ = minimum_value;
set_item_count(distance(minimum_value_, maximum_value));
// The number of items needs to include the begin and end so distance + 1.
set_item_count(distance(minimum_value_, maximum_value) + 1);
if(value < minimum_value_) {
set_item_position(0);
@ -103,7 +104,8 @@ void tslider::set_maximum_value(const int maximum_value)
const int value = get_value();
set_item_count(distance(minimum_value_, maximum_value));
// The number of items needs to include the begin and end so distance + 1.
set_item_count(distance(minimum_value_, maximum_value) + 1);
if(value > maximum_value) {
set_item_position(get_maximum_value());

View file

@ -48,7 +48,9 @@ public:
void set_maximum_value(const int maximum_value);
/** Inherited from tinteger_selector_. */
int get_maximum_value() const { return minimum_value_ + get_item_count(); }
int get_maximum_value() const
// The number of items needs to include the begin and end so count - 1.
{ return minimum_value_ + get_item_count() - 1; }
private: