cosmic-comp/src/shell/element/stack_hover.rs

71 lines
1.9 KiB
Rust
Raw Normal View History

2023-07-24 19:31:31 +02:00
use crate::{
fl,
utils::iced::{IcedElement, Program},
};
use calloop::LoopHandle;
use cosmic::{
iced::{
widget::{container, row},
Alignment,
},
2024-02-09 16:48:03 -08:00
iced_core::{Background, Border, Color, Length},
2023-07-24 19:31:31 +02:00
theme,
widget::{horizontal_space, icon::from_name, text},
2023-10-02 19:37:23 +02:00
Apply,
2023-07-24 19:31:31 +02:00
};
use smithay::utils::{Logical, Size};
pub type StackHover = IcedElement<StackHoverInternal>;
pub fn stack_hover(
2023-09-29 21:33:16 +02:00
evlh: LoopHandle<'static, crate::state::State>,
2023-07-24 19:31:31 +02:00
size: Size<i32, Logical>,
theme: cosmic::Theme,
2023-07-24 19:31:31 +02:00
) -> StackHover {
StackHover::new(StackHoverInternal, size, evlh, theme)
2023-07-24 19:31:31 +02:00
}
pub struct StackHoverInternal;
impl Program for StackHoverInternal {
type Message = ();
2024-02-09 16:48:03 -08:00
fn view(&self) -> cosmic::Element<'_, Self::Message> {
2023-07-24 19:31:31 +02:00
row(vec![
2023-10-02 19:37:23 +02:00
from_name("window-stack-symbolic")
.size(32)
2023-10-02 19:37:23 +02:00
.prefer_svg(true)
.icon()
2023-07-24 19:31:31 +02:00
.into(),
horizontal_space(16).into(),
text::title3(fl!("stack-windows")).into(),
2023-07-24 19:31:31 +02:00
])
.align_items(Alignment::Center)
.apply(container)
.center_x()
.center_y()
.padding(16)
2023-07-24 19:31:31 +02:00
.apply(container)
.style(theme::Container::custom(|theme| container::Appearance {
2023-10-02 19:37:23 +02:00
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())),
2024-02-09 16:48:03 -08:00
border: Border {
radius: 18.0.into(),
2024-02-09 16:48:03 -08:00
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
2023-07-24 19:31:31 +02:00
}))
.width(Length::Shrink)
.height(Length::Shrink)
2023-07-24 19:31:31 +02:00
.apply(container)
.width(Length::Fill)
.height(Length::Fill)
.center_x()
.center_y()
2023-07-24 19:31:31 +02:00
.into()
}
}