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)'.
This commit is contained in:
Elyse 2021-10-31 12:27:52 -06:00 committed by Andreas Kling
parent d53e1fa1fa
commit 086615535f
Notes: sideshowbarker 2024-07-17 21:55:24 +09:00
8 changed files with 10 additions and 10 deletions

View file

@ -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);
}
}
}

View file

@ -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)

View file

@ -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());
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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)

View file

@ -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) {

View file

@ -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) {