egui/atomics/
sized_atom_kind.rs1use crate::Image;
2use emath::Vec2;
3use epaint::Galley;
4use std::sync::Arc;
5
6#[derive(Clone, Debug)]
8pub enum SizedAtomKind<'a> {
9 Empty { size: Option<Vec2> },
10 Text(Arc<Galley>),
11 Image { image: Image<'a>, size: Vec2 },
12}
13
14impl Default for SizedAtomKind<'_> {
15 fn default() -> Self {
16 Self::Empty { size: None }
17 }
18}
19
20impl SizedAtomKind<'_> {
21 pub fn size(&self) -> Vec2 {
23 match self {
24 SizedAtomKind::Text(galley) => galley.size(),
25 SizedAtomKind::Image { image: _, size } => *size,
26 SizedAtomKind::Empty { size } => size.unwrap_or_default(),
27 }
28 }
29}