Escher: Use a scrollview

Change-Id: I24c754a7ea860b79d1d660adfbf143ed0e42c8a5
This commit is contained in:
Romain Goyet
2016-05-30 18:28:18 +02:00
parent 4ed72f60df
commit eb3273d785
3 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
#include <escher/scroll_view.h>
extern "C" {
#include <assert.h>
}
ScrollView::ScrollView(View * contentView) :
View(),
m_offset(KDPointZero),
m_contentView(contentView)
{
setSubview(m_contentView, 0);
//setSubview(&m_verticalScrollIndicator, 1);
}
int ScrollView::numberOfSubviews() const {
return 1;
}
const View * ScrollView::subview(int index) const {
assert(index == 0);
return m_contentView;
}
void ScrollView::storeSubviewAtIndex(View * view, int index) {
assert(index == 0);
m_contentView = view;
}
void ScrollView::layoutSubviews() {
// Layout indicators
// TODO
// Layout contentview
// FIXME: Use KDCoordinateMax
m_contentView->setFrame({m_offset.x, m_offset.y, (KDCoordinate)9999, (KDCoordinate)9999});
}
#if ESCHER_VIEW_LOGGING
const char * ScrollView::className() const {
return "ScrollView";
}
void ScrollView::logAttributes(std::ostream &os) const {
View::logAttributes(os);
os << " offset=\"" << (int)m_offset.x << "," << (int)m_offset.y << "\"";
}
#endif