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

Method updateScrollbar

launcher/ui/instanceview/InstanceView.cpp:125–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125void InstanceView::updateScrollbar()
126{
127 int previousScroll = verticalScrollBar()->value();
128 if (m_groups.isEmpty())
129 {
130 verticalScrollBar()->setRange(0, 0);
131 }
132 else
133 {
134 int totalHeight = 0;
135 // top margin
136 totalHeight += m_categoryMargin;
137 int itemScroll = 0;
138 for (auto category : m_groups)
139 {
140 category->m_verticalPosition = totalHeight;
141 totalHeight += category->totalHeight() + m_categoryMargin;
142 if(!itemScroll && category->totalHeight() != 0)
143 {
144 itemScroll = category->contentHeight() / category->numRows();
145 }
146 }
147 // do not divide by zero
148 if(itemScroll == 0)
149 itemScroll = 64;
150
151 totalHeight += m_bottomMargin;
152 verticalScrollBar()->setSingleStep ( itemScroll );
153 const int rowsPerPage = qMax ( viewport()->height() / itemScroll, 1 );
154 verticalScrollBar()->setPageStep ( rowsPerPage * itemScroll );
155
156 verticalScrollBar()->setRange(0, totalHeight - height());
157 }
158
159 verticalScrollBar()->setValue(qMin(previousScroll, verticalScrollBar()->maximum()));
160}
161
162void InstanceView::updateGeometries()
163{

Callers

nothing calls this directly

Calls 4

isEmptyMethod · 0.80
totalHeightMethod · 0.80
contentHeightMethod · 0.80
numRowsMethod · 0.80

Tested by

no test coverage detected