improv(widget): share object-select svg handle between widgets using it

This commit is contained in:
Michael Aaron Murphy 2024-02-22 21:05:21 +01:00 committed by Michael Murphy
parent 552077bd8e
commit bd353c6b54
5 changed files with 51 additions and 71 deletions

18
src/widget/common.rs Normal file
View file

@ -0,0 +1,18 @@
use crate::widget::svg;
use std::sync::OnceLock;
/// Static `svg::Handle` to the `object-select-symbolic` icon.
pub fn object_select() -> &'static svg::Handle {
static SELECTION_ICON: OnceLock<svg::Handle> = OnceLock::new();
SELECTION_ICON.get_or_init(|| {
crate::widget::icon::from_name("object-select-symbolic")
.size(16)
.icon()
.into_svg_handle()
.unwrap_or_else(|| {
let bytes: &'static [u8] = &[];
iced_core::svg::Handle::from_memory(bytes)
})
})
}