mirror of
https://github.com/edubart/otclient.git
synced 2025-11-07 13:56:22 +01:00
add chat buffer
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user