MouseSettings: Add "Natural scrolling" toggle
This commit is contained in:
parent
5a083c03a6
commit
2e3efd34c3
Notes:
sideshowbarker
2024-07-17 03:44:21 +09:00
Author: https://github.com/filiphsps Commit: https://github.com/SerenityOS/serenity/commit/2e3efd34c3 Pull-request: https://github.com/SerenityOS/serenity/pull/16265 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/linusg
3 changed files with 22 additions and 4 deletions
|
@ -53,7 +53,7 @@
|
|||
}
|
||||
|
||||
@GUI::GroupBox {
|
||||
title: "Scroll Wheel Step Size"
|
||||
title: "Scroll Wheel"
|
||||
fixed_height: 106
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [6]
|
||||
|
@ -79,7 +79,7 @@
|
|||
|
||||
@GUI::Widget {
|
||||
layout: @GUI::HorizontalBoxLayout {
|
||||
margins: [8]
|
||||
margins: [4, 0, 2, 8]
|
||||
spacing: 8
|
||||
}
|
||||
|
||||
|
@ -97,10 +97,19 @@
|
|||
min: 0
|
||||
max: 100
|
||||
value: 50
|
||||
fixed_width: 100
|
||||
preferred_width: "opportunistic_grow"
|
||||
}
|
||||
|
||||
@GUI::Layout::Spacer {}
|
||||
@GUI::Widget {
|
||||
fixed_width: 16
|
||||
}
|
||||
|
||||
@GUI::CheckBox {
|
||||
name: "natural_scroll_checkbox"
|
||||
text: "Natural scrolling"
|
||||
tooltip: "Content follows motion instead of the viewport,\nalso commonly referred to as \"reverse scrolling\"."
|
||||
preferred_width: 108
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,12 @@ MouseWidget::MouseWidget()
|
|||
set_modified(true);
|
||||
};
|
||||
|
||||
m_natural_scroll_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("natural_scroll_checkbox");
|
||||
m_natural_scroll_checkbox->set_checked(GUI::ConnectionToWindowServer::the().is_natural_scroll(), GUI::AllowCallback::No);
|
||||
m_natural_scroll_checkbox->on_checked = [&](auto) {
|
||||
set_modified(true);
|
||||
};
|
||||
|
||||
update_speed_label();
|
||||
update_double_click_speed_label();
|
||||
m_double_click_arrow_widget->set_double_click_speed(m_double_click_speed_slider->value());
|
||||
|
@ -69,6 +75,7 @@ void MouseWidget::apply_settings()
|
|||
GUI::ConnectionToWindowServer::the().async_set_scroll_step_size(m_scroll_length_spinbox->value());
|
||||
GUI::ConnectionToWindowServer::the().async_set_double_click_speed(m_double_click_speed_slider->value());
|
||||
GUI::ConnectionToWindowServer::the().async_set_buttons_switched(m_switch_buttons_checkbox->is_checked());
|
||||
GUI::ConnectionToWindowServer::the().async_set_natural_scroll(m_natural_scroll_checkbox->is_checked());
|
||||
}
|
||||
|
||||
void MouseWidget::reset_default_values()
|
||||
|
@ -77,6 +84,7 @@ void MouseWidget::reset_default_values()
|
|||
m_scroll_length_spinbox->set_value(default_scroll_length);
|
||||
m_double_click_speed_slider->set_value(double_click_speed_default);
|
||||
m_switch_buttons_checkbox->set_checked(false);
|
||||
m_natural_scroll_checkbox->set_checked(false);
|
||||
}
|
||||
|
||||
void MouseWidget::update_speed_label()
|
||||
|
|
|
@ -31,5 +31,6 @@ private:
|
|||
RefPtr<GUI::HorizontalSlider> m_double_click_speed_slider;
|
||||
RefPtr<GUI::Label> m_double_click_speed_label;
|
||||
RefPtr<GUI::CheckBox> m_switch_buttons_checkbox;
|
||||
RefPtr<GUI::CheckBox> m_natural_scroll_checkbox;
|
||||
RefPtr<MouseSettings::DoubleClickArrowWidget> m_double_click_arrow_widget;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue