#[macro_export]
macro_rules! icon {
($icon:ident) => {{ $crate::widgets::icon($crate::icons::Icon::$icon) }};
}
macro_rules! icons {
(
$(
#[$doc:meta]
$icon:ident
),* $(,)?
) => {
#[expect(dead_code, reason = "not all icons are used at the moment")]
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Icon {
$(
#[$doc]
$icon
),*
}
mod __static_icons {
$(
#[expect(nonstandard_style, reason = "handy for creating statics")]
pub(super) static $icon: std::sync::LazyLock<iced::widget::svg::Handle> = std::sync::LazyLock::new(|| {
iced::widget::svg::Handle::from_memory(include_bytes!(concat!(
"../icons/",
stringify!($icon),
".svg"
)))
});
)*
}
impl Icon {
pub fn svg(self) -> iced::widget::svg::Handle {
match self {
$(Self::$icon => __static_icons::$icon.clone()),*
}
}
}
}
}
icons! {
Save,
Circle,
Clipboard,
Close,
Cursor,
Fullscreen,
Pen,
Square,
Text,
}