mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 15:50:49 +01:00
[escher] Add a ScrollViewDelegate
This commit is contained in:
committed by
LeaNumworks
parent
7851aa6fff
commit
daee2998c5
@@ -3,12 +3,23 @@
|
||||
|
||||
#include <kandinsky.h>
|
||||
|
||||
class ScrollViewDataSource;
|
||||
|
||||
class ScrollViewDelegate {
|
||||
public:
|
||||
virtual void scrollViewDidChangeOffset(ScrollViewDataSource * scrollViewDataSource) = 0;
|
||||
};
|
||||
|
||||
class ScrollViewDataSource {
|
||||
public:
|
||||
ScrollViewDataSource();
|
||||
KDPoint offset() const;
|
||||
ScrollViewDataSource() : m_delegate(nullptr), m_offset(KDPointZero) {}
|
||||
KDPoint offset() const { return m_offset; }
|
||||
bool setOffset(KDPoint offset);
|
||||
void setScrollViewDelegate(ScrollViewDelegate * delegate) {
|
||||
m_delegate = delegate;
|
||||
}
|
||||
private:
|
||||
ScrollViewDelegate * m_delegate;
|
||||
KDPoint m_offset;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
class ScrollableView : public Responder, public ScrollView {
|
||||
public:
|
||||
ScrollableView(Responder * parentResponder, View * view, ScrollViewDataSource * dataSource);
|
||||
ScrollableView(Responder * parentResponder, View * view, ScrollViewDataSource * dataSource);
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void reloadScroll(bool forceRelayout = false);
|
||||
protected:
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
#include <escher/scroll_view_data_source.h>
|
||||
|
||||
ScrollViewDataSource::ScrollViewDataSource() :
|
||||
m_offset(KDPointZero)
|
||||
{
|
||||
}
|
||||
|
||||
KDPoint ScrollViewDataSource::offset() const {
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
bool ScrollViewDataSource::setOffset(KDPoint offset) {
|
||||
if (offset != m_offset) {
|
||||
m_offset = offset;
|
||||
if (m_delegate) {
|
||||
m_delegate->scrollViewDidChangeOffset(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user