add unfinished vertical box layout
This commit is contained in:
parent
96a7739341
commit
91a3ed6a87
2 changed files with 55 additions and 0 deletions
28
src/VerticalBoxLayout.cpp
Normal file
28
src/VerticalBoxLayout.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include "VerticalBoxLayout.hpp"
|
||||||
|
#include "Point.hpp"
|
||||||
|
#include "Widget.hpp"
|
||||||
|
|
||||||
|
namespace Raven {
|
||||||
|
|
||||||
|
void VerticalBoxLayout::run() {
|
||||||
|
if (!m_target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point current_point { m_target->rect().x() + m_margin, m_target->rect().y() + m_margin };
|
||||||
|
|
||||||
|
auto& children = m_target->children();
|
||||||
|
for (auto child : children) {
|
||||||
|
if (child->absolute()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
child->rect().set_x(current_point.x());
|
||||||
|
child->rect().set_y(current_point.y());
|
||||||
|
|
||||||
|
current_point.add(0, child->rect().height() + m_margin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
27
src/VerticalBoxLayout.hpp
Normal file
27
src/VerticalBoxLayout.hpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Layout.hpp"
|
||||||
|
|
||||||
|
namespace Raven {
|
||||||
|
|
||||||
|
class VerticalBoxLayout : public Layout {
|
||||||
|
private:
|
||||||
|
double m_margin { 0.0 };
|
||||||
|
public:
|
||||||
|
VerticalBoxLayout()
|
||||||
|
: Layout() {}
|
||||||
|
|
||||||
|
VerticalBoxLayout(double margin)
|
||||||
|
: Layout()
|
||||||
|
, m_margin(margin) {}
|
||||||
|
|
||||||
|
void run();
|
||||||
|
|
||||||
|
double margin() { return m_margin; }
|
||||||
|
void set_margin(double margin) { m_margin = margin; run(); }
|
||||||
|
|
||||||
|
virtual ~VerticalBoxLayout() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue