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

80 lines
2.2 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},
2024-02-09 16:48:03 -08:00
iced_core::{Background, Border, Color, Length},
2023-07-24 19:31:31 +02:00
theme,
2023-10-02 19:37:23 +02:00
widget::{icon::from_name, text},
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(24)
.prefer_svg(true)
.icon()
2023-07-24 19:31:31 +02:00
.apply(container)
2023-07-25 14:27:33 +02:00
.padding([0, 8, 0, 0])
2023-07-24 19:31:31 +02:00
.width(Length::Shrink)
.apply(container)
.center_y()
.height(Length::Fill)
.into(),
text(fl!("stack-windows"))
.font(cosmic::font::FONT)
.size(24)
2023-07-25 14:27:33 +02:00
.line_height(1.3)
2023-07-24 19:31:31 +02:00
.apply(container)
.width(Length::Shrink)
.apply(container)
.center_y()
.height(Length::Fill)
.into(),
])
.width(Length::Shrink)
.height(Length::Shrink)
.apply(container)
2023-07-25 14:27:33 +02:00
.padding([8, 16])
2023-07-24 19:31:31 +02:00
.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: 24.0.into(),
width: 0.0,
color: Color::TRANSPARENT,
},
shadow: Default::default(),
2023-07-24 19:31:31 +02:00
}))
.width(Length::Shrink)
.height(Length::Fixed(48.))
.apply(container)
.center_x()
.center_y()
.width(Length::Fill)
.height(Length::Fill)
.into()
}
}