summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElyse <kevincristian@outlook.com>2021-12-28 21:47:26 -0600
committerAndreas Kling <kling@serenityos.org>2021-12-30 14:31:50 +0100
commitd53e1fa1fa62cdbb5ead03c5a52f5690d86235a6 (patch)
treeee6b5f7df6eb8676d58bac0c380ef09afd09f825
parent8b8f4041466c40acce1adb14882de752020082fb (diff)
downloadserenity-d53e1fa1fa62cdbb5ead03c5a52f5690d86235a6.zip
Everywhere: Use 'increase_slider_by()' method from AbstractSlider
This method help us to avoid repeating the pattern 'set_value(value() + delta)'.
-rw-r--r--Userland/Applications/PDFViewer/PDFViewer.cpp2
-rw-r--r--Userland/Applications/Piano/RollWidget.cpp2
-rw-r--r--Userland/Applications/PixelPaint/LayerListWidget.cpp2
-rw-r--r--Userland/Applications/PixelPaint/Tools/Tool.cpp4
-rw-r--r--Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp4
-rw-r--r--Userland/Libraries/LibGUI/AbstractView.cpp4
-rw-r--r--Userland/Libraries/LibGUI/Scrollbar.cpp2
-rw-r--r--Userland/Libraries/LibGUI/Slider.cpp2
-rw-r--r--Userland/Libraries/LibGUI/ValueSlider.cpp4
-rw-r--r--Userland/Libraries/LibVT/TerminalWidget.cpp6
-rw-r--r--Userland/Libraries/LibWeb/InProcessWebView.cpp2
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.cpp4
12 files changed, 19 insertions, 19 deletions
diff --git a/Userland/Applications/PDFViewer/PDFViewer.cpp b/Userland/Applications/PDFViewer/PDFViewer.cpp
index a5fc4bb67d..57ff4ab869 100644
--- a/Userland/Applications/PDFViewer/PDFViewer.cpp
+++ b/Userland/Applications/PDFViewer/PDFViewer.cpp
@@ -95,7 +95,7 @@ void PDFViewer::mousewheel_event(GUI::MouseEvent& event)
scrollbar.set_value(0);
}
} else {
- scrollbar.set_value(scrollbar.value() + 20);
+ scrollbar.increase_slider_by(20);
}
} else {
if (scrollbar.value() == 0) {
diff --git a/Userland/Applications/Piano/RollWidget.cpp b/Userland/Applications/Piano/RollWidget.cpp
index d2c6312dbd..915da0e294 100644
--- a/Userland/Applications/Piano/RollWidget.cpp
+++ b/Userland/Applications/Piano/RollWidget.cpp
@@ -239,7 +239,7 @@ void RollWidget::mouseup_event([[maybe_unused]] GUI::MouseEvent& event)
void RollWidget::mousewheel_event(GUI::MouseEvent& event)
{
if (event.modifiers() & KeyModifier::Mod_Shift) {
- horizontal_scrollbar().set_value(horizontal_scrollbar().value() + (event.wheel_delta() * horizontal_scroll_sensitivity));
+ horizontal_scrollbar().increase_slider_by(event.wheel_delta() * horizontal_scroll_sensitivity);
return;
}
diff --git a/Userland/Applications/PixelPaint/LayerListWidget.cpp b/Userland/Applications/PixelPaint/LayerListWidget.cpp
index 3414c57c7a..0a4b4f92cb 100644
--- a/Userland/Applications/PixelPaint/LayerListWidget.cpp
+++ b/Userland/Applications/PixelPaint/LayerListWidget.cpp
@@ -248,7 +248,7 @@ void LayerListWidget::on_automatic_scrolling_timer_fired()
if (vertical_scrollbar().is_max() && m_automatic_scroll_delta.y() > 0)
return;
- vertical_scrollbar().set_value(vertical_scrollbar().value() + m_automatic_scroll_delta.y());
+ vertical_scrollbar().increase_slider_by(m_automatic_scroll_delta.y());
gadget.movement_delta.set_y(gadget.movement_delta.y() + m_automatic_scroll_delta.y());
auto inner_rect_max_height = widget_inner_rect().height() - 2 + vertical_scrollbar().max();
diff --git a/Userland/Applications/PixelPaint/Tools/Tool.cpp b/Userland/Applications/PixelPaint/Tools/Tool.cpp
index d1e6f9f6b2..1165f11d74 100644
--- a/Userland/Applications/PixelPaint/Tools/Tool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/Tool.cpp
@@ -38,7 +38,7 @@ void Tool::on_keydown(GUI::KeyEvent& event)
break;
case KeyCode::Key_RightBracket:
if (m_primary_slider)
- m_primary_slider->set_value(m_primary_slider->value() + 1);
+ m_primary_slider->increase_slider_by(1);
break;
case KeyCode::Key_LeftBrace:
if (m_secondary_slider)
@@ -46,7 +46,7 @@ void Tool::on_keydown(GUI::KeyEvent& event)
break;
case KeyCode::Key_RightBrace:
if (m_secondary_slider)
- m_secondary_slider->set_value(m_secondary_slider->value() + 1);
+ m_secondary_slider->increase_slider_by(1);
break;
default:
break;
diff --git a/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp b/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp
index 702079c5e1..963f230c7d 100644
--- a/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp
+++ b/Userland/Libraries/LibGUI/AbstractScrollableWidget.cpp
@@ -49,9 +49,9 @@ void AbstractScrollableWidget::handle_wheel_event(MouseEvent& event, Widget& eve
}
// FIXME: The wheel delta multiplier should probably come from... somewhere?
if (event.shift() || &event_source == m_horizontal_scrollbar.ptr()) {
- horizontal_scrollbar().set_value(horizontal_scrollbar().value() + event.wheel_delta() * 60);
+ horizontal_scrollbar().increase_slider_by(event.wheel_delta() * 60);
} else {
- vertical_scrollbar().set_value(vertical_scrollbar().value() + event.wheel_delta() * 20);
+ vertical_scrollbar().increase_slider_by(event.wheel_delta() * 20);
}
}
diff --git a/Userland/Libraries/LibGUI/AbstractView.cpp b/Userland/Libraries/LibGUI/AbstractView.cpp
index 1af93ffa35..2b4da3728b 100644
--- a/Userland/Libraries/LibGUI/AbstractView.cpp
+++ b/Userland/Libraries/LibGUI/AbstractView.cpp
@@ -797,8 +797,8 @@ void AbstractView::on_automatic_scrolling_timer_fired()
if (m_automatic_scroll_delta.is_null())
return;
- vertical_scrollbar().set_value(vertical_scrollbar().value() + m_automatic_scroll_delta.y());
- horizontal_scrollbar().set_value(horizontal_scrollbar().value() + m_automatic_scroll_delta.x());
+ vertical_scrollbar().increase_slider_by(m_automatic_scroll_delta.y());
+ horizontal_scrollbar().increase_slider_by(m_automatic_scroll_delta.x());
}
}
diff --git a/Userland/Libraries/LibGUI/Scrollbar.cpp b/Userland/Libraries/LibGUI/Scrollbar.cpp
index b6c108a196..467d68443b 100644
--- a/Userland/Libraries/LibGUI/Scrollbar.cpp
+++ b/Userland/Libraries/LibGUI/Scrollbar.cpp
@@ -332,7 +332,7 @@ void Scrollbar::scroll_by_page(const Gfx::IntPoint& click_position)
set_value(value() - page_increment);
} else {
gutter_click_state = GutterClickState::AfterScrubber;
- set_value(value() + page_increment);
+ increase_slider_by(page_increment);
}
}
diff --git a/Userland/Libraries/LibGUI/Slider.cpp b/Userland/Libraries/LibGUI/Slider.cpp
index 355d407132..70d6f08574 100644
--- a/Userland/Libraries/LibGUI/Slider.cpp
+++ b/Userland/Libraries/LibGUI/Slider.cpp
@@ -149,7 +149,7 @@ void Slider::mousewheel_event(MouseEvent& event)
if (orientation() == Orientation::Horizontal)
set_value(value() - wheel_delta * acceleration_modifier);
else
- set_value(value() + wheel_delta * acceleration_modifier);
+ increase_slider_by(wheel_delta * acceleration_modifier);
Widget::mousewheel_event(event);
}
diff --git a/Userland/Libraries/LibGUI/ValueSlider.cpp b/Userland/Libraries/LibGUI/ValueSlider.cpp
index 64f3cf2f35..854e4f0961 100644
--- a/Userland/Libraries/LibGUI/ValueSlider.cpp
+++ b/Userland/Libraries/LibGUI/ValueSlider.cpp
@@ -46,7 +46,7 @@ ValueSlider::ValueSlider(Gfx::Orientation orientation, String suffix)
m_textbox->on_up_pressed = [&]() {
if (value() < max())
- AbstractSlider::set_value(value() + 1);
+ AbstractSlider::increase_slider_by(1);
m_textbox->set_text(formatted_value());
};
@@ -159,7 +159,7 @@ void ValueSlider::leave_event(Core::Event&)
void ValueSlider::mousewheel_event(MouseEvent& event)
{
if (event.wheel_delta() < 0)
- set_value(value() + 1);
+ increase_slider_by(1);
else
set_value(value() - 1);
}
diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp
index f1454aa5b1..c271113f30 100644
--- a/Userland/Libraries/LibVT/TerminalWidget.cpp
+++ b/Userland/Libraries/LibVT/TerminalWidget.cpp
@@ -107,7 +107,7 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy)
m_auto_scroll_timer->on_timeout = [this] {
if (m_auto_scroll_direction != AutoScrollDirection::None) {
int scroll_amount = m_auto_scroll_direction == AutoScrollDirection::Up ? -1 : 1;
- m_scrollbar->set_value(m_scrollbar->value() + scroll_amount);
+ m_scrollbar->increase_slider_by(scroll_amount);
}
};
m_auto_scroll_timer->start();
@@ -219,7 +219,7 @@ void TerminalWidget::keydown_event(GUI::KeyEvent& event)
return;
}
if (event.key() == KeyCode::Key_PageDown && event.modifiers() == Mod_Shift) {
- m_scrollbar->set_value(m_scrollbar->value() + m_terminal.rows());
+ m_scrollbar->increase_slider_by(m_terminal.rows());
return;
}
if (event.key() == KeyCode::Key_Alt) {
@@ -916,7 +916,7 @@ void TerminalWidget::mousewheel_event(GUI::MouseEvent& event)
if (!is_scrollable())
return;
set_auto_scroll_direction(AutoScrollDirection::None);
- m_scrollbar->set_value(m_scrollbar->value() + event.wheel_delta() * scroll_length());
+ m_scrollbar->increase_slider_by(event.wheel_delta() * scroll_length());
GUI::Frame::mousewheel_event(event);
}
diff --git a/Userland/Libraries/LibWeb/InProcessWebView.cpp b/Userland/Libraries/LibWeb/InProcessWebView.cpp
index dc7361ad12..e0c2b1df8d 100644
--- a/Userland/Libraries/LibWeb/InProcessWebView.cpp
+++ b/Userland/Libraries/LibWeb/InProcessWebView.cpp
@@ -266,7 +266,7 @@ void InProcessWebView::keydown_event(GUI::KeyEvent& event)
horizontal_scrollbar().set_value(horizontal_scrollbar().value() - horizontal_scrollbar().step());
break;
case Key_PageDown:
- vertical_scrollbar().set_value(vertical_scrollbar().value() + frame_inner_rect().height());
+ vertical_scrollbar().increase_slider_by(frame_inner_rect().height());
break;
case Key_PageUp:
vertical_scrollbar().set_value(vertical_scrollbar().value() - frame_inner_rect().height());
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
index 3e418e5881..a3aa229c22 100644
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
+++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
@@ -243,8 +243,8 @@ void OutOfProcessWebView::notify_server_did_change_title(Badge<WebContentClient>
void OutOfProcessWebView::notify_server_did_request_scroll(Badge<WebContentClient>, i32 x_delta, i32 y_delta)
{
- horizontal_scrollbar().set_value(horizontal_scrollbar().value() + x_delta);
- vertical_scrollbar().set_value(vertical_scrollbar().value() + y_delta);
+ horizontal_scrollbar().increase_slider_by(x_delta);
+ vertical_scrollbar().increase_slider_by(y_delta);
}
void OutOfProcessWebView::notify_server_did_request_scroll_to(Badge<WebContentClient>, Gfx::IntPoint const& scroll_position)