From cd17687f01420952712a500107e0f93e7ab8d5f8 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:34 -0500 Subject: Second Life viewer sources 1.19.1.0 --- linden/indra/newview/lltoolmgr.cpp | 50 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'linden/indra/newview/lltoolmgr.cpp') 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() void LLToolset::addTool(LLTool* tool) { - llassert( !mToolList.checkData( tool ) ); // check for duplicates - - mToolList.addDataAtEnd( tool ); + mToolList.push_back( tool ); if( !mSelectedTool ) { mSelectedTool = tool; @@ -457,7 +455,7 @@ void LLToolset::selectTool(LLTool* tool) void LLToolset::selectToolByIndex( S32 index ) { - LLTool *tool = mToolList.getNthData( index ); + LLTool *tool = (index >= 0 && index < (S32)mToolList.size()) ? mToolList[index] : NULL; if (tool) { mSelectedTool = tool; @@ -467,13 +465,14 @@ void LLToolset::selectToolByIndex( S32 index ) BOOL LLToolset::isToolSelected( S32 index ) { - return (mToolList.getNthData( index ) == mSelectedTool); + LLTool *tool = (index >= 0 && index < (S32)mToolList.size()) ? mToolList[index] : NULL; + return (tool == mSelectedTool); } void LLToolset::selectFirstTool() { - mSelectedTool = mToolList.getFirstData(); + mSelectedTool = (0 < mToolList.size()) ? mToolList[0] : NULL; if (gToolMgr) { gToolMgr->setCurrentTool( mSelectedTool ); @@ -484,43 +483,52 @@ void LLToolset::selectFirstTool() void LLToolset::selectNextTool() { LLTool* next = NULL; - for( LLTool* cur = mToolList.getFirstData(); cur; cur = mToolList.getNextData() ) + for( tool_list_t::iterator iter = mToolList.begin(); + iter != mToolList.end(); ) { - if( cur == mSelectedTool ) + LLTool* cur = *iter++; + if( cur == mSelectedTool && iter != mToolList.end() ) { - next = mToolList.getNextData(); + next = *iter; break; } } - if( !next ) + if( next ) { - next = mToolList.getFirstData(); + mSelectedTool = next; + gToolMgr->setCurrentTool( mSelectedTool ); + } + else + { + selectFirstTool(); } - - mSelectedTool = next; - gToolMgr->setCurrentTool( mSelectedTool ); } void LLToolset::selectPrevTool() { LLTool* prev = NULL; - for( LLTool* cur = mToolList.getLastData(); cur; cur = mToolList.getPreviousData() ) + for( tool_list_t::reverse_iterator iter = mToolList.rbegin(); + iter != mToolList.rend(); ) { - if( cur == mSelectedTool ) + LLTool* cur = *iter++; + if( cur == mSelectedTool && iter != mToolList.rend() ) { - prev = mToolList.getPreviousData(); + prev = *iter; break; } } - if( !prev ) + if( prev ) { - prev = mToolList.getLastData(); + mSelectedTool = prev; + gToolMgr->setCurrentTool( mSelectedTool ); + } + else if (mToolList.size() > 0) + { + selectToolByIndex((S32)mToolList.size()-1); } - mSelectedTool = prev; - gToolMgr->setCurrentTool( mSelectedTool ); } void select_tool( void *tool_pointer ) -- cgit v1.1