MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / updateScrollbar

Method updateScrollbar

launcher/ui/instanceview/InstanceView.cpp:147–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147void InstanceView::updateScrollbar()
148{
149 int previousScroll = verticalScrollBar()->value();
150 if (m_groups.isEmpty()) {
151 verticalScrollBar()->setRange(0, 0);
152 } else {
153 int totalHeight = 0;
154 // top margin
155 totalHeight += m_categoryMargin;
156 int itemScroll = 0;
157 for (auto category : m_groups) {
158 category->m_verticalPosition = totalHeight;
159 totalHeight += category->totalHeight() + m_categoryMargin;
160 if (!itemScroll && category->totalHeight() != 0) {
161 itemScroll = category->contentHeight() / category->numRows();
162 }
163 }
164 // do not divide by zero
165 if (itemScroll == 0)
166 itemScroll = 64;
167
168 totalHeight += m_bottomMargin;
169 verticalScrollBar()->setSingleStep(itemScroll);
170 const int rowsPerPage = qMax(viewport()->height() / itemScroll, 1);
171 verticalScrollBar()->setPageStep(rowsPerPage * itemScroll);
172
173 verticalScrollBar()->setRange(0, totalHeight - height());
174 }
175
176 verticalScrollBar()->setValue(qMin(previousScroll, verticalScrollBar()->maximum()));
177}
178
179void InstanceView::updateGeometries()
180{

Callers

nothing calls this directly

Calls 7

valueMethod · 0.80
setRangeMethod · 0.80
totalHeightMethod · 0.80
contentHeightMethod · 0.80
numRowsMethod · 0.80
setValueMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected