chore: update libcosmic

This commit is contained in:
Ashley Wulber 2024-02-02 16:16:32 -05:00 committed by Ashley Wulber
parent c71420ccf9
commit 0ab6f724fb
9 changed files with 613 additions and 575 deletions

842
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -44,10 +44,13 @@ tracing-log = "0.2.0"
lto = "thin" lto = "thin"
# lto = "fat" # lto = "fat"
# [patch."https://github.com/pop-os/cosmic-time"] [patch."https://github.com/pop-os/cosmic-time"]
cosmic-time = { git = "https://github.com/pop-os/cosmic-time//", branch = "wip-iced-update" }
# cosmic-time = { path = "../cosmic-time" } # cosmic-time = { path = "../cosmic-time" }
# [patch."https://github.com/pop-os/libcosmic"] [patch."https://github.com/pop-os/libcosmic"]
# libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "refactor-config-watch" } libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "update-iced-latest" }
# cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "refactor-config-watch" } cosmic-config = { git = "https://github.com/pop-os/libcosmic//", branch = "update-iced-latest" }
# libcosmic = { path = "../libcosmic"}
# cosmic-config = { path = "../libcosmic/cosmic-config"}
[patch."https://github.com/Smithay/client-toolkit"] [patch."https://github.com/Smithay/client-toolkit"]
sctk = { git = "https://github.com/smithay/client-toolkit//", package = "smithay-client-toolkit", rev = "e63ab5f" } sctk = { git = "https://github.com/smithay/client-toolkit//", package = "smithay-client-toolkit", rev = "e63ab5f" }

View file

@ -25,7 +25,10 @@ use cosmic::iced::widget::vertical_space;
use cosmic::iced::widget::{column, dnd_source, mouse_area, row, Column, Row}; use cosmic::iced::widget::{column, dnd_source, mouse_area, row, Column, Row};
use cosmic::iced::Color; use cosmic::iced::Color;
use cosmic::iced::{window, Subscription}; use cosmic::iced::{window, Subscription};
use cosmic::iced_core::window::Icon;
use cosmic::iced_core::Border;
use cosmic::iced_core::Padding; use cosmic::iced_core::Padding;
use cosmic::iced_core::Shadow;
use cosmic::iced_runtime::core::alignment::Horizontal; use cosmic::iced_runtime::core::alignment::Horizontal;
use cosmic::iced_runtime::core::event; use cosmic::iced_runtime::core::event;
use cosmic::iced_sctk::commands::data_device::accept_mime_type; use cosmic::iced_sctk::commands::data_device::accept_mime_type;
@ -132,9 +135,12 @@ impl DockItem {
background: Some(Background::Color( background: Some(Background::Color(
theme.cosmic().on_bg_color().into(), theme.cosmic().on_bg_color().into(),
)), )),
border_radius: 4.0.into(), border: Border {
border_width: 0.0, radius: 4.0.into(),
border_color: Color::TRANSPARENT, width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Shadow::default(),
icon_color: Some(Color::TRANSPARENT), icon_color: Some(Color::TRANSPARENT),
}, },
))) )))

View file

