embedded_ui/icons/
mod.rs

1pub mod icons5;
2
3use crate::{kit::icon::Icon, render::Renderer, size::Size};
4
5#[derive(Clone, Copy)]
6pub enum InternalIcon {
7    ArrowLeft,
8    ArrowRight,
9}
10
11#[derive(Clone, Copy)]
12pub enum IconKind {
13    // Arrows //
14    ArrowLeft,
15    ArrowRight,
16    ArrowUp,
17    ArrowDown,
18    SolidArrowLeft,
19    SolidArrowRight,
20    SolidArrowUp,
21    SolidArrowDown,
22    SmallArrowLeft,
23    SmallArrowRight,
24    SmallArrowUp,
25    SmallArrowDown,
26
27    // Geometric shapes //
28    Square,
29    SmallSquare,
30    Circle,
31
32    // Standard UI //
33    Bars,
34    BarsV,
35    Check,
36    List,
37    ListFlipped,
38    ThreeDotsV,
39    Frame,
40    FunnelDown,
41    FunnelUp,
42
43    // Actions //
44    ExpandH,
45    ExpandV,
46    ExpandLeftToRight,
47    ExpandRightToLeft,
48    CollapseH,
49    CollapseV,
50    CollapseLeftRoRight,
51    CollapseRightToLeft,
52    AimCenter,
53    ConnectUp,
54    ConnectRight,
55    ConnectLeft,
56    ConnectDown,
57    MoreH,
58    MoreV,
59
60    // Symbols //
61    Heart,
62    SolidHeart,
63    Cross,
64    Hashtag,
65    Diamond,
66    Smile,
67
68    // Math //
69    Plus,
70    Minus,
71    SquareBrackets,
72    SmallPlus,
73    SmallCross,
74    LineV,
75    Equal,
76
77    // Music //
78    MusicNote,
79    Pause,
80
81    // Unsorted //
82    LinesTiltLeft,
83    LinesTiltRight,
84    BarsRise,
85    BarsFall,
86    BracketRight,
87    BracketLeft,
88    BracketUp,
89    BracketDown,
90    Brackets,
91    DotInBrackets,
92    Fork,
93    Flag,
94    Slash,
95    Backslash,
96    StairsUp,
97    StairsDown,
98    SnakeCw,
99    SnakeCcw,
100    SpiralCw,
101    SpiralCcw,
102    BorderLeft,
103    BorderRight,
104    BorderV,
105    BorderH,
106    OutlinedDot,
107    Human,
108    Translucent,
109    Building,
110    Interconnection,
111    Jar,
112    Tare,
113    Ladder,
114
115    Ascent,
116    Descent,
117
118    TopLeft,
119    TopRight,
120    BottomRight,
121    BottomLeft,
122
123    BoundTopLeft,
124    BoundTopRight,
125    BoundBottomRight,
126    BoundBottomLeft,
127
128    // Dice (?) //
129    Dot,
130    TwoDots,
131    ThreeDots,
132    FourDots,
133    FiveDots,
134    SixDots,
135
136    EightDots,
137    NineDots,
138
139    // Nodes //
140    NodeSingle,
141    NodeAngle,
142    NodeH,
143    NodeAll,
144
145    // Hardware //
146    Power,
147    Contact,
148
149    // Computer //
150    Cursor,
151    Terminal,
152    Underline,
153    Overline,
154    Bin,
155    Directory,
156    File,
157}
158
159#[derive(Clone, Copy)]
160pub struct IconData<'a> {
161    pub size: u32,
162    pub data: &'a [u8],
163}
164
165impl<'a> IconData<'a> {
166    pub fn new(size: u32, data: &'a [u8]) -> Self {
167        Self { size, data }
168    }
169}
170
171// pub trait IntoIcon<R: Renderer> {
172//     fn into_icon<'a>(self) -> IconData<'a>;
173// }
174
175pub trait InternalIconSet<R: Renderer> {
176    fn internal<'a>(icon: InternalIcon) -> IconData<'a>;
177}
178
179pub trait IconSet {
180    const SIZE: u32;
181
182    fn pick(&self, kind: IconKind) -> Option<IconData<'_>>;
183}
184
185#[macro_export]
186macro_rules! make_icon_set {
187    ($vis: vis $name: ident: $size: literal {
188        $($data_name: ident: $method_name: ident = $data: expr),*
189        $(,)?
190    }) => {
191        $vis struct $name;
192
193        impl $crate::icons::IconSet for $name {
194            const SIZE: u32 = $size;
195
196            fn pick(&self, kind: $crate::icons::IconKind) -> Option<$crate::icons::IconData<'_>> {
197                match kind {
198                    $($crate::icons::IconKind::$data_name => Some(self.$method_name()),)*
199                    _ => None
200                }
201            }
202        }
203
204        impl $name {
205            $(
206                #[allow(non_upper_case_globals)]
207                const $data_name: &'static [u8] = $data;
208
209                #[inline]
210                pub fn $method_name(&self) -> $crate::icons::IconData<'_> {
211                    $crate::icons::IconData::new(<Self as $crate::icons::IconSet>::SIZE, Self::$data_name)
212                }
213            )*
214        }
215    };
216}
217
218pub use make_icon_set;
219
220use self::icons5::Icons5;