mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Escher: Use a scrollview
Change-Id: I24c754a7ea860b79d1d660adfbf143ed0e42c8a5
This commit is contained in:
@@ -4,6 +4,7 @@ objs += $(addprefix escher/src/,\
|
||||
app.o\
|
||||
childless_view.o\
|
||||
responder.o\
|
||||
scroll_view.o\
|
||||
solid_color_view.o\
|
||||
tab_view.o\
|
||||
tab_view_cell.o\
|
||||
|
||||
27
escher/include/escher/scroll_view.h
Normal file
27
escher/include/escher/scroll_view.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef ESCHER_SCROLL_VIEW_H
|
||||
#define ESCHER_SCROLL_VIEW_H
|
||||
|
||||
#include <escher/view.h>
|
||||
|
||||
class ScrollView : public View {
|
||||
public:
|
||||
ScrollView(View * contentView);
|
||||
|
||||
int numberOfSubviews() const override;
|
||||
const View * subview(int index) const override;
|
||||
void storeSubviewAtIndex(View * view, int index) override;
|
||||
void layoutSubviews() override;
|
||||
|
||||
void setContentOffset(KDPoint offset);
|
||||
protected:
|
||||
#if ESCHER_VIEW_LOGGING
|
||||
virtual const char * className() const;
|
||||
virtual void logAttributes(std::ostream &os) const;
|
||||
#endif
|
||||
private:
|
||||
KDPoint m_offset;
|
||||
View * m_contentView;
|
||||
//ScollIndicator m_verticalScrollIndicator;
|
||||
};
|
||||
|
||||
#endif
|
||||
46
escher/src/scroll_view.cpp
Normal file
46
escher/src/scroll_view.cpp
Normal 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
|
||||
Reference in New Issue
Block a user