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

Method update

source/windowing/StarVerticalLayout.cpp:12–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10}
11
12void VerticalLayout::update(float) {
13 m_size = Vec2I(0, 0);
14
15 if (m_members.empty())
16 return;
17
18 for (auto const& child : m_members) {
19 auto childSize = child->size();
20 m_size[1] += childSize[1];
21 m_size[0] = max(m_size[0], childSize[0]);
22 }
23 m_size[1] += (m_members.size() - 1) * m_verticalSpacing;
24
25 auto bounds = contentBoundRect();
26
27 int verticalPos = m_fillDown ? bounds.yMax() : bounds.yMin();
28 for (auto const& child : reverseIterate(m_members)) {
29 auto childSize = child->size();
30
31 Vec2I targetPosition;
32
33 if (m_horizontalAnchor == HorizontalAnchor::LeftAnchor)
34 targetPosition[0] = bounds.xMin();
35 else if (m_horizontalAnchor == HorizontalAnchor::RightAnchor)
36 targetPosition[0] = bounds.xMax() - childSize[0];
37 else if (m_horizontalAnchor == HorizontalAnchor::HMidAnchor)
38 targetPosition[0] = -childSize[0] / 2;
39
40 if (m_fillDown) {
41 verticalPos -= childSize[1];
42 targetPosition[1] = verticalPos;
43 verticalPos -= m_verticalSpacing;
44 } else {
45 targetPosition[1] = verticalPos;
46 verticalPos -= childSize[1];
47 verticalPos -= m_verticalSpacing;
48 }
49
50 // needed because position is included in relativeBoundRect
51 child->setPosition(Vec2I(0, 0));
52
53 child->setPosition(targetPosition - child->relativeBoundRect().min());
54 }
55}
56
57Vec2I VerticalLayout::size() const {
58 return m_size;

Callers

nothing calls this directly

Calls 10

reverseIterateFunction · 0.85
yMaxMethod · 0.80
yMinMethod · 0.80
xMinMethod · 0.80
xMaxMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
setPositionMethod · 0.45
minMethod · 0.45
relativeBoundRectMethod · 0.45

Tested by

no test coverage detected