From a4c06ac61dcb9f11ab41b26215cdcfbd7606e8b9 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Mon, 19 Feb 2024 13:57:33 +0100 Subject: [PATCH] fix center alignment with padding --- hui/src/element/builtin/container.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hui/src/element/builtin/container.rs b/hui/src/element/builtin/container.rs index 32734b6..5b2f992 100644 --- a/hui/src/element/builtin/container.rs +++ b/hui/src/element/builtin/container.rs @@ -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;