diff options
Diffstat (limited to 'linden/indra/llui/llscrollcontainer.cpp')
-rw-r--r-- | linden/indra/llui/llscrollcontainer.cpp | 176 |
1 files changed, 73 insertions, 103 deletions
diff --git a/linden/indra/llui/llscrollcontainer.cpp b/linden/indra/llui/llscrollcontainer.cpp index 15b59d4..a6c1c6d 100644 --- a/linden/indra/llui/llscrollcontainer.cpp +++ b/linden/indra/llui/llscrollcontainer.cpp | |||
@@ -61,6 +61,8 @@ static const F32 AUTO_SCROLL_RATE_ACCEL = 120.f; | |||
61 | /// Class LLScrollableContainerView | 61 | /// Class LLScrollableContainerView |
62 | ///---------------------------------------------------------------------------- | 62 | ///---------------------------------------------------------------------------- |
63 | 63 | ||
64 | static LLRegisterWidget<LLScrollableContainerView> r("scroll_container"); | ||
65 | |||
64 | // Default constructor | 66 | // Default constructor |
65 | LLScrollableContainerView::LLScrollableContainerView( const LLString& name, | 67 | LLScrollableContainerView::LLScrollableContainerView( const LLString& name, |
66 | const LLRect& rect, | 68 | const LLRect& rect, |
@@ -210,63 +212,33 @@ void LLScrollableContainerView::reshape(S32 width, S32 height, | |||
210 | } | 212 | } |
211 | } | 213 | } |
212 | 214 | ||
213 | BOOL LLScrollableContainerView::handleKey( KEY key, MASK mask, BOOL called_from_parent ) | 215 | BOOL LLScrollableContainerView::handleKeyHere(KEY key, MASK mask) |
214 | { | 216 | { |
215 | if( getVisible() && getEnabled() ) | 217 | for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) |
216 | { | 218 | { |
217 | if( called_from_parent ) | 219 | if( mScrollbar[i]->handleKeyHere(key, mask) ) |
218 | { | ||
219 | // Downward traversal | ||
220 | |||
221 | // Don't pass keys to scrollbars on downward. | ||
222 | |||
223 | // Handle 'child' view. | ||
224 | if( mScrolledView && mScrolledView->handleKey(key, mask, TRUE) ) | ||
225 | { | ||
226 | return TRUE; | ||
227 | } | ||
228 | } | ||
229 | else | ||
230 | { | 220 | { |
231 | // Upward traversal | 221 | return TRUE; |
232 | |||
233 | for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) | ||
234 | { | ||
235 | // Note: the scrollbar _is_ actually being called from it's parent. Here | ||
236 | // we're delgating LLScrollableContainerView's upward traversal to the scrollbars | ||
237 | if( mScrollbar[i]->handleKey(key, mask, TRUE) ) | ||
238 | { | ||
239 | return TRUE; | ||
240 | } | ||
241 | } | ||
242 | |||
243 | if (getParent()) | ||
244 | { | ||
245 | return getParent()->handleKey( key, mask, FALSE ); | ||
246 | } | ||
247 | } | 222 | } |
248 | } | 223 | } |
249 | 224 | ||
250 | return FALSE; | 225 | return FALSE; |
251 | } | 226 | } |
252 | 227 | ||
253 | BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks ) | 228 | BOOL LLScrollableContainerView::handleScrollWheel( S32 x, S32 y, S32 clicks ) |
254 | { | 229 | { |
255 | if( getEnabled() ) | 230 | for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) |
256 | { | 231 | { |
257 | for( S32 i = 0; i < SCROLLBAR_COUNT; i++ ) | 232 | // Note: tries vertical and then horizontal |
258 | { | ||
259 | // Note: tries vertical and then horizontal | ||
260 | 233 | ||
261 | // Pretend the mouse is over the scrollbar | 234 | // Pretend the mouse is over the scrollbar |
262 | if( mScrollbar[i]->handleScrollWheel( 0, 0, clicks ) ) | 235 | if( mScrollbar[i]->handleScrollWheel( 0, 0, clicks ) ) |
263 | { | 236 | { |
264 | return TRUE; | 237 | return TRUE; |
265 | } | ||
266 | } | 238 | } |
267 | } | 239 | } |
268 | 240 | ||
269 | // Opaque | 241 | // Eat scroll wheel event (to avoid scrolling nested containers?) |
270 | return TRUE; | 242 | return TRUE; |
271 | } | 243 | } |
272 | 244 | ||
@@ -446,80 +418,78 @@ void LLScrollableContainerView::draw() | |||
446 | // clear this flag to be set on next call to handleDragAndDrop | 418 | // clear this flag to be set on next call to handleDragAndDrop |
447 | mAutoScrolling = FALSE; | 419 | mAutoScrolling = FALSE; |
448 | 420 | ||
449 | if( getVisible() ) | 421 | // auto-focus when scrollbar active |
422 | // this allows us to capture user intent (i.e. stop automatically scrolling the view/etc) | ||
423 | if (!gFocusMgr.childHasKeyboardFocus(this) && | ||
424 | (mScrollbar[VERTICAL]->hasMouseCapture() || mScrollbar[HORIZONTAL]->hasMouseCapture())) | ||
450 | { | 425 | { |
451 | // auto-focus when scrollbar active | 426 | focusFirstItem(); |
452 | // this allows us to capture user intent (i.e. stop automatically scrolling the view/etc) | 427 | } |
453 | if (!gFocusMgr.childHasKeyboardFocus(this) && | ||
454 | (mScrollbar[VERTICAL]->hasMouseCapture() || mScrollbar[HORIZONTAL]->hasMouseCapture())) | ||
455 | { | ||
456 | focusFirstItem(); | ||
457 | } | ||
458 | 428 | ||
459 | // Draw background | 429 | // Draw background |
460 | if( mIsOpaque ) | 430 | if( mIsOpaque ) |
431 | { | ||
432 | LLGLSNoTexture no_texture; | ||
433 | glColor4fv( mBackgroundColor.mV ); | ||
434 | gl_rect_2d( mInnerRect ); | ||
435 | } | ||
436 | |||
437 | // Draw mScrolledViews and update scroll bars. | ||
438 | // get a scissor region ready, and draw the scrolling view. The | ||
439 | // scissor region ensures that we don't draw outside of the bounds | ||
440 | // of the rectangle. | ||
441 | if( mScrolledView ) | ||
442 | { | ||
443 | updateScroll(); | ||
444 | |||
445 | // Draw the scrolled area. | ||
461 | { | 446 | { |
462 | LLGLSNoTexture no_texture; | 447 | S32 visible_width = 0; |
463 | gGL.color4fv( mBackgroundColor.mV ); | 448 | S32 visible_height = 0; |
464 | gl_rect_2d( mInnerRect ); | 449 | BOOL show_v_scrollbar = FALSE; |
450 | BOOL show_h_scrollbar = FALSE; | ||
451 | calcVisibleSize( mScrolledView->getRect(), &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar ); | ||
452 | |||
453 | LLLocalClipRect clip(LLRect(mInnerRect.mLeft, | ||
454 | mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0) + visible_height, | ||
455 | visible_width, | ||
456 | mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0) | ||
457 | )); | ||
458 | drawChild(mScrolledView); | ||
465 | } | 459 | } |
466 | 460 | } | |
467 | // Draw mScrolledViews and update scroll bars. | ||
468 | // get a scissor region ready, and draw the scrolling view. The | ||
469 | // scissor region ensures that we don't draw outside of the bounds | ||
470 | // of the rectangle. | ||
471 | if( mScrolledView ) | ||
472 | { | ||
473 | updateScroll(); | ||
474 | 461 | ||
475 | // Draw the scrolled area. | 462 | // Highlight border if a child of this container has keyboard focus |
476 | { | 463 | if( mBorder->getVisible() ) |
477 | S32 visible_width = 0; | 464 | { |
478 | S32 visible_height = 0; | 465 | mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus(this) ); |
479 | BOOL show_v_scrollbar = FALSE; | 466 | } |
480 | BOOL show_h_scrollbar = FALSE; | ||
481 | calcVisibleSize( mScrolledView->getRect(), &visible_width, &visible_height, &show_h_scrollbar, &show_v_scrollbar ); | ||
482 | |||
483 | LLLocalClipRect clip(LLRect(mInnerRect.mLeft, | ||
484 | mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0) + visible_height, | ||
485 | visible_width, | ||
486 | mInnerRect.mBottom + (show_h_scrollbar ? SCROLLBAR_SIZE : 0) | ||
487 | )); | ||
488 | drawChild(mScrolledView); | ||
489 | } | ||
490 | } | ||
491 | 467 | ||
492 | // Highlight border if a child of this container has keyboard focus | 468 | // Draw all children except mScrolledView |
493 | if( mBorder->getVisible() ) | 469 | // Note: scrollbars have been adjusted by above drawing code |
470 | for (child_list_const_reverse_iter_t child_iter = getChildList()->rbegin(); | ||
471 | child_iter != getChildList()->rend(); ++child_iter) | ||
472 | { | ||
473 | LLView *viewp = *child_iter; | ||
474 | if( sDebugRects ) | ||
494 | { | 475 | { |
495 | mBorder->setKeyboardFocusHighlight( gFocusMgr.childHasKeyboardFocus(this) ); | 476 | sDepth++; |
496 | } | 477 | } |
497 | 478 | if( (viewp != mScrolledView) && viewp->getVisible() ) | |
498 | // Draw all children except mScrolledView | ||
499 | // Note: scrollbars have been adjusted by above drawing code | ||
500 | for (child_list_const_reverse_iter_t child_iter = getChildList()->rbegin(); | ||
501 | child_iter != getChildList()->rend(); ++child_iter) | ||
502 | { | 479 | { |
503 | LLView *viewp = *child_iter; | 480 | drawChild(viewp); |
504 | if( sDebugRects ) | ||
505 | { | ||
506 | sDepth++; | ||
507 | } | ||
508 | if( (viewp != mScrolledView) && viewp->getVisible() ) | ||
509 | { | ||
510 | drawChild(viewp); | ||
511 | } | ||
512 | if( sDebugRects ) | ||
513 | { | ||
514 | sDepth--; | ||
515 | } | ||
516 | } | 481 | } |
517 | 482 | if( sDebugRects ) | |
518 | if (sDebugRects) | ||
519 | { | 483 | { |
520 | drawDebugRect(); | 484 | sDepth--; |
521 | } | 485 | } |
522 | } | 486 | } |
487 | |||
488 | if (sDebugRects) | ||
489 | { | ||
490 | drawDebugRect(); | ||
491 | } | ||
492 | |||
523 | } // end draw | 493 | } // end draw |
524 | 494 | ||
525 | void LLScrollableContainerView::updateScroll() | 495 | void LLScrollableContainerView::updateScroll() |