From 941c1ee7f8a0446937c37ba6ce31503a0c360d50 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 9 Jan 2020 20:54:36 +0200 Subject: SL-11172 Scroll to focused object if object is not in visible area --- indra/llui/llaccordionctrl.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'indra/llui/llaccordionctrl.cpp') diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp index 623f570cef..779508df49 100644 --- a/indra/llui/llaccordionctrl.cpp +++ b/indra/llui/llaccordionctrl.cpp @@ -655,6 +655,37 @@ void LLAccordionCtrl::onScrollPosChangeCallback(S32, LLScrollbar*) { updateLayout(getRect().getWidth(),getRect().getHeight()); } + +// virtual +void LLAccordionCtrl::onChildGotFocus(const LLUICtrl *cntrl) +{ + if (mScrollbar && mScrollbar->getVisible()) + { + // same as scrollToShowRect + 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); +} + void LLAccordionCtrl::onOpen (const LLSD& key) { for(size_t i=0;i Date: Mon, 13 Apr 2020 15:06:11 +0300 Subject: SL-11172 Re-fixed, now should affect 'tab' only --- indra/llui/llaccordionctrl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llui/llaccordionctrl.cpp') diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp index 779508df49..962b8e9bb5 100644 --- a/indra/llui/llaccordionctrl.cpp +++ b/indra/llui/llaccordionctrl.cpp @@ -657,7 +657,7 @@ void LLAccordionCtrl::onScrollPosChangeCallback(S32, LLScrollbar*) } // virtual -void LLAccordionCtrl::onChildGotFocus(const LLUICtrl *cntrl) +void LLAccordionCtrl::onUpdateScrollToChild(const LLUICtrl *cntrl) { if (mScrollbar && mScrollbar->getVisible()) { @@ -683,7 +683,7 @@ void LLAccordionCtrl::onChildGotFocus(const LLUICtrl *cntrl) } } - LLUICtrl::onChildGotFocus(cntrl); + LLUICtrl::onUpdateScrollToChild(cntrl); } void LLAccordionCtrl::onOpen (const LLSD& key) -- cgit v1.2.3