Merge branch 'lua_ui_focus_loss' into 'master'

Work around MyGUI bug in a less destructive way

See merge request OpenMW/openmw!3511
macos_ci_fix
Petr Mikheev 1 year ago
commit 26ff56f150

@ -92,15 +92,21 @@ namespace LuaUi
w->widget()->detachFromWidget(); w->widget()->detachFromWidget();
} }
void WidgetExtension::updateVisible()
{
// 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);
}
void WidgetExtension::attach(WidgetExtension* ext) void WidgetExtension::attach(WidgetExtension* ext)
{ {
ext->mParent = this; ext->mParent = this;
ext->mTemplateChild = false; ext->mTemplateChild = false;
ext->widget()->attachToWidget(mSlot->widget()); ext->widget()->attachToWidget(mSlot->widget());
// workaround for MyGUI bug
// parent visibility doesn't affect added children
ext->widget()->setVisible(!ext->widget()->getVisible());
ext->widget()->setVisible(!ext->widget()->getVisible());
} }
void WidgetExtension::attachTemplate(WidgetExtension* ext) void WidgetExtension::attachTemplate(WidgetExtension* ext)
@ -108,10 +114,6 @@ namespace LuaUi
ext->mParent = this; ext->mParent = this;
ext->mTemplateChild = true; ext->mTemplateChild = true;
ext->widget()->attachToWidget(widget()); ext->widget()->attachToWidget(widget());
// workaround for MyGUI bug
// parent visibility doesn't affect added children
ext->widget()->setVisible(!ext->widget()->getVisible());
ext->widget()->setVisible(!ext->widget()->getVisible());
} }
WidgetExtension* WidgetExtension::findDeep(std::string_view flagName) WidgetExtension* WidgetExtension::findDeep(std::string_view flagName)
@ -256,6 +258,8 @@ namespace LuaUi
void WidgetExtension::updateCoord() void WidgetExtension::updateCoord()
{ {
updateVisible();
MyGUI::IntCoord oldCoord = mWidget->getCoord(); MyGUI::IntCoord oldCoord = mWidget->getCoord();
MyGUI::IntCoord newCoord = calculateCoord(); MyGUI::IntCoord newCoord = calculateCoord();

@ -173,6 +173,8 @@ namespace LuaUi
void focusLoss(MyGUI::Widget*, MyGUI::Widget*); void focusLoss(MyGUI::Widget*, MyGUI::Widget*);
std::optional<std::function<void(WidgetExtension*, MyGUI::IntCoord)>> mOnCoordChange; std::optional<std::function<void(WidgetExtension*, MyGUI::IntCoord)>> mOnCoordChange;
void updateVisible();
}; };
class LuaWidget : public MyGUI::Widget, public WidgetExtension class LuaWidget : public MyGUI::Widget, public WidgetExtension

Loading…
Cancel
Save