[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

@@ -104,10 +104,8 @@ KDRect ScrollView::visibleContentRect() {
}
void ScrollView::layoutSubviews() {
// Layout contentView
// We're only re-positionning the contentView, not modifying its size.
KDPoint absoluteOffset = contentOffset().opposite().translatedBy(KDPoint(m_leftMargin, m_topMargin));
KDRect contentFrame = KDRect(absoluteOffset, m_contentView->bounds().size());
KDRect contentFrame = KDRect(absoluteOffset, contentSize());
m_contentView->setFrame(contentFrame);
KDSize content(
m_contentView->bounds().width() + m_leftMargin + m_rightMargin,
@@ -116,10 +114,6 @@ void ScrollView::layoutSubviews() {
decorator()->layoutIndicators(content, contentOffset(), m_frame.size());
}
KDSize ScrollView::contentSize() {
return m_contentView->minimalSizeForOptimalDisplay();
}
void ScrollView::setContentOffset(KDPoint offset, bool forceRelayout) {
if (m_dataSource->setOffset(offset) || forceRelayout) {
layoutSubviews();