diff options
| -rw-r--r-- | plugingui/slider.cc | 52 | ||||
| -rw-r--r-- | plugingui/slider.h | 1 | 
2 files changed, 23 insertions, 30 deletions
| diff --git a/plugingui/slider.cc b/plugingui/slider.cc index 6a764b8..7d5cdb4 100644 --- a/plugingui/slider.cc +++ b/plugingui/slider.cc @@ -104,16 +104,6 @@ void Slider::buttonEvent(ButtonEvent* buttonEvent)  		state = State::down;  		recomputeCurrentValue(buttonEvent->x); -		if(current_value < 0) -		{ -			current_value = 0; -		} - -		if(current_value > 1) -		{ -			current_value = 1; -		} -  		redraw();  		clickNotifier();  	} @@ -123,16 +113,6 @@ void Slider::buttonEvent(ButtonEvent* buttonEvent)  		state = State::up;  		recomputeCurrentValue(buttonEvent->x); -		if(current_value < 0) -		{ -			current_value = 0; -		} - -		if(current_value > 1) -		{ -			current_value = 1; -		} -  		redraw();  		clickNotifier();  	} @@ -144,21 +124,25 @@ void Slider::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)  	{  		recomputeCurrentValue(mouseMoveEvent->x); -		if(current_value < 0) -		{ -			current_value = 0; -		} - -		if(current_value > 1) -		{ -			current_value = 1; -		} -  		redraw();  		clickNotifier();  	}  } +void Slider::scrollEvent(ScrollEvent* scrollEvent) +{ +	current_value += scrollEvent->delta/(float)getControlWidth(); +	if (current_value < 0.) +	{ +		current_value = 0.; +	} +	else if (current_value > 1.0) { +		current_value = 1.0; +	} + +	redraw(); +} +  std::size_t Slider::getControlWidth() const  {  	if(width() < 2 * button_offset) @@ -179,6 +163,14 @@ void Slider::recomputeCurrentValue(float x)  	{  		current_value = (maximum / getControlWidth()) * (x - button_offset);  	} + +	if (current_value < 0.) +	{ +		current_value = 0.; +	} +	else if (current_value > 1.0) { +		current_value = 1.0; +	}  }  } // GUI:: diff --git a/plugingui/slider.h b/plugingui/slider.h index 9620fd0..ff2db29 100644 --- a/plugingui/slider.h +++ b/plugingui/slider.h @@ -63,6 +63,7 @@ protected:  	virtual void repaintEvent(RepaintEvent* repaintEvent) override;  	virtual void buttonEvent(ButtonEvent* buttonEvent) override;  	virtual void mouseMoveEvent(MouseMoveEvent* mouseMoveEvent) override; +	virtual void scrollEvent(ScrollEvent* scrollEvent) override;  private:  	enum class State | 
