MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / update

Method update

source/windowing/StarFlowLayout.cpp:7–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5FlowLayout::FlowLayout() : m_wrap(true) {}
6
7void 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
28void FlowLayout::setSpacing(Vec2I const& spacing) {
29 m_spacing = spacing;

Callers

nothing calls this directly

Calls 3

sizeFunction · 0.85
sizeMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected