diff options
author | Elyse <kevincristian@outlook.com> | 2021-10-31 12:27:52 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-30 14:31:50 +0100 |
commit | 086615535f00b2406a053a99038cfa2c768c42b0 (patch) | |
tree | 3331e4506f20c3a6a335a9d238ff89d278dc07d9 | |
parent | d53e1fa1fa62cdbb5ead03c5a52f5690d86235a6 (diff) | |
download | serenity-086615535f00b2406a053a99038cfa2c768c42b0.zip |
Everywhere: Use 'decrease_slider_by()' method from AbstractSlider
The same idea as 'increase_slider_by()', it helps us to avoid repeating
the pattern 'set_value(value() - delta)'.
-rw-r--r-- | Userland/Applications/PDFViewer/PDFViewer.cpp | 2 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/Tools/Tool.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/OpacitySlider.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Scrollbar.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Slider.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ValueSlider.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibVT/TerminalWidget.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/InProcessWebView.cpp | 2 |
8 files changed, 10 insertions, 10 deletions
diff --git a/Userland/Applications/PDFViewer/PDFViewer.cpp b/Userland/Applications/PDFViewer/PDFViewer.cpp index 57ff4ab869..f377466ca8 100644 --- a/Userland/Applications/PDFViewer/PDFViewer.cpp +++ b/Userland/Applications/PDFViewer/PDFViewer.cpp @@ -106,7 +106,7 @@ void PDFViewer::mousewheel_event(GUI::MouseEvent& event) scrollbar.set_value(scrollbar.max()); } } else { - scrollbar.set_value(scrollbar.value() - 20); + scrollbar.decrease_slider_by(20); } } } diff --git a/Userland/Applications/PixelPaint/Tools/Tool.cpp b/Userland/Applications/PixelPaint/Tools/Tool.cpp index 1165f11d74..566b00218b 100644 --- a/Userland/Applications/PixelPaint/Tools/Tool.cpp +++ b/Userland/Applications/PixelPaint/Tools/Tool.cpp @@ -34,7 +34,7 @@ void Tool::on_keydown(GUI::KeyEvent& event) switch (event.key()) { case KeyCode::Key_LeftBracket: if (m_primary_slider) - m_primary_slider->set_value(m_primary_slider->value() - 1); + m_primary_slider->decrease_slider_by(1); break; case KeyCode::Key_RightBracket: if (m_primary_slider) @@ -42,7 +42,7 @@ void Tool::on_keydown(GUI::KeyEvent& event) break; case KeyCode::Key_LeftBrace: if (m_secondary_slider) - m_secondary_slider->set_value(m_secondary_slider->value() - 1); + m_secondary_slider->decrease_slider_by(1); break; case KeyCode::Key_RightBrace: if (m_secondary_slider) diff --git a/Userland/Libraries/LibGUI/OpacitySlider.cpp b/Userland/Libraries/LibGUI/OpacitySlider.cpp index f97d7a0ef4..d8cc98e457 100644 --- a/Userland/Libraries/LibGUI/OpacitySlider.cpp +++ b/Userland/Libraries/LibGUI/OpacitySlider.cpp @@ -139,7 +139,7 @@ void OpacitySlider::mouseup_event(MouseEvent& event) void OpacitySlider::mousewheel_event(MouseEvent& event) { - set_value(value() - event.wheel_delta()); + decrease_slider_by(event.wheel_delta()); } } diff --git a/Userland/Libraries/LibGUI/Scrollbar.cpp b/Userland/Libraries/LibGUI/Scrollbar.cpp index 467d68443b..e1f303b156 100644 --- a/Userland/Libraries/LibGUI/Scrollbar.cpp +++ b/Userland/Libraries/LibGUI/Scrollbar.cpp @@ -329,7 +329,7 @@ void Scrollbar::scroll_by_page(const Gfx::IntPoint& click_position) if (click_position.primary_offset_for_orientation(orientation()) < scrubber_rect().primary_offset_for_orientation(orientation())) { gutter_click_state = GutterClickState::BeforeScrubber; - set_value(value() - page_increment); + decrease_slider_by(page_increment); } else { gutter_click_state = GutterClickState::AfterScrubber; increase_slider_by(page_increment); diff --git a/Userland/Libraries/LibGUI/Slider.cpp b/Userland/Libraries/LibGUI/Slider.cpp index 70d6f08574..19f7c5cc43 100644 --- a/Userland/Libraries/LibGUI/Slider.cpp +++ b/Userland/Libraries/LibGUI/Slider.cpp @@ -147,7 +147,7 @@ void Slider::mousewheel_event(MouseEvent& event) wheel_delta /= abs(wheel_delta); if (orientation() == Orientation::Horizontal) - set_value(value() - wheel_delta * acceleration_modifier); + decrease_slider_by(wheel_delta * acceleration_modifier); else increase_slider_by(wheel_delta * acceleration_modifier); diff --git a/Userland/Libraries/LibGUI/ValueSlider.cpp b/Userland/Libraries/LibGUI/ValueSlider.cpp index 854e4f0961..79b3b5c342 100644 --- a/Userland/Libraries/LibGUI/ValueSlider.cpp +++ b/Userland/Libraries/LibGUI/ValueSlider.cpp @@ -52,7 +52,7 @@ ValueSlider::ValueSlider(Gfx::Orientation orientation, String suffix) m_textbox->on_down_pressed = [&]() { if (value() > min()) - AbstractSlider::set_value(value() - 1); + AbstractSlider::decrease_slider_by(1); m_textbox->set_text(formatted_value()); }; @@ -161,7 +161,7 @@ void ValueSlider::mousewheel_event(MouseEvent& event) if (event.wheel_delta() < 0) increase_slider_by(1); else - set_value(value() - 1); + decrease_slider_by(1); } void ValueSlider::mousemove_event(MouseEvent& event) diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp index c271113f30..064c77b376 100644 --- a/Userland/Libraries/LibVT/TerminalWidget.cpp +++ b/Userland/Libraries/LibVT/TerminalWidget.cpp @@ -215,7 +215,7 @@ void TerminalWidget::keydown_event(GUI::KeyEvent& event) m_cursor_blink_timer->start(); if (event.key() == KeyCode::Key_PageUp && event.modifiers() == Mod_Shift) { - m_scrollbar->set_value(m_scrollbar->value() - m_terminal.rows()); + m_scrollbar->decrease_slider_by(m_terminal.rows()); return; } if (event.key() == KeyCode::Key_PageDown && event.modifiers() == Mod_Shift) { diff --git a/Userland/Libraries/LibWeb/InProcessWebView.cpp b/Userland/Libraries/LibWeb/InProcessWebView.cpp index e0c2b1df8d..bc26f73fad 100644 --- a/Userland/Libraries/LibWeb/InProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/InProcessWebView.cpp @@ -269,7 +269,7 @@ void InProcessWebView::keydown_event(GUI::KeyEvent& event) vertical_scrollbar().increase_slider_by(frame_inner_rect().height()); break; case Key_PageUp: - vertical_scrollbar().set_value(vertical_scrollbar().value() - frame_inner_rect().height()); + vertical_scrollbar().decrease_slider_by(frame_inner_rect().height()); break; default: if (!page_accepted_event) { |