Add CenteredLabel (#35)
This commit is contained in:
@@ -62,6 +62,13 @@ pub enum ModularElement {
|
|||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
data: LabelContent,
|
data: LabelContent,
|
||||||
},
|
},
|
||||||
|
CenteredLabel {
|
||||||
|
rect: [f32; 4],
|
||||||
|
font_size: isize,
|
||||||
|
fg_color: Arc<str>,
|
||||||
|
#[serde(flatten)]
|
||||||
|
data: LabelContent,
|
||||||
|
},
|
||||||
Button {
|
Button {
|
||||||
rect: [f32; 4],
|
rect: [f32; 4],
|
||||||
font_size: isize,
|
font_size: isize,
|
||||||
@@ -143,6 +150,17 @@ pub fn modular_canvas(
|
|||||||
let label = canvas.label(*x, *y, *w, *h, empty_str.clone());
|
let label = canvas.label(*x, *y, *w, *h, empty_str.clone());
|
||||||
modular_label_init(label, data);
|
modular_label_init(label, data);
|
||||||
}
|
}
|
||||||
|
ModularElement::CenteredLabel {
|
||||||
|
rect: [x, y, w, h],
|
||||||
|
font_size,
|
||||||
|
fg_color,
|
||||||
|
data,
|
||||||
|
} => {
|
||||||
|
canvas.font_size = *font_size;
|
||||||
|
canvas.fg_color = color_parse(fg_color).unwrap_or(*FALLBACK_COLOR);
|
||||||
|
let label = canvas.label(*x, *y, *w, *h, empty_str.clone());
|
||||||
|
modular_label_init(label, data);
|
||||||
|
}
|
||||||
ModularElement::Button {
|
ModularElement::Button {
|
||||||
rect: [x, y, w, h],
|
rect: [x, y, w, h],
|
||||||
font_size,
|
font_size,
|
||||||
|
|||||||
Reference in New Issue
Block a user