From 8cc51a107e27e1cb5ae8343fa0151db9c9a66852 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 25 Nov 2025 21:54:58 +0300 Subject: [PATCH] fix: panel width differs to size specified in xml --- src/graphics/ui/elements/Panel.cpp | 4 +++- src/graphics/ui/gui_xml.cpp | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/graphics/ui/elements/Panel.cpp b/src/graphics/ui/elements/Panel.cpp index 945c45e7..ed9af66c 100644 --- a/src/graphics/ui/elements/Panel.cpp +++ b/src/graphics/ui/elements/Panel.cpp @@ -81,7 +81,9 @@ void Panel::refresh() { float ex = x + margin.x; node->setPos(glm::vec2(ex, y)); - float width = size.x - padding.x - padding.z - margin.x - margin.z; + int width = glm::floor( + size.x - padding.x - padding.z - margin.x - margin.z + ); if (node->isResizing()) { node->setMaxSize({width, node->getMaxSize().y}); node->setSize(glm::vec2(width, node->getSize().y)); diff --git a/src/graphics/ui/gui_xml.cpp b/src/graphics/ui/gui_xml.cpp index 3e8bcf5d..11e0e860 100644 --- a/src/graphics/ui/gui_xml.cpp +++ b/src/graphics/ui/gui_xml.cpp @@ -244,10 +244,7 @@ static void read_base_panel_impl( if (element.has("padding")) { glm::vec4 padding = element.attr("padding").asVec4(); panel.setPadding(padding); - glm::vec2 size = panel.getSize(); - panel.setSize(glm::vec2( - size.x + padding.x + padding.z, size.y + padding.y + padding.w - )); + panel.refresh(); } if (element.has("orientation")) { auto& oname = element.attr("orientation").getText();