1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:17:42 +00:00

LibGUI+LibWeb: Use 'decrease_slider_by_steps()' method

This method allow us to avoid repeating the pattern
'set_value(value() - step() * step_number)'.
This commit is contained in:
Elyse 2021-10-31 12:34:55 -06:00 committed by Andreas Kling
parent cee4e02134
commit 8d1fb299b1
2 changed files with 3 additions and 3 deletions

View file

@ -228,7 +228,7 @@ void Scrollbar::paint_event(PaintEvent& event)
void Scrollbar::on_automatic_scrolling_timer_fired() void Scrollbar::on_automatic_scrolling_timer_fired()
{ {
if (m_pressed_component == Component::DecrementButton && component_at_position(m_last_mouse_position) == Component::DecrementButton) { if (m_pressed_component == Component::DecrementButton && component_at_position(m_last_mouse_position) == Component::DecrementButton) {
set_value(value() - step()); decrease_slider_by_steps(1);
return; return;
} }
if (m_pressed_component == Component::IncrementButton && component_at_position(m_last_mouse_position) == Component::IncrementButton) { if (m_pressed_component == Component::IncrementButton && component_at_position(m_last_mouse_position) == Component::IncrementButton) {

View file

@ -257,13 +257,13 @@ void InProcessWebView::keydown_event(GUI::KeyEvent& event)
vertical_scrollbar().increase_slider_by_steps(1); vertical_scrollbar().increase_slider_by_steps(1);
break; break;
case Key_Up: case Key_Up:
vertical_scrollbar().set_value(vertical_scrollbar().value() - vertical_scrollbar().step()); vertical_scrollbar().decrease_slider_by_steps(1);
break; break;
case Key_Left: case Key_Left:
horizontal_scrollbar().increase_slider_by_steps(1); horizontal_scrollbar().increase_slider_by_steps(1);
break; break;
case Key_Right: case Key_Right:
horizontal_scrollbar().set_value(horizontal_scrollbar().value() - horizontal_scrollbar().step()); horizontal_scrollbar().decrease_slider_by_steps(1);
break; break;
case Key_PageDown: case Key_PageDown:
vertical_scrollbar().increase_slider_by(frame_inner_rect().height()); vertical_scrollbar().increase_slider_by(frame_inner_rect().height());