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 icon_name: String,
45 pub tooltip: String,
46 pub hidden: bool,
48 pub enabled: bool,
50}
51
52impl Default for ThumbButton {
53 fn default() -> Self {
54 Self { icon: None, icon_name: String::new(), tooltip: String::new(), hidden: false, enabled: true }
55 }
56}
57
58#[derive(Clone, Debug, PartialEq, Eq)]
60pub struct JumpTask {
61 pub title: String,
62 pub arguments: String,
63}
64
65#[derive(Clone, Debug, PartialEq)]
67pub struct TaskbarSpec {
68 pub progress: TaskbarProgress,
69 pub value: f32,
71 pub badge: String,
73 pub badge_description: String,
75 pub badge_color: Color,
76 pub buttons: Vec<ThumbButton>,
77 pub tasks: Vec<JumpTask>,
78}
79
80impl Default for TaskbarSpec {
81 fn default() -> Self {
82 Self {
83 progress: TaskbarProgress::None,
84 value: 0.0,
85 badge: String::new(),
86 badge_description: String::new(),
87 badge_color: Color::rgb(0xE5, 0x39, 0x35),
88 buttons: Vec::new(),
89 tasks: Vec::new(),
90 }
91 }
92}
93
94#[derive(Clone, Copy, Debug, PartialEq, Eq)]
96pub struct TaskbarEvent {
97 pub button: usize,
98}
99
100impl Ui {
101 pub fn taskbars(&self) -> Vec<(ComponentId, ComponentId, TaskbarSpec)> {
103 self.components()
104 .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)))
105 .collect()
106 }
107}