1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-04-18 00:06:45 +00:00

Fix visibility breaking after multiple updates

This commit is contained in:
uramer 2023-11-17 18:15:07 +01:00
parent d214f6f6ef
commit 9403f06618
2 changed files with 7 additions and 5 deletions

View file

@ -9,6 +9,7 @@ namespace LuaUi
: mForcePosition(false) : mForcePosition(false)
, mForceSize(false) , mForceSize(false)
, mPropagateEvents(true) , mPropagateEvents(true)
, mVisible(true)
, mLua(nullptr) , mLua(nullptr)
, mWidget(nullptr) , mWidget(nullptr)
, mSlot(this) , mSlot(this)
@ -92,10 +93,9 @@ namespace LuaUi
{ {
// workaround for MyGUI bug // workaround for MyGUI bug
// parent visibility doesn't affect added children // parent visibility doesn't affect added children
MyGUI::Widget* widget = this->widget(); MyGUI::Widget* parent = widget()->getParent();
MyGUI::Widget* parent = widget->getParent(); bool inheritedVisible = mVisible && (parent == nullptr || parent->getInheritedVisible());
bool inheritedVisible = widget->getVisible() && (parent == nullptr || parent->getInheritedVisible()); widget()->setVisible(inheritedVisible);
widget->setVisible(inheritedVisible);
} }
void WidgetExtension::attach(WidgetExtension* ext) void WidgetExtension::attach(WidgetExtension* ext)
@ -278,7 +278,8 @@ namespace LuaUi
mRelativeCoord = propertyValue("relativePosition", MyGUI::FloatPoint()); mRelativeCoord = propertyValue("relativePosition", MyGUI::FloatPoint());
mRelativeCoord = propertyValue("relativeSize", MyGUI::FloatSize()); mRelativeCoord = propertyValue("relativeSize", MyGUI::FloatSize());
mAnchor = propertyValue("anchor", 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->setPointer(propertyValue("pointer", std::string("arrow")));
mWidget->setAlpha(propertyValue("alpha", 1.f)); mWidget->setAlpha(propertyValue("alpha", 1.f));
mWidget->setInheritsAlpha(propertyValue("inheritAlpha", true)); mWidget->setInheritsAlpha(propertyValue("inheritAlpha", true));

View file

@ -135,6 +135,7 @@ namespace LuaUi
MyGUI::FloatSize mAnchor; MyGUI::FloatSize mAnchor;
bool mPropagateEvents; bool mPropagateEvents;
bool mVisible; // used to implement updateVisible
private: private:
// use lua_State* instead of sol::state_view because MyGUI requires a default constructor // use lua_State* instead of sol::state_view because MyGUI requires a default constructor