mod preset;
use std::path::Path;
pub use preset::IconName;
#[derive(Debug, Clone)]
pub enum WindowIcon {
Emoji(String),
Preset(IconName),
Image {
data: Vec<u8>,
width: u32,
height: u32,
},
}
impl WindowIcon {
pub fn emoji(emoji: impl Into<String>) -> Self {
Self::Emoji(emoji.into())
}
pub fn preset(name: IconName) -> Self {
Self::Preset(name)
}
pub fn image(data: Vec<u8>, width: u32, height: u32) -> Self {
Self::Image { data, width, height }
}
pub fn from_path(path: impl AsRef<Path>) -> Result<Self, String> {
let loaded = crate::gui::util::load_image(path.as_ref(), Some(64), Some(64))?;
Ok(Self::Image { data: loaded.data, width: loaded.width, height: loaded.height })
}
pub fn from_path_sized(
path: impl AsRef<Path>,
width: u32,
height: u32,
) -> Result<Self, String> {
let loaded = crate::gui::util::load_image(path.as_ref(), Some(width), Some(height))?;
Ok(Self::Image { data: loaded.data, width: loaded.width, height: loaded.height })
}
}