@ -778,7 +778,7 @@ fn revealer(
options: Vec<(String, String)>, options: Vec<(String, String)>,
toggle: Message, toggle: Message,
mut change: impl FnMut(String) -> Message + 'static, mut change: impl FnMut(String) -> Message + 'static,
) -> widget::Column<'static, Message, Renderer> { ) -> widget::Column<'static, Message, crate::Theme, Renderer> {
if open { if open {
options.iter().fold( options.iter().fold(
column![revealer_head(open, title, selected, toggle)].width(Length::Fill), column![revealer_head(open, title, selected, toggle)].width(Length::Fill),

View file

@ -353,7 +353,7 @@ impl cosmic::Application for Window {
fn button_icon<'a>( fn button_icon<'a>(
cur_mode: Option<GraphicsMode>, cur_mode: Option<GraphicsMode>,
button_mode: Graphics, button_mode: Graphics,
) -> Container<'a, Message, cosmic::Renderer> { ) -> Container<'a, Message, cosmic::Theme, cosmic::Renderer> {
match cur_mode { match cur_mode {
Some(GraphicsMode::Selected { prev: _, new }) if new == button_mode => { Some(GraphicsMode::Selected { prev: _, new }) if new == button_mode => {
cosmic::widget::container( cosmic::widget::container(

View file

@ -10,6 +10,7 @@ use cosmic::iced::event::{listen_with, PlatformSpecific};
use cosmic::iced::time; use cosmic::iced::time;
use cosmic::iced::wayland::actions::layer_surface::SctkLayerSurfaceSettings; use cosmic::iced::wayland::actions::layer_surface::SctkLayerSurfaceSettings;
use cosmic::iced::wayland::popup::{destroy_popup, get_popup}; use cosmic::iced::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced_core::{Border, Shadow};
use cosmic::iced_runtime::core::layout::Limits; use cosmic::iced_runtime::core::layout::Limits;
use cosmic::iced_sctk::commands::layer_surface::{ use cosmic::iced_sctk::commands::layer_surface::{
destroy_layer_surface, get_layer_surface, Anchor, KeyboardInteractivity, destroy_layer_surface, get_layer_surface, Anchor, KeyboardInteractivity,
@ -323,9 +324,12 @@ impl cosmic::Application for Power {
background: Some( background: Some(
Color::from(theme.cosmic().background.base).into(), Color::from(theme.cosmic().background.base).into(),
), ),
border_radius: 12.0.into(), border: Border {
border_width: 2.0, radius: 12.0.into(),
border_color: theme.cosmic().bg_divider().into(), width: 2.0,
color: theme.cosmic().bg_divider().into(),
},
shadow: Shadow::default(),
} }
})) }))
.width(Length::Shrink) .width(Length::Shrink)

View file

@ -8,7 +8,7 @@ use cosmic::{
}, },
window, Subscription, window, Subscription,
}, },
iced_style::application, iced_style::{application, menu},
Theme, Theme,
}; };
use std::collections::BTreeMap; use std::collections::BTreeMap;
@ -173,18 +173,13 @@ impl cosmic::Application for App {
fn view(&self) -> cosmic::Element<'_, Msg> { fn view(&self) -> cosmic::Element<'_, Msg> {
// XXX connect open event // XXX connect open event
iced::widget::row( iced::widget::row(self.menus.iter().map(|(id, menu)| {
self.menus self.core
.iter() .applet
.map(|(id, menu)| { .icon_button(menu.icon_name())
self.core .on_press(Msg::TogglePopup(*id))
.applet .into()
.icon_button(menu.icon_name()) }))
.on_press(Msg::TogglePopup(*id))
.into()
})
.collect(),
)
.into() .into()
} }

View file

@ -79,84 +79,76 @@ impl State {
} }
fn layout_view(layout: &Layout, expanded: Option<i32>) -> cosmic::Element<Msg> { fn layout_view(layout: &Layout, expanded: Option<i32>) -> cosmic::Element<Msg> {
iced::widget::column( iced::widget::column(layout.children().iter().filter_map(|i| {
layout if !i.visible() {
.children() None
.iter() } else if i.type_() == Some("separator") {
.filter_map(|i| { Some(iced::widget::horizontal_rule(2).into())
if !i.visible() { } else if let Some(label) = i.label() {
None // Strip _ when not doubled
} else if i.type_() == Some("separator") { // TODO: interpret as "access key"? And label with underline.
Some(iced::widget::horizontal_rule(2).into()) let mut is_underscore = false;
} else if let Some(label) = i.label() { let label = label
// Strip _ when not doubled .chars()
// TODO: interpret as "access key"? And label with underline. .filter(|c| {
let mut is_underscore = false; let prev_is_underscore = is_underscore;
let label = label is_underscore = !is_underscore && *c == '_';
.chars() *c != '_' || prev_is_underscore
.filter(|c| { })
let prev_is_underscore = is_underscore; .collect::<String>();
is_underscore = !is_underscore && *c == '_';
*c != '_' || prev_is_underscore
})
.collect::<String>();
let is_submenu = i.children_display() == Some("submenu"); let is_submenu = i.children_display() == Some("submenu");
let is_expanded = expanded == Some(i.id()); let is_expanded = expanded == Some(i.id());
let text = iced::widget::text(label).width(iced::Length::Fill); let text = iced::widget::text(label).width(iced::Length::Fill);
let mut children: Vec<cosmic::Element<_>> = vec![text.into()]; let mut children: Vec<cosmic::Element<_>> = vec![text.into()];
if is_submenu { if is_submenu {
let icon = cosmic::widget::icon::from_name(if is_expanded { let icon = cosmic::widget::icon::from_name(if is_expanded {
"go-down-symbolic" "go-down-symbolic"
} else {
"go-next-symbolic"
})
.size(14)
.symbolic(true);
children.push(icon.into());
}
if let Some(icon_data) = i.icon_data() {
let handle = iced::widget::image::Handle::from_memory(icon_data.to_vec());
children.insert(0, iced::widget::Image::new(handle).into());
} else if let Some(icon_name) = i.icon_name() {
let icon = cosmic::widget::icon::from_name(icon_name)
.size(14)
.symbolic(true);
children.insert(0, icon.into());
}
if i.toggle_state() == Some(1) {
let icon = cosmic::widget::icon::from_name("emblem-ok-symbolic")
.size(14)
.symbolic(true);
children.push(icon.into());
}
let button = row_button(children).on_press(Msg::Click(i.id(), is_submenu));
if is_submenu && is_expanded {
Some(
iced::widget::column![
button,
// XXX nested
iced::widget::container(layout_view(i, None)).padding(
iced::Padding {
left: 12.,
..iced::Padding::ZERO
}
)
]
.into(),
)
} else {
Some(button.into())
}
} else { } else {
None "go-next-symbolic"
} })
}) .size(14)
.collect(), .symbolic(true);
) children.push(icon.into());
}
if let Some(icon_data) = i.icon_data() {
let handle = iced::widget::image::Handle::from_memory(icon_data.to_vec());
children.insert(0, iced::widget::Image::new(handle).into());
} else if let Some(icon_name) = i.icon_name() {
let icon = cosmic::widget::icon::from_name(icon_name)
.size(14)
.symbolic(true);
children.insert(0, icon.into());
}
if i.toggle_state() == Some(1) {
let icon = cosmic::widget::icon::from_name("emblem-ok-symbolic")
.size(14)
.symbolic(true);
children.push(icon.into());
}
let button = row_button(children).on_press(Msg::Click(i.id(), is_submenu));
if is_submenu && is_expanded {
Some(
iced::widget::column![
button,
// XXX nested
iced::widget::container(layout_view(i, None)).padding(iced::Padding {
left: 12.,
..iced::Padding::ZERO
})
]
.into(),
)
} else {
Some(button.into())
}
} else {
None
}
}))
.into() .into()
} }

