summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-16 17:42:46 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-16 17:54:12 +0200
commitd42019e4d15ff62926b1a98b45a0fcd154567620 (patch)
tree45932be0a093af0df689cc490219734bb234dec3 /options
parent190ec92ac66c4b2c44d692be9b861ec98853355a (diff)
options/slider: use double precision
Made Accela slider inaccurate.
Diffstat (limited to 'options')
-rw-r--r--options/slider.cpp12
-rw-r--r--options/slider.hpp10
2 files changed, 11 insertions, 11 deletions
diff --git a/options/slider.cpp b/options/slider.cpp
index fe34d8e6..001e8104 100644
--- a/options/slider.cpp
+++ b/options/slider.cpp
@@ -38,7 +38,7 @@ bool slider_value::operator==(const slider_value& v) const
{
using std::fabs;
- static constexpr float eps = float(1e-2 + 2.5e-3);
+ static constexpr double eps = 2e-3;
#if 1
return (fabs(v.cur_ - cur_) < eps &&
@@ -55,7 +55,7 @@ slider_value slider_value::update_from_slider(int pos, int q_min, int q_max) con
const int q_diff = q_max - q_min;
const double sv_pos = q_diff == 0
- ? -1e6
+ ? 0
: (((pos - q_min) * (v.max() - v.min())) / q_diff + v.min());
if (sv_pos < v.min())
@@ -80,9 +80,9 @@ QT_BEGIN_NAMESPACE
QDataStream& operator << (QDataStream& out, const options::slider_value& v)
{
- out << float(v.cur())
- << float(v.min())
- << float(v.max());
+ out << v.cur()
+ << v.min()
+ << v.max();
return out;
}
@@ -93,7 +93,7 @@ QDebug operator << (QDebug dbg, const options::slider_value& val)
QDataStream& operator >> (QDataStream& in, options::slider_value& v)
{
- float cur = 0, min = 0, max = 0;
+ double cur = 0, min = 0, max = 0;
in >> cur >> min >> max;
v = options::slider_value(cur, min, max);
return in;
diff --git a/options/slider.hpp b/options/slider.hpp
index de5937d2..dff841c6 100644
--- a/options/slider.hpp
+++ b/options/slider.hpp
@@ -16,21 +16,21 @@ namespace options
{
class OPENTRACK_OPTIONS_EXPORT slider_value final
{
- float cur_, min_, max_;
+ double cur_, min_, max_;
public:
slider_value(float cur, float min, float max);
template<typename t, typename u, typename v> slider_value(t cur, u min, v max) :
- cur_(float(cur)),
- min_(float(min)),
- max_(float(max))
+ cur_(double(cur)),
+ min_(double(min)),
+ max_(double(max))
{}
slider_value(const slider_value& v);
slider_value();
slider_value& operator=(const slider_value& v);
bool operator==(const slider_value& v) const;
- operator float() const { return cur_; }
+ operator double() const { return cur_; }
double cur() const { return double(cur_); }
double min() const { return double(min_); }
double max() const { return double(max_); }