BlueGit

ict rusty-teams

Files

rusty-teams / crates / app / src / call / caption_style.rs

caption_style.rs

caption_style.rs 1.8 KiB Download Raw
1#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
2pub enum CaptionSize {
3 Small,
4 #[default]
5 Medium,
6 Large,
7}
8
9impl CaptionSize {
10 pub const ALL: [CaptionSize; 3] = [CaptionSize::Small, CaptionSize::Medium, CaptionSize::Large];
11
12 pub fn label(self) -> &'static str {
13 match self {
14 CaptionSize::Small => "Small",
15 CaptionSize::Medium => "Medium",
16 CaptionSize::Large => "Large",
17 }
18 }
19
20 pub fn text_size(self) -> f32 {
21 match self {
22 CaptionSize::Small => 13.,
23 CaptionSize::Medium => 16.,
24 CaptionSize::Large => 21.,
25 }
26 }
27
28 pub fn meta(self) -> &'static str {
29 match self {
30 CaptionSize::Small => "small",
31 CaptionSize::Medium => "medium",
32 CaptionSize::Large => "large",
33 }
34 }
35
36 pub fn from_meta(value: &str) -> CaptionSize {
37 match value {
38 "small" => CaptionSize::Small,
39 "large" => CaptionSize::Large,
40 _ => CaptionSize::Medium,
41 }
42 }
43}
44
45#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
46pub enum CaptionPosition {
47 #[default]
48 Bottom,
49 Top,
50}
51
52impl CaptionPosition {
53 pub const ALL: [CaptionPosition; 2] = [CaptionPosition::Bottom, CaptionPosition::Top];
54
55 pub fn label(self) -> &'static str {
56 match self {
57 CaptionPosition::Bottom => "Bottom",
58 CaptionPosition::Top => "Top",
59 }
60 }
61
62 pub fn meta(self) -> &'static str {
63 match self {
64 CaptionPosition::Bottom => "bottom",
65 CaptionPosition::Top => "top",
66 }
67 }
68
69 pub fn from_meta(value: &str) -> CaptionPosition {
70 match value {
71 "top" => CaptionPosition::Top,
72 _ => CaptionPosition::Bottom,
73 }
74 }
75}