summaryrefslogtreecommitdiff
path: root/plugingui/slider.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2017-04-19 22:47:08 +0200
committerAndré Nusser <andre.nusser@googlemail.com>2017-04-19 22:47:08 +0200
commit11e2bda54641c1ef4cad38c11d742524966c7e86 (patch)
tree83186978f4725e33afe3340702e9425135c4a62c /plugingui/slider.cc
parent34e894ed6fbb5af0dcd0a61b02de75d6044aede8 (diff)
Take memory specific code out of Slider and fix a bug on the way.
Diffstat (limited to 'plugingui/slider.cc')
-rw-r--r--plugingui/slider.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/plugingui/slider.cc b/plugingui/slider.cc
index ed23fad..b558468 100644
--- a/plugingui/slider.cc
+++ b/plugingui/slider.cc
@@ -34,8 +34,6 @@
namespace GUI
{
-static constexpr float _4GB = 1024.0 * 1024.0 * 1024.0 * 4.0;
-
Slider::Slider(Widget* parent) : Widget(parent)
{
state = State::up;
@@ -47,10 +45,12 @@ Slider::Slider(Widget* parent) : Widget(parent)
void Slider::setValue(float new_value)
{
- current_value = new_value / (float)_4GB; // TODO: Scale to [0, 1] range
+ // TODO make sure that we get values in range [0, 1]
+
+ current_value = new_value;
redraw();
clickNotifier();
- valueChangedNotifier(current_value * _4GB); // TODO: Scale up to full range
+ valueChangedNotifier(current_value);
}
float Slider::value() const
@@ -109,6 +109,7 @@ void Slider::buttonEvent(ButtonEvent* buttonEvent)
redraw();
clickNotifier();
+ valueChangedNotifier(current_value);
}
if(buttonEvent->direction == Direction::up)
@@ -118,6 +119,7 @@ void Slider::buttonEvent(ButtonEvent* buttonEvent)
redraw();
clickNotifier();
+ valueChangedNotifier(current_value);
}
}
@@ -129,7 +131,7 @@ void Slider::mouseMoveEvent(MouseMoveEvent* mouseMoveEvent)
redraw();
clickNotifier();
- valueChangedNotifier(current_value * _4GB); // TODO: Scale up to full range
+ valueChangedNotifier(current_value);
}
}
@@ -146,7 +148,7 @@ void Slider::scrollEvent(ScrollEvent* scrollEvent)
redraw();
clickNotifier();
- valueChangedNotifier(current_value * _4GB); // TODO: Scale up to full range
+ valueChangedNotifier(current_value);
}
std::size_t Slider::getControlWidth() const
@@ -167,7 +169,7 @@ void Slider::recomputeCurrentValue(float x)
}
else
{
- current_value = (maximum / getControlWidth()) * (x - button_offset);
+ current_value = (x - button_offset) / getControlWidth();
}
if (current_value < 0.)