mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-23 15:50:49 +01:00
[escher] ScrollableView: discard duplicate data source of scrolling
offset
This commit is contained in:
@@ -7,8 +7,7 @@ static inline KDCoordinate maxCoordinate(KDCoordinate x, KDCoordinate y) { retur
|
||||
|
||||
ScrollableView::ScrollableView(Responder * parentResponder, View * view, ScrollViewDataSource * dataSource) :
|
||||
Responder(parentResponder),
|
||||
ScrollView(view, dataSource),
|
||||
m_manualScrollingOffset(KDPointZero)
|
||||
ScrollView(view, dataSource)
|
||||
{
|
||||
setDecoratorType(ScrollView::Decorator::Type::None);
|
||||
}
|
||||
@@ -16,40 +15,38 @@ ScrollableView::ScrollableView(Responder * parentResponder, View * view, ScrollV
|
||||
bool ScrollableView::handleEvent(Ion::Events::Event event) {
|
||||
KDPoint translation = KDPointZero;
|
||||
if (event == Ion::Events::Left) {
|
||||
KDCoordinate movementToEdge = m_manualScrollingOffset.x();
|
||||
KDCoordinate movementToEdge = contentOffset().x();
|
||||
if (movementToEdge > 0) {
|
||||
translation = KDPoint(-minCoordinate(Metric::ScrollStep, movementToEdge), 0);
|
||||
}
|
||||
}
|
||||
if (event == Ion::Events::Right) {
|
||||
KDCoordinate movementToEdge = minimalSizeForOptimalDisplay().width() - bounds().width() - m_manualScrollingOffset.x();
|
||||
KDCoordinate movementToEdge = minimalSizeForOptimalDisplay().width() - bounds().width() - contentOffset().x();
|
||||
if (movementToEdge > 0) {
|
||||
translation = KDPoint(minCoordinate(Metric::ScrollStep, movementToEdge), 0);
|
||||
}
|
||||
}
|
||||
if (event == Ion::Events::Up) {
|
||||
KDCoordinate movementToEdge = m_manualScrollingOffset.y();
|
||||
KDCoordinate movementToEdge = contentOffset().y();
|
||||
if (movementToEdge > 0) {
|
||||
translation = KDPoint(0, -minCoordinate(Metric::ScrollStep, movementToEdge));
|
||||
}
|
||||
}
|
||||
if (event == Ion::Events::Down) {
|
||||
KDCoordinate movementToEdge = minimalSizeForOptimalDisplay().height() - bounds().height() - m_manualScrollingOffset.y();
|
||||
KDCoordinate movementToEdge = minimalSizeForOptimalDisplay().height() - bounds().height() - contentOffset().y();
|
||||
if (movementToEdge > 0) {
|
||||
translation = KDPoint(0, minCoordinate(Metric::ScrollStep, movementToEdge));
|
||||
}
|
||||
}
|
||||
if (translation != KDPointZero) {
|
||||
m_manualScrollingOffset = m_manualScrollingOffset.translatedBy(translation);
|
||||
setContentOffset(m_manualScrollingOffset);
|
||||
setContentOffset(contentOffset().translatedBy(translation));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScrollableView::reloadScroll(bool forceReLayout) {
|
||||
m_manualScrollingOffset = KDPointZero;
|
||||
setContentOffset(m_manualScrollingOffset, forceReLayout);
|
||||
setContentOffset(KDPointZero, forceReLayout);
|
||||
}
|
||||
|
||||
KDSize ScrollableView::contentSize() const {
|
||||
|
||||
Reference in New Issue
Block a user