fix(drawable/text): alignment
This commit is contained in:
@@ -17,18 +17,17 @@ use super::{TextAspect, TextStyle};
|
|||||||
static TEXT_REGISTRY: Registry<Text> = Registry::new();
|
static TEXT_REGISTRY: Registry<Text> = Registry::new();
|
||||||
|
|
||||||
fn convert_align(x_align: super::XAlign, y_align: super::YAlign) -> TextAlign {
|
fn convert_align(x_align: super::XAlign, y_align: super::YAlign) -> TextAlign {
|
||||||
let x_align = match x_align {
|
match (x_align, y_align) {
|
||||||
super::XAlign::Left => TextAlign::XLeft,
|
(super::XAlign::Left, super::YAlign::Top) => TextAlign::Left,
|
||||||
super::XAlign::Center => TextAlign::XCenter,
|
(super::XAlign::Left, super::YAlign::Center) => TextAlign::CenterLeft,
|
||||||
super::XAlign::Right => TextAlign::XRight,
|
(super::XAlign::Left, super::YAlign::Bottom) => TextAlign::BottomLeft,
|
||||||
} as u32;
|
(super::XAlign::Center, super::YAlign::Top) => TextAlign::Center,
|
||||||
let y_align = match y_align {
|
(super::XAlign::Center, super::YAlign::Center) => TextAlign::Center,
|
||||||
super::YAlign::Top => TextAlign::YTop,
|
(super::XAlign::Center, super::YAlign::Bottom) => TextAlign::BottomCenter,
|
||||||
super::YAlign::Center => TextAlign::YCenter,
|
(super::XAlign::Right, super::YAlign::Top) => TextAlign::Right,
|
||||||
super::YAlign::Bottom => TextAlign::YBottom,
|
(super::XAlign::Right, super::YAlign::Center) => TextAlign::CenterRight,
|
||||||
} as u32;
|
(super::XAlign::Right, super::YAlign::Bottom) => TextAlign::BottomRight,
|
||||||
|
}
|
||||||
unsafe { std::mem::transmute(x_align | y_align) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Text {
|
pub struct Text {
|
||||||
@@ -94,8 +93,8 @@ impl Text {
|
|||||||
super::TextFit::Overflow => TextFit::Overflow,
|
super::TextFit::Overflow => TextFit::Overflow,
|
||||||
},
|
},
|
||||||
*style,
|
*style,
|
||||||
convert_align(bounds.anchor_align_x.clone(), bounds.anchor_align_y.clone()),
|
convert_align(bounds.anchor_align_x, bounds.anchor_align_y),
|
||||||
convert_align(data.text_align_x.clone(), data.text_align_y.clone()),
|
convert_align(data.text_align_x, data.text_align_y),
|
||||||
vec3(0.0, 0.0, 0.0),
|
vec3(0.0, 0.0, 0.0),
|
||||||
Color128::from([data.color.c.r, data.color.c.g, data.color.c.b, data.color.a]),
|
Color128::from([data.color.c.r, data.color.c.g, data.color.c.b, data.color.a]),
|
||||||
);
|
);
|
||||||
@@ -105,7 +104,7 @@ impl Text {
|
|||||||
transform,
|
transform,
|
||||||
*style,
|
*style,
|
||||||
TextAlign::Center,
|
TextAlign::Center,
|
||||||
convert_align(data.text_align_x.clone(), data.text_align_y.clone()),
|
convert_align(data.text_align_x, data.text_align_y),
|
||||||
vec3(0.0, 0.0, 0.0),
|
vec3(0.0, 0.0, 0.0),
|
||||||
Color128::from([data.color.c.r, data.color.c.g, data.color.c.b, data.color.a]),
|
Color128::from([data.color.c.r, data.color.c.g, data.color.c.b, data.color.a]),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user