lltool.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "lltool.h"
00035 
00036 #include "indra_constants.h"
00037 #include "llerror.h"
00038 #include "llview.h"
00039 
00040 #include "llviewerwindow.h"
00041 #include "lltoolcomp.h"
00042 #include "lltoolfocus.h"
00043 #include "llfocusmgr.h"
00044 #include "llagent.h"
00045 #include "llviewborder.h"
00046 
00047 extern BOOL gDebugClicks;
00048 
00049 //static
00050 const LLString LLTool::sNameNull("null");
00051 
00052 LLTool::LLTool( const LLString& name, LLToolComposite* composite ) :
00053         mComposite( composite ),
00054         mName(name)
00055 {
00056 }
00057 
00058 LLTool::~LLTool()
00059 {
00060         if( hasMouseCapture() )
00061         {
00062                 llwarns << "Tool deleted holding mouse capture.  Mouse capture removed." << llendl;
00063                 gFocusMgr.removeMouseCaptureWithoutCallback( this );
00064         }
00065 }
00066 
00067 
00068 BOOL LLTool::handleMouseDown(S32 x, S32 y, MASK mask)
00069 {
00070         if (gDebugClicks)
00071         {
00072                 llinfos << "LLTool left mouse down" << llendl;
00073         }
00074         // by default, didn't handle it
00075         // llinfos << "LLTool::handleMouseDown" << llendl;
00076         gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_DOWN);
00077         return TRUE;
00078 }
00079 
00080 BOOL LLTool::handleMouseUp(S32 x, S32 y, MASK mask)
00081 {
00082         if (gDebugClicks) 
00083         {
00084                 llinfos << "LLTool left mouse up" << llendl;
00085         }
00086         // by default, didn't handle it
00087         // llinfos << "LLTool::handleMouseUp" << llendl;
00088         gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_UP);
00089         return TRUE;
00090 }
00091 
00092 BOOL LLTool::handleHover(S32 x, S32 y, MASK mask)
00093 {
00094         gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
00095         lldebugst(LLERR_USER_INPUT) << "hover handled by a tool" << llendl;             
00096         // by default, do nothing, say we handled it
00097         return TRUE;
00098 }
00099 
00100 BOOL LLTool::handleScrollWheel(S32 x, S32 y, S32 clicks)
00101 {
00102         // by default, didn't handle it
00103         // llinfos << "LLTool::handleScrollWheel" << llendl;
00104         return FALSE;
00105 }
00106 
00107 BOOL LLTool::handleDoubleClick(S32 x,S32 y,MASK mask)
00108 {
00109         // llinfos << "LLTool::handleDoubleClick" << llendl;
00110         // by default, pretend it's a left click
00111         return FALSE;
00112 }
00113 
00114 BOOL LLTool::handleRightMouseDown(S32 x,S32 y,MASK mask)
00115 {
00116         // by default, didn't handle it
00117         // llinfos << "LLTool::handleRightMouseDown" << llendl;
00118         return FALSE;
00119 }
00120 
00121 BOOL LLTool::handleRightMouseUp(S32 x, S32 y, MASK mask)
00122 {
00123         // by default, didn't handle it
00124         // llinfos << "LLTool::handleRightMouseDown" << llendl;
00125         return FALSE;
00126 }
00127 
00128 BOOL LLTool::handleToolTip(S32 x, S32 y, LLString& msg, LLRect* sticky_rect_screen)
00129 {
00130         // by default, didn't handle it
00131         // llinfos << "LLTool::handleToolTip" << llendl;
00132         return FALSE;
00133 }
00134 
00135 void LLTool::setMouseCapture( BOOL b )
00136 {
00137         if( b )
00138         {
00139                 gViewerWindow->setMouseCapture(mComposite ? mComposite : this );
00140         }
00141         else
00142         if( hasMouseCapture() )
00143         {
00144                 gViewerWindow->setMouseCapture( NULL );
00145         }
00146 }
00147 
00148 // virtual
00149 void LLTool::draw()
00150 { }
00151 
00152 BOOL LLTool::hasMouseCapture()
00153 {
00154         return gFocusMgr.getMouseCapture() == (mComposite ? mComposite : this);
00155 }
00156 
00157 BOOL LLTool::handleKey(KEY key, MASK mask)
00158 {
00159         return FALSE;
00160 }
00161 
00162 LLTool* LLTool::getOverrideTool(MASK mask)
00163 {
00164         if (mask & MASK_ALT)
00165         {
00166                 return gToolCamera;
00167         }
00168         return NULL;
00169 }

Generated on Thu Jul 1 06:09:19 2010 for Second Life Viewer by  doxygen 1.4.7