mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-29 03:29:58 +02:00
[escher/scroll_view] Fix virtuality issues of layoutSubviews
Method contentSize() made virtual and overridden by ScrollableView so that ScrollableView and TableView do not need to setSize themselves and that setSize/setFrame is not called twice over m_contentView.
This commit is contained in:
committed by
EmilieNumworks
parent
c439d6f376
commit
cda88b3c3b
@@ -38,12 +38,20 @@ const char * TableView::className() const {
|
||||
#endif
|
||||
|
||||
void TableView::layoutSubviews() {
|
||||
// We only have to layout our contentView.
|
||||
// We will size it here, and ScrollView::layoutSubviews will position it.
|
||||
|
||||
m_contentView.resizeToFitContent();
|
||||
|
||||
ScrollView::layoutSubviews();
|
||||
m_contentView.layoutSubviews();
|
||||
/* FIXME:
|
||||
* On the one hand, ScrollView::layoutSubviews()
|
||||
* calls setFrame(...) over m_contentView,
|
||||
* which typically calls layoutSubviews() over m_contentView.
|
||||
* However, if the frame happens to be unchanged,
|
||||
* setFrame(...) does not call layoutSubviews.
|
||||
* On the other hand, calling only m_contentView.layoutSubviews()
|
||||
* does not relayout ScrollView when the offset
|
||||
* or the content's size changes.
|
||||
* For those reasons, we call both of them explicitly.
|
||||
* Finally, this solution is not optimal at all since
|
||||
* layoutSubviews is called twice over m_contentView. */
|
||||
}
|
||||
|
||||
void TableView::reloadCellAtLocation(int i, int j) {
|
||||
@@ -75,13 +83,6 @@ KDCoordinate TableView::ContentView::columnWidth(int i) const {
|
||||
return columnWidth;
|
||||
}
|
||||
|
||||
void TableView::ContentView::resizeToFitContent() {
|
||||
if (!(m_tableView->bounds() == KDRectZero)) {
|
||||
layoutSubviews();
|
||||
setSize(KDSize(width(), height()));
|
||||
}
|
||||
}
|
||||
|
||||
KDCoordinate TableView::ContentView::height() const {
|
||||
return m_dataSource->cumulatedHeightFromIndex(m_dataSource->numberOfRows())+m_verticalCellOverlap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user