From 173a84a2efdb6fa28b4bcafb06e5f954a16f9a36 Mon Sep 17 00:00:00 2001 From: Elyse Date: Sun, 31 Oct 2021 12:38:15 -0600 Subject: [PATCH] LibGUI+SoundPlayer: Use 'decrease_slider_by_page_steps()' method This method allow us to avoid repeating the pattern 'set_value(value() - page_step() * page_number)'. --- .../Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp | 2 +- Userland/Libraries/LibGUI/Slider.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp index 7281ea9425..4065cdc211 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp @@ -152,7 +152,7 @@ void SoundPlayerWidgetAdvancedView::keydown_event(GUI::KeyEvent& event) m_volume_slider->increase_slider_by_page_steps(1); if (event.key() == Key_Down) - m_volume_slider->set_value(m_volume_slider->value() - m_volume_slider->page_step()); + m_volume_slider->decrease_slider_by_page_steps(1); GUI::Widget::keydown_event(event); } diff --git a/Userland/Libraries/LibGUI/Slider.cpp b/Userland/Libraries/LibGUI/Slider.cpp index a30cecbcb9..15998aa433 100644 --- a/Userland/Libraries/LibGUI/Slider.cpp +++ b/Userland/Libraries/LibGUI/Slider.cpp @@ -106,7 +106,7 @@ void Slider::mousedown_event(MouseEvent& event) if (mouse_offset > knob_last_edge) increase_slider_by_page_steps(1); else if (mouse_offset < knob_first_edge) - set_value(value() - page_step()); + decrease_slider_by_page_steps(1); } } return Widget::mousedown_event(event);