1use std::sync::Arc;
7
8use crate::color::Color;
9use crate::component::ComponentId;
10use crate::ui::Ui;
11
12#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
14pub enum TaskbarProgress {
15 #[default]
16 None,
17 Normal,
18 Paused,
19 Error,
20 Indeterminate,
22}
23
24impl crate::prop::PropEnum for TaskbarProgress {
25 const NAMES: &'static [&'static str] = &["none", "normal", "paused", "error", "indeterminate"];
26
27 fn from_index(index: usize) -> Option<Self> {
28 [Self::None, Self::Normal, Self::Paused, Self::Error, Self::Indeterminate].get(index).copied()
29 }
30
31 fn index(self) -> usize {
32 self as usize
33 }
34}
35
36#[derive(Clone, Debug, PartialEq)]
38pub struct ThumbButton {
39 pub icon: Option<Arc<Vec<u8>>>,
41 pub tooltip: String,
42}
43
44#[derive(Clone, Debug, PartialEq, Eq)]
46pub struct JumpTask {
47 pub title: String,
48 pub arguments: String,
49}
50
51#[derive(Clone, Debug, PartialEq)]
53pub struct TaskbarSpec {
54 pub progress: TaskbarProgress,
55 pub value: f32,
57 pub badge: String,
59 pub badge_color: Color,
60 pub buttons: Vec<ThumbButton>,
61 pub tasks: Vec<JumpTask>,
62}
63
64impl Default for TaskbarSpec {
65 fn default() -> Self {
66 Self {
67 progress: TaskbarProgress::None,
68 value: 0.0,
69 badge: String::new(),
70 badge_color: Color::rgb(0xE5, 0x39, 0x35),
71 buttons: Vec::new(),
72 tasks: Vec::new(),
73 }
74 }
75}
76
77#[derive(Clone, Copy, Debug, PartialEq, Eq)]
79pub struct TaskbarEvent {
80 pub button: usize,
81}
82
83impl Ui {
84 pub fn taskbars(&self) -> Vec<(ComponentId, ComponentId, TaskbarSpec)> {
86 self.components()
87 .filter_map(|id| self.component(id).and_then(|c| c.platform_hooks()).and_then(|h| h.taskbar()).map(|spec| (id, self.root_of(id), spec)))
88 .collect()
89 }
90}