Fix dynamic ribbon widget being shown above a dialog after resized

This commit is contained in:
CodingJellyfish 2024-04-27 15:05:52 +08:00
parent 10b6c4b1e1
commit 97ca195e20
5 changed files with 34 additions and 1 deletions

View File

@ -573,6 +573,27 @@ public:
}
virtual bool setChildEnd(IGUIElement* end)
{
if (end == 0)
{
ChildEnd = core::list<IGUIElement*>::Iterator();
return true;
}
core::list<IGUIElement*>::Iterator it = Children.begin();
for (; it != Children.end(); ++it)
{
if (*it == end)
{
ChildEnd = it;
return true;
}
}
return false;
}
//! Finds the first element with the given id.
/** \param id: Id to search for.
\param searchchildren: Set this to true, if also children of this
@ -823,7 +844,10 @@ protected:
child->remove(); // remove from old parent
child->LastParentRect = getAbsolutePosition();
child->Parent = this;
Children.push_back(child);
if (ChildEnd.isValid())
Children.insert_after(ChildEnd, child);
else
Children.push_back(child);
}
}
@ -1027,6 +1051,8 @@ protected:
//! type of element
EGUI_ELEMENT_TYPE Type;
core::list<IGUIElement*>::Iterator ChildEnd;
};

View File

@ -612,6 +612,8 @@ public:
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node) =0;
virtual void removeHovered(IGUIElement* element) = 0;
virtual bool setChildEnd(IGUIElement* end) = 0;
};

View File

@ -73,6 +73,7 @@ public:
T & operator * () { return Current->Element; }
T * operator ->() { return &Current->Element; }
bool isValid() const { return Current != 0; }
private:
explicit Iterator(SKListNode* begin) : Current(begin) {}

View File

@ -257,6 +257,8 @@ public:
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node);
virtual void removeHovered(IGUIElement* element);
virtual bool setChildEnd(IGUIElement* end) { return IGUIElement::setChildEnd(end); }
private:
IGUIElement* getNextElement(bool reverse=false, bool group=false);

View File

@ -197,9 +197,11 @@ void DynamicRibbonWidget::resize()
for (unsigned i = 0; i < MAX_PLAYER_COUNT; i++)
selected[i] = getSelectionIDString(i);
Widget::resize();
GUIEngine::getGUIEnv()->setChildEnd(m_left_widget->m_element);
updateForResizing();
buildInternalStructure();
updateItemDisplay();
GUIEngine::getGUIEnv()->setChildEnd(NULL);
for (unsigned i = 0; i < MAX_PLAYER_COUNT; i++)
{
if (!selected[i].empty())