improve window moving, minor changes to enable others apps use otclient framework

This commit is contained in:
Eduardo Bart
2011-11-11 18:26:10 -02:00
parent 3f4ad7977c
commit fc65f99ead
31 changed files with 96 additions and 83 deletions

View File

@@ -497,6 +497,18 @@ void UIWidget::moveChildToTop(const UIWidgetPtr& child)
m_children.push_back(child);
}
void UIWidget::moveChildToIndex(const UIWidgetPtr& child, int index)
{
if(!child)
return;
// remove and push child again
auto it = std::find(m_children.begin(), m_children.end(), child);
assert(it != m_children.end());
m_children.erase(it);
m_children.insert(m_children.begin() + index - 1, child);
}
void UIWidget::lockChild(const UIWidgetPtr& child)
{
if(!child)
@@ -572,6 +584,17 @@ bool UIWidget::isChildLocked(const UIWidgetPtr& child)
return it != m_lockedChildren.end();
}
int UIWidget::getChildIndex(const UIWidgetPtr& child)
{
int index = 1;
for(auto it = m_children.begin(); it != m_children.end(); ++it) {
if(*it == child)
return index;
++index;
}
return -1;
}
void UIWidget::updateParentLayout()
{
if(UIWidgetPtr parent = getParent())