From a36360cbde80084b86f489ca79c069ab910aae43 Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 11 Nov 2023 13:42:35 +0100 Subject: [PATCH] Update parent coords when updating element --- components/lua_ui/element.cpp | 10 ++++++++++ components/lua_ui/widget.hpp | 1 + 2 files changed, 11 insertions(+) diff --git a/components/lua_ui/element.cpp b/components/lua_ui/element.cpp index b15647b1c4..996ba67bb4 100644 --- a/components/lua_ui/element.cpp +++ b/components/lua_ui/element.cpp @@ -79,6 +79,14 @@ namespace LuaUi destroyWidget(ext); } + void updateRootCoord(LuaUi::WidgetExtension* ext) + { + LuaUi::WidgetExtension* root = ext; + while (root->getParent()) + root = root->getParent(); + root->updateCoord(); + } + WidgetExtension* createWidget(const sol::table& layout, uint64_t depth); void updateWidget(WidgetExtension* ext, const sol::table& layout, uint64_t depth); @@ -246,6 +254,7 @@ namespace LuaUi mRoot = createWidget(layout(), 0); mLayer = setLayer(mRoot, layout()); updateAttachment(); + updateRootCoord(mRoot); } } @@ -264,6 +273,7 @@ namespace LuaUi } mLayer = setLayer(mRoot, layout()); updateAttachment(); + updateRootCoord(mRoot); } mUpdate = false; } diff --git a/components/lua_ui/widget.hpp b/components/lua_ui/widget.hpp index e5edd91113..0902434e19 100644 --- a/components/lua_ui/widget.hpp +++ b/components/lua_ui/widget.hpp @@ -34,6 +34,7 @@ namespace LuaUi WidgetExtension* slot() const { return mSlot; } bool isRoot() const { return mElementRoot; } + WidgetExtension* getParent() const { return mParent; } void reset();