Commit 62057f1e authored by cutealien's avatar cutealien

CGUISpinBox range does now also use decimal places to avoid getting endless...

CGUISpinBox range does now also use decimal places to avoid getting endless loops in setValue/verifyValueRange.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3902 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 7b5f3909
......@@ -50,6 +50,7 @@ namespace gui
virtual void setStepSize(f32 step=1.f) = 0;
//! Sets the number of decimal places to display.
//! Note that this also rounds the range to the same number of decimal places.
/** \param places: The number of decimal places to display, use -1 to reset */
virtual void setDecimalPlaces(s32 places) = 0;
......
......@@ -133,6 +133,14 @@ void CGUISpinBox::setRange(f32 min, f32 max)
core::swap(min, max);
RangeMin = min;
RangeMax = max;
// we have to round the range - otherwise we can get into an infinte setValue/verifyValueRange cycle.
wchar_t str[100];
swprintf(str, 99, FormatString.c_str(), RangeMin);
RangeMin = core::fast_atof(core::stringc(str).c_str());
swprintf(str, 99, FormatString.c_str(), RangeMax);
RangeMax = core::fast_atof(core::stringc(str).c_str());
verifyValueRange();
}
......@@ -173,6 +181,7 @@ void CGUISpinBox::setDecimalPlaces(s32 places)
FormatString += places;
FormatString += "f";
}
setRange( RangeMin, RangeMax );
setValue(getValue());
}
......
......@@ -72,6 +72,7 @@ namespace gui
virtual const wchar_t* getText() const;
//! Sets the number of decimal places to display.
//! Note that this also rounds the range to the same number of decimal places.
/** \param places: The number of decimal places to display, use -1 to reset */
virtual void setDecimalPlaces(s32 places);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment