Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit dac9cdb

Browse files
committed
Make GUIPanel::AddChild a little more readable
1 parent 27ef923 commit dac9cdb

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

GUI/GUIPanel.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,24 @@ void GUIPanel::AddChild(GUIPanel *child, bool convertToAbsolutePos)
124124
child->m_Height -= (child->m_Y + child->m_Height) - (m_Y + m_Height);
125125
*/
126126
// Make sure the rectangle is valid
127-
child->m_Width = MAX(child->m_Width, 0);
128-
child->m_Height = MAX(child->m_Height, 0);
127+
child->m_Width = std::max(child->m_Width, 0);
128+
child->m_Height = std::max(child->m_Height, 0);
129129

130-
int Z = 0;
130+
int Zpos = 0;
131131
// Get the last child in the list
132132
if (m_Children.size() > 0) {
133-
GUIPanel *p = (GUIPanel *)m_Children.at(m_Children.size()-1);
134-
Z = p->GetZPos()+1;
133+
GUIPanel *lastChild = m_Children.back();
134+
Zpos = lastChild->GetZPos() + 1;
135135
}
136136

137137
// Remove the child from any previous parent
138-
if (child->GetParentPanel())
139-
child->GetParentPanel()->GUIPanel::RemoveChild(child);
138+
if (child->GetParentPanel()) {
139+
child->GetParentPanel()->GUIPanel::RemoveChild(child);
140+
}
140141

141142
// Setup the inherited values
142143
child->m_Parent = this;
143-
child->Setup(m_Manager, Z);
144+
child->Setup(m_Manager, Zpos);
144145

145146
// Add the child to the list
146147
m_Children.push_back(child);

0 commit comments

Comments
 (0)