aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llscrollbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llui/llscrollbar.cpp')
-rw-r--r--linden/indra/llui/llscrollbar.cpp191
1 files changed, 81 insertions, 110 deletions
diff --git a/linden/indra/llui/llscrollbar.cpp b/linden/indra/llui/llscrollbar.cpp
index cf64742..cdabda0 100644
--- a/linden/indra/llui/llscrollbar.cpp
+++ b/linden/indra/llui/llscrollbar.cpp
@@ -414,17 +414,8 @@ BOOL LLScrollbar::handleHover(S32 x, S32 y, MASK mask)
414 414
415BOOL LLScrollbar::handleScrollWheel(S32 x, S32 y, S32 clicks) 415BOOL LLScrollbar::handleScrollWheel(S32 x, S32 y, S32 clicks)
416{ 416{
417 BOOL handled = FALSE; 417 changeLine( clicks * mStepSize, TRUE );
418 if( getVisible() && getRect().localPointInRect( x, y ) ) 418 return TRUE;
419 {
420 if( getEnabled() )
421 {
422 changeLine( clicks * mStepSize, TRUE );
423 }
424 handled = TRUE;
425 }
426
427 return handled;
428} 419}
429 420
430BOOL LLScrollbar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, 421BOOL LLScrollbar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
@@ -475,85 +466,68 @@ void LLScrollbar::reshape(S32 width, S32 height, BOOL called_from_parent)
475 466
476void LLScrollbar::draw() 467void LLScrollbar::draw()
477{ 468{
478 if( getVisible() ) 469 S32 local_mouse_x;
470 S32 local_mouse_y;
471 LLCoordWindow cursor_pos_window;
472 getWindow()->getCursorPosition(&cursor_pos_window);
473 LLCoordGL cursor_pos_gl;
474 getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl);
475
476 screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y);
477 BOOL other_captor = gFocusMgr.getMouseCapture() && gFocusMgr.getMouseCapture() != this;
478 BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y));
479 if (hovered)
479 { 480 {
480 S32 local_mouse_x; 481 mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f));
481 S32 local_mouse_y; 482 }
482 LLCoordWindow cursor_pos_window; 483 else
483 getWindow()->getCursorPosition(&cursor_pos_window); 484 {
484 LLCoordGL cursor_pos_gl; 485 mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f));
485 getWindow()->convertCoords(cursor_pos_window, &cursor_pos_gl); 486 }
486
487 screenPointToLocal(cursor_pos_gl.mX, cursor_pos_gl.mY, &local_mouse_x, &local_mouse_y);
488 BOOL other_captor = gFocusMgr.getMouseCapture() && gFocusMgr.getMouseCapture() != this;
489 BOOL hovered = getEnabled() && !other_captor && (hasMouseCapture() || mThumbRect.pointInRect(local_mouse_x, local_mouse_y));
490 if (hovered)
491 {
492 mCurGlowStrength = lerp(mCurGlowStrength, mHoverGlowStrength, LLCriticalDamp::getInterpolant(0.05f));
493 }
494 else
495 {
496 mCurGlowStrength = lerp(mCurGlowStrength, 0.f, LLCriticalDamp::getInterpolant(0.05f));
497 }
498 487
499 488
500 // Draw background and thumb. 489 // Draw background and thumb.
501 LLUUID rounded_rect_image_id; 490 LLUIImage* rounded_rect_imagep = LLUI::sImageProvider->getUIImage("rounded_square.tga");
502 rounded_rect_image_id.set(LLUI::sAssetsGroup->getString("rounded_square.tga"));
503 LLImageGL* rounded_rect_imagep = LLUI::sImageProvider->getImageByID(rounded_rect_image_id);
504 491
505 if (!rounded_rect_imagep) 492 if (!rounded_rect_imagep)
506 { 493 {
507 gl_rect_2d(mOrientation == HORIZONTAL ? SCROLLBAR_SIZE : 0, 494 gl_rect_2d(mOrientation == HORIZONTAL ? SCROLLBAR_SIZE : 0,
508 mOrientation == VERTICAL ? getRect().getHeight() - 2 * SCROLLBAR_SIZE : getRect().getHeight(), 495 mOrientation == VERTICAL ? getRect().getHeight() - 2 * SCROLLBAR_SIZE : getRect().getHeight(),
509 mOrientation == HORIZONTAL ? getRect().getWidth() - 2 * SCROLLBAR_SIZE : getRect().getWidth(), 496 mOrientation == HORIZONTAL ? getRect().getWidth() - 2 * SCROLLBAR_SIZE : getRect().getWidth(),
510 mOrientation == VERTICAL ? SCROLLBAR_SIZE : 0, mTrackColor, TRUE); 497 mOrientation == VERTICAL ? SCROLLBAR_SIZE : 0, mTrackColor, TRUE);
511 498
512 gl_rect_2d(mThumbRect, mThumbColor, TRUE); 499 gl_rect_2d(mThumbRect, mThumbColor, TRUE);
513 500
514 } 501 }
515 else 502 else
516 { 503 {
517 // Background 504 // Thumb
518 gl_draw_scaled_image_with_border(mOrientation == HORIZONTAL ? SCROLLBAR_SIZE : 0, 505 LLRect outline_rect = mThumbRect;
519 mOrientation == VERTICAL ? SCROLLBAR_SIZE : 0, 506 outline_rect.stretch(2);
520 16,
521 16,
522 mOrientation == HORIZONTAL ? getRect().getWidth() - 2 * SCROLLBAR_SIZE : getRect().getWidth(),
523 mOrientation == VERTICAL ? getRect().getHeight() - 2 * SCROLLBAR_SIZE : getRect().getHeight(),
524 rounded_rect_imagep,
525 mTrackColor,
526 TRUE);
527
528 // Thumb
529 LLRect outline_rect = mThumbRect;
530 outline_rect.stretch(2);
531
532 if (gFocusMgr.getKeyboardFocus() == this)
533 {
534 gl_draw_scaled_image_with_border(outline_rect.mLeft, outline_rect.mBottom, 16, 16, outline_rect.getWidth(), outline_rect.getHeight(),
535 rounded_rect_imagep, gFocusMgr.getFocusColor() );
536 }
537 507
538 gl_draw_scaled_image_with_border(mThumbRect.mLeft, mThumbRect.mBottom, 16, 16, mThumbRect.getWidth(), mThumbRect.getHeight(), 508 if (gFocusMgr.getKeyboardFocus() == this)
539 rounded_rect_imagep, mThumbColor ); 509 {
540 if (mCurGlowStrength > 0.01f) 510 rounded_rect_imagep->draw(outline_rect, gFocusMgr.getFocusColor());
541 {
542 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE);
543 gl_draw_scaled_image_with_border(mThumbRect.mLeft, mThumbRect.mBottom, 16, 16, mThumbRect.getWidth(), mThumbRect.getHeight(),
544 rounded_rect_imagep, LLColor4(1.f, 1.f, 1.f, mCurGlowStrength), TRUE);
545 gGL.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
546 }
547 } 511 }
548 512
549 BOOL was_scrolled_to_bottom = (getDocPos() == getDocPosMax()); 513 rounded_rect_imagep->draw(mThumbRect, mThumbColor);
550 if (mOnScrollEndCallback && was_scrolled_to_bottom) 514 if (mCurGlowStrength > 0.01f)
551 { 515 {
552 mOnScrollEndCallback(mOnScrollEndData); 516 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
517 rounded_rect_imagep->drawSolid(mThumbRect, LLColor4(1.f, 1.f, 1.f, mCurGlowStrength));
518 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
553 } 519 }
554 // Draw children 520
555 LLView::draw();
556 } 521 }
522
523 BOOL was_scrolled_to_bottom = (getDocPos() == getDocPosMax());
524 if (mOnScrollEndCallback && was_scrolled_to_bottom)
525 {
526 mOnScrollEndCallback(mOnScrollEndData);
527 }
528
529 // Draw children
530 LLView::draw();
557} // end draw 531} // end draw
558 532
559 533
@@ -582,42 +556,39 @@ void LLScrollbar::setValue(const LLSD& value)
582} 556}
583 557
584 558
585BOOL LLScrollbar::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) 559BOOL LLScrollbar::handleKeyHere(KEY key, MASK mask)
586{ 560{
587 BOOL handled = FALSE; 561 BOOL handled = FALSE;
588 562
589 if( getVisible() && getEnabled() && !called_from_parent ) 563 switch( key )
590 { 564 {
591 switch( key ) 565 case KEY_HOME:
592 { 566 changeLine( -mDocPos, TRUE );
593 case KEY_HOME: 567 handled = TRUE;
594 changeLine( -mDocPos, TRUE ); 568 break;
595 handled = TRUE; 569
596 break; 570 case KEY_END:
597 571 changeLine( getDocPosMax() - mDocPos, TRUE );
598 case KEY_END: 572 handled = TRUE;
599 changeLine( getDocPosMax() - mDocPos, TRUE ); 573 break;
600 handled = TRUE; 574
601 break; 575 case KEY_DOWN:
602 576 changeLine( mStepSize, TRUE );
603 case KEY_DOWN: 577 handled = TRUE;
604 changeLine( mStepSize, TRUE ); 578 break;
605 handled = TRUE; 579
606 break; 580 case KEY_UP:
607 581 changeLine( - mStepSize, TRUE );
608 case KEY_UP: 582 handled = TRUE;
609 changeLine( - mStepSize, TRUE ); 583 break;
610 handled = TRUE; 584
611 break; 585 case KEY_PAGE_DOWN:
612 586 pageDown(1);
613 case KEY_PAGE_DOWN: 587 break;
614 pageDown(1); 588
615 break; 589 case KEY_PAGE_UP:
616 590 pageUp(1);
617 case KEY_PAGE_UP: 591 break;
618 pageUp(1);
619 break;
620 }
621 } 592 }
622 593
623 return handled; 594 return handled;