MCPcopy Create free account
hub / github.com/axmolengine/axmol / scrollViewDidScroll

Method scrollViewDidScroll

extensions/GUI/src/GUI/ScrollView/TableView.cpp:471–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471void TableView::scrollViewDidScroll(ScrollView* /*view*/)
472{
473 if (!_dataSource)
474 return;
475 ssize_t countOfItems = _dataSource->numberOfCellsInTableView(this);
476 if (0 == countOfItems)
477 {
478 return;
479 }
480
481 if (_isUsedCellsDirty)
482 {
483 _isUsedCellsDirty = false;
484 std::sort(_cellsUsed.begin(), _cellsUsed.end(),
485 [](TableViewCell* a, TableViewCell* b) -> bool { return a->getIdx() < b->getIdx(); });
486 }
487
488 ssize_t startIdx = 0, endIdx = 0, idx = 0, maxIdx = 0;
489 Vec2 offset = this->getContentOffset() * -1;
490 maxIdx = MAX(countOfItems - 1, 0);
491
492 if (_vordering == VerticalFillOrder::TOP_DOWN)
493 {
494 offset.y = offset.y + _viewSize.height / this->getContainer()->getScaleY();
495 }
496 startIdx = this->_indexFromOffset(offset);
497 if (startIdx == AX_INVALID_INDEX)
498 {
499 startIdx = countOfItems - 1;
500 }
501
502 if (_vordering == VerticalFillOrder::TOP_DOWN)
503 {
504 offset.y -= _viewSize.height / this->getContainer()->getScaleY();
505 }
506 else
507 {
508 offset.y += _viewSize.height / this->getContainer()->getScaleY();
509 }
510 offset.x += _viewSize.width / this->getContainer()->getScaleX();
511
512 endIdx = this->_indexFromOffset(offset);
513 if (endIdx == AX_INVALID_INDEX)
514 {
515 endIdx = countOfItems - 1;
516 }
517
518#if 0 // For Testing.
519 Object* pObj;
520 int i = 0;
521 CCARRAY_FOREACH(_cellsUsed, pObj)
522 {
523 TableViewCell* pCell = static_cast<TableViewCell*>(pObj);
524 AXLOGD("cells Used index {}, value = {}", i, pCell->getIdx());
525 i++;
526 }
527 AXLOGD("---------------------------------------");
528 i = 0;

Callers 4

reloadDataMethod · 0.95
setContentOffsetMethod · 0.45
stoppedAnimatedScrollMethod · 0.45

Calls 15

_indexFromOffsetMethod · 0.95
_moveCellOutOfSightMethod · 0.95
updateCellAtIndexMethod · 0.95
getIdxMethod · 0.80
getContentOffsetMethod · 0.80
getContainerMethod · 0.80
sortFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
getScaleYMethod · 0.45
getScaleXMethod · 0.45

Tested by

no test coverage detected