summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2016-11-11 10:46:17 +0100
committerGitHub <noreply@github.com>2016-11-11 10:46:17 +0100
commit34f0ce1168ece7b293d39d99ef4187cdd278dca0 (patch)
tree0c49f1d29c1f7d9f8b06c5f2235c670792bca564 /scene/gui
parent7d1230a266f4eab3262ebfcbf4a89148dfcb3c48 (diff)
parent0955371447181a0fc20eb68dc6bc5aae67b73d0d (diff)
Merge pull request #6833 from Elinvention/master
Make the step property useful for sliders
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/range.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index e056c55f71..ed58c4eb49 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -136,16 +136,25 @@ double Range::get_page() const {
}
void Range::set_unit_value(double p_value) {
+
+ double v;
+
if (shared->exp_unit_value && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
-
- set_val( v );
+ v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
} else {
- set_val( (get_max() - get_min()) * p_value + get_min() );
+
+ double percent = (get_max() - get_min()) * p_value;
+ if (get_step() > 0) {
+ double steps = round(percent / get_step());
+ v = steps * get_step() + get_min();
+ } else {
+ v = percent + get_min();
+ }
}
+ set_val( v );
}
double Range::get_unit_value() const {