[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:
Ruben Dashyan
2019-01-31 15:20:05 +01:00
committed by EmilieNumworks
parent c439d6f376
commit cda88b3c3b
6 changed files with 22 additions and 29 deletions

View File

@@ -50,10 +50,9 @@ void ScrollableView::reloadScroll(bool forceReLayout) {
setContentOffset(m_manualScrollingOffset, forceReLayout);
}
void ScrollableView::layoutSubviews() {
KDSize viewSize = contentSize();
KDCoordinate viewWidth = max(viewSize.width(), bounds().width() - leftMargin() - rightMargin());
KDCoordinate viewHeight = max(viewSize.height(), bounds().height() - topMargin() - bottomMargin());
m_contentView->setSize(KDSize(viewWidth, viewHeight));
ScrollView::layoutSubviews();
KDSize ScrollableView::contentSize() const {
KDSize viewSize = ScrollView::contentSize();
KDCoordinate viewWidth = max(viewSize.width(), maxContentWidthDisplayableWithoutScrolling());
KDCoordinate viewHeight = max(viewSize.height(), maxContentHeightDisplayableWithoutScrolling());
return KDSize(viewWidth, viewHeight);
}