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

@@ -28,6 +28,7 @@ UIVerticalLayout::UIVerticalLayout(UIWidgetPtr parentWidget)
: UILayout(parentWidget)
{
m_alignBottom = false;
m_padding = 0;
}
void UIVerticalLayout::applyStyle(const OTMLNodePtr& styleNode)
@@ -37,6 +38,8 @@ void UIVerticalLayout::applyStyle(const OTMLNodePtr& styleNode)
for(const OTMLNodePtr& node : styleNode->children()) {
if(node->tag() == "align bottom")
m_alignBottom = node->value<bool>();
else if(node->tag() == "padding")
m_padding = node->value<int>();
}
}
@@ -45,12 +48,6 @@ void UIVerticalLayout::update()
UIWidgetPtr parentWidget = getParentWidget();
UIWidgetList widgets = parentWidget->getChildren();
// sort by Y pos
std::sort(widgets.begin(), widgets.end(),
[](const UIWidgetPtr& first, const UIWidgetPtr& second) -> bool {
return first->getY() < second->getY();
});
if(m_alignBottom)
std::reverse(widgets.begin(), widgets.end());
@@ -68,13 +65,12 @@ void UIVerticalLayout::update()
}
widget->setRect(Rect(pos, size));
pos.y += (m_alignBottom) ? -widget->getMarginTop() : (widget->getHeight() + widget->getMarginBottom());
pos.y += m_padding;
}
}
void UIVerticalLayout::addWidget(const UIWidgetPtr& widget)
{
// needed to be correctly sorted on the following update
widget->setY(9999);
update();
}