[escher] update the scroll indicator at each call to layoutSubviews

Change-Id: I3e3d5acbd983f30283ec2090fc7554c38c9cc4b7
This commit is contained in:
Émilie Feral
2016-09-22 15:58:18 +02:00
committed by Romain Goyet
parent 7708b903c9
commit 2e116344ea
2 changed files with 13 additions and 8 deletions

View File

@@ -15,6 +15,7 @@ protected:
KDCoordinate maxContentWidthDisplayableWithoutScrolling();
KDCoordinate maxContentHeightDisplayableWithoutScrolling();
void layoutSubviews() override;
void updateScrollIndicator();
#if ESCHER_VIEW_LOGGING
virtual const char * className() const override;
virtual void logAttributes(std::ostream &os) const override;

View File

@@ -56,18 +56,22 @@ void ScrollView::layoutSubviews() {
KDPoint absoluteOffset = m_offset.opposite().translatedBy(KDPoint(m_leftMargin, m_topMargin));
KDRect contentFrame = KDRect(absoluteOffset, m_contentView->bounds().size());
m_contentView->setFrame(contentFrame);
// We recompute the size of the scroll indicator
updateScrollIndicator();
}
void ScrollView::updateScrollIndicator() {
float contentHeight = m_contentView->bounds().height()+m_topMargin+m_bottomMargin;
float start = m_offset.y();
float end = m_offset.y() + m_frame.height();
m_verticalScrollIndicator.setStart(start/contentHeight);
m_verticalScrollIndicator.setEnd(end/contentHeight);
}
void ScrollView::setContentOffset(KDPoint offset) {
m_offset = offset;
float contentHeight = m_contentView->bounds().height()+m_topMargin+m_bottomMargin;
float start = offset.y();
float end = offset.y() + m_frame.height();
m_verticalScrollIndicator.setStart(start/contentHeight);
m_verticalScrollIndicator.setEnd(end/contentHeight);
layoutSubviews();
}