diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/OpacitySlider.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ValueSlider.cpp | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGUI/OpacitySlider.cpp b/Userland/Libraries/LibGUI/OpacitySlider.cpp index cb8aff8d79..df8917ba1d 100644 --- a/Userland/Libraries/LibGUI/OpacitySlider.cpp +++ b/Userland/Libraries/LibGUI/OpacitySlider.cpp @@ -103,7 +103,9 @@ int OpacitySlider::value_at(Gfx::IntPoint const& position) const if (position.x() > inner_rect.right()) return max(); float relative_offset = (float)(position.x() - inner_rect.x()) / (float)inner_rect.width(); - return relative_offset * (float)max(); + + int range = max() - min(); + return min() + (int)(relative_offset * (float)range); } void OpacitySlider::mousedown_event(MouseEvent& event) diff --git a/Userland/Libraries/LibGUI/ValueSlider.cpp b/Userland/Libraries/LibGUI/ValueSlider.cpp index 732b8081d2..d042f371fc 100644 --- a/Userland/Libraries/LibGUI/ValueSlider.cpp +++ b/Userland/Libraries/LibGUI/ValueSlider.cpp @@ -139,7 +139,9 @@ int ValueSlider::value_at(Gfx::IntPoint const& position) const if (position.x() > bar_rect().right()) return max(); float relative_offset = (float)(position.x() - bar_rect().left()) / (float)bar_rect().width(); - return (int)(relative_offset * (float)max()); + + int range = max() - min(); + return min() + (int)(relative_offset * (float)range); } void ValueSlider::set_value(int value, AllowCallback allow_callback, DoClamp do_clamp) |