summaryrefslogtreecommitdiff
path: root/indra/llui/llaccordionctrltab.cpp
diff options
context:
space:
mode:
authorandreykproductengine <andreykproductengine@lindenlab.com>2020-01-09 20:54:36 +0200
committerandreykproductengine <andreykproductengine@lindenlab.com>2020-01-09 20:54:36 +0200
commit941c1ee7f8a0446937c37ba6ce31503a0c360d50 (patch)
treee1800566b4a8fdec80962c56892888a57f95fa7a /indra/llui/llaccordionctrltab.cpp
parent7633285f9a8a2908e596df3316d025c0fb64a73e (diff)
SL-11172 Scroll to focused object if object is not in visible area
Diffstat (limited to 'indra/llui/llaccordionctrltab.cpp')
-rw-r--r--indra/llui/llaccordionctrltab.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp
index eaf1284237..d65d5b246e 100644
--- a/indra/llui/llaccordionctrltab.cpp
+++ b/indra/llui/llaccordionctrltab.cpp
@@ -452,6 +452,35 @@ void LLAccordionCtrlTab::onVisibilityChange(BOOL new_visibility)
notifyParent(LLSD().with("child_visibility_change", new_visibility));
}
+// virtual
+void LLAccordionCtrlTab::onChildGotFocus(const LLUICtrl *cntrl)
+{
+ if (mScrollbar && mScrollbar->getVisible())
+ {
+ LLRect rect;
+ cntrl->localRectToOtherView(cntrl->getLocalRect(), &rect, this);
+
+ // Translate to parent coordinatess to check if we are in visible rectangle
+ rect.translate(getRect().mLeft, getRect().mBottom);
+
+ if (!getRect().contains(rect))
+ {
+ // for accordition's scroll, height is in pixels
+ // Back to local coords and calculate position for scroller
+ S32 bottom = mScrollbar->getDocPos() - rect.mBottom + getRect().mBottom;
+ S32 top = mScrollbar->getDocPos() - rect.mTop + getRect().mTop;
+
+ S32 scroll_pos = llclamp(mScrollbar->getDocPos(),
+ bottom, // min vertical scroll
+ top); // max vertical scroll
+
+ mScrollbar->setDocPos(scroll_pos);
+ }
+ }
+
+ LLUICtrl::onChildGotFocus(cntrl);
+}
+
BOOL LLAccordionCtrlTab::handleMouseDown(S32 x, S32 y, MASK mask)
{
if(mCollapsible && mHeaderVisible && mCanOpenClose)