mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-21 23:00:45 +01:00
Escher: TableView reuses cells
Change-Id: Icdbfafba351057affc2bcb74f9c967971ffee667
This commit is contained in:
@@ -30,13 +30,14 @@ TableView::ContentView::ContentView(TableViewDataSource * dataSource) :
|
||||
}
|
||||
|
||||
int TableView::ContentView::numberOfSubviews() const {
|
||||
int numberOfDisplayableCells = m_frame.height / m_dataSource->cellHeight();
|
||||
return MIN(m_dataSource->numberOfCells(), numberOfDisplayableCells);
|
||||
return MIN(m_dataSource->numberOfCells(), numberOfDisplayableCells());
|
||||
}
|
||||
|
||||
View * TableView::ContentView::subview(int index) {
|
||||
int offset = cellScrollingOffset();
|
||||
return m_dataSource->cellAtIndex(offset+index);
|
||||
View * cell = m_dataSource->reusableCell(index);
|
||||
m_dataSource->willDisplayCellForIndex(cell, offset+index);
|
||||
return cell;
|
||||
}
|
||||
|
||||
void TableView::ContentView::storeSubviewAtIndex(View * view, int index) {
|
||||
@@ -59,6 +60,10 @@ void TableView::ContentView::layoutSubviews() {
|
||||
}
|
||||
}
|
||||
|
||||
int TableView::ContentView::numberOfDisplayableCells() const {
|
||||
return m_frame.height / m_dataSource->cellHeight();
|
||||
}
|
||||
|
||||
// Index of the topmost cell
|
||||
int TableView::ContentView::cellScrollingOffset() {
|
||||
/* Here, we want to translate the offset at which our superview is displaying
|
||||
|
||||
Reference in New Issue
Block a user