chore: theme-v2 libcosmic update

This commit is contained in:
Victoria Brekenfeld 2026-04-17 11:48:11 +02:00 committed by Victoria Brekenfeld
parent 667414bd92
commit 55d57ddba2
19 changed files with 609 additions and 386 deletions

View file

@ -1,4 +1,4 @@
use std::sync::Mutex;
use std::sync::{Arc, Mutex};
use crate::{
config::Config,
@ -12,9 +12,9 @@ use cosmic::{
Apply,
iced::{
Alignment,
widget::{column, container, row, space},
core::{Background, Border, Color, Length},
widget::{container, row, space},
},
iced_core::{Background, Border, Color, Length},
theme,
widget::{icon::from_name, text},
};
@ -67,120 +67,90 @@ impl Program for ResizeIndicatorInternal {
type Message = ();
fn view(&self) -> cosmic::Element<'_, Self::Message> {
let edges = self.edges.lock().unwrap();
let icon_container_style = || {
theme::Container::custom(|theme| container::Style {
row(vec![
text::heading(&self.shortcut1).into(),
text::body(fl!("grow-window")).into(),
space::horizontal().width(40).into(),
text::heading(&self.shortcut2).into(),
text::body(fl!("shrink-window")).into(),
])
.apply(container)
.align_x(Alignment::Center)
.align_y(Alignment::Center)
.padding(16)
.apply(container)
.class(theme::Container::custom(|theme| {
let mut background = theme.cosmic().accent_color();
if theme.transparent {
background.alpha = theme
.cosmic()
.alpha_map
.blurred_alpha(theme.cosmic().frosted);
}
container::Style {
snap: true,
icon_color: Some(Color::from(theme.cosmic().accent.on)),
text_color: Some(Color::from(theme.cosmic().accent.on)),
background: Some(Background::Color(theme.cosmic().accent_color().into())),
background: Some(Background::Color(background.into())),
border: Border {
radius: 18.0.into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
})
};
column(vec![
if edges.contains(ResizeEdge::TOP) {
from_name(if self.direction == ResizeDirection::Outwards {
"go-up-symbolic"
} else {
"go-down-symbolic"
})
.size(20)
.prefer_svg(true)
.apply(container)
.padding(8)
.class(icon_container_style())
.width(Length::Shrink)
.apply(container)
.center_x(Length::Fill)
.into()
} else {
space::vertical().height(36).into()
},
row(vec![
if edges.contains(ResizeEdge::LEFT) {
from_name(if self.direction == ResizeDirection::Outwards {
"go-previous-symbolic"
} else {
"go-next-symbolic"
})
.size(20)
.prefer_svg(true)
.apply(container)
.padding(8)
.class(icon_container_style())
.width(Length::Shrink)
.apply(container)
.center_y(Length::Fill)
.into()
} else {
space::horizontal().width(36).into()
},
row(vec![
text::heading(&self.shortcut1).into(),
text::body(fl!("grow-window")).into(),
space::horizontal().width(40).into(),
text::heading(&self.shortcut2).into(),
text::body(fl!("shrink-window")).into(),
])
.apply(container)
.align_x(Alignment::Center)
.align_y(Alignment::Center)
.padding(16)
.apply(container)
.class(icon_container_style())
.width(Length::Shrink)
.height(Length::Shrink)
.apply(container)
.center_x(Length::Fill)
.center_y(Length::Fill)
.into(),
if edges.contains(ResizeEdge::RIGHT) {
from_name(if self.direction == ResizeDirection::Outwards {
"go-next-symbolic"
} else {
"go-previous-symbolic"
})
.size(20)
.prefer_svg(true)
.apply(container)
.padding(8)
.class(icon_container_style())
.height(Length::Shrink)
.apply(container)
.center_y(Length::Fill)
.into()
} else {
space::horizontal().width(36).into()
},
])
.width(Length::Fill)
.height(Length::Fill)
.into(),
if edges.contains(ResizeEdge::BOTTOM) {
from_name(if self.direction == ResizeDirection::Outwards {
"go-down-symbolic"
} else {
"go-up-symbolic"
})
.size(20)
.prefer_svg(true)
.apply(container)
.padding(8)
.class(icon_container_style())
.width(Length::Shrink)
.apply(container)
.center_x(Length::Fill)
.into()
} else {
space::vertical().height(36).into()
},
])
}
}))
.width(Length::Shrink)
.height(Length::Shrink)
.into()
}
}
pub struct ResizeIndicatorArrow {
direction: Arc<Mutex<ResizeDirection>>,
icon_outwards: &'static str,
icon_inwards: &'static str,
}
impl Program for ResizeIndicatorArrow {
type Message = ();
fn view(&self) -> cosmic::Element<'_, Self::Message> {
from_name(
if *self.direction.lock().unwrap() == ResizeDirection::Outwards {
self.icon_outwards
} else {
self.icon_inwards
},
)
.size(20)
.prefer_svg(true)
.apply(container)
.padding(8)
.class(theme::Container::custom(|theme| {
let mut background = theme.cosmic().accent_color();
if theme.transparent {
background.alpha = theme
.cosmic()
.alpha_map
.blurred_alpha(theme.cosmic().frosted);
}
container::Style {
snap: true,
icon_color: Some(Color::from(theme.cosmic().accent.on)),
text_color: Some(Color::from(theme.cosmic().accent.on)),
background: Some(Background::Color(background.into())),
border: Border {
radius: theme.cosmic().radius_s().into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
}
}))
.width(Length::Shrink)
.into()
}
}