use std::sync::Arc;
use crate::color::Color;
use crate::component::ComponentId;
use crate::ui::Ui;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum TaskbarProgress {
#[default]
None,
Normal,
Paused,
Error,
Indeterminate,
}
impl crate::prop::PropEnum for TaskbarProgress {
const NAMES: &'static [&'static str] = &["none", "normal", "paused", "error", "indeterminate"];
fn from_index(index: usize) -> Option<Self> {
[Self::None, Self::Normal, Self::Paused, Self::Error, Self::Indeterminate].get(index).copied()
}
fn index(self) -> usize {
self as usize
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct ThumbButton {
pub icon: Option<Arc<Vec<u8>>>,
pub tooltip: String,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct JumpTask {
pub title: String,
pub arguments: String,
}
#[derive(Clone, Debug, PartialEq)]
pub struct TaskbarSpec {
pub progress: TaskbarProgress,
pub value: f32,
pub badge: String,
pub badge_color: Color,
pub buttons: Vec<ThumbButton>,
pub tasks: Vec<JumpTask>,
}
impl Default for TaskbarSpec {
fn default() -> Self {
Self {
progress: TaskbarProgress::None,
value: 0.0,
badge: String::new(),
badge_color: Color::rgb(0xE5, 0x39, 0x35),
buttons: Vec::new(),
tasks: Vec::new(),
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct TaskbarEvent {
pub button: usize,
}
impl Ui {
pub fn taskbars(&self) -> Vec<(ComponentId, ComponentId, TaskbarSpec)> {
self.components()
.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)))
.collect()
}
}