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

Method insertCellAtIndex

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

Source from the content-addressed store, hash-verified

183}
184
185void TableView::insertCellAtIndex(ssize_t idx)
186{
187 if (idx == AX_INVALID_INDEX)
188 {
189 return;
190 }
191
192 auto countOfItems = _dataSource->numberOfCellsInTableView(this);
193 if (0 == countOfItems || idx > countOfItems - 1)
194 {
195 return;
196 }
197
198 ssize_t newIdx = 0;
199
200 auto cell = cellAtIndex(idx);
201 if (cell)
202 {
203 newIdx = _cellsUsed.getIndex(cell);
204 // Move all cells behind the inserted position
205 for (auto i = newIdx; i < _cellsUsed.size(); i++)
206 {
207 cell = _cellsUsed.at(i);
208 this->_setIndexForCell(cell->getIdx() + 1, cell);
209 }
210 }
211
212 // insert a new cell
213 cell = _dataSource->tableCellAtIndex(this, idx);
214 this->_setIndexForCell(idx, cell);
215 this->_addCellIfNecessary(cell);
216
217 this->_updateCellPositions();
218 this->_updateContentSize();
219}
220
221void TableView::removeCellAtIndex(ssize_t idx)
222{

Calls 10

_setIndexForCellMethod · 0.95
_addCellIfNecessaryMethod · 0.95
_updateCellPositionsMethod · 0.95
_updateContentSizeMethod · 0.95
getIdxMethod · 0.80
getIndexMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
tableCellAtIndexMethod · 0.45

Tested by

no test coverage detected