From 9403f06618ff583ae7663fc3da2627fa8970cca1 Mon Sep 17 00:00:00 2001 From: uramer Date: Fri, 17 Nov 2023 18:15:07 +0100 Subject: [PATCH] Fix visibility breaking after multiple updates --- components/lua_ui/widget.cpp | 11 ++++++----- components/lua_ui/widget.hpp | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/lua_ui/widget.cpp b/components/lua_ui/widget.cpp index 855ba29b3c..9550c9de73 100644 --- a/components/lua_ui/widget.cpp +++ b/components/lua_ui/widget.cpp @@ -9,6 +9,7 @@ namespace LuaUi : mForcePosition(false) , mForceSize(false) , mPropagateEvents(true) + , mVisible(true) , mLua(nullptr) , mWidget(nullptr) , mSlot(this) @@ -92,10 +93,9 @@ namespace LuaUi { // workaround for MyGUI bug // parent visibility doesn't affect added children - MyGUI::Widget* widget = this->widget(); - MyGUI::Widget* parent = widget->getParent(); - bool inheritedVisible = widget->getVisible() && (parent == nullptr || parent->getInheritedVisible()); - widget->setVisible(inheritedVisible); + MyGUI::Widget* parent = widget()->getParent(); + bool inheritedVisible = mVisible && (parent == nullptr || parent->getInheritedVisible()); + widget()->setVisible(inheritedVisible); } void WidgetExtension::attach(WidgetExtension* ext) @@ -278,7 +278,8 @@ namespace LuaUi mRelativeCoord = propertyValue("relativePosition", MyGUI::FloatPoint()); mRelativeCoord = propertyValue("relativeSize", MyGUI::FloatSize()); mAnchor = propertyValue("anchor", MyGUI::FloatSize()); - mWidget->setVisible(propertyValue("visible", true)); + mVisible = propertyValue("visible", true); + mWidget->setVisible(mVisible); mWidget->setPointer(propertyValue("pointer", std::string("arrow"))); mWidget->setAlpha(propertyValue("alpha", 1.f)); mWidget->setInheritsAlpha(propertyValue("inheritAlpha", true)); diff --git a/components/lua_ui/widget.hpp b/components/lua_ui/widget.hpp index 1cda09b41b..c72b64ae3b 100644 --- a/components/lua_ui/widget.hpp +++ b/components/lua_ui/widget.hpp @@ -135,6 +135,7 @@ namespace LuaUi MyGUI::FloatSize mAnchor; bool mPropagateEvents; + bool mVisible; // used to implement updateVisible private: // use lua_State* instead of sol::state_view because MyGUI requires a default constructor