1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 21:55:07 +00:00

LibGUI+LibWeb: Use 'increase_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:31:49 -06:00 committed by Andreas Kling
parent 086615535f
commit cee4e02134
2 changed files with 4 additions and 4 deletions

View file

@ -232,7 +232,7 @@ void Scrollbar::on_automatic_scrolling_timer_fired()
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) {
set_value(value() + step()); increase_slider_by_steps(1);
return; return;
} }
if (m_pressed_component == Component::Gutter && component_at_position(m_last_mouse_position) == Component::Gutter) { if (m_pressed_component == Component::Gutter && component_at_position(m_last_mouse_position) == Component::Gutter) {
@ -299,7 +299,7 @@ void Scrollbar::mousewheel_event(MouseEvent& event)
{ {
if (!is_scrollable()) if (!is_scrollable())
return; return;
set_value(value() + event.wheel_delta() * step()); increase_slider_by_steps(event.wheel_delta());
Widget::mousewheel_event(event); Widget::mousewheel_event(event);
} }

View file

@ -254,13 +254,13 @@ void InProcessWebView::keydown_event(GUI::KeyEvent& event)
vertical_scrollbar().set_value(vertical_scrollbar().max()); vertical_scrollbar().set_value(vertical_scrollbar().max());
break; break;
case Key_Down: case Key_Down:
vertical_scrollbar().set_value(vertical_scrollbar().value() + vertical_scrollbar().step()); 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().set_value(vertical_scrollbar().value() - vertical_scrollbar().step());
break; break;
case Key_Left: case Key_Left:
horizontal_scrollbar().set_value(horizontal_scrollbar().value() + horizontal_scrollbar().step()); 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().set_value(horizontal_scrollbar().value() - horizontal_scrollbar().step());