summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--options/slider.cpp22
-rw-r--r--options/slider.hpp24
2 files changed, 20 insertions, 26 deletions
diff --git a/options/slider.cpp b/options/slider.cpp
index 5789e951..aea3c48a 100644
--- a/options/slider.cpp
+++ b/options/slider.cpp
@@ -11,7 +11,7 @@
namespace options {
-constexpr slider_value::slider_value(double cur, double min, double max) :
+slider_value::slider_value(double cur, double min, double max) :
cur_(cur),
min_(min),
max_(max)
@@ -24,31 +24,25 @@ constexpr slider_value::slider_value(double cur, double min, double max) :
cur_ = min_;
}
-template<typename t>
-static constexpr auto abs_(t x)
-{
- return x < t{0} ? -x : x;
-}
-
-constexpr bool slider_value::operator==(const slider_value& v) const
+bool slider_value::operator==(const slider_value& v) const
{
constexpr double eps = 2e-3;
#if 1
- return (abs_(v.cur_ - cur_) < eps &&
- abs_(v.min_ - min_) < eps &&
- abs_(v.max_ - max_) < eps);
+ return (std::fabs(v.cur_ - cur_) < eps &&
+ std::fabs(v.min_ - min_) < eps &&
+ std::fabs(v.max_ - max_) < eps);
#else
- return (abs_(v.cur_ - cur_) < eps);
+ return (std::fabs(v.cur_ - cur_) < eps);
#endif
}
-constexpr bool slider_value::operator!=(const slider_value& v) const
+bool slider_value::operator!=(const slider_value& v) const
{
return !(*this == v);
}
-constexpr slider_value slider_value::update_from_slider(int pos, int q_min, int q_max) const
+slider_value slider_value::update_from_slider(int pos, int q_min, int q_max) const
{
slider_value v(*this);
diff --git a/options/slider.hpp b/options/slider.hpp
index 1366e390..1dd9ec7c 100644
--- a/options/slider.hpp
+++ b/options/slider.hpp
@@ -23,26 +23,26 @@ namespace options
double cur_, min_, max_;
public:
- constexpr slider_value(double cur, double min, double max);
+ slider_value(double cur, double min, double max);
template<typename t, typename u, typename v>
- constexpr slider_value(t cur, u min, v max) :
+ slider_value(t cur, u min, v max) :
cur_(double(cur)),
min_(double(min)),
max_(double(max))
{}
slider_value& operator=(const slider_value& v) = default;
- constexpr slider_value(const slider_value& v) = default;
- constexpr slider_value() : slider_value{0, 0, 0} {};
-
- constexpr bool operator==(const slider_value& v) const;
- constexpr bool operator!=(const slider_value& v) const;
- constexpr operator double() const { return cur_; }
- constexpr double cur() const { return cur_; }
- constexpr double min() const { return min_; }
- constexpr double max() const { return max_; }
- constexpr slider_value update_from_slider(int pos, int q_min, int q_max) const;
+ slider_value(const slider_value& v) = default;
+ slider_value() : slider_value{0, 0, 0} {};
+
+ bool operator==(const slider_value& v) const;
+ bool operator!=(const slider_value& v) const;
+ operator double() const { return cur_; }
+ double cur() const { return cur_; }
+ double min() const { return min_; }
+ double max() const { return max_; }
+ slider_value update_from_slider(int pos, int q_min, int q_max) const;
int to_slider_pos(int q_min, int q_max) const;
};
}