29 slider_impl(aOrientation), iMinimum{}, iMaximum{}, iStep{}, iValue{}, iSettingNormalizedValue{ false }
34 basic_slider<T>::basic_slider(i_widget& aParent, slider_orientation aOrientation) :
35 slider_impl(aParent, aOrientation), iMinimum{}, iMaximum{}, iStep{}, iValue{}, iSettingNormalizedValue{ false }
40 basic_slider<T>::basic_slider(i_layout& aLayout, slider_orientation aOrientation) :
41 slider_impl(aLayout, aOrientation), iMinimum{}, iMaximum{}, iStep{}, iValue{}, iSettingNormalizedValue{ false }
46 typename basic_slider<T>::value_type basic_slider<T>::minimum()
const
52 void basic_slider<T>::set_minimum(value_type aMinimum)
55 ConstraintsChanged.trigger();
56 if (iValue < minimum())
61 typename basic_slider<T>::value_type basic_slider<T>::maximum()
const
67 void basic_slider<T>::set_maximum(value_type aMaximum)
70 ConstraintsChanged.trigger();
71 if (iValue > maximum())
76 typename basic_slider<T>::value_type basic_slider<T>::step()
const
82 void basic_slider<T>::set_step(value_type aStep)
85 ConstraintsChanged.trigger();
89 typename basic_slider<T>::value_type basic_slider<T>::value()
const
95 void basic_slider<T>::set_value(value_type aValue)
100 if (!iSettingNormalizedValue)
101 slider_impl::set_normalized_value(normalized_value());
102 if (!handling_event())
103 ValueChanged.sync_trigger();
105 ValueChanged.trigger();
109 template <
typename T>
110 double basic_slider<T>::normalized_step_value()
const
112 auto range = maximum() - minimum();
115 return static_cast<double>(step()) / range;
118 template <
typename T>
119 double basic_slider<T>::normalized_value()
const
121 auto range = maximum() - minimum();
124 return (
static_cast<double>(value()) - minimum()) / range;
127 template <
typename T>
128 void basic_slider<T>::set_normalized_value(
double aValue)
130 double const stepValue = normalized_step_value();
132 auto r = std::modf(aValue / stepValue, &steps);
133 if (r > stepValue / 2.0)
135 aValue = std::max(0.0, std::min(1.0, steps * stepValue));
137 auto const range = maximum() - minimum();
138 auto denormalized = range * aValue + minimum();
139 if (std::is_integral<value_type>())
141 if (denormalized < 0.0)
142 denormalized = std::floor(denormalized + 0.5);
143 else if (denormalized > 0.0)
144 denormalized = std::ceil(denormalized - 0.5);
146 set_value(
static_cast<value_type
>(denormalized));
147 slider_impl::set_normalized_value(aValue);