aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llui/llmultislider.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:42 -0500
committerJacek Antonelli2008-08-15 23:45:42 -0500
commitce28e056c20bf2723f565bbf464b87781ec248a2 (patch)
treeef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llui/llmultislider.cpp
parentSecond Life viewer sources 1.19.1.4b (diff)
downloadmeta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2
meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz
Second Life viewer sources 1.20.2
Diffstat (limited to 'linden/indra/llui/llmultislider.cpp')
-rw-r--r--linden/indra/llui/llmultislider.cpp308
1 files changed, 131 insertions, 177 deletions
diff --git a/linden/indra/llui/llmultislider.cpp b/linden/indra/llui/llmultislider.cpp
index d0c9002..dfa36fa 100644
--- a/linden/indra/llui/llmultislider.cpp
+++ b/linden/indra/llui/llmultislider.cpp
@@ -43,6 +43,8 @@
43 43
44#include <sstream> 44#include <sstream>
45 45
46static LLRegisterWidget<LLMultiSlider> r("multi_slider_bar");
47
46const S32 MULTI_THUMB_WIDTH = 8; 48const S32 MULTI_THUMB_WIDTH = 8;
47const S32 MULTI_TRACK_HEIGHT = 6; 49const S32 MULTI_TRACK_HEIGHT = 6;
48const F32 FLOAT_THRESHOLD = 0.00001f; 50const F32 FLOAT_THRESHOLD = 0.00001f;
@@ -98,16 +100,6 @@ LLMultiSlider::LLMultiSlider(
98 setValue(getValue()); 100 setValue(getValue());
99} 101}
100 102
101EWidgetType LLMultiSlider::getWidgetType() const
102{
103 return WIDGET_TYPE_MULTI_SLIDER_BAR;
104}
105
106LLString LLMultiSlider::getWidgetTag() const
107{
108 return LL_MULTI_SLIDER_TAG;
109}
110
111void LLMultiSlider::setSliderValue(const LLString& name, F32 value, BOOL from_event) 103void LLMultiSlider::setSliderValue(const LLString& name, F32 value, BOOL from_event)
112{ 104{
113 // exit if not there 105 // exit if not there
@@ -403,31 +395,28 @@ BOOL LLMultiSlider::handleMouseDown(S32 x, S32 y, MASK mask)
403 return TRUE; 395 return TRUE;
404} 396}
405 397
406BOOL LLMultiSlider::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) 398BOOL LLMultiSlider::handleKeyHere(KEY key, MASK mask)
407{ 399{
408 BOOL handled = FALSE; 400 BOOL handled = FALSE;
409 if( getVisible() && getEnabled() && !called_from_parent ) 401 switch(key)
410 { 402 {
411 switch(key) 403 case KEY_UP:
412 { 404 case KEY_DOWN:
413 case KEY_UP: 405 // eat up and down keys to be consistent
414 case KEY_DOWN: 406 handled = TRUE;
415 // eat up and down keys to be consistent 407 break;
416 handled = TRUE; 408 case KEY_LEFT:
417 break; 409 setCurSliderValue(getCurSliderValue() - getIncrement());
418 case KEY_LEFT: 410 onCommit();
419 setCurSliderValue(getCurSliderValue() - getIncrement()); 411 handled = TRUE;
420 onCommit(); 412 break;
421 handled = TRUE; 413 case KEY_RIGHT:
422 break; 414 setCurSliderValue(getCurSliderValue() + getIncrement());
423 case KEY_RIGHT: 415 onCommit();
424 setCurSliderValue(getCurSliderValue() + getIncrement()); 416 handled = TRUE;
425 onCommit(); 417 break;
426 handled = TRUE; 418 default:
427 break; 419 break;
428 default:
429 break;
430 }
431 } 420 }
432 return handled; 421 return handled;
433} 422}
@@ -438,177 +427,142 @@ void LLMultiSlider::draw()
438 427
439 std::map<LLString, LLRect>::iterator mIt; 428 std::map<LLString, LLRect>::iterator mIt;
440 std::map<LLString, LLRect>::iterator curSldrIt; 429 std::map<LLString, LLRect>::iterator curSldrIt;
441 if( getVisible() )
442 {
443 // Draw background and thumb.
444 430
445 // drawing solids requires texturing be disabled 431 // Draw background and thumb.
446 LLGLSNoTexture no_texture;
447 432
448 LLRect rect(mDragStartThumbRect); 433 // drawing solids requires texturing be disabled
434 LLGLSNoTexture no_texture;
449 435
450 F32 opacity = getEnabled() ? 1.f : 0.3f; 436 LLRect rect(mDragStartThumbRect);
451 437
452 // Track 438 F32 opacity = getEnabled() ? 1.f : 0.3f;
453 LLUUID thumb_image_id;
454 thumb_image_id.set(LLUI::sAssetsGroup->getString("rounded_square.tga"));
455 LLPointer<LLImageGL> thumb_imagep(LLUI::sImageProvider->getUIImageByID(thumb_image_id)->getImage());
456 439
457 S32 height_offset = (getRect().getHeight() - MULTI_TRACK_HEIGHT) / 2; 440 // Track
458 LLRect track_rect(0, getRect().getHeight() - height_offset, getRect().getWidth(), height_offset ); 441 LLUIImagePtr thumb_imagep = LLUI::sImageProvider->getUIImage("rounded_square.tga");
459 442
443 S32 height_offset = (getRect().getHeight() - MULTI_TRACK_HEIGHT) / 2;
444 LLRect track_rect(0, getRect().getHeight() - height_offset, getRect().getWidth(), height_offset );
460 445
461 if(mDrawTrack)
462 {
463 track_rect.stretch(-1);
464 gl_draw_scaled_image_with_border(track_rect.mLeft, track_rect.mBottom, 16, 16, track_rect.getWidth(), track_rect.getHeight(),
465 thumb_imagep, mTrackColor % opacity);
466 }
467 446
468 // if we're supposed to use a drawn triangle 447 if(mDrawTrack)
469 // simple gl call for the triangle 448 {
470 if(mUseTriangle) { 449 track_rect.stretch(-1);
450 thumb_imagep->draw(track_rect, mTrackColor % opacity);
451 }
471 452
472 for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) { 453 // if we're supposed to use a drawn triangle
454 // simple gl call for the triangle
455 if(mUseTriangle) {
473 456
474 gl_triangle_2d( 457 for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) {
475 mIt->second.mLeft - EXTRA_TRIANGLE_WIDTH, 458
476 mIt->second.mTop + EXTRA_TRIANGLE_HEIGHT, 459 gl_triangle_2d(
477 mIt->second.mRight + EXTRA_TRIANGLE_WIDTH, 460 mIt->second.mLeft - EXTRA_TRIANGLE_WIDTH,
478 mIt->second.mTop + EXTRA_TRIANGLE_HEIGHT, 461 mIt->second.mTop + EXTRA_TRIANGLE_HEIGHT,
479 mIt->second.mLeft + mIt->second.getWidth() / 2, 462 mIt->second.mRight + EXTRA_TRIANGLE_WIDTH,
480 mIt->second.mBottom - EXTRA_TRIANGLE_HEIGHT, 463 mIt->second.mTop + EXTRA_TRIANGLE_HEIGHT,
481 mTriangleColor, TRUE); 464 mIt->second.mLeft + mIt->second.getWidth() / 2,
482 } 465 mIt->second.mBottom - EXTRA_TRIANGLE_HEIGHT,
466 mTriangleColor, TRUE);
483 } 467 }
484 else if (!thumb_imagep) 468 }
485 { 469 else if (!thumb_imagep)
486 // draw all the thumbs 470 {
487 curSldrIt = mThumbRects.end(); 471 // draw all the thumbs
488 for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) { 472 curSldrIt = mThumbRects.end();
473 for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) {
474
475 // choose the color
476 curThumbColor = mThumbCenterColor;
477 if(mIt->first == mCurSlider) {
489 478
490 // choose the color 479 curSldrIt = mIt;
491 curThumbColor = mThumbCenterColor; 480 continue;
492 if(mIt->first == mCurSlider) { 481 //curThumbColor = mThumbCenterSelectedColor;
493
494 curSldrIt = mIt;
495 continue;
496 //curThumbColor = mThumbCenterSelectedColor;
497 }
498
499 // the draw command
500 gl_rect_2d(mIt->second, curThumbColor, TRUE);
501 } 482 }
502 483
503 // now draw the current slider 484 // the draw command
504 if(curSldrIt != mThumbRects.end()) { 485 gl_rect_2d(mIt->second, curThumbColor, TRUE);
505 gl_rect_2d(curSldrIt->second, mThumbCenterSelectedColor, TRUE); 486 }
506 }
507 487
508 // and draw the drag start 488 // now draw the current slider
509 if (gFocusMgr.getMouseCapture() == this) 489 if(curSldrIt != mThumbRects.end()) {
510 { 490 gl_rect_2d(curSldrIt->second, mThumbCenterSelectedColor, TRUE);
511 gl_rect_2d(mDragStartThumbRect, mThumbCenterColor % opacity, FALSE);
512 }
513 } 491 }
514 else if( gFocusMgr.getMouseCapture() == this ) 492
493 // and draw the drag start
494 if (gFocusMgr.getMouseCapture() == this)
515 { 495 {
516 // draw drag start 496 gl_rect_2d(mDragStartThumbRect, mThumbCenterColor % opacity, FALSE);
517 gl_draw_scaled_image_with_border(mDragStartThumbRect.mLeft, 497 }
518 mDragStartThumbRect.mBottom, 16, 16, 498 }
519 mDragStartThumbRect.getWidth(), 499 else if( gFocusMgr.getMouseCapture() == this )
520 mDragStartThumbRect.getHeight(), 500 {
521 thumb_imagep, mThumbCenterColor % 0.3f, TRUE); 501 // draw drag start
522 502 thumb_imagep->drawSolid(mDragStartThumbRect, mThumbCenterColor % 0.3f);
523 // draw the highlight 503
524 if (hasFocus()) 504 // draw the highlight
505 if (hasFocus())
506 {
507 thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth());
508 }
509
510 // draw the thumbs
511 curSldrIt = mThumbRects.end();
512 for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++)
513 {
514 // choose the color
515 curThumbColor = mThumbCenterColor;
516 if(mIt->first == mCurSlider)
525 { 517 {
526 F32 lerp_amt = gFocusMgr.getFocusFlashAmt(); 518 // don't draw now, draw last
527 LLRect highlight_rect = mThumbRects[mCurSlider]; 519 curSldrIt = mIt;
528 highlight_rect.stretch(llround(lerp(1.f, 3.f, lerp_amt))); 520 continue;
529 gl_draw_scaled_image_with_border(highlight_rect.mLeft,
530 highlight_rect.mBottom, 16, 16, highlight_rect.getWidth(),
531 highlight_rect.getHeight(),
532 thumb_imagep, gFocusMgr.getFocusColor());
533 } 521 }
522
523 // the draw command
524 thumb_imagep->drawSolid(mIt->second, curThumbColor);
525 }
526
527 // draw cur slider last
528 if(curSldrIt != mThumbRects.end())
529 {
530 thumb_imagep->drawSolid(curSldrIt->second, mThumbCenterSelectedColor);
531 }
532
533 }
534 else
535 {
536 // draw highlight
537 if (hasFocus())
538 {
539 thumb_imagep->drawBorder(mThumbRects[mCurSlider], gFocusMgr.getFocusColor(), gFocusMgr.getFocusFlashWidth());
540 }
534 541
535 // draw the thumbs 542 // draw thumbs
536 curSldrIt = mThumbRects.end(); 543 curSldrIt = mThumbRects.end();
537 for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) { 544 for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++)
538 545 {
539 // choose the color
540 curThumbColor = mThumbCenterColor;
541 if(mIt->first == mCurSlider) {
542 // don't draw now, draw last
543 curSldrIt = mIt;
544 continue;
545 }
546
547 // the draw command
548 gl_draw_scaled_image_with_border(
549 mIt->second.mLeft,
550 mIt->second.mBottom, 16, 16,
551 mIt->second.getWidth(),
552 mIt->second.getHeight(), thumb_imagep,
553 curThumbColor, TRUE);
554 }
555 546
556 // draw cur slider last 547 // choose the color
557 if(curSldrIt != mThumbRects.end()) { 548 curThumbColor = mThumbCenterColor;
558 gl_draw_scaled_image_with_border( 549 if(mIt->first == mCurSlider)
559 curSldrIt->second.mLeft, 550 {
560 curSldrIt->second.mBottom, 16, 16, 551 curSldrIt = mIt;
561 curSldrIt->second.getWidth(), 552 continue;
562 curSldrIt->second.getHeight(), thumb_imagep, 553 //curThumbColor = mThumbCenterSelectedColor;
563 mThumbCenterSelectedColor, TRUE); 554 }
564 }
565 555
556 thumb_imagep->drawSolid(mIt->second, curThumbColor % opacity);
566 } 557 }
567 else
568 {
569 // draw highlight
570 if (hasFocus())
571 {
572 F32 lerp_amt = gFocusMgr.getFocusFlashAmt();
573 LLRect highlight_rect = mThumbRects[mCurSlider];
574 highlight_rect.stretch(llround(lerp(1.f, 3.f, lerp_amt)));
575 gl_draw_scaled_image_with_border(highlight_rect.mLeft, highlight_rect.mBottom, 16, 16, highlight_rect.getWidth(), highlight_rect.getHeight(),
576 thumb_imagep, gFocusMgr.getFocusColor());
577 }
578 558
579 // draw thumbs 559 if(curSldrIt != mThumbRects.end())
580 curSldrIt = mThumbRects.end(); 560 {
581 for(mIt = mThumbRects.begin(); mIt != mThumbRects.end(); mIt++) { 561 thumb_imagep->drawSolid(curSldrIt->second, mThumbCenterSelectedColor % opacity);
582
583 // choose the color
584 curThumbColor = mThumbCenterColor;
585 if(mIt->first == mCurSlider) {
586 curSldrIt = mIt;
587 continue;
588 //curThumbColor = mThumbCenterSelectedColor;
589 }
590
591 // the draw command
592 gl_draw_scaled_image_with_border(
593 mIt->second.mLeft,
594 mIt->second.mBottom, 16, 16,
595 mIt->second.getWidth(),
596 mIt->second.getHeight(), thumb_imagep,
597 curThumbColor % opacity, TRUE);
598 }
599
600 if(curSldrIt != mThumbRects.end()) {
601 gl_draw_scaled_image_with_border(
602 curSldrIt->second.mLeft,
603 curSldrIt->second.mBottom, 16, 16,
604 curSldrIt->second.getWidth(),
605 curSldrIt->second.getHeight(), thumb_imagep,
606 mThumbCenterSelectedColor % opacity, TRUE);
607 }
608 } 562 }
609
610 LLUICtrl::draw();
611 } 563 }
564
565 LLUICtrl::draw();
612} 566}
613 567
614// virtual 568// virtual