UI: Have scroll views directly remember their pos.

Kinda like checkboxes, cleaner this way.
This commit is contained in:
Unknown W. Brackets committed 2021-09-27 23:25:41 -07:00
1 parent 4d5a63a74e
commit fc78b408b2
4 files changed
+14 -16

No files matched your search

+3 -5
View File
@@ -1017,17 +1017,13 @@ void ScrollView::PersistData(PersistStatus status, std::string anonId, PersistMa
void ScrollView::SetVisibility(Visibility visibility) {
ViewGroup::SetVisibility(visibility);
if (visibility == V_GONE && !rememberPosition_) {
if (visibility == V_GONE && !rememberPos_) {
// Since this is no longer shown, forget the scroll position.
// For example, this happens when switching tabs.
ScrollTo(0.0f);
}
}
float ScrollView::GetScrollPosition() {
return scrollPos_;
}
void ScrollView::ScrollTo(float newScrollPos) {
scrollTarget_ = newScrollPos;
scrollToTarget_ = true;
@@ -1141,6 +1137,8 @@ void ScrollView::Update() {
if (oldPos != scrollPos_)
orientation_ == ORIENT_HORIZONTAL ? lastScrollPosX = scrollPos_ : lastScrollPosY = scrollPos_;
if (rememberPos_)
*rememberPos_ = scrollPos_;
}
void AnchorLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) {