improv(inputs): fix visual style of slider controls
This commit is contained in:
parent
9c95e2a7c0
commit
3de1aa31fa
6 changed files with 226 additions and 195 deletions
|
|
@ -2,10 +2,10 @@ use cosmic::{
|
|||
cctk::sctk::reexports::client::{backend::ObjectId, protocol::wl_output::WlOutput, Proxy},
|
||||
cosmic_config::{self, CosmicConfigEntry},
|
||||
iced::Length,
|
||||
iced_widget::slider,
|
||||
theme,
|
||||
widget::{
|
||||
button, container, dropdown, horizontal_space, icon, list, row, settings, text, toggler,
|
||||
button, container, dropdown, horizontal_space, icon, list, row, settings, slider, text,
|
||||
toggler,
|
||||
},
|
||||
Element,
|
||||
};
|
||||
|
|
@ -208,6 +208,7 @@ pub(crate) fn style<
|
|||
slider(0..=100, (panel_config.opacity * 100.0) as i32, |v| {
|
||||
Message::Opacity(v as f32 / 100.0)
|
||||
})
|
||||
.breakpoints(&[50])
|
||||
.into(),
|
||||
text(fl!("number", HashMap::from_iter(vec![("number", 100)]))).into(),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ pub enum Message {
|
|||
PinchToZoom(bool),
|
||||
PrimaryButtonSelected(cosmic::widget::segmented_button::Entity, bool),
|
||||
SetAcceleration(bool, bool),
|
||||
SetDoubleClickSpeed(u32, bool),
|
||||
SetMouseSpeed(f64, bool),
|
||||
SetNaturalScroll(bool, bool),
|
||||
SetScrollFactor(f64, bool),
|
||||
|
|
@ -143,10 +142,6 @@ impl Page {
|
|||
x.acceleration.get_or_insert(AccelConfig::default()).speed = value;
|
||||
}),
|
||||
|
||||
Message::SetDoubleClickSpeed(_value, _touchpad) => {
|
||||
// TODO
|
||||
}
|
||||
|
||||
Message::DisableWhileTyping(disabled, touchpad) => {
|
||||
self.update_input(touchpad, |conf| {
|
||||
conf.disable_while_typing = Some(disabled);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use apply::Apply;
|
||||
use cosmic::widget::{self, settings};
|
||||
use cosmic::iced::Alignment;
|
||||
use cosmic::widget::{self, row, settings, text};
|
||||
use cosmic::Element;
|
||||
use cosmic_comp_config::input::AccelProfile;
|
||||
use cosmic_settings_page::Section;
|
||||
|
|
@ -52,6 +53,7 @@ fn mouse() -> Section<crate::pages::Message> {
|
|||
])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let input = binder.page::<super::Page>().expect("input page not found");
|
||||
let theme = cosmic::theme::active();
|
||||
|
||||
settings::view_section(§ion.title)
|
||||
.add(settings::item(
|
||||
|
|
@ -60,19 +62,27 @@ fn mouse() -> Section<crate::pages::Message> {
|
|||
.minimum_button_width(0)
|
||||
.on_activate(|x| Message::PrimaryButtonSelected(x, false)),
|
||||
))
|
||||
.add(
|
||||
settings::item::builder(&*MOUSE_SPEED).control(widget::slider(
|
||||
1.0..=80.0,
|
||||
(input
|
||||
.input_default
|
||||
.acceleration
|
||||
.as_ref()
|
||||
.map_or(0.0, |x| x.speed)
|
||||
+ 1.0)
|
||||
* 50.0,
|
||||
|value| Message::SetMouseSpeed((value / 50.0) - 1.0, false),
|
||||
)),
|
||||
)
|
||||
.add(settings::item::builder(&*MOUSE_SPEED).control({
|
||||
let value = (input
|
||||
.input_default
|
||||
.acceleration
|
||||
.as_ref()
|
||||
.map_or(0.0, |x| x.speed)
|
||||
+ 1.0)
|
||||
* 50.0;
|
||||
|
||||
let slider = widget::slider(10.0..=80.0, value, |value| {
|
||||
Message::SetMouseSpeed((value / 50.0) - 1.0, false)
|
||||
})
|
||||
.width(250.0)
|
||||
.breakpoints(&[45.0]);
|
||||
|
||||
row::with_capacity(2)
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(theme.cosmic().space_s())
|
||||
.push(text(format!("{:.0}", value.round())))
|
||||
.push(slider)
|
||||
}))
|
||||
.add(
|
||||
settings::item::builder(&*MOUSE_ACCELERATION)
|
||||
.description(&*super::ACCELERATION_DESC)
|
||||
|
|
@ -94,37 +104,41 @@ fn scrolling() -> Section<crate::pages::Message> {
|
|||
Section::default()
|
||||
.title(fl!("scrolling"))
|
||||
.descriptions(vec![
|
||||
fl!("scrolling", "speed").into(),
|
||||
fl!("scrolling", "natural").into(),
|
||||
fl!("scrolling", "natural-desc").into(),
|
||||
super::SCROLLING_SPEED.as_str().into(),
|
||||
super::SCROLLING_NATURAL.as_str().into(),
|
||||
super::SCROLLING_NATURAL_DESC.as_str().into(),
|
||||
])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let descriptions = §ion.descriptions;
|
||||
|
||||
let input = binder.page::<super::Page>().expect("input page not found");
|
||||
let theme = cosmic::theme::active();
|
||||
|
||||
settings::view_section(§ion.title)
|
||||
.add(settings::item(
|
||||
&*descriptions[0],
|
||||
// TODO show numeric value
|
||||
// TODO desired range?
|
||||
widget::slider(
|
||||
1.0..=100.0,
|
||||
input
|
||||
.input_default
|
||||
.scroll_config
|
||||
.as_ref()
|
||||
.and_then(|x| x.scroll_factor)
|
||||
.unwrap_or(1.)
|
||||
.log(2.)
|
||||
* 10.0
|
||||
+ 50.0,
|
||||
|value| Message::SetScrollFactor(2f64.powf((value - 50.0) / 10.0), false),
|
||||
),
|
||||
))
|
||||
.add(settings::item(&*super::SCROLLING_SPEED, {
|
||||
let value = input
|
||||
.input_default
|
||||
.scroll_config
|
||||
.as_ref()
|
||||
.and_then(|x| x.scroll_factor)
|
||||
.unwrap_or(1.)
|
||||
.log(2.)
|
||||
* 10.0
|
||||
+ 50.0;
|
||||
|
||||
let slider = widget::slider(1.0..=100.0, value, |value| {
|
||||
Message::SetScrollFactor(2f64.powf((value - 50.0) / 10.0), false)
|
||||
})
|
||||
.width(250.0)
|
||||
.breakpoints(&[50.0]);
|
||||
|
||||
row::with_capacity(2)
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(theme.cosmic().space_s())
|
||||
.push(text(format!("{:.0}", value.round())))
|
||||
.push(slider)
|
||||
}))
|
||||
.add(
|
||||
settings::item::builder(&*descriptions[1])
|
||||
.description(&*descriptions[2])
|
||||
settings::item::builder(&*super::SCROLLING_NATURAL)
|
||||
.description(&*super::SCROLLING_NATURAL_DESC)
|
||||
.toggler(
|
||||
input
|
||||
.input_default
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use cosmic::widget::{self, settings, text};
|
||||
use cosmic::iced::Alignment;
|
||||
use cosmic::widget::{self, row, settings, text};
|
||||
use cosmic::{Apply, Element};
|
||||
use cosmic_comp_config::input::{AccelProfile, ScrollMethod};
|
||||
use cosmic_settings_page::Section;
|
||||
|
|
@ -67,6 +68,7 @@ fn touchpad() -> Section<crate::pages::Message> {
|
|||
])
|
||||
.view::<Page>(|binder, _page, section| {
|
||||
let input = binder.page::<super::Page>().expect("input page not found");
|
||||
let theme = cosmic::theme::active();
|
||||
|
||||
settings::view_section(§ion.title)
|
||||
.add(settings::item(
|
||||
|
|
@ -75,19 +77,27 @@ fn touchpad() -> Section<crate::pages::Message> {
|
|||
.minimum_button_width(0)
|
||||
.on_activate(|x| Message::PrimaryButtonSelected(x, true)),
|
||||
))
|
||||
.add(
|
||||
settings::item::builder(&*TOUCHPAD_SPEED).control(widget::slider(
|
||||
10.0..=90.0,
|
||||
(input
|
||||
.input_touchpad
|
||||
.acceleration
|
||||
.as_ref()
|
||||
.map_or(0.0, |x| x.speed)
|
||||
+ 1.0)
|
||||
* 50.0,
|
||||
|value| Message::SetMouseSpeed((value / 50.0) - 1.0, true),
|
||||
)),
|
||||
)
|
||||
.add(settings::item::builder(&*TOUCHPAD_SPEED).control({
|
||||
let value = (input
|
||||
.input_touchpad
|
||||
.acceleration
|
||||
.as_ref()
|
||||
.map_or(0.0, |x| x.speed)
|
||||
+ 1.0)
|
||||
* 50.0;
|
||||
|
||||
let slider = widget::slider(10.0..=90.0, value, |value| {
|
||||
Message::SetMouseSpeed((value / 50.0) - 1.0, true)
|
||||
})
|
||||
.width(250.0)
|
||||
.breakpoints(&[50.0]);
|
||||
|
||||
row::with_capacity(2)
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(theme.cosmic().space_s())
|
||||
.push(text(format!("{:.0}", value.round())))
|
||||
.push(slider)
|
||||
}))
|
||||
.add(
|
||||
settings::item::builder(&*TOUCHPAD_ACCELERAION)
|
||||
.description(&*super::ACCELERATION_DESC)
|
||||
|
|
@ -156,26 +166,33 @@ fn scrolling() -> Section<crate::pages::Message> {
|
|||
let page = binder
|
||||
.page::<super::Page>()
|
||||
.expect("input devices page not found");
|
||||
let theme = cosmic::theme::active();
|
||||
|
||||
settings::view_section(§ion.title)
|
||||
// Scroll speed slider
|
||||
.add(settings::item(
|
||||
&*super::SCROLLING_SPEED,
|
||||
// TODO show numeric value
|
||||
// TODO desired range?
|
||||
widget::slider(
|
||||
1.0..=1000.0,
|
||||
page.input_touchpad
|
||||
.scroll_config
|
||||
.as_ref()
|
||||
.and_then(|x| x.scroll_factor)
|
||||
.unwrap_or(1.)
|
||||
.log(2.)
|
||||
* 10.0
|
||||
+ 50.0,
|
||||
|value| Message::SetScrollFactor(2f64.powf((value - 50.0) / 10.0), true),
|
||||
),
|
||||
))
|
||||
.add(settings::item(&*super::SCROLLING_SPEED, {
|
||||
let value = page
|
||||
.input_touchpad
|
||||
.scroll_config
|
||||
.as_ref()
|
||||
.and_then(|x| x.scroll_factor)
|
||||
.unwrap_or(1.)
|
||||
.log(2.)
|
||||
* 10.0
|
||||
+ 50.0;
|
||||
|
||||
let slider = widget::slider(1.0..=100.0, value, |value| {
|
||||
Message::SetScrollFactor(2f64.powf((value - 50.0) / 10.0), true)
|
||||
})
|
||||
.width(250.0)
|
||||
.breakpoints(&[50.0]);
|
||||
|
||||
row::with_capacity(2)
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(theme.cosmic().space_s())
|
||||
.push(text(format!("{:.0}", value.round())))
|
||||
.push(slider)
|
||||
}))
|
||||
// Natural scrolling toggle
|
||||
.add(
|
||||
settings::item::builder(&*super::SCROLLING_NATURAL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue