From c18b156d8b5df7668b305e32b47652bdbdd329ca Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Mon, 11 Feb 2013 03:36:46 +0100 Subject: [PATCH] Bug fix for scrolling folder views. An LLFolderView is added as child to LLScrollableContainerView, but also adds the LLScrollableContainerView to it's mScrollContainer. As a result, when scrolling inside a LLFolderView the event is passed to the mScrollContainer, which then passes it first on to it's children (see the "Bad UI design" remark in the code), causing an infinite loop. This patch breaks that loop for those objects that have a mScrollContainer: LLFolderView and LLContainerView. --- indra/llui/llscrollcontainer.cpp | 5 +++-- indra/llui/llscrollcontainer.h | 2 ++ indra/newview/llcontainerview.cpp | 7 +++++++ indra/newview/llcontainerview.h | 2 +- indra/newview/llfolderview.cpp | 6 ++++++ indra/newview/llfolderview.h | 2 +- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/indra/llui/llscrollcontainer.cpp b/indra/llui/llscrollcontainer.cpp index 8e740384a..1206d3b76 100644 --- a/indra/llui/llscrollcontainer.cpp +++ b/indra/llui/llscrollcontainer.cpp @@ -77,7 +77,8 @@ LLScrollableContainerView::LLScrollableContainerView( const std::string& name, mReserveScrollCorner( FALSE ), mMinAutoScrollRate( MIN_AUTO_SCROLL_RATE ), mMaxAutoScrollRate( MAX_AUTO_SCROLL_RATE ), - mScrolledView( scrolled_view ) + mScrolledView( scrolled_view ), + mPassBackToChildren(true) { if( mScrolledView ) { @@ -218,7 +219,7 @@ BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks ) { // Give event to my child views - they may have scroll bars // (Bad UI design, but technically possible.) - if (LLUICtrl::handleScrollWheel(x,y,clicks)) + if (mPassBackToChildren && LLUICtrl::handleScrollWheel(x,y,clicks)) return TRUE; // When the vertical scrollbar is visible, scroll wheel diff --git a/indra/llui/llscrollcontainer.h b/indra/llui/llscrollcontainer.h index a5002a341..2e1cf1dd3 100644 --- a/indra/llui/llscrollcontainer.h +++ b/indra/llui/llscrollcontainer.h @@ -70,6 +70,7 @@ public: virtual void setValue(const LLSD& value) { mInnerRect.setValue(value); } void setBorderVisible( BOOL b ); + void setPassBackToChildren(bool b) { mPassBackToChildren = b; } void scrollToShowRect( const LLRect& rect, const LLRect& constraint); void scrollToShowRect( const LLRect& rect) { scrollToShowRect(rect, LLRect(0, mInnerRect.getHeight(), mInnerRect.getWidth(), 0)); } @@ -128,6 +129,7 @@ private: F32 mMinAutoScrollRate; F32 mMaxAutoScrollRate; bool mHideScrollbar; + bool mPassBackToChildren; }; diff --git a/indra/newview/llcontainerview.cpp b/indra/newview/llcontainerview.cpp index be7be72c7..e6d9b0119 100644 --- a/indra/newview/llcontainerview.cpp +++ b/indra/newview/llcontainerview.cpp @@ -278,3 +278,10 @@ void LLContainerView::setDisplayChildren(const BOOL displayChildren) childp->setVisible(mDisplayChildren); } } + +void LLContainerView::setScrollContainer(LLScrollableContainerView* scroll) +{ + mScrollContainer = scroll; + scroll->setPassBackToChildren(false); +} + diff --git a/indra/newview/llcontainerview.h b/indra/newview/llcontainerview.h index 37c2d97f3..1b337b09b 100644 --- a/indra/newview/llcontainerview.h +++ b/indra/newview/llcontainerview.h @@ -61,7 +61,7 @@ public: void showLabel(BOOL show) { mShowLabel = show; } void setDisplayChildren(const BOOL displayChildren); BOOL getDisplayChildren() { return mDisplayChildren; } - void setScrollContainer(LLScrollableContainerView* scroll) {mScrollContainer = scroll;} + void setScrollContainer(LLScrollableContainerView* scroll); private: LLScrollableContainerView* mScrollContainer; diff --git a/indra/newview/llfolderview.cpp b/indra/newview/llfolderview.cpp index bea49eb6b..e474dec9e 100644 --- a/indra/newview/llfolderview.cpp +++ b/indra/newview/llfolderview.cpp @@ -2068,6 +2068,12 @@ void LLFolderView::scrollToShowItem(LLFolderViewItem* item, const LLRect& constr } } +void LLFolderView::setScrollContainer(LLScrollableContainerView* parent) +{ + mScrollContainer = parent; + parent->setPassBackToChildren(false); +} + LLRect LLFolderView::getVisibleRect() { S32 visible_height = mScrollContainer->getRect().getHeight(); diff --git a/indra/newview/llfolderview.h b/indra/newview/llfolderview.h index 0d36bfe3b..c2771ed77 100644 --- a/indra/newview/llfolderview.h +++ b/indra/newview/llfolderview.h @@ -217,7 +217,7 @@ public: void scrollToShowSelection(); void scrollToShowItem(LLFolderViewItem* item, const LLRect& constraint_rect); - void setScrollContainer( LLScrollableContainerView* parent ) { mScrollContainer = parent; } + void setScrollContainer(LLScrollableContainerView* parent); LLRect getVisibleRect(); BOOL search(LLFolderViewItem* first_item, const std::string &search_string, BOOL backward);