add chat buffer

This commit is contained in:
Eduardo Bart
2011-11-03 21:34:32 -02:00
parent 6aadf896da
commit 39c62942cf
12 changed files with 81 additions and 22 deletions

View File

@@ -22,10 +22,22 @@
#include "uiverticallayout.h"
#include "uiwidget.h"
#include <framework/otml/otml.h>
UIVerticalLayout::UIVerticalLayout(UIWidgetPtr parentWidget)
: UILayout(parentWidget)
{
m_alignBottom = false;
}
void UIVerticalLayout::applyStyle(const OTMLNodePtr& styleNode)
{
UILayout::applyStyle(styleNode);
for(const OTMLNodePtr& node : styleNode->children()) {
if(node->tag() == "align bottom")
m_alignBottom = node->value<bool>();
}
}
void UIVerticalLayout::update()
@@ -39,10 +51,14 @@ void UIVerticalLayout::update()
return first->getY() < second->getY();
});
Point pos = parentWidget->getPosition();
if(m_alignBottom)
std::reverse(widgets.begin(), widgets.end());
Point pos = (m_alignBottom) ? parentWidget->getRect().bottomLeft() : parentWidget->getPosition();
for(const UIWidgetPtr& widget : widgets) {
Size size = widget->getSize();
pos.y += widget->getMarginTop();
pos.y += (m_alignBottom) ? -(widget->getMarginBottom()+widget->getHeight()) : widget->getMarginTop();
if(widget->isSizeFixed()) {
pos.x = parentWidget->getX() + (parentWidget->getWidth() - (widget->getMarginLeft() + widget->getWidth() + widget->getMarginRight()))/2;
pos.x = std::max(pos.x, parentWidget->getX());
@@ -51,7 +67,7 @@ void UIVerticalLayout::update()
pos.x = std::max(pos.x, parentWidget->getX() + (parentWidget->getWidth() - size.width())/2);
}
widget->setRect(Rect(pos, size));
pos.y += widget->getHeight() + widget->getMarginBottom();
pos.y += (m_alignBottom) ? -widget->getMarginTop() : (widget->getHeight() + widget->getMarginBottom());
}
}