summaryrefslogtreecommitdiff
path: root/indra/llui/llscrollcontainer.cpp
diff options
context:
space:
mode:
authorErik Kundiman <erik@megapahit.org>2026-09-01 18:35:23 +0800
committerErik Kundiman <erik@megapahit.org>2026-09-04 21:58:53 +0800
commit00bb3bb6f07660bd914d29a1389342bb3060d254 (patch)
tree431f574922494d2201718f13085f17bc6bd7fb42 /indra/llui/llscrollcontainer.cpp
parenta8636720129952c10cf49ab80da21bf8b340b96c (diff)
parent4ef9f8f14b35ed388c294d53767a0dca0e890924 (diff)
Merge remote-tracking branch 'secondlife/release/26.4' into 26.4
Diffstat (limited to 'indra/llui/llscrollcontainer.cpp')
-rw-r--r--indra/llui/llscrollcontainer.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp
index e36fd45bb4..ad2f58db69 100644
--- a/indra/llui/llscrollcontainer.cpp
+++ b/indra/llui/llscrollcontainer.cpp
@@ -75,6 +75,7 @@ LLScrollContainer::Params::Params()
max_auto_scroll_rate("max_auto_scroll_rate", 1000),
max_auto_scroll_zone("max_auto_scroll_zone", 16),
reserve_scroll_corner("reserve_scroll_corner", false),
+ keep_scroll_pos("keep_scroll_pos", false),
size("size", -1)
{}
@@ -93,8 +94,12 @@ LLScrollContainer::LLScrollContainer(const LLScrollContainer::Params& p)
mMaxAutoScrollRate(p.max_auto_scroll_rate),
mMaxAutoScrollZone(p.max_auto_scroll_zone),
mScrolledView(NULL),
+ mKeepScrollPos(p.keep_scroll_pos),
mSize(p.size)
{
+ mStoredDocPos[VERTICAL] = 0;
+ mStoredDocPos[HORIZONTAL] = 0;
+
static LLUICachedControl<S32> scrollbar_size_control ("UIScrollbarSize", 0);
S32 scrollbar_size = (mSize == -1 ? scrollbar_size_control : mSize);
@@ -605,6 +610,22 @@ void LLScrollContainer::updateScroll()
calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
S32 border_width = getBorderWidth();
+
+ // Remember the position only while the scrollbar is genuinely showing scrollable
+ // content, so a transient empty pass (e.g. a list clearing before it repopulates)
+ // cannot overwrite it with 0.
+ if (mKeepScrollPos)
+ {
+ if (show_v_scrollbar && mScrollbar[VERTICAL]->getVisible())
+ {
+ mStoredDocPos[VERTICAL] = mScrollbar[VERTICAL]->getDocPos();
+ }
+ if (show_h_scrollbar && mScrollbar[HORIZONTAL]->getVisible())
+ {
+ mStoredDocPos[HORIZONTAL] = mScrollbar[HORIZONTAL]->getDocPos();
+ }
+ }
+
if( show_v_scrollbar )
{
if( doc_rect.mTop < getRect().getHeight() - border_width )
@@ -673,6 +694,18 @@ void LLScrollContainer::updateScroll()
mScrollbar[VERTICAL]->setDocSize( doc_height );
mScrollbar[VERTICAL]->setPageSize( visible_height );
+
+ if (mKeepScrollPos)
+ {
+ if (show_v_scrollbar)
+ {
+ mScrollbar[VERTICAL]->setDocPos(mStoredDocPos[VERTICAL]);
+ }
+ if (show_h_scrollbar)
+ {
+ mScrollbar[HORIZONTAL]->setDocPos(mStoredDocPos[HORIZONTAL]);
+ }
+ }
} // end updateScroll
void LLScrollContainer::setBorderVisible(bool b)