summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-05 20:32:23 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-05 20:32:23 +0200
commit4712b6760f15b024e0913db045553528504c29cd (patch)
tree6ccbbd3bfc50238b647ce5e49104fab11755bcd0 /options
parent2c66c32e9185cdfac2d6e0b3b90a0834482aab31 (diff)
options/slider: adjust eps, simplify
Diffstat (limited to 'options')
-rw-r--r--options/slider.cpp33
-rw-r--r--options/slider.hpp25
2 files changed, 33 insertions, 25 deletions
diff --git a/options/slider.cpp b/options/slider.cpp
index 8d46d51b..fe34d8e6 100644
--- a/options/slider.cpp
+++ b/options/slider.cpp
@@ -20,8 +20,6 @@ slider_value::slider_value(const slider_value& v) : slider_value(v.cur(), v.min(
{
}
-
-
slider_value::slider_value() : slider_value(0.f, 0.f, 0.f)
{
}
@@ -40,11 +38,15 @@ bool slider_value::operator==(const slider_value& v) const
{
using std::fabs;
- static constexpr float eps = 1e-3f;
+ static constexpr float eps = float(1e-2 + 2.5e-3);
+#if 1
return (fabs(v.cur_ - cur_) < eps &&
fabs(v.min_ - min_) < eps &&
fabs(v.max_ - max_) < eps);
+#else
+ return (fabs(v.cur_ - cur_) < eps);
+#endif
}
slider_value slider_value::update_from_slider(int pos, int q_min, int q_max) const
@@ -73,3 +75,28 @@ int slider_value::to_slider_pos(int q_min, int q_max) const
}
} // end ns options
+
+QT_BEGIN_NAMESPACE
+
+QDataStream& operator << (QDataStream& out, const options::slider_value& v)
+{
+ out << float(v.cur())
+ << float(v.min())
+ << float(v.max());
+ return out;
+}
+
+QDebug operator << (QDebug dbg, const options::slider_value& val)
+{
+ return dbg << val.cur();
+}
+
+QDataStream& operator >> (QDataStream& in, options::slider_value& v)
+{
+ float cur = 0, min = 0, max = 0;
+ in >> cur >> min >> max;
+ v = options::slider_value(cur, min, max);
+ return in;
+}
+
+QT_END_NAMESPACE
diff --git a/options/slider.hpp b/options/slider.hpp
index 1d02f17f..de5937d2 100644
--- a/options/slider.hpp
+++ b/options/slider.hpp
@@ -41,28 +41,9 @@ namespace options
QT_BEGIN_NAMESPACE
-inline QDebug operator << (QDebug dbg, const options::slider_value& val)
-{
- return dbg << val.cur();
-}
-
-inline QDataStream& operator << (QDataStream& out, const options::slider_value& v)
-{
- out << float(v.cur())
- << float(v.min())
- << float(v.max());
- return out;
-}
-
-inline QDataStream& operator >> (QDataStream& in, options::slider_value& v)
-{
- float cur, min, max;
- in >> cur;
- in >> min;
- in >> max;
- v = options::slider_value(cur, min, max);
- return in;
-}
+QDebug operator << (QDebug dbg, const options::slider_value& val);
+QDataStream& operator << (QDataStream& out, const options::slider_value& v);
+QDataStream& operator >> (QDataStream& in, options::slider_value& v);
QT_END_NAMESPACE