diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/pwl/cpwl_scroll_bar.cpp | 28 | ||||
-rw-r--r-- | fpdfsdk/pwl/cpwl_scroll_bar.h | 9 |
2 files changed, 12 insertions, 25 deletions
diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.cpp b/fpdfsdk/pwl/cpwl_scroll_bar.cpp index 472e6afc24..ced049a175 100644 --- a/fpdfsdk/pwl/cpwl_scroll_bar.cpp +++ b/fpdfsdk/pwl/cpwl_scroll_bar.cpp @@ -8,6 +8,7 @@ #include <algorithm> #include <sstream> +#include <utility> #include <vector> #include "core/fxge/cfx_pathdata.h" @@ -24,27 +25,14 @@ constexpr float kScrollBarTriangleHalfLength = 2.0f; #define PWL_DEFAULT_HEAVYGRAYCOLOR CFX_Color(CFX_Color::kGray, 0.50) -PWL_FLOATRANGE::PWL_FLOATRANGE() { - Default(); -} - -PWL_FLOATRANGE::PWL_FLOATRANGE(float min, float max) { - Set(min, max); +void PWL_FLOATRANGE::Reset() { + fMin = 0.0f; + fMax = 0.0f; } -void PWL_FLOATRANGE::Default() { - fMin = 0; - fMax = 0; -} - -void PWL_FLOATRANGE::Set(float min, float max) { - if (min > max) { - fMin = max; - fMax = min; - } else { - fMin = min; - fMax = max; - } +void PWL_FLOATRANGE::Set(float f1, float f2) { + fMin = std::min(f1, f2); + fMax = std::max(f1, f2); } bool PWL_FLOATRANGE::In(float x) const { @@ -61,7 +49,7 @@ PWL_SCROLL_PRIVATEDATA::PWL_SCROLL_PRIVATEDATA() { } void PWL_SCROLL_PRIVATEDATA::Default() { - ScrollRange.Default(); + ScrollRange.Reset(); fScrollPos = ScrollRange.fMin; fClientWidth = 0; fBigStep = 10; diff --git a/fpdfsdk/pwl/cpwl_scroll_bar.h b/fpdfsdk/pwl/cpwl_scroll_bar.h index 3c3c56e4bb..3592423a7d 100644 --- a/fpdfsdk/pwl/cpwl_scroll_bar.h +++ b/fpdfsdk/pwl/cpwl_scroll_bar.h @@ -64,21 +64,20 @@ class CPWL_SBButton final : public CPWL_Wnd { struct PWL_FLOATRANGE { public: - PWL_FLOATRANGE(); - PWL_FLOATRANGE(float min, float max); + PWL_FLOATRANGE() = default; bool operator==(const PWL_FLOATRANGE& that) const { return fMin == that.fMin && fMax == that.fMax; } bool operator!=(const PWL_FLOATRANGE& that) const { return !(*this == that); } - void Default(); + void Reset(); void Set(float min, float max); bool In(float x) const; float GetWidth() const; - float fMin; - float fMax; + float fMin = 0.0f; + float fMax = 0.0f; }; struct PWL_SCROLL_PRIVATEDATA { |