View file

@ -4,7 +4,7 @@ use cosmic::iced::event;
use cosmic::iced::mouse::{self, ScrollDelta}; use cosmic::iced::mouse::{self, ScrollDelta};
use cosmic::iced::widget::{button, column, container, row, text}; use cosmic::iced::widget::{button, column, container, row, text};
use cosmic::iced::{Event::Mouse, Length, Subscription}; use cosmic::iced::{Event::Mouse, Length, Subscription};
use cosmic::iced_core::Background; use cosmic::iced_core::{Background, Border};
use cosmic::iced_style::application; use cosmic::iced_style::application;
use cosmic::{applet::cosmic_panel_config::PanelAnchor, font::FONT_BOLD, Command}; use cosmic::{applet::cosmic_panel_config::PanelAnchor, font::FONT_BOLD, Command};
use cosmic::{Element, Theme}; use cosmic::{Element, Theme};
@ -121,83 +121,101 @@ impl cosmic::Application for IcedWorkspacesApplet {
if self.workspaces.is_empty() { if self.workspaces.is_empty() {
return row![].padding(8).into(); return row![].padding(8).into();
} }
let buttons = self let buttons = self.workspaces.iter().filter_map(|w| {
.workspaces let btn = button(
.iter() text(w.0.clone())
.filter_map(|w| { .font(FONT_BOLD)
let btn = button( .size(16)
text(w.0.clone()) .horizontal_alignment(Horizontal::Center)
.font(FONT_BOLD) .vertical_alignment(Vertical::Center)
.size(16) .width(Length::Fill)
.horizontal_alignment(Horizontal::Center) .height(Length::Fill),
.vertical_alignment(Vertical::Center) )
.width(Length::Fill) .width(Length::Fixed(
.height(Length::Fill), self.core.applet.suggested_size().0 as f32
) + match self.layout {
.width(Length::Fixed( Layout::Row => 20.0,
self.core.applet.suggested_size().0 as f32 Layout::Column => 16.0,
+ match self.layout { },
Layout::Row => 20.0, ))
Layout::Column => 16.0, .height(Length::Fixed(
}, self.core.applet.suggested_size().0 as f32
)) + match self.layout {
.height(Length::Fixed( Layout::Row => 16.0,
self.core.applet.suggested_size().0 as f32 Layout::Column => 20.0,
+ match self.layout { },
Layout::Row => 16.0, ))
Layout::Column => 20.0, .on_press(Message::WorkspacePressed(w.2.clone()))
}, .padding(0);
))
.on_press(Message::WorkspacePressed(w.2.clone()))
.padding(0);
Some( Some(
btn.style(match w.1 { btn.style(match w.1 {
Some(zcosmic_workspace_handle_v1::State::Active) => { Some(zcosmic_workspace_handle_v1::State::Active) => {
cosmic::theme::iced::Button::Primary cosmic::theme::iced::Button::Primary
} }
Some(zcosmic_workspace_handle_v1::State::Urgent) => { Some(zcosmic_workspace_handle_v1::State::Urgent) => {
let appearance = |theme: &Theme| button::Appearance { let appearance = |theme: &Theme| {
let cosmic = theme.cosmic();
button::Appearance {
background: Some(Background::Color( background: Some(Background::Color(
theme.cosmic().palette.neutral_3.into(), cosmic.palette.neutral_3.into(),
)), )),
border: Border {
radius: cosmic.radius_xl().into(),
..Default::default()
},
border_radius: theme.cosmic().radius_xl().into(), border_radius: theme.cosmic().radius_xl().into(),
text_color: theme.cosmic().destructive_button.base.into(), text_color: theme.cosmic().destructive_button.base.into(),
..button::Appearance::default() ..button::Appearance::default()
};
cosmic::theme::iced::Button::Custom {
active: Box::new(appearance),
hover: Box::new(move |theme| button::Appearance {
background: Some(Background::Color(
theme.current_container().component.hover.into(),
)),
..appearance(theme)
}),
} }
};
cosmic::theme::iced::Button::Custom {
active: Box::new(appearance),
hover: Box::new(move |theme| button::Appearance {
background: Some(Background::Color(
theme.current_container().component.hover.into(),
)),
border: Border {
radius: theme.cosmic().radius_xl().into(),
..Default::default()
},
..appearance(theme)
}),
} }
None => { }
let appearance = |theme: &Theme| button::Appearance { None => {
let appearance = |theme: &Theme| {
let cosmic = theme.cosmic();
button::Appearance {
background: None, background: None,
border_radius: theme.cosmic().radius_xl().into(), border: Border {
radius: cosmic.radius_xl().into(),
..Default::default()
},
border_radius: cosmic.radius_xl().into(),
text_color: theme.current_container().component.on.into(), text_color: theme.current_container().component.on.into(),
..button::Appearance::default() ..button::Appearance::default()
};
cosmic::theme::iced::Button::Custom {
active: Box::new(appearance),
hover: Box::new(move |theme| button::Appearance {
background: Some(Background::Color(
theme.current_container().component.hover.into(),
)),
..appearance(theme)
}),
} }
};
cosmic::theme::iced::Button::Custom {
active: Box::new(appearance),
hover: Box::new(move |theme| button::Appearance {
background: Some(Background::Color(
theme.current_container().component.hover.into(),
)),
border: Border {
radius: theme.cosmic().radius_xl().into(),
..Default::default()
},
..appearance(theme)
}),
} }
_ => return None, }
}) _ => return None,
.into(), })
) .into(),
}) )
.collect(); });
let layout_section: Element<_> = match self.layout { let layout_section: Element<_> = match self.layout {
Layout::Row => row(buttons) Layout::Row => row(buttons)
.width(Length::Shrink) .width(Length::Shrink)