improv: radio button style improvements

This commit is contained in:
Vukašin Vojinović 2024-08-30 16:57:13 +02:00 committed by GitHub
parent db44cc1e01
commit fbd9e231d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 220 additions and 226 deletions

286
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -431,7 +431,7 @@ impl Page {
model: impl Fn(&Self) -> &ColorPickerModel,
) -> Element<'_, crate::pages::Message> {
cosmic::widget::column()
.push_maybe(description.map(|description| text(description).width(Length::Fill)))
.push_maybe(description.map(|description| text::body(description).width(Length::Fill)))
.push(
model(self)
.builder(on_update)
@ -1175,7 +1175,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
.padding([8, 0])
.selected(page.theme_mode.is_dark)
.on_press(Message::DarkMode(true)),
text(&descriptions[dark])
text::body(&descriptions[dark])
]
.spacing(8)
.width(Length::FillPortion(1))
@ -1190,7 +1190,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
.selected(!page.theme_mode.is_dark)
.padding([8, 0])
.on_press(Message::DarkMode(false)),
text(&descriptions[light])
text::body(&descriptions[light])
]
.spacing(8)
.width(Length::FillPortion(1))
@ -1221,7 +1221,7 @@ pub fn mode_and_colors() -> Section<crate::pages::Message> {
)
.add(
cosmic::iced::widget::column![
text(&descriptions[accent_color]),
text::body(&descriptions[accent_color]),
scrollable(
cosmic::iced::widget::row![
color_button(
@ -1420,7 +1420,7 @@ pub fn style() -> Section<crate::pages::Message> {
.style(button::Style::Image)
.padding(8)
.on_press(Message::Roundness(Roundness::Round)),
text(&descriptions[round])
text::body(&descriptions[round])
]
.spacing(8)
.width(Length::FillPortion(1))
@ -1442,7 +1442,7 @@ pub fn style() -> Section<crate::pages::Message> {
.style(button::Style::Image)
.padding(8)
.on_press(Message::Roundness(Roundness::SlightlyRound)),
text(&descriptions[slightly_round])
text::body(&descriptions[slightly_round])
]
.spacing(8)
.width(Length::FillPortion(1))
@ -1465,7 +1465,7 @@ pub fn style() -> Section<crate::pages::Message> {
.style(button::Style::Image)
.padding(8)
.on_press(Message::Roundness(Roundness::Square)),
text(&descriptions[square])
text::body(&descriptions[square])
]
.spacing(8)
.align_items(cosmic::iced_core::Alignment::Center)
@ -1877,7 +1877,7 @@ fn icon_theme_button(
}),
)
.push(
text(if name.len() > ICON_NAME_TRUNC {
text::body(if name.len() > ICON_NAME_TRUNC {
format!("{name:.ICON_NAME_TRUNC$}...")
} else {
name.into()

View file

@ -152,7 +152,7 @@ pub(crate) fn enable() -> Section<crate::pages::Message> {
.view::<Page>(move |_binder, page, section| {
let descriptions = &section.descriptions;
let Some(container_config) = page.inner.container_config.as_ref() else {
return Element::from(text(fl!("unknown")));
return Element::from(text::body(fl!("unknown")));
};
settings::view_section(&section.title)
.add(settings::item(

View file

@ -264,12 +264,12 @@ impl Page {
row::with_children(vec![
icon::from_name(&*info.icon).size(32).icon().into(),
column::with_capacity(2)
.push(text(info.name.clone()))
.push(text(info.description.clone()).size(10))
.push(text::body(info.name.clone()))
.push(text::caption(info.description.clone()))
.spacing(spacing.space_xxxs)
.width(Length::Fill)
.into(),
button(text(fl!("add")))
button(text::body(fl!("add")))
.style(button::Style::Custom {
active: Box::new(|focused, theme| {
let mut style = theme.active(focused, false, &button::Style::Text);
@ -305,7 +305,7 @@ impl Page {
}
if !has_some {
list_column = list_column.add(
text(fl!("no-applets-found"))
text::body(fl!("no-applets-found"))
.width(Length::Fill)
.horizontal_alignment(Horizontal::Center),
);
@ -472,12 +472,12 @@ pub fn lists<
let spacing = cosmic::theme::active().cosmic().spacing;
let page = page.inner();
let Some(config) = page.current_config.as_ref() else {
return Element::from(text(fl!("unknown")));
return Element::from(text::body(fl!("unknown")));
};
column::with_children(vec![
column::with_children(vec![
text(fl!("start-segment")).into(),
text::body(fl!("start-segment")).into(),
AppletReorderList::new(
config
.plugins_wings
@ -509,7 +509,7 @@ pub fn lists<
.spacing(spacing.space_xxs)
.into(),
column::with_children(vec![
text(fl!("center-segment")).into(),
text::body(fl!("center-segment")).into(),
AppletReorderList::new(
config
.plugins_center
@ -540,7 +540,7 @@ pub fn lists<
.spacing(spacing.space_xxs)
.into(),
column::with_children(vec![
text(fl!("end-segment")).into(),
text::body(fl!("end-segment")).into(),
AppletReorderList::new(
config
.plugins_wings
@ -689,7 +689,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
column::with_capacity(2)
.spacing(spacing.space_xxxs)
.width(Length::Fill)
.push(text(info.name))
.push(text::body(info.name))
.push_maybe(if info.description.is_empty() {
None
} else {
@ -730,7 +730,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
surface_ids,
inner: if active_dnd.is_some() && applet_buttons.is_empty() {
container(
text(fl!("drop-here"))
text::body(fl!("drop-here"))
.width(Length::Fill)
.height(Length::Fill)
.vertical_alignment(Vertical::Center)
@ -778,7 +778,7 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
column::with_capacity(2)
.spacing(4.0)
.width(Length::Fill)
.push(text(info.name))
.push(text::body(info.name))
.push(text::caption(info.description))
.into(),
button::icon(icon::from_name("edit-delete-symbolic"))

View file

@ -107,7 +107,7 @@ pub(crate) fn behavior_and_position<
let descriptions = &section.descriptions;
let page = page.inner();
let Some(panel_config) = page.panel_config.as_ref() else {
return Element::from(text(fl!("unknown")));
return Element::from(text::body(fl!("unknown")));
};
settings::view_section(&section.title)
.add(settings::item(
@ -163,7 +163,7 @@ pub(crate) fn style<
let descriptions = &section.descriptions;
let inner = page.inner();
let Some(panel_config) = inner.panel_config.as_ref() else {
return Element::from(text(fl!("unknown")));
return Element::from(text::body(fl!("unknown")));
};
settings::view_section(&section.title)
.add(settings::item(
@ -195,7 +195,7 @@ pub(crate) fn style<
&descriptions[size],
// TODO custom discrete slider variant
row::with_children(vec![
text(fl!("small")).into(),
text::body(fl!("small")).into(),
slider(
0..=4,
match panel_config.size {
@ -220,20 +220,20 @@ pub(crate) fn style<
},
)
.into(),
text(fl!("large")).into(),
text::body(fl!("large")).into(),
])
.spacing(12),
))
.add(settings::flex_item(
&descriptions[background_opacity],
row::with_children(vec![
text(fl!("number", HashMap::from_iter(vec![("number", 0)]))).into(),
text::body(fl!("number", HashMap::from_iter(vec![("number", 0)]))).into(),
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(),
text::body(fl!("number", HashMap::from_iter(vec![("number", 100)]))).into(),
])
.spacing(12),
))

View file

@ -3,10 +3,9 @@
// TODO make settings work
use cosmic::widget::settings;
use cosmic::{
cosmic_config::{self, ConfigGet, ConfigSet},
widget::radio,
widget::{radio, settings, text},
Apply, Element,
};
use cosmic_comp_config::workspace::{WorkspaceConfig, WorkspaceLayout, WorkspaceMode};
@ -136,14 +135,14 @@ fn multi_behavior() -> Section<crate::pages::Message> {
let descriptions = &section.descriptions;
settings::view_section(&section.title)
.add(settings::item_row(vec![radio(
&descriptions[span],
text::body(&descriptions[span]),
WorkspaceMode::Global,
Some(page.comp_workspace_config.workspace_mode),
Message::SetWorkspaceMode,
)
.into()]))
.add(settings::item_row(vec![radio(
&descriptions[separate],
text::body(&descriptions[separate]),
WorkspaceMode::OutputBound,
Some(page.comp_workspace_config.workspace_mode),
Message::SetWorkspaceMode,
@ -167,14 +166,14 @@ fn workspace_orientation() -> Section<crate::pages::Message> {
let descriptions = &section.descriptions;
settings::view_section(&section.title)
.add(settings::item_row(vec![radio(
&*descriptions[vertical],
text::body(&descriptions[vertical]),
WorkspaceLayout::Vertical,
Some(page.comp_workspace_config.workspace_layout),
Message::SetWorkspaceLayout,
)
.into()]))
.add(settings::item_row(vec![radio(
&*descriptions[horizontal],
text::body(&descriptions[horizontal]),
WorkspaceLayout::Horizontal,
Some(page.comp_workspace_config.workspace_layout),
Message::SetWorkspaceLayout,

View file

@ -133,7 +133,7 @@ fn popover_menu_row(
label: String,
message: impl Fn(DefaultKey) -> SourceContext + 'static,
) -> cosmic::Element<'static, Message> {
widget::text(label)
widget::text::body(label)
.apply(widget::container)
.style(cosmic::theme::Container::custom(|theme| {
iced_style::container::Appearance {

View file

@ -544,11 +544,11 @@ fn shortcut_item(custom: bool, id: usize, data: &ShortcutModel) -> Element<Short
.iter()
.take(3)
.filter(|(_, shortcut)| shortcut.binding.is_set())
.map(|(_, shortcut)| widget::text::body(shortcut.binding.to_string()).into())
.map(|(_, shortcut)| text::body(shortcut.binding.to_string()).into())
.collect::<Vec<_>>();
let shortcuts: Element<LocalMessage> = if bindings.is_empty() {
widget::text::body(fl!("disabled")).into()
text::body(fl!("disabled")).into()
} else {
widget::column::with_children(bindings)
.align_items(Alignment::End)
@ -558,7 +558,7 @@ fn shortcut_item(custom: bool, id: usize, data: &ShortcutModel) -> Element<Short
let modified = if data.modified == 0 {
None
} else {
Some(widget::text::body(fl!("modified", count = data.modified)))
Some(text::body(fl!("modified", count = data.modified)))
};
let control = widget::row::with_capacity(4)

View file

@ -81,7 +81,7 @@ fn mouse() -> Section<crate::pages::Message> {
row::with_capacity(2)
.align_items(Alignment::Center)
.spacing(theme.cosmic().space_s())
.push(text(format!("{:.0}", value.round())))
.push(text::body(format!("{:.0}", value.round())))
.push(slider)
}),
)
@ -140,7 +140,7 @@ fn scrolling() -> Section<crate::pages::Message> {
row::with_capacity(2)
.align_items(Alignment::Center)
.spacing(theme.cosmic().space_s())
.push(text(format!("{:.0}", value.round())))
.push(text::body(format!("{:.0}", value.round())))
.push(slider)
}))
.add(

View file

@ -104,7 +104,7 @@ fn touchpad() -> Section<crate::pages::Message> {
row::with_capacity(2)
.align_items(Alignment::Center)
.spacing(theme.cosmic().space_s())
.push(text(format!("{:.0}", value.round())))
.push(text::body(format!("{:.0}", value.round())))
.push(slider)
}),
)
@ -151,7 +151,7 @@ fn click_behavior() -> Section<crate::pages::Message> {
settings::view_section(&*section.title)
// Secondary click via two fingers, and middle-click via three fingers
.add(settings::item_row(vec![widget::radio(
&descriptions[click_finger],
text::body(&descriptions[click_finger]),
ClickMethod::Clickfinger,
page.input_touchpad.click_method,
|option| Message::SetSecondaryClickBehavior(Some(option), true),
@ -159,7 +159,7 @@ fn click_behavior() -> Section<crate::pages::Message> {
.into()]))
// Secondary and middle-click via button areas.
.add(settings::item_row(vec![widget::radio(
&descriptions[button_areas],
text::body(&descriptions[button_areas]),
ClickMethod::ButtonAreas,
page.input_touchpad.click_method,
|option| Message::SetSecondaryClickBehavior(Some(option), true),
@ -201,7 +201,7 @@ fn scrolling() -> Section<crate::pages::Message> {
settings::view_section(&section.title)
// Two-finger scrolling toggle
.add(settings::item_row(vec![widget::radio(
&descriptions[two_finger],
text::body(&descriptions[two_finger]),
ScrollMethod::TwoFinger,
page.input_touchpad
.scroll_config
@ -212,7 +212,7 @@ fn scrolling() -> Section<crate::pages::Message> {
.into()]))
// Edge scrolling toggle
.add(settings::item_row(vec![widget::radio(
&descriptions[edge],
text::body(&descriptions[edge]),
ScrollMethod::Edge,
page.input_touchpad
.scroll_config
@ -244,7 +244,7 @@ fn scrolling() -> Section<crate::pages::Message> {
row::with_capacity(2)
.align_items(Alignment::Center)
.spacing(theme.cosmic().space_s())
.push(text(format!("{:.0}", value.round())))
.push(text::body(format!("{:.0}", value.round())))
.push(slider)
}))
// Natural scrolling toggle
@ -273,24 +273,24 @@ fn gestures() -> Section<crate::pages::Message> {
// let four_finger_up = descriptions.insert(fl!("gestures", "four-finger-up"));
// let three_finger_any = descriptions.insert(fl!("gestures", "three-finger-any"));
let switch_workspaces = descriptions.insert(fl!("switch-workspaces"));
let switch_workspaces_horizontal = descriptions.insert(fl!("switch-workspaces", "horizontal"));
let switch_workspaces_vertical = descriptions.insert(fl!("switch-workspaces", "vertical"));
// let open_application_library = descriptions.insert(fl!("open-application-library"));
// let open_workspaces_view = descriptions.insert(fl!("open-workspaces-view"));
// let switch_between_windows = descriptions.insert(fl!("switch-between-windows"));
let switch_workspaces = descriptions.insert(fl!("switch-workspaces"));
let switch_workspaces_horizontal = descriptions.insert(fl!("switch-workspaces", "horizontal"));
let switch_workspaces_vertical = descriptions.insert(fl!("switch-workspaces", "vertical"));
Section::default()
.title(fl!("gestures"))
.descriptions(descriptions)
.view::<Page>(move |_binder, page, section| {
let descriptions = &section.descriptions;
settings::view_section(&*section.title)
settings::view_section(&section.title)
// .add(
// settings::item::builder(&descriptions[three_finger_any])
// .flex_control(text(&descriptions[switch_between_windows])),
// .flex_control(text::body(&descriptions[switch_between_windows])),
// )
.add(
settings::item::builder(
@ -299,7 +299,7 @@ fn gestures() -> Section<crate::pages::Message> {
WorkspaceLayout::Vertical => switch_workspaces_vertical,
}],
)
.flex_control(text(&descriptions[switch_workspaces])),
.flex_control(text::body(&descriptions[switch_workspaces])),
)
// .add(
// settings::item::builder(
@ -308,7 +308,7 @@ fn gestures() -> Section<crate::pages::Message> {
// WorkspaceLayout::Vertical => four_finger_right,
// }],
// )
// .flex_control(text(&descriptions[open_workspaces_view])),
// .flex_control(text::body(&descriptions[open_workspaces_view])),
// )
// .add(
// settings::item::builder(
@ -317,7 +317,7 @@ fn gestures() -> Section<crate::pages::Message> {
// WorkspaceLayout::Vertical => four_finger_left,
// }],
// )
// .flex_control(text(&descriptions[open_application_library])),
// .flex_control(text::body(&descriptions[open_application_library])),
// )
.apply(Element::from)
.map(crate::pages::Message::Input)

View file

@ -78,10 +78,10 @@ fn battery_info() -> Section<crate::pages::Message> {
.show_while::<Page>(|page| page.battery.is_present)
.view::<Page>(move |_binder, page, section| {
let battery_icon = widget::icon::from_name(page.battery.icon_name.clone());
let battery_percent = widget::text(format!("{}%", page.battery.percent));
let battery_percent = widget::text::body(format!("{}%", page.battery.percent));
let battery_time =
widget::text(if page.battery.remaining_duration > TimeDelta::zero() {
widget::text::body(if page.battery.remaining_duration > TimeDelta::zero() {
&page.battery.remaining_time
} else {
""
@ -134,7 +134,7 @@ fn profiles() -> Section<crate::pages::Message> {
})
.fold(section, settings::Section::add);
} else {
let item = widget::text::body(fl!("power-mode", "nobackend"));
let item = text::body(fl!("power-mode", "nobackend"));
section = section.add(item);
}

View file

@ -719,8 +719,8 @@ fn output() -> Section<crate::pages::Message> {
// .descriptions(descriptions)
// .view::<Page>(move |_binder, _page, section| {
// settings::view_section(&section.title)
// .add(settings::item(&section.descriptions[volume], text("TODO")))
// .add(settings::item(&section.descriptions[sound], text("TODO")))
// .add(settings::item(&section.descriptions[volume], text::body("TODO")))
// .add(settings::item(&section.descriptions[sound], text::body("TODO")))
// .into()
// })
// }
@ -737,7 +737,7 @@ fn output() -> Section<crate::pages::Message> {
// settings::view_section(&section.title)
// .add(settings::item(
// &*section.descriptions[applications],
// text("TODO"),
// text::body("TODO"),
// ))
// .into()
// })

View file

@ -153,23 +153,29 @@ fn hardware() -> Section<crate::pages::Message> {
let sections = settings::view_section(&section.title)
.add(settings::flex_item(
&*desc[model],
text(&page.info.hardware_model),
text::body(&page.info.hardware_model),
))
.add(settings::flex_item(
&*desc[memory],
text::body(&page.info.memory),
))
.add(settings::flex_item(&*desc[memory], text(&page.info.memory)))
.add(settings::flex_item(
&*desc[processor],
text(&page.info.processor),
text::body(&page.info.processor),
));
page.info
.graphics
.iter()
.fold(sections, |sections, card| {
sections.add(settings::flex_item(&*desc[graphics], text(card.as_str())))
sections.add(settings::flex_item(
&*desc[graphics],
text::body(card.as_str()),
))
})
.add(settings::flex_item(
&*desc[disk_capacity],
text(&page.info.disk_capacity),
text::body(&page.info.disk_capacity),
))
.into()
})
@ -191,19 +197,19 @@ fn os() -> Section<crate::pages::Message> {
settings::view_section(&section.title)
.add(settings::flex_item(
&*desc[os],
text(&page.info.operating_system),
text::body(&page.info.operating_system),
))
.add(settings::flex_item(
&*desc[os_arch],
text(&page.info.os_architecture),
text::body(&page.info.os_architecture),
))
.add(settings::flex_item(
&*desc[desktop],
text(&page.info.desktop_environment),
text::body(&page.info.desktop_environment),
))
.add(settings::flex_item(
&*desc[windowing_system],
text(&page.info.windowing_system),
text::body(&page.info.windowing_system),
))
.into()
})
@ -216,7 +222,7 @@ fn os() -> Section<crate::pages::Message> {
// .descriptions(vec![fl!("about-related", "support").into()])
// .view::<Page>(move |_binder, _page, section| {
// settings::view_section(&section.title)
// .add(settings::item(&*section.descriptions[0], text("TODO")))
// .add(settings::item(&*section.descriptions[0], text::body("TODO")))
// .into()
// })
// }

View file

@ -380,7 +380,7 @@ fn date() -> Section<crate::pages::Message> {
.add(
settings::item::builder(&*section.descriptions[title])
.description(fl!("time-date", "auto-ntp"))
.control(widget::text(&page.formatted_date)),
.control(widget::text::body(&page.formatted_date)),
)
.apply(cosmic::Element::from)
.map(crate::pages::Message::DateAndTime)
@ -452,7 +452,7 @@ fn timezone() -> Section<crate::pages::Message> {
let timezone_context_button = widget::row::with_capacity(2)
.spacing(12)
.push(
widget::text(
widget::text::body(
page.timezone
.map(|id| &*page.timezone_list[id])
.unwrap_or_default(),

View file

@ -23,8 +23,7 @@ pub fn search_header<Message>(
let parent_meta = &pages.info[parent];
column_children.push(
text(parent_meta.title.as_str())
.size(14)
text::body(parent_meta.title.as_str())
.apply(container)
.padding([0, 0, 0, 6])
.into(),
@ -58,7 +57,7 @@ pub fn page_title<Message: 'static>(page: &page::Info) -> Element<Message> {
#[must_use]
pub fn unimplemented_page<Message: 'static>() -> Element<'static, Message> {
settings::view_section("")
.add(text("We haven't created that panel yet, and/or it is using a similar idea as current Pop! designs."))
.add(text::body("We haven't created that panel yet, and/or it is using a similar idea as current Pop! designs."))
.into()
}
@ -126,7 +125,7 @@ pub fn sub_page_header<'a, Message: 'static + Clone>(
pub fn go_next_item<Msg: Clone + 'static>(description: &str, msg: Msg) -> cosmic::Element<'_, Msg> {
settings::item_row(vec![
text(description).wrap(Wrap::Word).into(),
text::body(description).wrap(Wrap::Word).into(),
horizontal_space(Length::Fill).into(),
icon::from_name("go-next-symbolic").size(16).icon().into(),
])

View file

@ -179,8 +179,8 @@ super-key = Super key
.applications = Open Applications
window-controls = Window Controls
.minimize = Show minimize button
.maximize = Show maximize button
.minimize = Show minimize button
## Desktop: Workspaces

View file

@ -179,8 +179,8 @@ super-key = Super тастер
.applications = Отвори Апликације
window-controls = Контрола прозора
.minimize = Прикажи дугме за минимизовање
.maximize = Прикажи дугме за максимизовање
.minimize = Прикажи дугме за минимизовање
## Desktop: Workspaces

View file

@ -179,8 +179,8 @@ super-key = Super taster
.applications = Otvori Aplikacije
window-controls = Kontrole prozora
.minimize = Prikaži dugme za minimizovanje
.maximize = Prikaži dugme za maksimizovanje
.minimize = Prikaži dugme za minimizovanje
## Desktop: Workspaces