feat(input): additional configuration options
This commit is contained in:
parent
926692200d
commit
02ff3e6445
12 changed files with 423 additions and 287 deletions
|
|
@ -6,7 +6,9 @@ use cosmic::{
|
|||
iced_widget::core::layout,
|
||||
};
|
||||
use cosmic_comp_config::{
|
||||
input::{AccelProfile, InputConfig},
|
||||
input::{
|
||||
AccelConfig, AccelProfile, InputConfig, ScrollConfig, ScrollMethod, TapButtonMap, TapConfig,
|
||||
},
|
||||
XkbConfig,
|
||||
};
|
||||
use cosmic_settings_page as page;
|
||||
|
|
@ -17,19 +19,34 @@ pub mod keyboard;
|
|||
mod mouse;
|
||||
mod touchpad;
|
||||
|
||||
crate::cache_dynamic_lazy! {
|
||||
static ACCELERAION_DESC: String = fl!("acceleration-desc");
|
||||
static DISABLE_WHILE_TYPING: String = fl!("disable-while-typing");
|
||||
static DOUBLE_CLICK_SPEED_DESC: String = fl!("double-click-speed", "desc");
|
||||
static DOUBLE_CLICK_SPEED: String = fl!("double-click-speed");
|
||||
static PRIMARY_BUTTON: String = fl!("primary-button");
|
||||
static SCROLLING_NATURAL_DESC: String = fl!("scrolling", "natural-desc");
|
||||
static SCROLLING_NATURAL: String = fl!("scrolling", "natural");
|
||||
static SCROLLING_SPEED: String = fl!("scrolling", "speed");
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Message {
|
||||
SetAcceleration(bool, bool),
|
||||
SetNaturalScroll(bool, bool),
|
||||
SetScrollFactor(f64, bool),
|
||||
SetDoubleClickSpeed(u32, bool),
|
||||
SetMouseSpeed(f64, bool),
|
||||
PrimaryButtonSelected(cosmic::widget::segmented_button::Entity, bool),
|
||||
CloseSpecialCharacterDialog,
|
||||
// seperate close message, to make sure another isn't closed?
|
||||
DisableWhileTyping(bool, bool),
|
||||
ExpandInputSourcePopover(Option<String>),
|
||||
OpenSpecialCharacterDialog(keyboard::SpecialKey),
|
||||
CloseSpecialCharacterDialog,
|
||||
PinchToZoom(bool),
|
||||
PrimaryButtonSelected(cosmic::widget::segmented_button::Entity, bool),
|
||||
SetAcceleration(bool, bool),
|
||||
SetDoubleClickSpeed(u32, bool),
|
||||
SetMouseSpeed(f64, bool),
|
||||
SetNaturalScroll(bool, bool),
|
||||
SetScrollFactor(f64, bool),
|
||||
SetScrollMethod(Option<ScrollMethod>, bool),
|
||||
SpecialCharacterSelect(Option<&'static str>),
|
||||
TapToClick(bool),
|
||||
}
|
||||
|
||||
pub struct Page {
|
||||
|
|
@ -55,8 +72,8 @@ fn get_config<T: Default + serde::de::DeserializeOwned>(
|
|||
config: &cosmic_config::Config,
|
||||
key: &str,
|
||||
) -> T {
|
||||
config.get(key).unwrap_or_else(|err| {
|
||||
error!(?err, "Failed to read config '{}'", key);
|
||||
config.get(key).unwrap_or_else(|why| {
|
||||
error!(?why, "Failed to read config '{}'", key);
|
||||
T::default()
|
||||
})
|
||||
}
|
||||
|
|
@ -69,19 +86,11 @@ impl Default for Page {
|
|||
let xkb = get_config(&config, "xkb_config");
|
||||
|
||||
let mut primary_button = mouse::default_primary_button();
|
||||
let idx = if input_default.left_handed.unwrap_or(false) {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let idx = input_default.left_handed.unwrap_or(false) as u16;
|
||||
primary_button.activate_position(idx);
|
||||
|
||||
let mut touchpad_primary_button = mouse::default_primary_button();
|
||||
let idx = if input_touchpad.left_handed.unwrap_or(false) {
|
||||
1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let idx = input_touchpad.left_handed.unwrap_or(false) as u16;
|
||||
touchpad_primary_button.activate_position(idx);
|
||||
|
||||
Self {
|
||||
|
|
@ -117,6 +126,7 @@ impl Page {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub fn update(&mut self, message: Message) -> iced::Command<app::Message> {
|
||||
match message {
|
||||
Message::SetAcceleration(value, touchpad) => {
|
||||
|
|
@ -125,26 +135,46 @@ impl Page {
|
|||
} else {
|
||||
AccelProfile::Flat
|
||||
};
|
||||
|
||||
self.update_input(touchpad, |x| {
|
||||
x.acceleration.get_or_insert(Default::default()).profile = Some(profile);
|
||||
x.acceleration.get_or_insert(AccelConfig::default()).profile = Some(profile);
|
||||
});
|
||||
}
|
||||
Message::SetNaturalScroll(value, touchpad) => self.update_input(touchpad, |x| {
|
||||
x.scroll_config
|
||||
.get_or_insert(Default::default())
|
||||
.natural_scroll = Some(value);
|
||||
}),
|
||||
Message::SetScrollFactor(value, touchpad) => self.update_input(touchpad, |x| {
|
||||
x.scroll_config
|
||||
.get_or_insert(Default::default())
|
||||
.scroll_factor = Some(value)
|
||||
|
||||
Message::SetMouseSpeed(value, touchpad) => self.update_input(touchpad, |x| {
|
||||
x.acceleration.get_or_insert(AccelConfig::default()).speed = value;
|
||||
}),
|
||||
|
||||
Message::SetDoubleClickSpeed(_value, _touchpad) => {
|
||||
// TODO
|
||||
}
|
||||
Message::SetMouseSpeed(value, touchpad) => self.update_input(touchpad, |x| {
|
||||
x.acceleration.get_or_insert(Default::default()).speed = value
|
||||
|
||||
Message::DisableWhileTyping(disabled, touchpad) => {
|
||||
self.update_input(touchpad, |conf| {
|
||||
conf.disable_while_typing = Some(disabled);
|
||||
});
|
||||
}
|
||||
|
||||
Message::SetNaturalScroll(enabled, touchpad) => self.update_input(touchpad, |x| {
|
||||
x.scroll_config
|
||||
.get_or_insert(ScrollConfig::default())
|
||||
.natural_scroll = Some(enabled);
|
||||
}),
|
||||
|
||||
Message::SetScrollFactor(value, touchpad) => self.update_input(touchpad, |x| {
|
||||
x.scroll_config
|
||||
.get_or_insert(ScrollConfig::default())
|
||||
.scroll_factor = Some(value);
|
||||
}),
|
||||
|
||||
Message::SetScrollMethod(method, touchpad) => {
|
||||
self.update_input(touchpad, |conf| {
|
||||
conf.scroll_config
|
||||
.get_or_insert(ScrollConfig::default())
|
||||
.method = method;
|
||||
});
|
||||
}
|
||||
|
||||
Message::PrimaryButtonSelected(entity, touchpad) => {
|
||||
let select_model = if touchpad {
|
||||
&mut self.touchpad_primary_button
|
||||
|
|
@ -152,13 +182,19 @@ impl Page {
|
|||
&mut self.primary_button
|
||||
};
|
||||
select_model.activate(entity);
|
||||
let left_entity = select_model.entity_at(1).unwrap();
|
||||
|
||||
let Some(left_entity) = select_model.entity_at(1) else {
|
||||
return cosmic::Command::none();
|
||||
};
|
||||
|
||||
let left_handed = select_model.active() == left_entity;
|
||||
self.update_input(touchpad, |x| x.left_handed = Some(left_handed));
|
||||
}
|
||||
|
||||
Message::ExpandInputSourcePopover(value) => {
|
||||
self.expanded_source_popover = value;
|
||||
}
|
||||
|
||||
Message::OpenSpecialCharacterDialog(special_key) => {
|
||||
self.special_character_dialog = Some(special_key);
|
||||
let window_settings = SctkWindowSettings {
|
||||
|
|
@ -180,10 +216,12 @@ impl Page {
|
|||
};
|
||||
return commands::window::get_window(window_settings);
|
||||
}
|
||||
|
||||
Message::CloseSpecialCharacterDialog => {
|
||||
self.special_character_dialog = None;
|
||||
return commands::window::close_window(*keyboard::SPECIAL_CHARACTER_DIALOGUE_ID);
|
||||
}
|
||||
|
||||
Message::SpecialCharacterSelect(id) => {
|
||||
if let Some(special_key) = self.special_character_dialog {
|
||||
let options = self.xkb.options.as_deref().unwrap_or("");
|
||||
|
|
@ -191,7 +229,7 @@ impl Page {
|
|||
let new_options = options
|
||||
.split(',')
|
||||
.filter(|x| !x.starts_with(prefix))
|
||||
.chain(id.into_iter())
|
||||
.chain(id)
|
||||
.join(",");
|
||||
self.xkb.options = Some(new_options).filter(|x| !x.is_empty());
|
||||
if let Err(err) = self.config.set("xkb_config", &self.xkb) {
|
||||
|
|
@ -199,8 +237,24 @@ impl Page {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Message::PinchToZoom(_enabled) => {}
|
||||
|
||||
Message::TapToClick(enabled) => {
|
||||
self.update_input(true, |conf| {
|
||||
conf.tap_config
|
||||
.get_or_insert(TapConfig {
|
||||
enabled: true,
|
||||
button_map: Some(TapButtonMap::LeftRightMiddle),
|
||||
drag: true,
|
||||
drag_lock: false,
|
||||
})
|
||||
.enabled = enabled;
|
||||
});
|
||||
}
|
||||
}
|
||||
iced::Command::none()
|
||||
|
||||
cosmic::Command::none()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,15 @@ use slotmap::SlotMap;
|
|||
|
||||
use super::Message;
|
||||
|
||||
crate::cache_dynamic_lazy! {
|
||||
static MOUSE_ACCELERATION: String = fl!("mouse", "acceleration");
|
||||
static MOUSE_SPEED: String = fl!("mouse", "speed");
|
||||
}
|
||||
|
||||
pub fn default_primary_button() -> cosmic::widget::segmented_button::SingleSelectModel {
|
||||
let mut model = cosmic::widget::segmented_button::SingleSelectModel::builder()
|
||||
.insert(|b| b.text(fl!("mouse", "primary-button-left")))
|
||||
.insert(|b| b.text(fl!("mouse", "primary-button-right")))
|
||||
.insert(|b| b.text(fl!("primary-button", "left")))
|
||||
.insert(|b| b.text(fl!("primary-button", "right")))
|
||||
.build();
|
||||
model.activate_position(0);
|
||||
model
|
||||
|
|
@ -40,26 +45,25 @@ impl page::AutoBind<crate::pages::Message> for Page {}
|
|||
fn mouse() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.descriptions(vec![
|
||||
fl!("mouse", "primary-button").into(),
|
||||
fl!("mouse", "speed").into(),
|
||||
fl!("mouse", "acceleration").into(),
|
||||
fl!("mouse", "acceleration-desc").into(),
|
||||
fl!("mouse", "double-click-speed").into(),
|
||||
fl!("mouse", "double-click-speed-desc").into(),
|
||||
super::PRIMARY_BUTTON.as_str().into(),
|
||||
MOUSE_SPEED.as_str().into(),
|
||||
MOUSE_ACCELERATION.as_str().into(),
|
||||
super::ACCELERAION_DESC.as_str().into(),
|
||||
super::DOUBLE_CLICK_SPEED.as_str().into(),
|
||||
super::DOUBLE_CLICK_SPEED_DESC.as_str().into(),
|
||||
])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let descriptions = §ion.descriptions;
|
||||
|
||||
let input = binder.page::<super::Page>().expect("input page not found");
|
||||
|
||||
settings::view_section(§ion.title)
|
||||
.add(settings::item(
|
||||
&*descriptions[0],
|
||||
&*super::PRIMARY_BUTTON,
|
||||
cosmic::widget::segmented_selection::horizontal(&input.primary_button)
|
||||
.minimum_button_width(0)
|
||||
.on_activate(|x| Message::PrimaryButtonSelected(x, false)),
|
||||
))
|
||||
.add(
|
||||
settings::item::builder(&*descriptions[1]).control(widget::slider(
|
||||
settings::item::builder(&*MOUSE_SPEED).control(widget::slider(
|
||||
0.0..=100.0,
|
||||
(input
|
||||
.input_default
|
||||
|
|
@ -72,8 +76,8 @@ fn mouse() -> Section<crate::pages::Message> {
|
|||
)),
|
||||
)
|
||||
.add(
|
||||
settings::item::builder(&*descriptions[2])
|
||||
.description(&*descriptions[3])
|
||||
settings::item::builder(&*MOUSE_ACCELERATION)
|
||||
.description(&*super::ACCELERAION_DESC)
|
||||
.toggler(
|
||||
input
|
||||
.input_default
|
||||
|
|
@ -84,8 +88,8 @@ fn mouse() -> Section<crate::pages::Message> {
|
|||
),
|
||||
)
|
||||
.add(
|
||||
settings::item::builder(&*descriptions[4])
|
||||
.description(&*descriptions[5])
|
||||
settings::item::builder(&*super::DOUBLE_CLICK_SPEED)
|
||||
.description(&*super::DOUBLE_CLICK_SPEED_DESC)
|
||||
.control(widget::slider(0..=100, 0, |x| {
|
||||
Message::SetDoubleClickSpeed(x, false)
|
||||
})),
|
||||
|
|
@ -97,11 +101,11 @@ fn mouse() -> Section<crate::pages::Message> {
|
|||
|
||||
fn scrolling() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.title(fl!("mouse-scrolling"))
|
||||
.title(fl!("scrolling"))
|
||||
.descriptions(vec![
|
||||
fl!("mouse-scrolling", "speed").into(),
|
||||
fl!("mouse-scrolling", "natural").into(),
|
||||
fl!("mouse-scrolling", "natural-desc").into(),
|
||||
fl!("scrolling", "speed").into(),
|
||||
fl!("scrolling", "natural").into(),
|
||||
fl!("scrolling", "natural-desc").into(),
|
||||
])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let descriptions = §ion.descriptions;
|
||||
|
|
|
|||
|
|
@ -1,24 +1,35 @@
|
|||
use apply::Apply;
|
||||
use cosmic::iced::Length;
|
||||
use cosmic::widget::{self, settings};
|
||||
use cosmic::Element;
|
||||
use cosmic_comp_config::input::AccelProfile;
|
||||
use cosmic::{Apply, Element};
|
||||
use cosmic_comp_config::input::{AccelProfile, ScrollMethod};
|
||||
use cosmic_settings_page::Section;
|
||||
use cosmic_settings_page::{self as page, section};
|
||||
use slotmap::SlotMap;
|
||||
use std::borrow::Cow;
|
||||
|
||||
use super::Message;
|
||||
|
||||
crate::cache_dynamic_lazy! {
|
||||
static MOUSE_SCROLL_SPEED: String = fl!("mouse-scrolling", "speed");
|
||||
static MOUSE_SCROLL_NATURAL: String = fl!("mouse-scrolling", "natural");
|
||||
static MOUSE_SCROLL_NATURAL_DESC: String = fl!("mouse-scrolling", "natural-desc");
|
||||
static TOUCHPAD_PRIMARY_BUTTON: String = fl!("touchpad", "primary-button");
|
||||
static TOUCHPAD_SPEED: String = fl!("touchpad", "speed");
|
||||
static EDGE_SCROLLING_DESC: String = fl!("edge-scrolling", "desc");
|
||||
static EDGE_SCROLLING: String = fl!("edge-scrolling");
|
||||
static TWO_FINGER_SCROLLING: String = fl!("two-finger-scrolling");
|
||||
static PINCH_TO_ZOOM_DESC: String = fl!("pinch-to-zoom", "desc");
|
||||
static PINCH_TO_ZOOM: String = fl!("pinch-to-zoom");
|
||||
// static SWIPING_FOUR_FINGER_DOWN: String = fl!("swiping", "four-finger-down");
|
||||
// static SWIPING_FOUR_FINGER_LEFT: String = fl!("swiping", "four-finger-left");
|
||||
// static SWIPING_FOUR_FINGER_RIGHT: String = fl!("swiping", "four-finger-right");
|
||||
// static SWIPING_FOUR_FINGER_UP: String = fl!("swiping", "four-finger-up");
|
||||
// static SWIPING_THREE_FINGER_ANY: String = fl!("swiping", "three-finger-any");
|
||||
// static SWIPING: String = fl!("swiping");
|
||||
static TAP_TO_CLICK_DESC: String = fl!("tap-to-click", "desc");
|
||||
static TAP_TO_CLICK: String = fl!("tap-to-click");
|
||||
static TAPPING_AND_PINCHING: String = fl!("tapping-and-pinching");
|
||||
static TOUCHPAD_ACCELERAION: String = fl!("touchpad", "acceleration");
|
||||
static TOUCHPAD_ACCELERAION_DESC: String = fl!("touchpad", "acceleration-desc");
|
||||
static TOUCHPAD_DOUBLE_CLICK_SPEED: String = fl!("touchpad", "double-click-speed");
|
||||
static TOUCHPAD_DOUBLE_CLICK_SPEED_DESC: String = fl!("touchpad", "double-click-speed-desc");
|
||||
static TOUCHPAD_SPEED: String = fl!("touchpad", "speed");
|
||||
// static SWITCH_BETWEEN_WINDOWS: String = fl!("switch-between-windows");
|
||||
// static SWITCH_TO_NEXT_WORKSPACE: String = fl!("switch-to-next-workspace");
|
||||
// static SWITCH_TO_PREV_WORKSPACE: String = fl!("switch-to-prev-workspace");
|
||||
// static OPEN_APPLICATION_LIBRARY: String = fl!("open-application-library");
|
||||
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -31,7 +42,9 @@ impl page::Page<crate::pages::Message> for Page {
|
|||
) -> Option<page::Content> {
|
||||
Some(vec![
|
||||
sections.insert(touchpad()),
|
||||
sections.insert(tapping_and_pinching()),
|
||||
sections.insert(scrolling()),
|
||||
// sections.insert(swiping()),
|
||||
])
|
||||
}
|
||||
|
||||
|
|
@ -47,20 +60,22 @@ impl page::AutoBind<crate::pages::Message> for Page {}
|
|||
fn touchpad() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.descriptions(vec![
|
||||
TOUCHPAD_PRIMARY_BUTTON.as_str().into(),
|
||||
super::PRIMARY_BUTTON.as_str().into(),
|
||||
TOUCHPAD_SPEED.as_str().into(),
|
||||
TOUCHPAD_ACCELERAION.as_str().into(),
|
||||
TOUCHPAD_ACCELERAION_DESC.as_str().into(),
|
||||
TOUCHPAD_DOUBLE_CLICK_SPEED.as_str().into(),
|
||||
TOUCHPAD_DOUBLE_CLICK_SPEED_DESC.as_str().into(),
|
||||
super::ACCELERAION_DESC.as_str().into(),
|
||||
super::DISABLE_WHILE_TYPING.as_str().into(),
|
||||
super::DOUBLE_CLICK_SPEED.as_str().into(),
|
||||
super::DOUBLE_CLICK_SPEED_DESC.as_str().into(),
|
||||
])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let input = binder.page::<super::Page>().expect("input page not found");
|
||||
|
||||
settings::view_section(§ion.title)
|
||||
.add(settings::item(
|
||||
&*TOUCHPAD_PRIMARY_BUTTON,
|
||||
&*super::PRIMARY_BUTTON,
|
||||
cosmic::widget::segmented_selection::horizontal(&input.touchpad_primary_button)
|
||||
.minimum_button_width(0)
|
||||
.on_activate(|x| Message::PrimaryButtonSelected(x, true)),
|
||||
))
|
||||
.add(
|
||||
|
|
@ -78,7 +93,7 @@ fn touchpad() -> Section<crate::pages::Message> {
|
|||
)
|
||||
.add(
|
||||
settings::item::builder(&*TOUCHPAD_ACCELERAION)
|
||||
.description(&*TOUCHPAD_ACCELERAION_DESC)
|
||||
.description(&*super::ACCELERAION_DESC)
|
||||
.toggler(
|
||||
input
|
||||
.input_touchpad
|
||||
|
|
@ -88,10 +103,15 @@ fn touchpad() -> Section<crate::pages::Message> {
|
|||
|x| Message::SetAcceleration(x, true),
|
||||
),
|
||||
)
|
||||
// TODO disable while typing
|
||||
.add(
|
||||
settings::item::builder(&*TOUCHPAD_DOUBLE_CLICK_SPEED)
|
||||
.description(&*TOUCHPAD_DOUBLE_CLICK_SPEED_DESC)
|
||||
settings::item::builder(&*super::DISABLE_WHILE_TYPING).toggler(
|
||||
input.input_touchpad.disable_while_typing.unwrap_or(false),
|
||||
|enabled| Message::DisableWhileTyping(enabled, true),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
settings::item::builder(&*super::DOUBLE_CLICK_SPEED)
|
||||
.description(&*super::DOUBLE_CLICK_SPEED_DESC)
|
||||
.control(widget::slider(0..=100, 0, |x| {
|
||||
Message::SetDoubleClickSpeed(x, true)
|
||||
})),
|
||||
|
|
@ -101,26 +121,61 @@ fn touchpad() -> Section<crate::pages::Message> {
|
|||
})
|
||||
}
|
||||
|
||||
fn tapping_and_pinching() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.title(fl!("tapping-and-pinching"))
|
||||
.descriptions(vec![
|
||||
TAP_TO_CLICK.as_str().into(),
|
||||
TAP_TO_CLICK_DESC.as_str().into(),
|
||||
PINCH_TO_ZOOM.as_str().into(),
|
||||
PINCH_TO_ZOOM_DESC.as_str().into(),
|
||||
])
|
||||
.view::<Page>(|binder, _page, _section| {
|
||||
let page = binder
|
||||
.page::<super::Page>()
|
||||
.expect("input devices page not found");
|
||||
|
||||
settings::view_section(&*TAPPING_AND_PINCHING)
|
||||
.add(
|
||||
settings::item::builder(&*TAP_TO_CLICK).toggler(
|
||||
page.input_touchpad
|
||||
.tap_config
|
||||
.as_ref()
|
||||
.map_or(false, |x| x.enabled),
|
||||
Message::TapToClick,
|
||||
),
|
||||
)
|
||||
.add(settings::item::builder(&*PINCH_TO_ZOOM).toggler(false, Message::PinchToZoom))
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Input)
|
||||
})
|
||||
}
|
||||
|
||||
fn scrolling() -> Section<crate::pages::Message> {
|
||||
Section::default()
|
||||
.title(fl!("mouse-scrolling"))
|
||||
.title(fl!("scrolling"))
|
||||
.descriptions(vec![
|
||||
MOUSE_SCROLL_SPEED.as_str().into(),
|
||||
MOUSE_SCROLL_NATURAL.as_str().into(),
|
||||
MOUSE_SCROLL_NATURAL_DESC.as_str().into(),
|
||||
super::SCROLLING_SPEED.as_str().into(),
|
||||
super::SCROLLING_NATURAL.as_str().into(),
|
||||
super::SCROLLING_NATURAL_DESC.as_str().into(),
|
||||
TWO_FINGER_SCROLLING.as_str().into(),
|
||||
EDGE_SCROLLING.as_str().into(),
|
||||
EDGE_SCROLLING_DESC.as_str().into(),
|
||||
])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let input = binder.page::<super::Page>().expect("input page not found");
|
||||
let page = binder
|
||||
.page::<super::Page>()
|
||||
.expect("input devices page not found");
|
||||
|
||||
settings::view_section(§ion.title)
|
||||
// Scroll speed slider
|
||||
.add(settings::item(
|
||||
&*MOUSE_SCROLL_SPEED,
|
||||
&*super::SCROLLING_SPEED,
|
||||
// TODO show numeric value
|
||||
// TODO desired range?
|
||||
widget::slider(
|
||||
1.0..=100.0,
|
||||
input
|
||||
.input_touchpad
|
||||
1.0..=1000.0,
|
||||
page.input_touchpad
|
||||
.scroll_config
|
||||
.as_ref()
|
||||
.and_then(|x| x.scroll_factor)
|
||||
|
|
@ -131,20 +186,63 @@ fn scrolling() -> Section<crate::pages::Message> {
|
|||
|value| Message::SetScrollFactor(2f64.powf((value - 50.0) / 10.0), true),
|
||||
),
|
||||
))
|
||||
// Natural scrolling toggle
|
||||
.add(
|
||||
settings::item::builder(&*MOUSE_SCROLL_NATURAL)
|
||||
.description(&*MOUSE_SCROLL_NATURAL_DESC)
|
||||
settings::item::builder(&*super::SCROLLING_NATURAL)
|
||||
.description(&*super::SCROLLING_NATURAL_DESC)
|
||||
.toggler(
|
||||
input
|
||||
.input_touchpad
|
||||
page.input_touchpad
|
||||
.scroll_config
|
||||
.as_ref()
|
||||
.and_then(|x| x.natural_scroll)
|
||||
.unwrap_or(false),
|
||||
|x| Message::SetNaturalScroll(x, true),
|
||||
.map_or(false, |conf| conf.natural_scroll.unwrap_or(false)),
|
||||
|enabled| Message::SetNaturalScroll(enabled, true),
|
||||
),
|
||||
)
|
||||
// Two-finger scrolling toggle
|
||||
.add(
|
||||
settings::item::builder(&*TWO_FINGER_SCROLLING).toggler(
|
||||
page.input_touchpad
|
||||
.scroll_config
|
||||
.as_ref()
|
||||
.map_or(false, |x| matches!(x.method, Some(ScrollMethod::TwoFinger))),
|
||||
|enabled| {
|
||||
Message::SetScrollMethod(
|
||||
enabled.then_some(ScrollMethod::TwoFinger),
|
||||
true,
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
// Edge scrolling toggle
|
||||
.add(
|
||||
settings::item::builder(&*EDGE_SCROLLING)
|
||||
.description(&*EDGE_SCROLLING_DESC)
|
||||
.toggler(
|
||||
page.input_touchpad
|
||||
.scroll_config
|
||||
.as_ref()
|
||||
.map_or(false, |x| matches!(x.method, Some(ScrollMethod::Edge))),
|
||||
|enabled| {
|
||||
Message::SetScrollMethod(
|
||||
enabled.then_some(ScrollMethod::Edge),
|
||||
true,
|
||||
)
|
||||
},
|
||||
),
|
||||
)
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::Input)
|
||||
})
|
||||
}
|
||||
|
||||
// fn swiping() -> Section<crate::pages::Message> {
|
||||
// Section::default()
|
||||
// .title(&*SWIPING)
|
||||
// .descriptions(vec![
|
||||
// SWIPING_FOUR_FINGER_DOWN.as_str().into(),
|
||||
// SWIPING_FOUR_FINGER_LEFT.as_str().into(),
|
||||
// SWIPING_FOUR_FINGER_RIGHT.as_str().into(),
|
||||
// SWIPING_FOUR_FINGER_UP.as_str().into(),
|
||||
// SWIPING_THREE_FINGER_ANY.as_str().into(),
|
||||
// ])
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue