fix center alignment with padding

This commit is contained in:
griffi-gh 2024-02-19 13:57:33 +01:00
parent e7cdc3e58e
commit e758b2459b

View file

@ -182,10 +182,10 @@ impl UiElement for Container {
match (self.align.0, self.direction) {
(Alignment::Begin, _) => (),
(Alignment::Center, UiDirection::Horizontal) => {
position.x += (ctx.measure.size.x - ctx.measure.hints.inner_content_size.unwrap().x) / 2.;
position.x += (ctx.measure.size.x - ctx.measure.hints.inner_content_size.unwrap().x) / 2. - self.padding.left;
},
(Alignment::Center, UiDirection::Vertical) => {
position.y += (ctx.measure.size.y - ctx.measure.hints.inner_content_size.unwrap().y) / 2.;
position.y += (ctx.measure.size.y - ctx.measure.hints.inner_content_size.unwrap().y) / 2. - self.padding.top;
},
(Alignment::End, UiDirection::Horizontal) => {
position.x += ctx.measure.size.x - ctx.measure.hints.inner_content_size.unwrap().x - self.padding.right - self.padding.left;