diff options
Diffstat (limited to 'src/ui/slider.cc')
| -rw-r--r-- | src/ui/slider.cc | 19 | 
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ui/slider.cc b/src/ui/slider.cc index 1fa999b..c1b473c 100644 --- a/src/ui/slider.cc +++ b/src/ui/slider.cc @@ -160,16 +160,15 @@ void Slider::on_mousemove(const math::Vector2f &cursor)  	}  	if (slider_dragging && (slider_maximum > slider_minimum)) { -		// total width of dragable area	 -		if ((cursor.x() >= 2.0f * height()) && (cursor.x() <= width() - 2.0f * height())) { -			const float w = (width() - 4.0f * height()); -			const float s = w / (slider_maximum - slider_minimum); -			const float p = cursor.x() - 2.0f * height(); -			const float newvalue = slider_minimum + round(p /s); -			if (slider_value != newvalue) { -				slider_value = newvalue; -				emit(EventSliderChanged, this); -			} +		float x = cursor.x(); +		math::clamp(x,  2.0f * height(), width() - 2.0f * height()); +		const float w = (width() - 4.0f * height()); +		const float s = w / (slider_maximum - slider_minimum); +		const float p = cursor.x() - 2.0f * height(); +		const float newvalue = slider_minimum + round(p /s); +		if (slider_value != newvalue) { +			slider_value = newvalue; +			emit(EventSliderChanged, this);  		}  	}  }  | 
