mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Everywhere: Use 'increase_slider_by()' method from AbstractSlider
This method help us to avoid repeating the pattern 'set_value(value() + delta)'.
This commit is contained in:
parent
8b8f404146
commit
d53e1fa1fa
12 changed files with 19 additions and 19 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue