mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
LibGUI: Fix {Value,Opacity}Slider value changes for values less than 0
This patch fixes a value glitch when changing the slider value via dragging the knob with the mouse and having a min value smaller than 0. Before this patch it was not possible to drag the value below 0 and it just snapped to the configured min value if the mouse was at the most left position. Now the value is calculated from the value range and mouse position within the widget.
This commit is contained in:
parent
ee6fb51db6
commit
f9ec3b986e
2 changed files with 6 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue