refactor: libcosmic rebase with Application API
This commit is contained in:
parent
d243e45094
commit
454894d82f
18 changed files with 1081 additions and 1198 deletions
|
|
@ -4,10 +4,9 @@
|
|||
use super::Message;
|
||||
use apply::Apply;
|
||||
use cosmic::{
|
||||
iced::widget::{button, container, horizontal_space, row},
|
||||
iced::Length,
|
||||
theme,
|
||||
widget::{icon, list, settings, toggler},
|
||||
widget::{button, container, horizontal_space, icon, list, row, settings, toggler},
|
||||
Element,
|
||||
};
|
||||
|
||||
|
|
@ -117,18 +116,19 @@ pub fn panel_dock_links() -> Section<crate::pages::Message> {
|
|||
settings = if let Some((panel_entity, panel_info)) =
|
||||
binder.info.iter().find(|(_, v)| v.id == "panel")
|
||||
{
|
||||
let control = row::with_children(vec![
|
||||
horizontal_space(Length::Fill).into(),
|
||||
icon::from_name("go-next-symbolic").size(16).into(),
|
||||
]);
|
||||
|
||||
settings.add(
|
||||
settings::item::builder(panel_info.title.clone())
|
||||
.description(panel_info.description.clone())
|
||||
.control(row!(
|
||||
horizontal_space(Length::Fill),
|
||||
icon("go-next-symbolic", 20).style(theme::Svg::Symbolic)
|
||||
))
|
||||
.control(control)
|
||||
.spacing(16)
|
||||
.apply(container)
|
||||
.style(theme::Container::custom(list::column::style))
|
||||
.style(theme::Container::custom(list::style))
|
||||
.apply(button)
|
||||
.padding(0)
|
||||
.style(theme::Button::Transparent)
|
||||
.on_press(crate::pages::Message::Page(panel_entity)),
|
||||
)
|
||||
|
|
@ -139,18 +139,19 @@ pub fn panel_dock_links() -> Section<crate::pages::Message> {
|
|||
settings = if let Some((dock_entity, dock_info)) =
|
||||
binder.info.iter().find(|(_, v)| v.id == "dock")
|
||||
{
|
||||
let control = row::with_children(vec![
|
||||
horizontal_space(Length::Fill).into(),
|
||||
icon::from_name("go-next-symbolic").size(16).into(),
|
||||
]);
|
||||
|
||||
settings.add(
|
||||
settings::item::builder(dock_info.title.clone())
|
||||
.description(dock_info.description.clone())
|
||||
.control(row!(
|
||||
horizontal_space(Length::Fill),
|
||||
icon("go-next-symbolic", 20).style(theme::Svg::Symbolic)
|
||||
))
|
||||
.control(control)
|
||||
.spacing(16)
|
||||
.apply(container)
|
||||
.style(theme::Container::custom(list::column::style))
|
||||
.style(theme::Container::custom(list::style))
|
||||
.apply(button)
|
||||
.padding(0)
|
||||
.style(theme::Button::Transparent)
|
||||
.on_press(crate::pages::Message::Page(dock_entity)),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
use apply::Apply;
|
||||
use button::StyleSheet as ButtonStyleSheet;
|
||||
use cosmic::iced_style::container::StyleSheet;
|
||||
use cosmic::iced_widget::text_input::{Icon, Side};
|
||||
use cosmic::widget::{
|
||||
button, column, container, header_bar, icon, list_column, row, scrollable, text, text_input,
|
||||
Column,
|
||||
};
|
||||
|
||||
use cosmic::{
|
||||
cosmic_config::{Config, CosmicConfigEntry},
|
||||
iced::{
|
||||
|
|
@ -18,26 +25,18 @@ use cosmic::{
|
|||
},
|
||||
iced_runtime::{command::platform_specific, core::id::Id, Command},
|
||||
iced_sctk::commands,
|
||||
iced_style::{
|
||||
button::StyleSheet as ButtonStyleSheet, container::StyleSheet as ContainerStyleSheet,
|
||||
},
|
||||
iced_widget::{
|
||||
column, container,
|
||||
core::{
|
||||
layout, renderer,
|
||||
widget::{tree, Operation, OperationOutputWrapper, Tree},
|
||||
Clipboard, Shell, Widget,
|
||||
},
|
||||
graphics::image::image_rs::EncodableLayout,
|
||||
row, scrollable, text, text_input,
|
||||
text_input::{Icon, Side},
|
||||
Column,
|
||||
},
|
||||
sctk::reexports::client::protocol::wl_data_device_manager::DndAction,
|
||||
theme,
|
||||
widget::{button, header_bar, icon, list_column},
|
||||
Element,
|
||||
theme, Apply, Element,
|
||||
};
|
||||
|
||||
use std::{
|
||||
borrow::{Borrow, Cow},
|
||||
fmt::Debug,
|
||||
|
|
@ -244,32 +243,49 @@ impl Page {
|
|||
}
|
||||
has_some = true;
|
||||
list_column = list_column.add(
|
||||
row![
|
||||
icon(info.icon.clone(), 32).style(theme::Svg::Symbolic),
|
||||
column![
|
||||
text(info.name.clone()),
|
||||
text(info.description.clone()).size(10)
|
||||
]
|
||||
.spacing(4.0)
|
||||
.width(Length::Fill),
|
||||
cosmic::iced::widget::button(text(fl!("add")))
|
||||
.style(theme::Button::Custom {
|
||||
active: Box::new(|theme| {
|
||||
let mut style = theme.active(&theme::Button::Text);
|
||||
style.text_color = theme.cosmic().accent_color().into();
|
||||
row::with_children(vec![
|
||||
icon::from_name(&*info.icon)
|
||||
.size(32)
|
||||
.symbolic(true)
|
||||
.icon()
|
||||
.into(),
|
||||
column::with_capacity(2)
|
||||
.push(text(info.name.clone()))
|
||||
.push(text(info.description.clone()).size(10))
|
||||
.spacing(4.0)
|
||||
.width(Length::Fill)
|
||||
.into(),
|
||||
button(text(fl!("add")))
|
||||
.style(button::Style::Custom {
|
||||
active: Box::new(|focused, theme| {
|
||||
let mut style = theme.active(focused, &button::Style::Text);
|
||||
style.text_color = Some(theme.cosmic().accent_color().into());
|
||||
style
|
||||
}),
|
||||
hover: Box::new(|theme| {
|
||||
let mut style = theme.hovered(&theme::Button::Text);
|
||||
style.text_color = theme.cosmic().accent_color().into();
|
||||
disabled: Box::new(|theme| {
|
||||
let mut style = theme.disabled(&button::Style::Text);
|
||||
let mut text_color: Color = theme.cosmic().accent_color().into();
|
||||
text_color.a *= 0.5;
|
||||
style.text_color = Some(text_color);
|
||||
style
|
||||
})
|
||||
}),
|
||||
hovered: Box::new(|focused, theme| {
|
||||
let mut style = theme.hovered(focused, &theme::Button::Text);
|
||||
style.text_color = Some(theme.cosmic().accent_color().into());
|
||||
style
|
||||
}),
|
||||
pressed: Box::new(|focused, theme| {
|
||||
let mut style = theme.pressed(focused, &theme::Button::Text);
|
||||
style.text_color = Some(theme.cosmic().accent_color().into());
|
||||
style
|
||||
}),
|
||||
})
|
||||
.padding(8.0)
|
||||
.on_press(app::Message::PageMessage(msg_map(Message::AddApplet(
|
||||
info.clone()
|
||||
)))),
|
||||
]
|
||||
info.clone(),
|
||||
))))
|
||||
.into(),
|
||||
])
|
||||
.padding([0, 32, 0, 32])
|
||||
.spacing(12)
|
||||
.align_items(Alignment::Center),
|
||||
|
|
@ -282,49 +298,43 @@ impl Page {
|
|||
.horizontal_alignment(Horizontal::Center),
|
||||
);
|
||||
}
|
||||
column![
|
||||
column::with_children(vec![
|
||||
header_bar()
|
||||
.title(fl!("add-applet"))
|
||||
.on_close(app::Message::PageMessage(msg_map(
|
||||
Message::CloseAppletDialogue
|
||||
Message::CloseAppletDialogue,
|
||||
)))
|
||||
.on_drag(app::Message::PageMessage(msg_map(
|
||||
Message::DragAppletDialogue
|
||||
))),
|
||||
Message::DragAppletDialogue,
|
||||
)))
|
||||
.into(),
|
||||
container(
|
||||
scrollable(
|
||||
column![
|
||||
text(fl!("add-applet")).size(24).width(Length::Fill),
|
||||
text_input(&fl!("search-applets"), &self.search)
|
||||
.style(theme::TextInput::Search)
|
||||
.padding([8, 24])
|
||||
.icon(Icon {
|
||||
font: cosmic::iced::Font::default(),
|
||||
code_point: '🔍',
|
||||
size: Some(12.0),
|
||||
spacing: 12.0,
|
||||
side: Side::Left,
|
||||
})
|
||||
column::with_children(vec![
|
||||
text(fl!("add-applet")).size(24).width(Length::Fill).into(),
|
||||
text_input::search_input(&fl!("search-applets"), &self.search, None)
|
||||
.on_input(move |s| {
|
||||
app::Message::PageMessage(msg_map(Message::Search(s)))
|
||||
})
|
||||
.on_paste(move |s| {
|
||||
app::Message::PageMessage(msg_map(Message::Search(s)))
|
||||
})
|
||||
.width(Length::Fixed(312.0)),
|
||||
list_column
|
||||
]
|
||||
.width(Length::Fixed(312.0))
|
||||
.into(),
|
||||
list_column.into(),
|
||||
])
|
||||
.padding([0, 64, 32, 64])
|
||||
.align_items(Alignment::Center)
|
||||
.spacing(8.0)
|
||||
.spacing(8.0),
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.height(Length::Fill),
|
||||
)
|
||||
.style(theme::Container::Background)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
]
|
||||
.into(),
|
||||
])
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
@ -497,33 +507,36 @@ pub fn lists<
|
|||
);
|
||||
};
|
||||
|
||||
let button = cosmic::iced::widget::button(text(fl!("add-applet")))
|
||||
.style(theme::Button::Secondary)
|
||||
.padding(8.0);
|
||||
column![
|
||||
column![
|
||||
row![
|
||||
text(fl!("applets")).width(Length::Fill).size(24),
|
||||
if page.has_dialogue {
|
||||
let button = button::standard(fl!("add-applet"));
|
||||
|
||||
column::with_children(vec![
|
||||
column::with_children(vec![
|
||||
row::with_children(vec![
|
||||
text(fl!("applets")).width(Length::Fill).size(24).into(),
|
||||
(if page.has_dialogue {
|
||||
button
|
||||
} else {
|
||||
button.on_press(Message::AddAppletDialogue)
|
||||
}
|
||||
],
|
||||
text(fl!("start-segment")),
|
||||
})
|
||||
.into(),
|
||||
])
|
||||
.into(),
|
||||
text(fl!("start-segment")).into(),
|
||||
AppletReorderList::new(
|
||||
config
|
||||
.plugins_wings
|
||||
.as_ref()
|
||||
.map(|list| list
|
||||
.0
|
||||
.iter()
|
||||
.filter_map(|id| page
|
||||
.available_entries
|
||||
.map(|list| {
|
||||
list.0
|
||||
.iter()
|
||||
.find(|e| e.id.as_ref() == id.as_str())
|
||||
.map(Applet::borrowed))
|
||||
.collect())
|
||||
.filter_map(|id| {
|
||||
page.available_entries
|
||||
.iter()
|
||||
.find(|e| e.id.as_ref() == id.as_str())
|
||||
.map(Applet::borrowed)
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
Some((window::Id(0), APPLET_DND_ICON_ID)),
|
||||
Message::StartDnd,
|
||||
|
|
@ -533,24 +546,28 @@ pub fn lists<
|
|||
Message::ReorderStart,
|
||||
Message::Save,
|
||||
Message::Cancel,
|
||||
page.reorder_widget_state.dragged_applet().as_ref()
|
||||
page.reorder_widget_state.dragged_applet().as_ref(),
|
||||
)
|
||||
]
|
||||
.spacing(8.0),
|
||||
column![
|
||||
text(fl!("center-segment")),
|
||||
.into(),
|
||||
])
|
||||
.spacing(8.0)
|
||||
.into(),
|
||||
column::with_children(vec![
|
||||
text(fl!("center-segment")).into(),
|
||||
AppletReorderList::new(
|
||||
config
|
||||
.plugins_center
|
||||
.as_ref()
|
||||
.map(|list| list
|
||||
.iter()
|
||||
.filter_map(|id| page
|
||||
.available_entries
|
||||
.iter()
|
||||
.find(|e| e.id.as_ref() == id.as_str())
|
||||
.map(Applet::borrowed))
|
||||
.collect())
|
||||
.map(|list| {
|
||||
list.iter()
|
||||
.filter_map(|id| {
|
||||
page.available_entries
|
||||
.iter()
|
||||
.find(|e| e.id.as_ref() == id.as_str())
|
||||
.map(Applet::borrowed)
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
Some((window::Id(0), APPLET_DND_ICON_ID)),
|
||||
Message::StartDnd,
|
||||
|
|
@ -560,25 +577,29 @@ pub fn lists<
|
|||
Message::ReorderCenter,
|
||||
Message::Save,
|
||||
Message::Cancel,
|
||||
page.reorder_widget_state.dragged_applet().as_ref()
|
||||
page.reorder_widget_state.dragged_applet().as_ref(),
|
||||
)
|
||||
]
|
||||
.spacing(8.0),
|
||||
column![
|
||||
text(fl!("end-segment")),
|
||||
.into(),
|
||||
])
|
||||
.spacing(8.0)
|
||||
.into(),
|
||||
column::with_children(vec![
|
||||
text(fl!("end-segment")).into(),
|
||||
AppletReorderList::new(
|
||||
config
|
||||
.plugins_wings
|
||||
.as_ref()
|
||||
.map(|list| list
|
||||
.1
|
||||
.iter()
|
||||
.filter_map(|id| page
|
||||
.available_entries
|
||||
.map(|list| {
|
||||
list.1
|
||||
.iter()
|
||||
.find(|e| e.id.as_ref() == id.as_str())
|
||||
.map(Applet::borrowed))
|
||||
.collect())
|
||||
.filter_map(|id| {
|
||||
page.available_entries
|
||||
.iter()
|
||||
.find(|e| e.id.as_ref() == id.as_str())
|
||||
.map(Applet::borrowed)
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
Some((window::Id(0), APPLET_DND_ICON_ID)),
|
||||
Message::StartDnd,
|
||||
|
|
@ -588,11 +609,13 @@ pub fn lists<
|
|||
Message::ReorderEnd,
|
||||
Message::Save,
|
||||
Message::Cancel,
|
||||
page.reorder_widget_state.dragged_applet().as_ref()
|
||||
page.reorder_widget_state.dragged_applet().as_ref(),
|
||||
)
|
||||
]
|
||||
.spacing(8.0),
|
||||
]
|
||||
.into(),
|
||||
])
|
||||
.spacing(8.0)
|
||||
.into(),
|
||||
])
|
||||
.padding([0, 16, 0, 16])
|
||||
.spacing(12.0)
|
||||
.apply(Element::from)
|
||||
|
|
@ -700,19 +723,27 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
|
|||
let id_clone = info.id.to_string();
|
||||
let is_dragged = active_dnd.as_ref().map_or(false, |dnd| dnd.id == info.id);
|
||||
container(
|
||||
row![
|
||||
icon("open-menu-symbolic", 16).style(theme::Svg::Symbolic),
|
||||
icon(info.icon, 32).style(theme::Svg::Symbolic),
|
||||
column![text(info.name), text(info.description).size(10)]
|
||||
row::with_children(vec![
|
||||
icon::from_name("open-menu-symbolic")
|
||||
.symbolic(true)
|
||||
.size(16)
|
||||
.into(),
|
||||
icon::from_name(info.icon).size(32).symbolic(true).into(),
|
||||
column::with_capacity(2)
|
||||
.spacing(4.0)
|
||||
.width(Length::Fill),
|
||||
button(theme::Button::Text)
|
||||
.icon(theme::Svg::Symbolic, "edit-delete-symbolic", 16)
|
||||
.on_press(on_remove(id_clone.clone())),
|
||||
button(theme::Button::Text)
|
||||
.icon(theme::Svg::Symbolic, "open-menu-symbolic", 16)
|
||||
.on_press(on_details(id_clone)),
|
||||
]
|
||||
.width(Length::Fill)
|
||||
.push(text(info.name))
|
||||
.push(text::caption(info.description))
|
||||
.into(),
|
||||
button::icon(icon::from_name("edit-delete-symbolic"))
|
||||
.extra_small()
|
||||
.on_press(on_remove(id_clone.clone()))
|
||||
.into(),
|
||||
button::icon(icon::from_name("open-menu-symbolic"))
|
||||
.extra_small()
|
||||
.on_press(on_details(id_clone))
|
||||
.into(),
|
||||
])
|
||||
.spacing(12)
|
||||
.align_items(Alignment::Center),
|
||||
)
|
||||
|
|
@ -781,23 +812,28 @@ impl<'a, Message: 'static + Clone> AppletReorderList<'a, Message> {
|
|||
surface_ids: None,
|
||||
inner: if let Some(info) = state.dragged_applet() {
|
||||
container(
|
||||
row![
|
||||
icon("open-menu-symbolic", 16).style(theme::Svg::Symbolic),
|
||||
icon(info.icon.into_owned(), 32).style(theme::Svg::Symbolic),
|
||||
column![text(info.name), text(info.description).size(10)]
|
||||
row::with_children(vec![
|
||||
icon::from_name("open-menu-symbolic")
|
||||
.size(16)
|
||||
.symbolic(true)
|
||||
.into(),
|
||||
icon::from_name(info.icon.into_owned())
|
||||
.size(32)
|
||||
.symbolic(true)
|
||||
.into(),
|
||||
column::with_capacity(2)
|
||||
.spacing(4.0)
|
||||
.width(Length::Fill),
|
||||
button(theme::Button::Text).icon(
|
||||
theme::Svg::Symbolic,
|
||||
"edit-delete-symbolic",
|
||||
16
|
||||
),
|
||||
button(theme::Button::Text).icon(
|
||||
theme::Svg::Symbolic,
|
||||
"open-menu-symbolic",
|
||||
16
|
||||
),
|
||||
]
|
||||
.width(Length::Fill)
|
||||
.push(text(info.name))
|
||||
.push(text::caption(info.description))
|
||||
.into(),
|
||||
button::icon(icon::from_name("edit-delete-symbolic"))
|
||||
.extra_small()
|
||||
.into(),
|
||||
button::icon(icon::from_name("open-menu-symbolic"))
|
||||
.extra_small()
|
||||
.into(),
|
||||
])
|
||||
.spacing(12)
|
||||
.align_items(Alignment::Center),
|
||||
)
|
||||
|
|
@ -939,6 +975,7 @@ where
|
|||
renderer: &cosmic::Renderer,
|
||||
clipboard: &mut dyn Clipboard,
|
||||
shell: &mut Shell<'_, Message>,
|
||||
viewport: &Rectangle,
|
||||
) -> event::Status {
|
||||
let mut ret = match self.inner.as_widget_mut().on_event(
|
||||
&mut tree.children[0],
|
||||
|
|
@ -948,6 +985,7 @@ where
|
|||
renderer,
|
||||
clipboard,
|
||||
shell,
|
||||
viewport,
|
||||
) {
|
||||
event::Status::Captured => return event::Status::Captured,
|
||||
event::Status::Ignored => event::Status::Ignored,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
use cosmic::{
|
||||
cosmic_config::{self, CosmicConfigEntry},
|
||||
iced::widget::{button, container, horizontal_space, pick_list, row},
|
||||
iced::Length,
|
||||
iced_widget::slider,
|
||||
sctk::reexports::client::{backend::ObjectId, protocol::wl_output::WlOutput, Proxy},
|
||||
theme,
|
||||
widget::{icon, list, settings, text, toggler},
|
||||
widget::{
|
||||
button, container, horizontal_space, icon, list, pick_list, row, settings, text, toggler,
|
||||
},
|
||||
Element,
|
||||
};
|
||||
|
||||
|
|
@ -14,7 +15,7 @@ use cosmic_panel_config::{
|
|||
AutoHide, CosmicPanelBackground, CosmicPanelConfig, CosmicPanelContainerConfig,
|
||||
CosmicPanelOuput, PanelAnchor, PanelSize,
|
||||
};
|
||||
use cosmic_settings_page::{self as page, section, Section};
|
||||
use cosmic_settings_page::{self as page, Section};
|
||||
use std::{borrow::Cow, collections::HashMap};
|
||||
|
||||
pub struct PageInner {
|
||||
|
|
@ -149,8 +150,8 @@ pub(crate) fn style<
|
|||
.add(settings::item(
|
||||
&descriptions[3],
|
||||
// TODO custom discrete slider variant
|
||||
row![
|
||||
text(fl!("small")),
|
||||
row::with_children(vec![
|
||||
text(fl!("small")).into(),
|
||||
slider(
|
||||
0..=4,
|
||||
match panel_config.size {
|
||||
|
|
@ -173,20 +174,22 @@ pub(crate) fn style<
|
|||
Message::PanelSize(PanelSize::XL)
|
||||
}
|
||||
},
|
||||
),
|
||||
text(fl!("large"))
|
||||
]
|
||||
)
|
||||
.into(),
|
||||
text(fl!("large")).into(),
|
||||
])
|
||||
.spacing(12),
|
||||
))
|
||||
.add(settings::item(
|
||||
&descriptions[4],
|
||||
row![
|
||||
text(fl!("number", HashMap::from_iter(vec![("number", 0)]))),
|
||||
row::with_children(vec![
|
||||
text(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)
|
||||
},),
|
||||
text(fl!("number", HashMap::from_iter(vec![("number", 100)]))),
|
||||
]
|
||||
})
|
||||
.into(),
|
||||
text(fl!("number", HashMap::from_iter(vec![("number", 100)]))).into(),
|
||||
])
|
||||
.spacing(12),
|
||||
))
|
||||
.apply(Element::from)
|
||||
|
|
@ -208,17 +211,18 @@ pub(crate) fn configuration<P: page::Page<crate::pages::Message> + PanelPage>(
|
|||
.iter()
|
||||
.find(|(_, v)| v.id == page.applets_page_id())
|
||||
{
|
||||
let control = row::with_children(vec![
|
||||
horizontal_space(Length::Fill).into(),
|
||||
icon::from_name("go-next-symbolic").size(16).into(),
|
||||
]);
|
||||
|
||||
settings.add(
|
||||
settings::item::builder(&descriptions[0])
|
||||
.control(row!(
|
||||
horizontal_space(Length::Fill),
|
||||
icon("go-next-symbolic", 20).style(theme::Svg::Symbolic)
|
||||
))
|
||||
.control(control)
|
||||
.spacing(16)
|
||||
.apply(container)
|
||||
.style(theme::Container::custom(list::column::style))
|
||||
.style(theme::Container::custom(list::style))
|
||||
.apply(button)
|
||||
.padding(0)
|
||||
.style(theme::Button::Transparent)
|
||||
.on_press(crate::pages::Message::Page(panel_applets_entity)),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use apply::Apply;
|
|||
use cosmic::widget::{
|
||||
list_column,
|
||||
segmented_button::{self, SingleSelectModel},
|
||||
settings, toggler,
|
||||
segmented_selection, settings, text, toggler,
|
||||
};
|
||||
use cosmic::{iced::Length, Element};
|
||||
use cosmic::{iced_core::alignment, iced_runtime::core::image::Handle as ImageHandle};
|
||||
|
|
@ -591,7 +591,7 @@ pub fn settings() -> Section<crate::pages::Message> {
|
|||
));
|
||||
|
||||
children.push(if page.config.same_on_all {
|
||||
cosmic::widget::text(fl!("all-displays"))
|
||||
text(fl!("all-displays"))
|
||||
.font(cosmic::font::FONT_SEMIBOLD)
|
||||
.horizontal_alignment(alignment::Horizontal::Center)
|
||||
.vertical_alignment(alignment::Vertical::Center)
|
||||
|
|
@ -602,7 +602,7 @@ pub fn settings() -> Section<crate::pages::Message> {
|
|||
.height(Length::Fixed(32.0))
|
||||
.into()
|
||||
} else {
|
||||
cosmic::widget::horizontal_segmented_selection(&page.outputs)
|
||||
segmented_selection::horizontal(&page.outputs)
|
||||
.on_activate(Message::Output)
|
||||
.into()
|
||||
});
|
||||
|
|
@ -669,7 +669,6 @@ pub fn settings() -> Section<crate::pages::Message> {
|
|||
|
||||
cosmic::iced::widget::column(children)
|
||||
.spacing(22)
|
||||
.max_width(683)
|
||||
.apply(Element::from)
|
||||
.map(crate::pages::Message::DesktopWallpaper)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use super::Message;
|
||||
use apply::Apply;
|
||||
use cosmic::iced_core::{self, gradient::Linear, Background, BorderRadius, Color, Degrees};
|
||||
use cosmic::iced_core::{alignment, Length};
|
||||
use cosmic::iced_runtime::core::image::Handle as ImageHandle;
|
||||
use cosmic::prelude::*;
|
||||
use cosmic::widget::{button, container, image, space};
|
||||
use cosmic::{iced, Element};
|
||||
use cosmic_settings_desktop::wallpaper;
|
||||
use slotmap::DefaultKey;
|
||||
|
|
@ -18,9 +19,9 @@ const ROW_SPACING: u16 = 16;
|
|||
|
||||
/// A button for selecting a color or gradient.
|
||||
pub fn color_button(color: wallpaper::Color) -> Element<'static, Message> {
|
||||
iced::widget::button(color_image(color.clone(), COLOR_WIDTH, COLOR_WIDTH, 8.0))
|
||||
button(color_image(color.clone(), COLOR_WIDTH, COLOR_WIDTH, 8.0))
|
||||
.padding(0)
|
||||
.style(cosmic::theme::Button::Transparent)
|
||||
.style(button::Style::IconVertical)
|
||||
.on_press(Message::ColorSelect(color))
|
||||
.into()
|
||||
}
|
||||
|
|
@ -32,9 +33,10 @@ pub fn color_image(
|
|||
height: u16,
|
||||
border_radius: f32,
|
||||
) -> Element<'static, Message> {
|
||||
iced::widget::container(iced::widget::space::Space::new(width, height))
|
||||
container(space::Space::new(width, height))
|
||||
.style(cosmic::theme::Container::custom(move |_theme| {
|
||||
iced::widget::container::Appearance {
|
||||
container::Appearance {
|
||||
icon_color: None,
|
||||
text_color: None,
|
||||
background: Some(match &color {
|
||||
wallpaper::Color::Single([r, g, b]) => {
|
||||
|
|
@ -98,9 +100,9 @@ fn flex_select_row<'a>(
|
|||
}
|
||||
|
||||
fn wallpaper_button(handle: &ImageHandle, id: DefaultKey) -> Element<Message> {
|
||||
let image = iced::widget::image(handle.clone()).apply(iced::Element::from);
|
||||
let image = image(handle.clone()).apply(iced::Element::from);
|
||||
|
||||
iced::widget::button(image)
|
||||
button(image)
|
||||
.padding(0)
|
||||
.style(cosmic::theme::Button::Transparent)
|
||||
.on_press(Message::Select(id))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue