فهرست منبع

LibGUI+LibWeb: Use 'increase_slider_by_steps()' method

This method allow us to avoid repeating the pattern
'set_value(value() + step() * step_number)'.
Elyse 3 سال پیش
والد
کامیت
cee4e02134
2فایلهای تغییر یافته به همراه4 افزوده شده و 4 حذف شده
  1. 2 2
      Userland/Libraries/LibGUI/Scrollbar.cpp
  2. 2 2
      Userland/Libraries/LibWeb/InProcessWebView.cpp

+ 2 - 2
Userland/Libraries/LibGUI/Scrollbar.cpp

@@ -232,7 +232,7 @@ void Scrollbar::on_automatic_scrolling_timer_fired()
         return;
     }
     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;
     }
     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())
         return;
-    set_value(value() + event.wheel_delta() * step());
+    increase_slider_by_steps(event.wheel_delta());
     Widget::mousewheel_event(event);
 }
 

+ 2 - 2
Userland/Libraries/LibWeb/InProcessWebView.cpp

@@ -254,13 +254,13 @@ void InProcessWebView::keydown_event(GUI::KeyEvent& event)
             vertical_scrollbar().set_value(vertical_scrollbar().max());
             break;
         case Key_Down:
-            vertical_scrollbar().set_value(vertical_scrollbar().value() + vertical_scrollbar().step());
+            vertical_scrollbar().increase_slider_by_steps(1);
             break;
         case Key_Up:
             vertical_scrollbar().set_value(vertical_scrollbar().value() - vertical_scrollbar().step());
             break;
         case Key_Left:
-            horizontal_scrollbar().set_value(horizontal_scrollbar().value() + horizontal_scrollbar().step());
+            horizontal_scrollbar().increase_slider_by_steps(1);
             break;
         case Key_Right:
             horizontal_scrollbar().set_value(horizontal_scrollbar().value() - horizontal_scrollbar().step());