mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
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:
parent
d53e1fa1fa
commit
086615535f
Notes:
sideshowbarker
2024-07-17 21:55:24 +09:00
Author: https://github.com/elyse0 Commit: https://github.com/SerenityOS/serenity/commit/086615535f0 Pull-request: https://github.com/SerenityOS/serenity/pull/11163 Reviewed-by: https://github.com/kleinesfilmroellchen ✅ Reviewed-by: https://github.com/metmo ✅
8 changed files with 10 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue