39 lines
912 B
C++
39 lines
912 B
C++
#include "RowLayout.hpp"
|
|
#include "Point.hpp"
|
|
#include "Widget.hpp"
|
|
|
|
namespace Raven {
|
|
|
|
void HorizontalBoxLayout::run() {
|
|
if (!m_target) {
|
|
return;
|
|
}
|
|
|
|
Point current_point { m_margin, m_margin };
|
|
double max_height_so_far = 0;
|
|
double requested_width = 0;
|
|
|
|
auto& children = m_target->children();
|
|
for (auto child : children) {
|
|
if (child->absolute()) {
|
|
continue;
|
|
}
|
|
|
|
if (child->rect().height() > max_height_so_far) {
|
|
max_height_so_far = child->rect().height();
|
|
}
|
|
|
|
requested_width += child->rect().width() + m_margin;
|
|
|
|
child->rect().set_x(current_point.x());
|
|
child->rect().set_y(current_point.y());
|
|
|
|
current_point.add(child->rect().width() + m_margin, 0);
|
|
}
|
|
|
|
m_target->rect().set_width(requested_width + m_margin);
|
|
m_target->rect().set_height(max_height_so_far + m_margin * 2);
|
|
}
|
|
|
|
}
|
|
|