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

Method updateSizeAndPosition

source/windowing/StarListWidget.cpp:105–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105void ListWidget::updateSizeAndPosition() {
106 int rows = m_members.size() % m_columns ? m_members.size() / m_columns + 1 : m_members.size() / m_columns;
107 for (size_t i = 0; i < m_members.size(); i++) {
108 Vec2I currentOffset;
109 int col = i % m_columns;
110 int row = rows - (i / m_columns) - 1;
111 if (m_fillDown)
112 row -= rows;
113 currentOffset = Vec2I((m_memberSize[0] + m_spacing[0]) * col, (m_memberSize[1] + m_spacing[1]) * row);
114 if (!m_fillDown)
115 currentOffset[1] += m_spacing[1];
116 m_members[i]->setPosition(currentOffset);
117 }
118 if (m_members.size()) {
119 auto width = (m_memberSize[0] + m_spacing[0]) * m_columns;
120 auto height = (m_memberSize[1] + m_spacing[1]) * rows;
121 setSize(Vec2I(width, height));
122 } else {
123 setSize(Vec2I());
124 }
125}
126
127void ListWidget::setEnabled(size_t pos, bool enabled) {
128 if (pos != NPos && pos < listSize()) {

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected