khora_editor/widgets/
brand.rs1use khora_sdk::editor_ui::{FontFamilyHint, TextAlign, UiBuilder, UiTheme};
22
23use super::paint::with_alpha;
24
25pub fn paint_diamond_outline(
31 ui: &mut dyn UiBuilder,
32 cx: f32,
33 cy: f32,
34 size: f32,
35 color: [f32; 4],
36 thickness: f32,
37) {
38 let top = [cx, cy - size];
39 let right = [cx + size, cy];
40 let bottom = [cx, cy + size];
41 let left = [cx - size, cy];
42 ui.paint_line(top, right, color, thickness);
43 ui.paint_line(right, bottom, color, thickness);
44 ui.paint_line(bottom, left, color, thickness);
45 ui.paint_line(left, top, color, thickness);
46}
47
48pub fn paint_diamond_filled(ui: &mut dyn UiBuilder, cx: f32, cy: f32, size: f32, color: [f32; 4]) {
52 khora_tool_ui::widgets::diamond(ui, [cx, cy], size * 2.0, color);
53}
54
55pub fn paint_brand_pill(
61 ui: &mut dyn UiBuilder,
62 origin: [f32; 2],
63 height: f32,
64 engine_name: &str,
65 project_name: &str,
66 theme: &UiTheme,
67) -> f32 {
68 let engine_w = ui.measure_text(
71 engine_name,
72 theme.font_size_body,
73 FontFamilyHint::Proportional,
74 )[0];
75 let project_w = ui.measure_text(
76 project_name,
77 theme.font_size_body - 1.0,
78 FontFamilyHint::Proportional,
79 )[0];
80 let total_w = 18.0 + 12.0 + engine_w + 14.0 + project_w + 24.0;
81
82 let pad_y = (height - 24.0).max(0.0) * 0.5;
83 let pill_h = (height - pad_y * 2.0).max(20.0);
84 let pill_x = origin[0];
85 let pill_y = origin[1] + pad_y;
86
87 ui.paint_rect_filled(
89 [pill_x, pill_y],
90 [total_w, pill_h],
91 with_alpha(theme.background, 0.6),
92 pill_h * 0.5,
93 );
94 ui.paint_rect_stroke(
95 [pill_x, pill_y],
96 [total_w, pill_h],
97 with_alpha(theme.separator, 0.6),
98 pill_h * 0.5,
99 1.0,
100 );
101
102 let diamond_cx = pill_x + 14.0;
104 let diamond_cy = pill_y + pill_h * 0.5;
105 paint_diamond_filled(ui, diamond_cx, diamond_cy, 6.5, theme.primary);
106
107 let text_y = pill_y + (pill_h - theme.font_size_body) * 0.5;
109 ui.paint_text_styled(
110 [pill_x + 26.0, text_y],
111 engine_name,
112 theme.font_size_body,
113 theme.text,
114 FontFamilyHint::Proportional,
115 TextAlign::Left,
116 );
117
118 let sep_x = pill_x + 26.0 + engine_w + 6.0;
120 ui.paint_line(
121 [sep_x, pill_y + 5.0],
122 [sep_x, pill_y + pill_h - 5.0],
123 with_alpha(theme.border, 0.7),
124 1.0,
125 );
126
127 ui.paint_text_styled(
129 [sep_x + 8.0, text_y],
130 project_name,
131 theme.font_size_body - 1.0,
132 theme.text_muted,
133 FontFamilyHint::Proportional,
134 TextAlign::Left,
135 );
136
137 pill_x + total_w
138}