mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-29 00:23:48 +00:00
Prevent setting slider ranges with min > max (fix #4191)
This commit is contained in:
parent
da7f51ee43
commit
d10f0cc054
@ -30,23 +30,30 @@ static bool slider_press_left;
|
||||
|
||||
Slider::Slider(int min, int max, int value, SliderDelegate* delegate)
|
||||
: Widget(kSliderWidget)
|
||||
, m_min(min)
|
||||
, m_max(max)
|
||||
, m_value(std::clamp(value, min, max))
|
||||
, m_value(value)
|
||||
, m_readOnly(false)
|
||||
, m_delegate(delegate)
|
||||
{
|
||||
enforceValidRange(min, max);
|
||||
setFocusStop(true);
|
||||
initTheme();
|
||||
}
|
||||
|
||||
void Slider::setRange(int min, int max)
|
||||
{
|
||||
enforceValidRange(min, max);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Slider::enforceValidRange(int min, int max)
|
||||
{
|
||||
// Do not allow min > max
|
||||
if (min > max)
|
||||
max = min;
|
||||
|
||||
m_min = min;
|
||||
m_max = max;
|
||||
m_value = std::clamp(m_value, min, max);
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Slider::setValue(int value)
|
||||
|
@ -55,6 +55,7 @@ namespace ui {
|
||||
|
||||
private:
|
||||
void setupSliderCursor();
|
||||
void enforceValidRange(int min, int max);
|
||||
|
||||
int m_min;
|
||||
int m_max;
|
||||
|
Loading…
Reference in New Issue
Block a user