summaryrefslogtreecommitdiffhomepage
path: root/opentrack-compat/options.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-12 23:00:55 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-14 18:14:46 +0200
commit9ed8d925822b2aee15899487e822480abb88541e (patch)
treeb1927153b6d5726c9f84b4a9310796569d3eec8b /opentrack-compat/options.cpp
parent0ba585a1d91b812158277c09aa890cedbc080790 (diff)
compat/options: use traits to prevent slider min/max persistence
Without it, the serialized min and max member vars were set in stone despite further code changes. Now only the current value is persisted. Add clamp for cur/min/max slider values. Store default value as t rather than underlying_t since it's always been casted anyway. Add trivial comment, update copyright.
Diffstat (limited to 'opentrack-compat/options.cpp')
-rw-r--r--opentrack-compat/options.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/opentrack-compat/options.cpp b/opentrack-compat/options.cpp
index 783cf5ec..ba8c7925 100644
--- a/opentrack-compat/options.cpp
+++ b/opentrack-compat/options.cpp
@@ -253,6 +253,12 @@ slider_value::slider_value(double cur, double min, double max) :
min_(min),
max_(max)
{
+ if (min_ > max_)
+ min_ = max_;
+ if (cur_ > max_)
+ cur_ = max;
+ if (cur_ < min_)
+ cur_ = min_;
}
slider_value::slider_value(const slider_value& v) : slider_value(v.cur(), v.min(), v.max())
@@ -266,6 +272,7 @@ slider_value::slider_value() : slider_value(0, 0, 0)
slider_value& slider_value::operator=(const slider_value& v)
{
cur_ = v.cur_;
+
min_ = v.min_;
max_ = v.max_;