MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / onRender

Method onRender

forms/listbox.cpp:44–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void ListBox::onRender()
45{
46 Control::onRender();
47
48 Vec2<int> controlOffset = {0, 0};
49 if (scroller == nullptr)
50 {
51 configureInternalScrollBar();
52 }
53
54 for (auto c = Controls.begin(); c != Controls.end(); c++)
55 {
56 auto ctrl = *c;
57 if (ctrl != scroller && ctrl->isVisible())
58 {
59 if (ListOrientation == ScrollOrientation && ItemSize != 0)
60 {
61 switch (ScrollOrientation)
62 {
63 case Orientation::Vertical:
64 ctrl->Size.x = (scroller_is_internal ? scroller->Location.x : this->Size.x);
65 ctrl->Size.y = ItemSize;
66 break;
67 case Orientation::Horizontal:
68 ctrl->Size.x = ItemSize;
69 ctrl->Size.y = (scroller_is_internal ? scroller->Location.y : this->Size.y);
70 break;
71 }
72 }
73
74 switch (ListOrientation)
75 {
76 case Orientation::Vertical:
77 if (ListOrientation != ScrollOrientation &&
78 controlOffset.y + ctrl->Size.y > Size.y)
79 {
80 controlOffset.y = 0;
81 controlOffset.x += ctrl->Size.x + ItemSpacing;
82 }
83 ctrl->Location = controlOffset - this->scrollOffset;
84 controlOffset.y += ctrl->Size.y + ItemSpacing;
85 break;
86 case Orientation::Horizontal:
87 if (ListOrientation != ScrollOrientation &&
88 controlOffset.x + ctrl->Size.x > Size.x)
89 {
90 controlOffset.x = 0;
91 controlOffset.y += ctrl->Size.y + ItemSpacing;
92 }
93 ctrl->Location = controlOffset - this->scrollOffset;
94 controlOffset.x += ctrl->Size.x + ItemSpacing;
95 break;
96 }
97 }
98 }
99
100 resolveLocation();
101 switch (ScrollOrientation)

Callers

nothing calls this directly

Calls 6

endMethod · 0.80
setMaximumMethod · 0.80
getMinimumMethod · 0.80
beginMethod · 0.45
isVisibleMethod · 0.45

Tested by

no test coverage detected