Skip to content

Commit

Permalink
Fix dynamic ribbon widget being shown above a dialog after resized
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingJellyfish committed Apr 27, 2024
1 parent 10b6c4b commit 97ca195
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
28 changes: 27 additions & 1 deletion lib/irrlicht/include/IGUIElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,27 @@ class IGUIElement : public virtual io::IAttributeExchangingObject, public IEvent
}


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
Expand Down Expand Up @@ -823,7 +844,10 @@ class IGUIElement : public virtual io::IAttributeExchangingObject, public IEvent
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);
}
}

Expand Down Expand Up @@ -1027,6 +1051,8 @@ class IGUIElement : public virtual io::IAttributeExchangingObject, public IEvent

//! type of element
EGUI_ELEMENT_TYPE Type;

core::list<IGUIElement*>::Iterator ChildEnd;
};


Expand Down
2 changes: 2 additions & 0 deletions lib/irrlicht/include/IGUIEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ class IGUIEnvironment : public virtual IReferenceCounted
virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node) =0;

virtual void removeHovered(IGUIElement* element) = 0;

virtual bool setChildEnd(IGUIElement* end) = 0;
};


Expand Down
1 change: 1 addition & 0 deletions lib/irrlicht/include/irrList.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class list

T & operator * () { return Current->Element; }
T * operator ->() { return &Current->Element; }
bool isValid() const { return Current != 0; }

private:
explicit Iterator(SKListNode* begin) : Current(begin) {}
Expand Down
2 changes: 2 additions & 0 deletions lib/irrlicht/source/Irrlicht/CGUIEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ class CGUIEnvironment : public IGUIEnvironment, public IGUIElement
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);
Expand Down
2 changes: 2 additions & 0 deletions src/guiengine/widgets/dynamic_ribbon_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 97ca195

Please sign in to comment.