aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolmgr.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/lltoolmgr.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/lltoolmgr.cpp')
-rw-r--r--linden/indra/newview/lltoolmgr.cpp50
1 files changed, 29 insertions, 21 deletions
diff --git a/linden/indra/newview/lltoolmgr.cpp b/linden/indra/newview/lltoolmgr.cpp
index 99cb54c..0a4a99d 100644
--- a/linden/indra/newview/lltoolmgr.cpp
+++ b/linden/indra/newview/lltoolmgr.cpp
@@ -438,9 +438,7 @@ void LLToolMgr::clearSavedTool()
438 438
439void LLToolset::addTool(LLTool* tool) 439void LLToolset::addTool(LLTool* tool)
440{ 440{
441 llassert( !mToolList.checkData( tool ) ); // check for duplicates 441 mToolList.push_back( tool );
442
443 mToolList.addDataAtEnd( tool );
444 if( !mSelectedTool ) 442 if( !mSelectedTool )
445 { 443 {
446 mSelectedTool = tool; 444 mSelectedTool = tool;
@@ -457,7 +455,7 @@ void LLToolset::selectTool(LLTool* tool)
457 455
458void LLToolset::selectToolByIndex( S32 index ) 456void LLToolset::selectToolByIndex( S32 index )
459{ 457{
460 LLTool *tool = mToolList.getNthData( index ); 458 LLTool *tool = (index >= 0 && index < (S32)mToolList.size()) ? mToolList[index] : NULL;
461 if (tool) 459 if (tool)
462 { 460 {
463 mSelectedTool = tool; 461 mSelectedTool = tool;
@@ -467,13 +465,14 @@ void LLToolset::selectToolByIndex( S32 index )
467 465
468BOOL LLToolset::isToolSelected( S32 index ) 466BOOL LLToolset::isToolSelected( S32 index )
469{ 467{
470 return (mToolList.getNthData( index ) == mSelectedTool); 468 LLTool *tool = (index >= 0 && index < (S32)mToolList.size()) ? mToolList[index] : NULL;
469 return (tool == mSelectedTool);
471} 470}
472 471
473 472
474void LLToolset::selectFirstTool() 473void LLToolset::selectFirstTool()
475{ 474{
476 mSelectedTool = mToolList.getFirstData(); 475 mSelectedTool = (0 < mToolList.size()) ? mToolList[0] : NULL;
477 if (gToolMgr) 476 if (gToolMgr)
478 { 477 {
479 gToolMgr->setCurrentTool( mSelectedTool ); 478 gToolMgr->setCurrentTool( mSelectedTool );
@@ -484,43 +483,52 @@ void LLToolset::selectFirstTool()
484void LLToolset::selectNextTool() 483void LLToolset::selectNextTool()
485{ 484{
486 LLTool* next = NULL; 485 LLTool* next = NULL;
487 for( LLTool* cur = mToolList.getFirstData(); cur; cur = mToolList.getNextData() ) 486 for( tool_list_t::iterator iter = mToolList.begin();
487 iter != mToolList.end(); )
488 { 488 {
489 if( cur == mSelectedTool ) 489 LLTool* cur = *iter++;
490 if( cur == mSelectedTool && iter != mToolList.end() )
490 { 491 {
491 next = mToolList.getNextData(); 492 next = *iter;
492 break; 493 break;
493 } 494 }
494 } 495 }
495 496
496 if( !next ) 497 if( next )
497 { 498 {
498 next = mToolList.getFirstData(); 499 mSelectedTool = next;
500 gToolMgr->setCurrentTool( mSelectedTool );
501 }
502 else
503 {
504 selectFirstTool();
499 } 505 }
500
501 mSelectedTool = next;
502 gToolMgr->setCurrentTool( mSelectedTool );
503} 506}
504 507
505void LLToolset::selectPrevTool() 508void LLToolset::selectPrevTool()
506{ 509{
507 LLTool* prev = NULL; 510 LLTool* prev = NULL;
508 for( LLTool* cur = mToolList.getLastData(); cur; cur = mToolList.getPreviousData() ) 511 for( tool_list_t::reverse_iterator iter = mToolList.rbegin();
512 iter != mToolList.rend(); )
509 { 513 {
510 if( cur == mSelectedTool ) 514 LLTool* cur = *iter++;
515 if( cur == mSelectedTool && iter != mToolList.rend() )
511 { 516 {
512 prev = mToolList.getPreviousData(); 517 prev = *iter;
513 break; 518 break;
514 } 519 }
515 } 520 }
516 521
517 if( !prev ) 522 if( prev )
518 { 523 {
519 prev = mToolList.getLastData(); 524 mSelectedTool = prev;
525 gToolMgr->setCurrentTool( mSelectedTool );
526 }
527 else if (mToolList.size() > 0)
528 {
529 selectToolByIndex((S32)mToolList.size()-1);
520 } 530 }
521 531
522 mSelectedTool = prev;
523 gToolMgr->setCurrentTool( mSelectedTool );
524} 532}
525 533
526void select_tool( void *tool_pointer ) 534void select_tool( void *tool_pointer )