Fixed up inventory filter. Basic folders now have an 'open' icon. Tweaked the indent size for inventory (looks a little nicer imo)
This commit is contained in:
@@ -69,52 +69,31 @@ LLScrollableContainerView::LLScrollableContainerView( const std::string& name,
|
||||
BOOL is_opaque,
|
||||
const LLColor4& bg_color ) :
|
||||
LLUICtrl( name, rect, FALSE, NULL, NULL ),
|
||||
mScrolledView( scrolled_view ),
|
||||
mIsOpaque( is_opaque ),
|
||||
mBackgroundColor( bg_color ),
|
||||
mReserveScrollCorner( FALSE ),
|
||||
mAutoScrolling( FALSE ),
|
||||
mAutoScrollRate( 0.f )
|
||||
mAutoScrollRate( 0.f ),
|
||||
mBackgroundColor( bg_color ),
|
||||
mIsOpaque( is_opaque ),
|
||||
mHideScrollbar( FALSE ),
|
||||
mReserveScrollCorner( FALSE ),
|
||||
mMinAutoScrollRate( MIN_AUTO_SCROLL_RATE ),
|
||||
mMaxAutoScrollRate( MAX_AUTO_SCROLL_RATE ),
|
||||
mScrolledView( scrolled_view )
|
||||
{
|
||||
if( mScrolledView )
|
||||
{
|
||||
addChild( mScrolledView );
|
||||
LLView::addChild( mScrolledView );
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
// LLUICtrl constructor
|
||||
LLScrollableContainerView::LLScrollableContainerView( const std::string& name, const LLRect& rect,
|
||||
LLUICtrl* scrolled_ctrl, BOOL is_opaque,
|
||||
const LLColor4& bg_color) :
|
||||
LLUICtrl( name, rect, FALSE, NULL, NULL ),
|
||||
mScrolledView( scrolled_ctrl ),
|
||||
mIsOpaque( is_opaque ),
|
||||
mBackgroundColor( bg_color ),
|
||||
mReserveScrollCorner( FALSE ),
|
||||
mAutoScrolling( FALSE ),
|
||||
mAutoScrollRate( 0.f )
|
||||
{
|
||||
if( scrolled_ctrl )
|
||||
{
|
||||
addChild( scrolled_ctrl );
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
void LLScrollableContainerView::init()
|
||||
{
|
||||
S32 scrollbar_size = SCROLLBAR_SIZE;
|
||||
LLRect border_rect( 0, getRect().getHeight(), getRect().getWidth(), 0 );
|
||||
mBorder = new LLViewBorder( std::string("scroll border"), border_rect, LLViewBorder::BEVEL_IN );
|
||||
addChild( mBorder );
|
||||
LLView::addChild( mBorder );
|
||||
|
||||
mInnerRect.set( 0, getRect().getHeight(), getRect().getWidth(), 0 );
|
||||
mInnerRect.stretch( -mBorder->getBorderWidth() );
|
||||
mInnerRect.stretch( -getBorderWidth() );
|
||||
|
||||
LLRect vertical_scroll_rect = mInnerRect;
|
||||
vertical_scroll_rect.mLeft = vertical_scroll_rect.mRight - SCROLLBAR_SIZE;
|
||||
vertical_scroll_rect.mLeft = vertical_scroll_rect.mRight - scrollbar_size;
|
||||
mScrollbar[VERTICAL] = new LLScrollbar( std::string("scrollable vertical"),
|
||||
vertical_scroll_rect,
|
||||
LLScrollbar::VERTICAL,
|
||||
@@ -123,14 +102,14 @@ void LLScrollableContainerView::init()
|
||||
mInnerRect.getHeight(),
|
||||
NULL, this,
|
||||
VERTICAL_MULTIPLE);
|
||||
addChild( mScrollbar[VERTICAL] );
|
||||
LLView::addChild( mScrollbar[VERTICAL] );
|
||||
mScrollbar[VERTICAL]->setVisible( FALSE );
|
||||
mScrollbar[VERTICAL]->setFollowsRight();
|
||||
mScrollbar[VERTICAL]->setFollowsTop();
|
||||
mScrollbar[VERTICAL]->setFollowsBottom();
|
||||
|
||||
LLRect horizontal_scroll_rect = mInnerRect;
|
||||
horizontal_scroll_rect.mTop = horizontal_scroll_rect.mBottom + SCROLLBAR_SIZE;
|
||||
horizontal_scroll_rect.mTop = horizontal_scroll_rect.mBottom + scrollbar_size;
|
||||
mScrollbar[HORIZONTAL] = new LLScrollbar( std::string("scrollable horizontal"),
|
||||
horizontal_scroll_rect,
|
||||
LLScrollbar::HORIZONTAL,
|
||||
@@ -139,7 +118,7 @@ void LLScrollableContainerView::init()
|
||||
mInnerRect.getWidth(),
|
||||
NULL, this,
|
||||
HORIZONTAL_MULTIPLE);
|
||||
addChild( mScrollbar[HORIZONTAL] );
|
||||
LLView::addChild( mScrollbar[HORIZONTAL] );
|
||||
mScrollbar[HORIZONTAL]->setVisible( FALSE );
|
||||
mScrollbar[HORIZONTAL]->setFollowsLeft();
|
||||
mScrollbar[HORIZONTAL]->setFollowsRight();
|
||||
@@ -190,8 +169,8 @@ void LLScrollableContainerView::reshape(S32 width, S32 height,
|
||||
{
|
||||
LLUICtrl::reshape( width, height, called_from_parent );
|
||||
|
||||
mInnerRect.set( 0, getRect().getHeight(), getRect().getWidth(), 0 );
|
||||
mInnerRect.stretch( -mBorder->getBorderWidth() );
|
||||
mInnerRect = getLocalRect();
|
||||
mInnerRect.stretch( -getBorderWidth() );
|
||||
|
||||
if (mScrolledView)
|
||||
{
|
||||
@@ -201,22 +180,33 @@ void LLScrollableContainerView::reshape(S32 width, S32 height,
|
||||
S32 visible_height = 0;
|
||||
BOOL show_v_scrollbar = FALSE;
|
||||
BOOL show_h_scrollbar = FALSE;
|
||||
calcVisibleSize( scrolled_rect, &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
|
||||
calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
|
||||
|
||||
mScrollbar[VERTICAL]->setDocSize( scrolled_rect.getHeight() );
|
||||
mScrollbar[VERTICAL]->setPageSize( visible_height );
|
||||
|
||||
mScrollbar[HORIZONTAL]->setDocSize( scrolled_rect.getWidth() );
|
||||
mScrollbar[HORIZONTAL]->setPageSize( visible_width );
|
||||
updateScroll();
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLScrollableContainerView::handleKeyHere(KEY key, MASK mask)
|
||||
{
|
||||
// allow scrolled view to handle keystrokes in case it delegated keyboard focus
|
||||
// to the scroll container.
|
||||
// NOTE: this should not recurse indefinitely as handleKeyHere
|
||||
// should not propagate to parent controls, so mScrolledView should *not*
|
||||
// call LLScrollContainer::handleKeyHere in turn
|
||||
if (mScrolledView && mScrolledView->handleKeyHere(key, mask))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
for( S32 i = 0; i < SCROLLBAR_COUNT; i++ )
|
||||
{
|
||||
if( mScrollbar[i]->handleKeyHere(key, mask) )
|
||||
{
|
||||
updateScroll();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -226,38 +216,37 @@ BOOL LLScrollableContainerView::handleKeyHere(KEY key, MASK mask)
|
||||
|
||||
BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks )
|
||||
{
|
||||
for( S32 i = 0; i < SCROLLBAR_COUNT; i++ )
|
||||
{
|
||||
// Note: tries vertical and then horizontal
|
||||
// Give event to my child views - they may have scroll bars
|
||||
// (Bad UI design, but technically possible.)
|
||||
if (LLUICtrl::handleScrollWheel(x,y,clicks))
|
||||
return TRUE;
|
||||
|
||||
// When the vertical scrollbar is visible, scroll wheel
|
||||
// only affects vertical scrolling. It's confusing to have
|
||||
// scroll wheel perform both vertical and horizontal in a
|
||||
// single container.
|
||||
LLScrollbar* vertical = mScrollbar[VERTICAL];
|
||||
if (vertical->getVisible()
|
||||
&& vertical->getEnabled())
|
||||
{
|
||||
// Pretend the mouse is over the scrollbar
|
||||
if( mScrollbar[i]->handleScrollWheel( 0, 0, clicks ) )
|
||||
if (vertical->handleScrollWheel( 0, 0, clicks ) )
|
||||
{
|
||||
return TRUE;
|
||||
updateScroll();
|
||||
}
|
||||
// Always eat the event
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Eat scroll wheel event (to avoid scrolling nested containers?)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL LLScrollableContainerView::needsToScroll(S32 x, S32 y, LLScrollableContainerView::SCROLL_ORIENTATION axis) const
|
||||
{
|
||||
if(mScrollbar[axis]->getVisible())
|
||||
LLScrollbar* horizontal = mScrollbar[HORIZONTAL];
|
||||
// Test enablement and visibility for consistency with
|
||||
// LLView::childrenHandleScrollWheel().
|
||||
if (horizontal->getVisible()
|
||||
&& horizontal->getEnabled()
|
||||
&& horizontal->handleScrollWheel( 0, 0, clicks ) )
|
||||
{
|
||||
LLRect inner_rect_local( 0, mInnerRect.getHeight(), mInnerRect.getWidth(), 0 );
|
||||
const S32 AUTOSCROLL_SIZE = 10;
|
||||
if(mScrollbar[axis]->getVisible())
|
||||
{
|
||||
inner_rect_local.mRight -= SCROLLBAR_SIZE;
|
||||
inner_rect_local.mTop += AUTOSCROLL_SIZE;
|
||||
inner_rect_local.mBottom = inner_rect_local.mTop - AUTOSCROLL_SIZE;
|
||||
}
|
||||
if( inner_rect_local.pointInRect( x, y ) && (mScrollbar[axis]->getDocPos() > 0) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
updateScroll();
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@@ -269,65 +258,10 @@ BOOL LLScrollableContainerView::handleDragAndDrop(S32 x, S32 y, MASK mask,
|
||||
EAcceptance* accept,
|
||||
std::string& tooltip_msg)
|
||||
{
|
||||
//S32 scrollbar_size = SCROLLBAR_SIZE;
|
||||
// Scroll folder view if needed. Never accepts a drag or drop.
|
||||
*accept = ACCEPT_NO;
|
||||
BOOL handled = FALSE;
|
||||
if( mScrollbar[HORIZONTAL]->getVisible() || mScrollbar[VERTICAL]->getVisible() )
|
||||
{
|
||||
const S32 AUTOSCROLL_SIZE = 10;
|
||||
S32 auto_scroll_speed = llround(mAutoScrollRate * LLFrameTimer::getFrameDeltaTimeF32());
|
||||
|
||||
LLRect inner_rect_local( 0, mInnerRect.getHeight(), mInnerRect.getWidth(), 0 );
|
||||
if( mScrollbar[HORIZONTAL]->getVisible() )
|
||||
{
|
||||
inner_rect_local.mBottom += SCROLLBAR_SIZE;
|
||||
}
|
||||
if( mScrollbar[VERTICAL]->getVisible() )
|
||||
{
|
||||
inner_rect_local.mRight -= SCROLLBAR_SIZE;
|
||||
}
|
||||
|
||||
if( mScrollbar[HORIZONTAL]->getVisible() )
|
||||
{
|
||||
LLRect left_scroll_rect = inner_rect_local;
|
||||
left_scroll_rect.mRight = AUTOSCROLL_SIZE;
|
||||
if( left_scroll_rect.pointInRect( x, y ) && (mScrollbar[HORIZONTAL]->getDocPos() > 0) )
|
||||
{
|
||||
mScrollbar[HORIZONTAL]->setDocPos( mScrollbar[HORIZONTAL]->getDocPos() - auto_scroll_speed );
|
||||
mAutoScrolling = TRUE;
|
||||
handled = TRUE;
|
||||
}
|
||||
|
||||
LLRect right_scroll_rect = inner_rect_local;
|
||||
right_scroll_rect.mLeft = inner_rect_local.mRight - AUTOSCROLL_SIZE;
|
||||
if( right_scroll_rect.pointInRect( x, y ) && (mScrollbar[HORIZONTAL]->getDocPos() < mScrollbar[HORIZONTAL]->getDocPosMax()) )
|
||||
{
|
||||
mScrollbar[HORIZONTAL]->setDocPos( mScrollbar[HORIZONTAL]->getDocPos() + auto_scroll_speed );
|
||||
mAutoScrolling = TRUE;
|
||||
handled = TRUE;
|
||||
}
|
||||
}
|
||||
if( mScrollbar[VERTICAL]->getVisible() )
|
||||
{
|
||||
LLRect bottom_scroll_rect = inner_rect_local;
|
||||
bottom_scroll_rect.mTop = AUTOSCROLL_SIZE + bottom_scroll_rect.mBottom;
|
||||
if( bottom_scroll_rect.pointInRect( x, y ) && (mScrollbar[VERTICAL]->getDocPos() < mScrollbar[VERTICAL]->getDocPosMax()) )
|
||||
{
|
||||
mScrollbar[VERTICAL]->setDocPos( mScrollbar[VERTICAL]->getDocPos() + auto_scroll_speed );
|
||||
mAutoScrolling = TRUE;
|
||||
handled = TRUE;
|
||||
}
|
||||
|
||||
LLRect top_scroll_rect = inner_rect_local;
|
||||
top_scroll_rect.mBottom = inner_rect_local.mTop - AUTOSCROLL_SIZE;
|
||||
if( top_scroll_rect.pointInRect( x, y ) && (mScrollbar[VERTICAL]->getDocPos() > 0) )
|
||||
{
|
||||
mScrollbar[VERTICAL]->setDocPos( mScrollbar[VERTICAL]->getDocPos() - auto_scroll_speed );
|
||||
mAutoScrolling = TRUE;
|
||||
handled = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
BOOL handled = autoScroll(x, y);
|
||||
|
||||
if( !handled )
|
||||
{
|
||||
@@ -338,6 +272,78 @@ BOOL LLScrollableContainerView::handleDragAndDrop(S32 x, S32 y, MASK mask,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool LLScrollableContainerView::autoScroll(S32 x, S32 y)
|
||||
{
|
||||
S32 scrollbar_size = SCROLLBAR_SIZE;
|
||||
|
||||
bool scrolling = false;
|
||||
if( mScrollbar[HORIZONTAL]->getVisible() || mScrollbar[VERTICAL]->getVisible() )
|
||||
{
|
||||
LLRect screen_local_extents;
|
||||
screenRectToLocal(getRootView()->getLocalRect(), &screen_local_extents);
|
||||
|
||||
LLRect inner_rect_local( 0, mInnerRect.getHeight(), mInnerRect.getWidth(), 0 );
|
||||
if( mScrollbar[HORIZONTAL]->getVisible() )
|
||||
{
|
||||
inner_rect_local.mBottom += scrollbar_size;
|
||||
}
|
||||
if( mScrollbar[VERTICAL]->getVisible() )
|
||||
{
|
||||
inner_rect_local.mRight -= scrollbar_size;
|
||||
}
|
||||
|
||||
// clip rect against root view
|
||||
inner_rect_local.intersectWith(screen_local_extents);
|
||||
|
||||
S32 auto_scroll_speed = llround(mAutoScrollRate * LLFrameTimer::getFrameDeltaTimeF32());
|
||||
// autoscroll region should take up no more than one third of visible scroller area
|
||||
S32 auto_scroll_region_width = llmin(inner_rect_local.getWidth() / 3, 10);
|
||||
S32 auto_scroll_region_height = llmin(inner_rect_local.getHeight() / 3, 10);
|
||||
|
||||
if( mScrollbar[HORIZONTAL]->getVisible() )
|
||||
{
|
||||
LLRect left_scroll_rect = screen_local_extents;
|
||||
left_scroll_rect.mRight = inner_rect_local.mLeft + auto_scroll_region_width;
|
||||
if( left_scroll_rect.pointInRect( x, y ) && (mScrollbar[HORIZONTAL]->getDocPos() > 0) )
|
||||
{
|
||||
mScrollbar[HORIZONTAL]->setDocPos( mScrollbar[HORIZONTAL]->getDocPos() - auto_scroll_speed );
|
||||
mAutoScrolling = TRUE;
|
||||
scrolling = true;
|
||||
}
|
||||
|
||||
LLRect right_scroll_rect = screen_local_extents;
|
||||
right_scroll_rect.mLeft = inner_rect_local.mRight - auto_scroll_region_width;
|
||||
if( right_scroll_rect.pointInRect( x, y ) && (mScrollbar[HORIZONTAL]->getDocPos() < mScrollbar[HORIZONTAL]->getDocPosMax()) )
|
||||
{
|
||||
mScrollbar[HORIZONTAL]->setDocPos( mScrollbar[HORIZONTAL]->getDocPos() + auto_scroll_speed );
|
||||
mAutoScrolling = TRUE;
|
||||
scrolling = true;
|
||||
}
|
||||
}
|
||||
if( mScrollbar[VERTICAL]->getVisible() )
|
||||
{
|
||||
LLRect bottom_scroll_rect = screen_local_extents;
|
||||
bottom_scroll_rect.mTop = inner_rect_local.mBottom + auto_scroll_region_height;
|
||||
if( bottom_scroll_rect.pointInRect( x, y ) && (mScrollbar[VERTICAL]->getDocPos() < mScrollbar[VERTICAL]->getDocPosMax()) )
|
||||
{
|
||||
mScrollbar[VERTICAL]->setDocPos( mScrollbar[VERTICAL]->getDocPos() + auto_scroll_speed );
|
||||
mAutoScrolling = TRUE;
|
||||
scrolling = true;
|
||||
}
|
||||
|
||||
LLRect top_scroll_rect = screen_local_extents;
|
||||
top_scroll_rect.mBottom = inner_rect_local.mTop - auto_scroll_region_height;
|
||||
if( top_scroll_rect.pointInRect( x, y ) && (mScrollbar[VERTICAL]->getDocPos() > 0) )
|
||||
{
|
||||
mScrollbar[VERTICAL]->setDocPos( mScrollbar[VERTICAL]->getDocPos() - auto_scroll_speed );
|
||||
mAutoScrolling = TRUE;
|
||||
scrolling = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return scrolling;
|
||||
}
|
||||
|
||||
|
||||
BOOL LLScrollableContainerView::handleToolTip(S32 x, S32 y, std::string& msg, LLRect* sticky_rect)
|
||||
{
|
||||
@@ -368,42 +374,44 @@ BOOL LLScrollableContainerView::handleToolTip(S32 x, S32 y, std::string& msg, LL
|
||||
|
||||
void LLScrollableContainerView::calcVisibleSize( S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const
|
||||
{
|
||||
const LLRect& rect = mScrolledView->getRect();
|
||||
calcVisibleSize(rect, visible_width, visible_height, show_h_scrollbar, show_v_scrollbar);
|
||||
}
|
||||
|
||||
void LLScrollableContainerView::calcVisibleSize( const LLRect& doc_rect, S32 *visible_width, S32 *visible_height, BOOL* show_h_scrollbar, BOOL* show_v_scrollbar ) const
|
||||
{
|
||||
const LLRect& doc_rect = getScrolledViewRect();
|
||||
S32 scrollbar_size = SCROLLBAR_SIZE;
|
||||
S32 doc_width = doc_rect.getWidth();
|
||||
S32 doc_height = doc_rect.getHeight();
|
||||
|
||||
*visible_width = getRect().getWidth() - 2 * mBorder->getBorderWidth();
|
||||
*visible_height = getRect().getHeight() - 2 * mBorder->getBorderWidth();
|
||||
S32 border_width = getBorderWidth();
|
||||
*visible_width = getRect().getWidth() - 2 * border_width;
|
||||
*visible_height = getRect().getHeight() - 2 * border_width;
|
||||
|
||||
*show_v_scrollbar = FALSE;
|
||||
if( *visible_height < doc_height )
|
||||
{
|
||||
*show_v_scrollbar = TRUE;
|
||||
*visible_width -= SCROLLBAR_SIZE;
|
||||
}
|
||||
|
||||
*show_h_scrollbar = FALSE;
|
||||
if( *visible_width < doc_width )
|
||||
{
|
||||
*show_h_scrollbar = TRUE;
|
||||
*visible_height -= SCROLLBAR_SIZE;
|
||||
|
||||
// Must retest now that visible_height has changed
|
||||
if( !*show_v_scrollbar && (*visible_height < doc_height) )
|
||||
if (!mHideScrollbar)
|
||||
{
|
||||
if( *visible_height < doc_height )
|
||||
{
|
||||
*show_v_scrollbar = TRUE;
|
||||
*visible_width -= SCROLLBAR_SIZE;
|
||||
*visible_width -= scrollbar_size;
|
||||
}
|
||||
|
||||
if( *visible_width < doc_width )
|
||||
{
|
||||
*show_h_scrollbar = TRUE;
|
||||
*visible_height -= scrollbar_size;
|
||||
|
||||
// Must retest now that visible_height has changed
|
||||
if( !*show_v_scrollbar && (*visible_height < doc_height) )
|
||||
{
|
||||
*show_v_scrollbar = TRUE;
|
||||
*visible_width -= scrollbar_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LLScrollableContainerView::draw()
|
||||
{
|
||||
S32 scrollbar_size = SCROLLBAR_SIZE;
|
||||
if (mAutoScrolling)
|
||||
{
|
||||
// add acceleration to autoscroll
|
||||
@@ -411,76 +419,79 @@ void LLScrollableContainerView::draw()
|
||||
}
|
||||
else
|
||||
{
|
||||
// reset to minimum
|
||||
mAutoScrollRate = MIN_AUTO_SCROLL_RATE;
|
||||
// reset to minimum for next time
|
||||
mAutoScrollRate = mMinAutoScrollRate;
|
||||
}
|
||||
// clear this flag to be set on next call to handleDragAndDrop
|
||||
// clear this flag to be set on next call to autoScroll
|
||||
mAutoScrolling = FALSE;
|
||||
|
||||
// auto-focus when scrollbar active
|
||||
// this allows us to capture user intent (i.e. stop automatically scrolling the view/etc)
|
||||
if (!gFocusMgr.childHasKeyboardFocus(this) &&
|
||||
(mScrollbar[VERTICAL]->hasMouseCapture() || mScrollbar[HORIZONTAL]->hasMouseCapture()))
|
||||
if (!hasFocus()
|
||||
&& (mScrollbar[VERTICAL]->hasMouseCapture() || mScrollbar[HORIZONTAL]->hasMouseCapture()))
|
||||
{
|
||||
focusFirstItem();
|
||||
}
|
||||
|
||||
// Draw background
|
||||
if( mIsOpaque )
|
||||
if (getRect().isValid())
|
||||
{
|
||||
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
|
||||
gGL.color4fv( mBackgroundColor.mV );
|
||||
gl_rect_2d( mInnerRect );
|
||||
}
|
||||
// Draw background
|
||||
if( mIsOpaque )
|
||||
{
|
||||
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
|
||||
gGL.color4fv( mBackgroundColor.mV );
|
||||
gl_rect_2d( mInnerRect );
|
||||
}
|
||||
|
||||
// Draw mScrolledViews and update scroll bars.
|
||||
// get a scissor region ready, and draw the scrolling view. The
|
||||
// scissor region ensures that we don't draw outside of the bounds
|
||||
// of the rectangle.
|
||||
if( mScrolledView )
|
||||
{
|
||||
updateScroll();
|
||||
|
||||
// Draw the scrolled area.
|
||||
// Draw mScrolledViews and update scroll bars.
|
||||
// get a scissor region ready, and draw the scrolling view. The
|
||||
// scissor region ensures that we don't draw outside of the bounds
|
||||
// of the rectangle.
|
||||
if( mScrolledView )
|
||||
{
|
||||
S32 visible_width = 0;
|
||||
S32 visible_height = 0;
|
||||
BOOL show_v_scrollbar = FALSE;
|
||||
BOOL show_h_scrollbar = FALSE;
|
||||
calcVisibleSize( mScrolledView->getRect(), &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
|
||||
updateScroll();
|
||||
|
||||
LLLocalClipRect clip(LLRect(mInnerRect.mLeft,
|
||||
mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0) + visible_height,
|
||||
visible_width,
|
||||
mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0)
|
||||
));
|
||||
drawChild(mScrolledView);
|
||||
// Draw the scrolled area.
|
||||
{
|
||||
S32 visible_width = 0;
|
||||
S32 visible_height = 0;
|
||||
BOOL show_v_scrollbar = FALSE;
|
||||
BOOL show_h_scrollbar = FALSE;
|
||||
calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
|
||||
|
||||
LLLocalClipRect clip(LLRect(mInnerRect.mLeft,
|
||||
mInnerRect.mBottom + (show_h_scrollbar ? scrollbar_size : 0) + visible_height,
|
||||
mInnerRect.mRight - (show_v_scrollbar ? scrollbar_size: 0),
|
||||
mInnerRect.mBottom + (show_h_scrollbar ? scrollbar_size : 0)
|
||||
));
|
||||
drawChild(mScrolledView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Highlight border if a child of this container has keyboard focus
|
||||
if( mBorder->getVisible() )
|
||||
{
|
||||
mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus(this) );
|
||||
}
|
||||
// Highlight border if a child of this container has keyboard focus
|
||||
if( mBorder->getVisible() )
|
||||
{
|
||||
mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus(this) );
|
||||
}
|
||||
|
||||
// Draw all children except mScrolledView
|
||||
// Note: scrollbars have been adjusted by above drawing code
|
||||
for (child_list_const_reverse_iter_t child_iter = getChildList()->rbegin();
|
||||
child_iter != getChildList()->rend(); ++child_iter)
|
||||
{
|
||||
LLView *viewp = *child_iter;
|
||||
if( sDebugRects )
|
||||
// Draw all children except mScrolledView
|
||||
// Note: scrollbars have been adjusted by above drawing code
|
||||
for (child_list_const_reverse_iter_t child_iter = getChildList()->rbegin();
|
||||
child_iter != getChildList()->rend(); ++child_iter)
|
||||
{
|
||||
sDepth++;
|
||||
}
|
||||
if( (viewp != mScrolledView) && viewp->getVisible() )
|
||||
{
|
||||
drawChild(viewp);
|
||||
}
|
||||
if( sDebugRects )
|
||||
{
|
||||
sDepth--;
|
||||
LLView *viewp = *child_iter;
|
||||
if( sDebugRects )
|
||||
{
|
||||
sDepth++;
|
||||
}
|
||||
if( (viewp != mScrolledView) && viewp->getVisible() )
|
||||
{
|
||||
drawChild(viewp);
|
||||
}
|
||||
if( sDebugRects )
|
||||
{
|
||||
sDepth--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -491,9 +502,30 @@ void LLScrollableContainerView::draw()
|
||||
|
||||
} // end draw
|
||||
|
||||
bool LLScrollableContainerView::addChild(LLView* view, S32 tab_group)
|
||||
{
|
||||
if (!mScrolledView)
|
||||
{
|
||||
// Use the first panel or container as the scrollable view (bit of a hack)
|
||||
mScrolledView = view;
|
||||
}
|
||||
|
||||
bool ret_val = LLView::addChild(view, tab_group);
|
||||
|
||||
//bring the scrollbars to the front
|
||||
sendChildToFront( mScrollbar[HORIZONTAL] );
|
||||
sendChildToFront( mScrollbar[VERTICAL] );
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
void LLScrollableContainerView::updateScroll()
|
||||
{
|
||||
if(!mScrolledView)return;
|
||||
if (!mScrolledView)
|
||||
{
|
||||
return;
|
||||
}
|
||||
S32 scrollbar_size = SCROLLBAR_SIZE;
|
||||
LLRect doc_rect = mScrolledView->getRect();
|
||||
S32 doc_width = doc_rect.getWidth();
|
||||
S32 doc_height = doc_rect.getHeight();
|
||||
@@ -501,9 +533,9 @@ void LLScrollableContainerView::updateScroll()
|
||||
S32 visible_height = 0;
|
||||
BOOL show_v_scrollbar = FALSE;
|
||||
BOOL show_h_scrollbar = FALSE;
|
||||
calcVisibleSize( doc_rect, &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
|
||||
calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
|
||||
|
||||
S32 border_width = mBorder->getBorderWidth();
|
||||
S32 border_width = getBorderWidth();
|
||||
if( show_v_scrollbar )
|
||||
{
|
||||
if( doc_rect.mTop < getRect().getHeight() - border_width )
|
||||
@@ -517,15 +549,15 @@ void LLScrollableContainerView::updateScroll()
|
||||
S32 v_scrollbar_height = visible_height;
|
||||
if( !show_h_scrollbar && mReserveScrollCorner )
|
||||
{
|
||||
v_scrollbar_height -= SCROLLBAR_SIZE;
|
||||
v_scrollbar_height -= scrollbar_size;
|
||||
}
|
||||
mScrollbar[VERTICAL]->reshape( SCROLLBAR_SIZE, v_scrollbar_height, TRUE );
|
||||
mScrollbar[VERTICAL]->reshape( scrollbar_size, v_scrollbar_height, TRUE );
|
||||
|
||||
// Make room for the horizontal scrollbar (or not)
|
||||
S32 v_scrollbar_offset = 0;
|
||||
if( show_h_scrollbar || mReserveScrollCorner )
|
||||
{
|
||||
v_scrollbar_offset = SCROLLBAR_SIZE;
|
||||
v_scrollbar_offset = scrollbar_size;
|
||||
}
|
||||
LLRect r = mScrollbar[VERTICAL]->getRect();
|
||||
r.translate( 0, mInnerRect.mBottom - r.mBottom + v_scrollbar_offset );
|
||||
@@ -555,9 +587,9 @@ void LLScrollableContainerView::updateScroll()
|
||||
S32 h_scrollbar_width = visible_width;
|
||||
if( !show_v_scrollbar && mReserveScrollCorner )
|
||||
{
|
||||
h_scrollbar_width -= SCROLLBAR_SIZE;
|
||||
h_scrollbar_width -= scrollbar_size;
|
||||
}
|
||||
mScrollbar[HORIZONTAL]->reshape( h_scrollbar_width, SCROLLBAR_SIZE, TRUE );
|
||||
mScrollbar[HORIZONTAL]->reshape( h_scrollbar_width, scrollbar_size, TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -577,8 +609,19 @@ void LLScrollableContainerView::updateScroll()
|
||||
void LLScrollableContainerView::setBorderVisible(BOOL b)
|
||||
{
|
||||
mBorder->setVisible( b );
|
||||
// Recompute inner rect, as border visibility changes it
|
||||
mInnerRect = getLocalRect();
|
||||
mInnerRect.stretch( -getBorderWidth() );
|
||||
}
|
||||
|
||||
LLRect LLScrollableContainerView::getVisibleContentRect()
|
||||
{
|
||||
updateScroll();
|
||||
LLRect visible_rect = getContentWindowRect();
|
||||
LLRect contents_rect = mScrolledView->getRect();
|
||||
visible_rect.translate(-contents_rect.mLeft, -contents_rect.mBottom);
|
||||
return visible_rect;
|
||||
}
|
||||
LLRect LLScrollableContainerView::getContentWindowRect()
|
||||
{
|
||||
updateScroll();
|
||||
@@ -588,7 +631,7 @@ LLRect LLScrollableContainerView::getContentWindowRect()
|
||||
BOOL show_h_scrollbar = FALSE;
|
||||
BOOL show_v_scrollbar = FALSE;
|
||||
calcVisibleSize( &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
|
||||
S32 border_width = mBorder->getBorderWidth();
|
||||
S32 border_width = getBorderWidth();
|
||||
scroller_view_rect.setOriginAndSize(border_width,
|
||||
show_h_scrollbar ? mScrollbar[HORIZONTAL]->getRect().mTop : border_width,
|
||||
visible_width,
|
||||
@@ -596,99 +639,85 @@ LLRect LLScrollableContainerView::getContentWindowRect()
|
||||
return scroller_view_rect;
|
||||
}
|
||||
|
||||
// Scroll so that as much of rect as possible is showing (where rect is defined in the space of scroller view, not scrolled)
|
||||
void LLScrollableContainerView::scrollToShowRect(const LLRect& rect, const LLCoordGL& desired_offset)
|
||||
// rect is in document coordinates, constraint is in display coordinates relative to content window rect
|
||||
void LLScrollableContainerView::scrollToShowRect(const LLRect& rect, const LLRect& constraint)
|
||||
{
|
||||
if (!mScrolledView)
|
||||
{
|
||||
llwarns << "LLScrollableContainerView::scrollToShowRect with no view!" << llendl;
|
||||
llwarns << "LLScrollContainer::scrollToShowRect with no view!" << llendl;
|
||||
return;
|
||||
}
|
||||
|
||||
S32 visible_width = 0;
|
||||
S32 visible_height = 0;
|
||||
BOOL show_v_scrollbar = FALSE;
|
||||
BOOL show_h_scrollbar = FALSE;
|
||||
const LLRect& scrolled_rect = mScrolledView->getRect();
|
||||
calcVisibleSize( scrolled_rect, &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar );
|
||||
LLRect content_window_rect = getContentWindowRect();
|
||||
// get document rect
|
||||
LLRect scrolled_rect = mScrolledView->getRect();
|
||||
|
||||
// can't be so far left that right side of rect goes off screen, or so far right that left side does
|
||||
S32 horiz_offset = llclamp(desired_offset.mX, llmin(0, -visible_width + rect.getWidth()), 0);
|
||||
// can't be so high that bottom of rect goes off screen, or so low that top does
|
||||
S32 vert_offset = llclamp(desired_offset.mY, 0, llmax(0, visible_height - rect.getHeight()));
|
||||
// shrink target rect to fit within constraint region, biasing towards top left
|
||||
LLRect rect_to_constrain = rect;
|
||||
rect_to_constrain.mBottom = llmax(rect_to_constrain.mBottom, rect_to_constrain.mTop - constraint.getHeight());
|
||||
rect_to_constrain.mRight = llmin(rect_to_constrain.mRight, rect_to_constrain.mLeft + constraint.getWidth());
|
||||
|
||||
// Vertical
|
||||
// 1. First make sure the top is visible
|
||||
// 2. Then, if possible without hiding the top, make the bottom visible.
|
||||
S32 vert_pos = mScrollbar[VERTICAL]->getDocPos();
|
||||
// calculate allowable positions for scroller window in document coordinates
|
||||
LLRect allowable_scroll_rect(rect_to_constrain.mRight - constraint.mRight,
|
||||
rect_to_constrain.mBottom - constraint.mBottom,
|
||||
rect_to_constrain.mLeft - constraint.mLeft,
|
||||
rect_to_constrain.mTop - constraint.mTop);
|
||||
|
||||
// find scrollbar position to get top of rect on screen (scrolling up)
|
||||
S32 top_offset = scrolled_rect.mTop - rect.mTop - vert_offset;
|
||||
// find scrollbar position to get bottom of rect on screen (scrolling down)
|
||||
S32 bottom_offset = vert_offset == 0 ? scrolled_rect.mTop - rect.mBottom - visible_height : top_offset;
|
||||
// scroll up far enough to see top or scroll down just enough if item is bigger than visual area
|
||||
if( vert_pos >= top_offset || visible_height < rect.getHeight())
|
||||
{
|
||||
vert_pos = top_offset;
|
||||
}
|
||||
// else scroll down far enough to see bottom
|
||||
else
|
||||
if( vert_pos <= bottom_offset )
|
||||
{
|
||||
vert_pos = bottom_offset;
|
||||
}
|
||||
// translate from allowable region for lower left corner to upper left corner
|
||||
allowable_scroll_rect.translate(0, content_window_rect.getHeight());
|
||||
|
||||
S32 vert_pos = llclamp(mScrollbar[VERTICAL]->getDocPos(),
|
||||
mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mTop, // min vertical scroll
|
||||
mScrollbar[VERTICAL]->getDocSize() - allowable_scroll_rect.mBottom); // max vertical scroll
|
||||
|
||||
mScrollbar[VERTICAL]->setDocSize( scrolled_rect.getHeight() );
|
||||
mScrollbar[VERTICAL]->setPageSize( visible_height );
|
||||
mScrollbar[VERTICAL]->setPageSize( content_window_rect.getHeight() );
|
||||
mScrollbar[VERTICAL]->setDocPos( vert_pos );
|
||||
|
||||
// Horizontal
|
||||
// 1. First make sure left side is visible
|
||||
// 2. Then, if possible without hiding the left side, make the right side visible.
|
||||
S32 horiz_pos = mScrollbar[HORIZONTAL]->getDocPos();
|
||||
S32 left_offset = rect.mLeft - scrolled_rect.mLeft + horiz_offset;
|
||||
S32 right_offset = horiz_offset == 0 ? rect.mRight - scrolled_rect.mLeft - visible_width : left_offset;
|
||||
S32 horizontal_pos = llclamp(mScrollbar[HORIZONTAL]->getDocPos(),
|
||||
allowable_scroll_rect.mLeft,
|
||||
allowable_scroll_rect.mRight);
|
||||
|
||||
if( horiz_pos >= left_offset || visible_width < rect.getWidth() )
|
||||
{
|
||||
horiz_pos = left_offset;
|
||||
}
|
||||
else if( horiz_pos <= right_offset )
|
||||
{
|
||||
horiz_pos = right_offset;
|
||||
}
|
||||
|
||||
mScrollbar[HORIZONTAL]->setDocSize( scrolled_rect.getWidth() );
|
||||
mScrollbar[HORIZONTAL]->setPageSize( visible_width );
|
||||
mScrollbar[HORIZONTAL]->setDocPos( horiz_pos );
|
||||
mScrollbar[HORIZONTAL]->setPageSize( content_window_rect.getWidth() );
|
||||
mScrollbar[HORIZONTAL]->setDocPos( horizontal_pos );
|
||||
|
||||
// propagate scroll to document
|
||||
updateScroll();
|
||||
|
||||
// In case we are in accordion tab notify parent to show selected rectangle
|
||||
LLRect screen_rc;
|
||||
localRectToScreen(rect_to_constrain, &screen_rc);
|
||||
notifyParent(LLSD().with("scrollToShowRect",screen_rc.getValue()));
|
||||
}
|
||||
|
||||
void LLScrollableContainerView::pageUp(S32 overlap)
|
||||
{
|
||||
mScrollbar[VERTICAL]->pageUp(overlap);
|
||||
updateScroll();
|
||||
}
|
||||
|
||||
void LLScrollableContainerView::pageDown(S32 overlap)
|
||||
{
|
||||
mScrollbar[VERTICAL]->pageDown(overlap);
|
||||
updateScroll();
|
||||
}
|
||||
|
||||
void LLScrollableContainerView::goToTop()
|
||||
{
|
||||
mScrollbar[VERTICAL]->setDocPos(0);
|
||||
updateScroll();
|
||||
}
|
||||
|
||||
void LLScrollableContainerView::goToBottom()
|
||||
{
|
||||
mScrollbar[VERTICAL]->setDocPos(mScrollbar[VERTICAL]->getDocSize());
|
||||
updateScroll();
|
||||
}
|
||||
|
||||
S32 LLScrollableContainerView::getBorderWidth() const
|
||||
{
|
||||
if (mBorder)
|
||||
if (mBorder && mBorder->getVisible())
|
||||
{
|
||||
return mBorder->getBorderWidth();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user