MCPcopy Create free account
hub / github.com/MyGUI/mygui / updateItems

Method updateItems

UnitTests/UnitTest_TreeControl/TreeControl.cpp:234–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232 }
233
234 void TreeControl::updateItems()
235 {
236 int nPosition = mnTopIndex * mnItemHeight + mnTopOffset;
237
238 int nHeight = (int)mItemWidgets.size() * mnItemHeight - mnTopOffset;
239 while ((nHeight <= (getClientWidget()->getHeight() + mnItemHeight)) && mItemWidgets.size() < mnExpandedNodes)
240 {
241 TreeControlItem* pItem = getClientWidget()->createWidget<TreeControlItem>(
242 mstrSkinLine,
243 0,
244 nHeight,
245 getClientWidget()->getWidth(),
246 mnItemHeight,
247 Align::Top | Align::HStretch);
248
249 pItem->eventMouseButtonPressed += newDelegate(this, &TreeControl::notifyMousePressed);
250 pItem->eventMouseButtonDoubleClick += newDelegate(this, &TreeControl::notifyMouseDoubleClick);
251 pItem->eventMouseWheel += newDelegate(this, &TreeControl::notifyMouseWheel);
252 pItem->eventMouseSetFocus += newDelegate(this, &TreeControl::notifyMouseSetFocus);
253 pItem->eventMouseLostFocus += newDelegate(this, &TreeControl::notifyMouseLostFocus);
254 pItem->_setInternalData((size_t)mItemWidgets.size());
255 pItem->getButtonExpandCollapse()->eventMouseButtonClick +=
256 newDelegate(this, &TreeControl::notifyExpandCollapse);
257
258 mItemWidgets.push_back(pItem);
259
260 nHeight += mnItemHeight;
261 }
262
263 if (nPosition >= mnScrollRange)
264 {
265 if (mnScrollRange <= 0)
266 {
267 if (nPosition || mnTopOffset || mnTopIndex)
268 {
269 nPosition = 0;
270 mnTopIndex = 0;
271 mnTopOffset = 0;
272 }
273 }
274 else
275 {
276 int nCount = getClientWidget()->getHeight() / mnItemHeight;
277 mnTopOffset = mnItemHeight - (getClientWidget()->getHeight() % mnItemHeight);
278
279 if (mnTopOffset == mnItemHeight)
280 {
281 mnTopOffset = 0;
282 nCount--;
283 }
284
285 mnTopIndex = ((int)mnExpandedNodes) - nCount - 1;
286 nPosition = mnTopIndex * mnItemHeight + mnTopOffset;
287 }
288 }
289
290 mpWidgetScroll->setScrollPosition(nPosition);
291 }

Callers

nothing calls this directly

Calls 8

newDelegateFunction · 0.85
_setInternalDataMethod · 0.80
sizeMethod · 0.45
getHeightMethod · 0.45
getWidthMethod · 0.45
push_backMethod · 0.45
setScrollPositionMethod · 0.45

Tested by

no test coverage detected