-
Notifications
You must be signed in to change notification settings - Fork 23
/
element.rs
759 lines (699 loc) · 23.7 KB
/
element.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
use std::borrow::Borrow;
use bevy::prelude::*;
use bevy_lunex_core::Widget;
// ===========================================================
// === ELEMENT DEFINITION ===
/// # Element
/// Struct holding all necessary information for binding an entity to a [`Widget`].
/// # Fields
/// * `relative` = position in % relative to the widget.
/// * `absolute` = position in pixels, always the same.
/// * `boundary` = width and height, for example image dimensions or text size.
/// * `scale` = size of the element in % of parent widget.
/// * `depth` = local depth of the element, starts at 0.0, usefull when you have 2 elements overlapping (image and text)
/// * `width` = optional, will force the width of the element in % of parent widget.
/// * `height` = optional, will force the height of the element in % of parent widget.
#[derive(Component, Clone, Debug)]
pub struct Element {
/// ### Relative
/// Position in % relative to the widget.
pub relative: Vec2,
/// ### Absolute
/// Position in pixels, always the same.
pub absolute: Vec2,
/// ### Boundary
/// Width and height, for example image dimensions or text size.
pub boundary: Vec2,
/// ### Scale
/// Size of the element in % of parent widget.
pub scale: f32,
/// ### Depth
/// Local depth of the element, starts at 0.0, usefull when you have 2 elements overlapping (image and text)
pub depth: f32,
/// ### Width
/// Optional, will force the width of the element in % of parent widget.
pub width: Option<f32>,
/// ### Height
/// Optional, will force the height of the element in % of parent widget.
pub height: Option<f32>,
}
impl Default for Element {
fn default() -> Self {
Element {
relative: Vec2::new(50.0, 50.0),
absolute: Vec2::new(0.0, 0.0),
boundary: Vec2::new(50.0, 50.0),
scale: 100.0,
depth: 0.0,
width: None,
height: None,
}
}
}
impl Element {
/// New element created from default
pub fn new() -> Element {
Element::default()
}
/// New element of the size 1x1 scaled to the size of a container
/// * transform.scale.x = width of the container
/// * transform.scale.y = height of the container
pub fn fullfill() -> Element {
Element::default().with_bounds(Vec2::splat(1.0)).with_width(Some(100.0)).with_height(Some(100.0))
}
/// Element set to a custom relative position
pub fn at(mut self, x: f32, y: f32) -> Element {
self.relative = Vec2::new(x, y);
self
}
/// Element set to a custom x relative position
pub fn at_x(mut self, x: f32) -> Element {
self.relative.x = x;
self
}
/// Element set to a custom y relative position
pub fn at_y(mut self, y: f32) -> Element {
self.relative.y = y;
self
}
/// Element set to a custom absolute position
pub fn at_abs(mut self, x: f32, y: f32) -> Element {
self.absolute = Vec2::new(x, y);
self
}
/// Element set to a custom x absolute position
pub fn at_x_abs(mut self, x: f32) -> Element {
self.absolute.x = x;
self
}
// Element set to a custom y absolute position
pub fn at_y_abs(mut self, y: f32) -> Element {
self.absolute.y = y;
self
}
/// Element set to a custom boundary
pub fn with_bounds(mut self, boundary: Vec2) -> Element {
self.boundary = boundary;
self
}
/// Element set to a custom scale
pub fn with_scale(mut self, scale: f32) -> Element {
self.scale = scale;
self
}
/// Element set to a custom depth
pub fn with_depth(mut self, depth: f32) -> Element {
self.depth = depth;
self
}
/// Element set to a custom width
pub fn with_width(mut self, width: Option<f32>) -> Element {
self.width = width;
self
}
/// Element set to a custom height
pub fn with_height(mut self, height: Option<f32>) -> Element {
self.height = height;
self
}
}
/// # Element Bundle
/// A bundle containing [`Element`] + [`Widget`].
/// It is recommended to use the [`element_spawn`] macro abstraction.
/// # Fields
/// * `widget`
/// * `element`
/// * `transform`
/// * `visibility`
/// * `global_transform`
/// * `computed_visibility`
#[derive(Bundle, Clone, Debug, Default)]
pub struct ElementBundle {
pub widget: Widget,
pub element: Element,
pub transform: Transform,
pub visibility: Visibility,
pub global_transform: GlobalTransform,
pub inherited_visibility: InheritedVisibility,
pub view_visibility: ViewVisibility,
}
impl ElementBundle {
/// # New
/// Creates new [`ElementBundle`] from given parameters.
/// # Arguments
/// * `widget` = widget to spawn element for.
/// * `element` = the element to spawn.
pub fn new(widget: impl Borrow<Widget>, element: Element) -> ElementBundle {
ElementBundle {
widget: widget.borrow().to_owned(),
element,
..default()
}
}
}
// ===========================================================
// === IMAGE ELEMENT ===
/// # Image Element Bundle
/// A bundle containing [`Image`] + [`Element`] + [`Widget`].
/// It is recommended to use the `new` method.
/// # Fields
/// * `widget`
/// * `element`
/// * `sprite`
/// * `texture`
/// * `transform`
/// * `visibility`
/// * `global_transform`
/// * `computed_visibility`
#[derive(Bundle, Clone, Debug, Default)]
pub struct ImageElementBundle {
pub widget: Widget,
pub element: Element,
pub sprite: Sprite,
pub texture: Handle<Image>,
pub transform: Transform,
pub visibility: Visibility,
pub global_transform: GlobalTransform,
pub inherited_visibility: InheritedVisibility,
pub view_visibility: ViewVisibility,
}
impl ImageElementBundle {
/// # New
/// Creates new [`ImageElementBundle`] from given parameters.
/// # Arguments
/// * `widget` = widget to spawn element for.
/// * `params` = dictates how the element should behave and be located.
/// * `texture` = image handle, you can use `asset_server.load("")`.
/// * `source_image_dimensions` = `Vec2` with width and height dimensions of the texture.
pub fn new(widget: impl Borrow<Widget>, params: impl Borrow<ImageParams>, texture: Handle<Image>, source_image_dimensions: Vec2) -> ImageElementBundle {
let params = params.borrow();
ImageElementBundle {
widget: widget.borrow().to_owned(),
element: Element {
relative: params.relative,
absolute: params.absolute,
boundary: source_image_dimensions,
scale: params.scale,
depth: params.depth,
width: params.width,
height: params.height,
..default()
},
texture,
sprite: Sprite {
anchor: params.anchor.clone(),
color: params.color.clone(),
flip_x: params.flip_x.clone(),
flip_y: params.flip_y.clone(),
..default()
},
..Default::default()
}
}
}
/// # Image parameters
/// Struct that is passed to [`image_element_spawn`] macro containing image information.
/// The fields are then transfered to the [`Element`] struct inside the macro.
/// # Fields
/// * `relative` = position in % relative to the widget.
/// * `absolute` = position in pixels, always the same.
/// * `anchor` = which corner of the image is origin (0.0).
/// * `color` = color tint of the image.
/// * `flip_x` = flips the image horizontally.
/// * `flip_y` = flips the image vertically.
/// * `scale` = size of the image in % of parent widget.
/// * `depth` = local depth of the image, starts at 0.0, usefull when you have 2 elements overlapping (image and text)
/// * `width` = optional, will force the width of the image in % of parent widget.
/// * `height` = optional, will force the height of the image in % of parent widget.
#[derive(Clone, Debug)]
pub struct ImageParams {
/// ### Relative
/// Position in % relative to the widget.
pub relative: Vec2,
/// ### Absolute
/// Position in pixels, always the same.
pub absolute: Vec2,
/// ### Anchor
/// Which corner of the image is origin (0.0).
pub anchor: bevy::sprite::Anchor,
/// ### Color
/// Color tint of the image.
pub color: Color,
/// ### Flip X
/// Flips the image horizontally.
pub flip_x: bool,
/// ### Flip Y
/// Flips the image vertically..
pub flip_y: bool,
/// ### Scale
/// Size of the image in % of parent widget.
pub scale: f32,
/// ### Depth
/// Local depth of the image, starts at 0.0, usefull when you have 2 elements overlapping (image and text)
pub depth: f32,
/// ### Width
/// Optional, will force the width of the image in % of parent widget.
pub width: Option<f32>,
/// ### Height
/// Optional, will force the height of the image in % of parent widget.
pub height: Option<f32>,
}
impl Default for ImageParams {
fn default() -> Self {
ImageParams {
relative: Vec2::new(0.0, 0.0),
absolute: Vec2::new(0.0, 0.0),
anchor: bevy::sprite::Anchor::TopLeft,
color: Color::WHITE,
flip_x: false,
flip_y: false,
scale: 100.0,
depth: 0.0,
width: None,
height: None,
}
}
}
impl ImageParams {
/// Image parameters set to top center position
pub fn topcenter() -> ImageParams {
ImageParams {
relative: Vec2::new(50.0, 0.0),
anchor: bevy::sprite::Anchor::TopCenter,
..Default::default()
}
}
/// Image parameters set to top left position
pub fn topleft() -> ImageParams {
ImageParams {
relative: Vec2::new(0.0, 0.0),
anchor: bevy::sprite::Anchor::TopLeft,
..Default::default()
}
}
/// Image parameters set to top right position
pub fn topright() -> ImageParams {
ImageParams {
relative: Vec2::new(100.0, 0.0),
anchor: bevy::sprite::Anchor::TopRight,
..Default::default()
}
}
/// Image parameters set to center position
pub fn center() -> ImageParams {
ImageParams {
relative: Vec2::new(50.0, 50.0),
anchor: bevy::sprite::Anchor::Center,
..Default::default()
}
}
/// Image parameters set to center left position
pub fn centerleft() -> ImageParams {
ImageParams {
relative: Vec2::new(0.0, 50.0),
anchor: bevy::sprite::Anchor::CenterLeft,
..Default::default()
}
}
/// Image parameters set to center right position
pub fn centerright() -> ImageParams {
ImageParams {
relative: Vec2::new(100.0, 50.0),
anchor: bevy::sprite::Anchor::CenterRight,
..Default::default()
}
}
/// Image parameters set to bottom center position
pub fn bottomcenter() -> ImageParams {
ImageParams {
relative: Vec2::new(50.0, 100.0),
anchor: bevy::sprite::Anchor::BottomCenter,
..Default::default()
}
}
/// Image parameters set to bottom left position
pub fn bottomleft() -> ImageParams {
ImageParams {
relative: Vec2::new(0.0, 100.0),
anchor: bevy::sprite::Anchor::BottomLeft,
..Default::default()
}
}
/// Image parameters set to bottom right position
pub fn bottomright() -> ImageParams {
ImageParams {
relative: Vec2::new(100.0, 100.0),
anchor: bevy::sprite::Anchor::BottomRight,
..Default::default()
}
}
/// Image parameters set to a custom relative position
pub fn at(mut self, x: f32, y: f32) -> ImageParams {
self.relative = Vec2::new(x, y);
self
}
/// Image parameters set to a custom x relative position
pub fn at_x(mut self, x: f32) -> ImageParams {
self.relative.x = x;
self
}
/// Image parameters set to a custom y relative position
pub fn at_y(mut self, y: f32) -> ImageParams {
self.relative.y = y;
self
}
/// Image parameters set to a custom absolute position
pub fn at_abs(mut self, x: f32, y: f32) -> ImageParams {
self.absolute = Vec2::new(x, y);
self
}
/// Image parameters set to a custom x absolute position
pub fn at_x_abs(mut self, x: f32) -> ImageParams {
self.absolute.x = x;
self
}
/// Image parameters set to a custom y absolute position
pub fn at_y_abs(mut self, y: f32) -> ImageParams {
self.absolute.y = y;
self
}
/// Image parameters set to a custom scale
pub fn with_scale(mut self, scale: f32) -> ImageParams {
self.scale = scale;
self
}
/// Image parameters set to a custom color
pub fn with_color(mut self, color: Color) -> ImageParams {
self.color = color;
self
}
/// Image parameters set to a custom flip_x
pub fn with_flip_x(mut self, flip_x: bool) -> ImageParams {
self.flip_x = flip_x;
self
}
/// Image parameters set to a custom flip_x
pub fn with_flip_y(mut self, flip_y: bool) -> ImageParams {
self.flip_y = flip_y;
self
}
/// Image parameters set to a custom depth
pub fn with_depth(mut self, depth: f32) -> ImageParams {
self.depth = depth;
self
}
/// Image parameters set to a custom width
pub fn with_width(mut self, width: Option<f32>) -> ImageParams {
self.width = width;
self
}
/// Image parameters set to a custom height
pub fn with_height(mut self, height: Option<f32>) -> ImageParams {
self.height = height;
self
}
}
// ===========================================================
// === TEXT ELEMENT ===
/// # Text Element Bundle
/// A bundle containing [`Text`] + [`Element`] + [`Widget`].
/// It is recommended to use the `new` method.
/// # Fields
/// * `widget`
/// * `element`
/// * `text`
/// * `text_anchor`
/// * `text_2d_bounds`
/// * `text_layout_info`
/// * `transform`
/// * `visibility`
/// * `global_transform`
/// * `computed_visibility`
#[derive(Bundle, Clone, Debug, Default)]
pub struct TextElementBundle {
pub widget: Widget,
pub element: Element,
pub text: Text,
pub text_anchor: bevy::sprite::Anchor,
pub text_2d_bounds: bevy::text::Text2dBounds,
pub text_layout_info: bevy::text::TextLayoutInfo,
pub transform: Transform,
pub visibility: Visibility,
pub global_transform: GlobalTransform,
pub inherited_visibility: InheritedVisibility,
pub view_visibility: ViewVisibility,
}
impl TextElementBundle {
/// # New
/// Creates new [`TextElementBundle`] from given parameters.
/// # Arguments
/// * `widget` = widget to spawn element for.
/// * `params` = dictates how the element should behave and be located.
/// * `text` = the text you want to display.
pub fn new(widget: impl Borrow<Widget>, params: impl Borrow<TextParams>, text: &str) -> TextElementBundle {
let params = params.borrow();
TextElementBundle {
widget: widget.borrow().to_owned(),
element: Element {
relative: params.relative,
absolute: params.absolute,
boundary: text_compute_size_simple(text, params.style.font_size),
scale: params.scale,
width: params.width,
height: params.height,
depth: params.depth,
..default()
},
text: Text::from_section(text, params.style.clone())
.with_alignment(params.alignment),
text_anchor: params.anchor.clone(),
..default()
}
}
}
/// # Text parameters
/// Struct that is passed to [`text_element_spawn`] macro containing text information.
/// The fields are then transfered to the [`Element`] struct inside the macro.
/// # Example:
/// ```
/// let params = TextParams::centerleft().at(20.0, 50.0).with_height(80.0);
/// ```
/// # Fields
/// * `relative` = position in % relative to the widget.
/// * `absolute` = position in pixels, always the same.
/// * `style` = [`TextStyle`] struct from Bevy.
/// * `alignment` = where the text is aligned - left/center/right.
/// * `anchor` = which corner of the text is origin (0.0).
/// * `scale` = size of the text in % of parent widget.
/// * `depth` = local depth of the text, starts at 0.0, usefull when you have 2 elements overlapping (image and text)
/// * `width` = optional, will force the width of the text in % of parent widget.
/// * `height` = optional, will force the height of the text in % of parent widget.
#[derive(Clone, Debug)]
pub struct TextParams {
/// ### Relative
/// Position in % relative to the widget.
pub relative: Vec2,
/// ### Absolute
/// Position in pixels, always the same.
pub absolute: Vec2,
/// ### Style
/// [`TextStyle`] struct from Bevy.
pub style: TextStyle,
/// ### Alignment
/// Where the text is aligned - left/center/right.
pub alignment: TextAlignment,
/// ### Anchor
/// Which corner of the text is origin (0.0).
pub anchor: bevy::sprite::Anchor,
/// ### Scale
/// Size of the text in % of parent widget.
pub scale: f32,
/// ### Depth
/// Local depth of the text, starts at 0.0, usefull when you have 2 elements overlapping (image and text)
pub depth: f32,
/// ### Width
/// Optional, will force the width of the text in % of parent widget.
pub width: Option<f32>,
/// ### Height
/// Optional, will force the height of the text in % of parent widget.
pub height: Option<f32>,
}
impl Default for TextParams {
fn default() -> Self {
TextParams {
relative: Vec2::new(0.0, 0.0),
absolute: Vec2::new(0.0, 0.0),
style: TextStyle::default(),
alignment: TextAlignment::Left,
anchor: bevy::sprite::Anchor::CenterLeft,
scale: 100.0,
depth: 3.0,
width: None,
height: None,
}
}
}
impl TextParams {
/// Text parameters set to top center position
pub fn topcenter() -> TextParams {
TextParams {
relative: Vec2::new(50.0, 0.0),
alignment: TextAlignment::Center,
anchor: bevy::sprite::Anchor::TopCenter,
..Default::default()
}
}
/// Text parameters set to top left position
pub fn topleft() -> TextParams {
TextParams {
relative: Vec2::new(0.0, 0.0),
alignment: TextAlignment::Left,
anchor: bevy::sprite::Anchor::TopLeft,
..Default::default()
}
}
/// Text parameters set to top right position
pub fn topright() -> TextParams {
TextParams {
relative: Vec2::new(100.0, 0.0),
alignment: TextAlignment::Right,
anchor: bevy::sprite::Anchor::TopRight,
..Default::default()
}
}
/// Text parameters set to center position
pub fn center() -> TextParams {
TextParams {
relative: Vec2::new(50.0, 50.0),
alignment: TextAlignment::Center,
anchor: bevy::sprite::Anchor::Center,
..Default::default()
}
}
/// Text parameters set to center left position
pub fn centerleft() -> TextParams {
TextParams {
relative: Vec2::new(0.0, 50.0),
alignment: TextAlignment::Left,
anchor: bevy::sprite::Anchor::CenterLeft,
..Default::default()
}
}
/// Text parameters set to center right position
pub fn centerright() -> TextParams {
TextParams {
relative: Vec2::new(100.0, 50.0),
alignment: TextAlignment::Right,
anchor: bevy::sprite::Anchor::CenterRight,
..Default::default()
}
}
/// Text parameters set to bottom center position
pub fn bottomcenter() -> TextParams {
TextParams {
relative: Vec2::new(50.0, 100.0),
alignment: TextAlignment::Center,
anchor: bevy::sprite::Anchor::BottomCenter,
..Default::default()
}
}
/// Text parameters set to bottom left position
pub fn bottomleft() -> TextParams {
TextParams {
relative: Vec2::new(0.0, 100.0),
alignment: TextAlignment::Left,
anchor: bevy::sprite::Anchor::BottomLeft,
..Default::default()
}
}
/// Text parameters set to bottom right position
pub fn bottomright() -> TextParams {
TextParams {
relative: Vec2::new(100.0, 100.0),
alignment: TextAlignment::Right,
anchor: bevy::sprite::Anchor::BottomRight,
..Default::default()
}
}
/// Text parameters set to a custom relative position
pub fn at(mut self, x: f32, y: f32) -> TextParams {
self.relative = Vec2::new(x, y);
self
}
/// Text parameters set to a custom x relative position
pub fn at_x(mut self, x: f32) -> TextParams {
self.relative.x = x;
self
}
/// Text parameters set to a custom y relative position
pub fn at_y(mut self, y: f32) -> TextParams {
self.relative.y = y;
self
}
/// Text parameters set to a custom absolute position
pub fn at_abs(mut self, x: f32, y: f32) -> TextParams {
self.absolute = Vec2::new(x, y);
self
}
/// Text parameters set to a custom x absolute position
pub fn at_x_abs(mut self, x: f32) -> TextParams {
self.absolute.x = x;
self
}
/// Text parameters set to a custom y absolute position
pub fn at_y_abs(mut self, y: f32) -> TextParams {
self.absolute.y = y;
self
}
/// Text parameters set to a specific text style
pub fn _with_style(mut self, style: &TextStyle) -> TextParams {
self.style = style.clone();
self
}
pub fn with_style(mut self, style: impl Borrow<TextStyle>) -> TextParams {
self.style = style.borrow().to_owned();
self
}
/// Text parameters set to a custom scale
pub fn with_scale(mut self, scale: f32) -> TextParams {
self.scale = scale;
self
}
/// Text parameters set to a custom depth
pub fn with_depth(mut self, depth: f32) -> TextParams {
self.depth = depth;
self
}
/// Text parameters set to a custom width
pub fn with_width(mut self, width: Option<f32>) -> TextParams {
self.width = width;
self
}
/// Text parameters set to a custom height
pub fn with_height(mut self, height: Option<f32>) -> TextParams {
self.height = height;
self
}
}
// ===========================================================
// === BOUNDARY COMPUTATION ===
/// # Text size compute
/// Simple and rough function to estimate boundary of a text.
/// This function exists because there is currently not a nice way on how to get text boundary from Bevy internals.
pub fn text_compute_size_simple(text: &str, font_size: f32) -> Vec2 {
const SYMBOL_WIDTH_WEIGHT: f32 = 0.8 * 0.5;
const SYMBOL_HEIGHT_WEIGHT: f32 = 1.2 * 0.5;
let mut width = 0.0;
let list: Vec<&str> = text.split("/n").collect();
for line in &list {
let len = line.chars().count();
if len as f32 > width {
width = len as f32
}
}
Vec2::new(
width * font_size * SYMBOL_WIDTH_WEIGHT,
list.len() as f32 * font_size * SYMBOL_HEIGHT_WEIGHT,
)
}
//# --------------------------------------------------------------------------------------------------------------