| 5 | FlowLayout::FlowLayout() : m_wrap(true) {} |
| 6 | |
| 7 | void FlowLayout::update(float dt) { |
| 8 | Layout::update(dt); |
| 9 | |
| 10 | int consumedWidth = 0; |
| 11 | int rowHeight = 0; |
| 12 | Vec2I currentOffset = {0, size()[1]}; |
| 13 | for (auto child : m_members) { |
| 14 | if (m_wrap && consumedWidth + child->size()[0] > size()[0] && consumedWidth != 0) { // wrapping |
| 15 | currentOffset[0] = 0; |
| 16 | consumedWidth = 0; |
| 17 | currentOffset[1] -= rowHeight + m_spacing[1]; |
| 18 | } |
| 19 | if (rowHeight < child->size()[1]) { |
| 20 | rowHeight = child->size()[1]; |
| 21 | } |
| 22 | child->setPosition(Vec2I{currentOffset[0], currentOffset[1] - child->size()[1]}); |
| 23 | consumedWidth += child->size()[0] + m_spacing[0]; |
| 24 | currentOffset[0] = consumedWidth; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | void FlowLayout::setSpacing(Vec2I const& spacing) { |
| 29 | m_spacing = spacing; |
nothing calls this directly
no test coverage detected