PageRenderTime 121ms CodeModel.GetById 48ms app.highlight 68ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lltoolcomp.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 786 lines | 565 code | 132 blank | 89 comment | 84 complexity | 48eb4e8dc3a7e70278f7e9746705443c MD5 | raw file
  1/** 
  2 * @file lltoolcomp.cpp
  3 * @brief Composite tools
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#include "llviewerprecompiledheaders.h"
 28
 29#include "lltoolcomp.h"
 30
 31#include "llfloaterreg.h"
 32#include "llgl.h"
 33#include "indra_constants.h"
 34
 35#include "llmanip.h"
 36#include "llmaniprotate.h"
 37#include "llmanipscale.h"
 38#include "llmaniptranslate.h"
 39#include "llmenugl.h"			// for right-click menu hack
 40#include "llselectmgr.h"
 41#include "lltoolfocus.h"
 42#include "lltoolgrab.h"
 43#include "lltoolgun.h"
 44#include "lltoolmgr.h"
 45#include "lltoolselectrect.h"
 46#include "lltoolplacer.h"
 47#include "llviewermenu.h"
 48#include "llviewerobject.h"
 49#include "llviewerwindow.h"
 50#include "llagent.h"
 51#include "llagentcamera.h"
 52#include "llfloatertools.h"
 53#include "llviewercontrol.h"
 54
 55const S32 BUTTON_HEIGHT = 16;
 56const S32 BUTTON_WIDTH_SMALL = 32;
 57const S32 BUTTON_WIDTH_BIG = 48;
 58const S32 HPAD = 4;
 59
 60extern LLControlGroup gSavedSettings;
 61
 62
 63// we use this in various places instead of NULL
 64static LLTool* sNullTool = new LLTool(std::string("null"), NULL); 
 65
 66//-----------------------------------------------------------------------
 67// LLToolComposite
 68
 69//static
 70void LLToolComposite::setCurrentTool( LLTool* new_tool )
 71{
 72	if( mCur != new_tool )
 73	{
 74		if( mSelected )
 75		{
 76			mCur->handleDeselect();
 77			mCur = new_tool;
 78			mCur->handleSelect();
 79		}
 80		else
 81		{
 82			mCur = new_tool;
 83		}
 84	}
 85}
 86
 87LLToolComposite::LLToolComposite(const std::string& name)
 88	: LLTool(name),
 89	  mCur(sNullTool), 
 90	  mDefault(sNullTool), 
 91	  mSelected(FALSE),
 92	  mMouseDown(FALSE), mManip(NULL), mSelectRect(NULL)
 93{
 94}
 95
 96// Returns to the default tool
 97BOOL LLToolComposite::handleMouseUp(S32 x, S32 y, MASK mask)
 98{ 
 99	BOOL handled = mCur->handleMouseUp( x, y, mask );
100	if( handled )
101	{
102		setCurrentTool( mDefault );
103	}
104 return handled;
105}
106
107void LLToolComposite::onMouseCaptureLost()
108{
109	mCur->onMouseCaptureLost();
110	setCurrentTool( mDefault );
111}
112
113BOOL LLToolComposite::isSelecting()
114{ 
115	return mCur == mSelectRect; 
116}
117
118void LLToolComposite::handleSelect()
119{
120	if (!gSavedSettings.getBOOL("EditLinkedParts"))
121	{
122		LLSelectMgr::getInstance()->promoteSelectionToRoot();
123	}
124	mCur = mDefault; 
125	mCur->handleSelect(); 
126	mSelected = TRUE; 
127}
128
129//----------------------------------------------------------------------------
130// LLToolCompInspect
131//----------------------------------------------------------------------------
132
133LLToolCompInspect::LLToolCompInspect()
134: LLToolComposite(std::string("Inspect"))
135{
136	mSelectRect		= new LLToolSelectRect(this);
137	mDefault = mSelectRect;
138}
139
140
141LLToolCompInspect::~LLToolCompInspect()
142{
143	delete mSelectRect;
144	mSelectRect = NULL;
145}
146
147BOOL LLToolCompInspect::handleMouseDown(S32 x, S32 y, MASK mask)
148{
149	mMouseDown = TRUE;
150	gViewerWindow->pickAsync(x, y, mask, pickCallback);
151	return TRUE;
152}
153
154void LLToolCompInspect::pickCallback(const LLPickInfo& pick_info)
155{
156	LLViewerObject* hit_obj = pick_info.getObject();
157
158	if (!LLToolCompInspect::getInstance()->mMouseDown)
159	{
160		// fast click on object, but mouse is already up...just do select
161		LLToolCompInspect::getInstance()->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
162		return;
163	}
164
165	if( hit_obj )
166	{
167		if (LLSelectMgr::getInstance()->getSelection()->getObjectCount())
168		{
169			LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
170		}
171		LLToolCompInspect::getInstance()->setCurrentTool( LLToolCompInspect::getInstance()->mSelectRect );
172		LLToolCompInspect::getInstance()->mSelectRect->handlePick( pick_info );
173
174	}
175	else
176	{
177		LLToolCompInspect::getInstance()->setCurrentTool( LLToolCompInspect::getInstance()->mSelectRect );
178		LLToolCompInspect::getInstance()->mSelectRect->handlePick( pick_info );
179	}
180}
181
182BOOL LLToolCompInspect::handleDoubleClick(S32 x, S32 y, MASK mask)
183{
184	return TRUE;
185}
186
187//----------------------------------------------------------------------------
188// LLToolCompTranslate
189//----------------------------------------------------------------------------
190
191LLToolCompTranslate::LLToolCompTranslate()
192	: LLToolComposite(std::string("Move"))
193{
194	mManip		= new LLManipTranslate(this);
195	mSelectRect		= new LLToolSelectRect(this);
196
197	mCur			= mManip;
198	mDefault		= mManip;
199}
200
201LLToolCompTranslate::~LLToolCompTranslate()
202{
203	delete mManip;
204	mManip = NULL;
205
206	delete mSelectRect;
207	mSelectRect = NULL;
208}
209
210BOOL LLToolCompTranslate::handleHover(S32 x, S32 y, MASK mask)
211{
212	if( !mCur->hasMouseCapture() )
213	{
214		setCurrentTool( mManip );
215	}
216	return mCur->handleHover( x, y, mask );
217}
218
219
220BOOL LLToolCompTranslate::handleMouseDown(S32 x, S32 y, MASK mask)
221{
222	mMouseDown = TRUE;
223	gViewerWindow->pickAsync(x, y, mask, pickCallback, TRUE);
224	return TRUE;
225}
226
227void LLToolCompTranslate::pickCallback(const LLPickInfo& pick_info)
228{
229	LLViewerObject* hit_obj = pick_info.getObject();
230
231	LLToolCompTranslate::getInstance()->mManip->highlightManipulators(pick_info.mMousePt.mX, pick_info.mMousePt.mY);
232	if (!LLToolCompTranslate::getInstance()->mMouseDown)
233	{
234		// fast click on object, but mouse is already up...just do select
235		LLToolCompTranslate::getInstance()->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
236		return;
237	}
238
239	if( hit_obj || LLToolCompTranslate::getInstance()->mManip->getHighlightedPart() != LLManip::LL_NO_PART )
240	{
241		if (LLToolCompTranslate::getInstance()->mManip->getSelection()->getObjectCount())
242		{
243			LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
244		}
245
246		BOOL can_move = LLToolCompTranslate::getInstance()->mManip->canAffectSelection();
247
248		if(	LLManip::LL_NO_PART != LLToolCompTranslate::getInstance()->mManip->getHighlightedPart() && can_move)
249		{
250			LLToolCompTranslate::getInstance()->setCurrentTool( LLToolCompTranslate::getInstance()->mManip );
251			LLToolCompTranslate::getInstance()->mManip->handleMouseDownOnPart( pick_info.mMousePt.mX, pick_info.mMousePt.mY, pick_info.mKeyMask );
252		}
253		else
254		{
255			LLToolCompTranslate::getInstance()->setCurrentTool( LLToolCompTranslate::getInstance()->mSelectRect );
256			LLToolCompTranslate::getInstance()->mSelectRect->handlePick( pick_info );
257
258			// *TODO: add toggle to trigger old click-drag functionality
259			// LLToolCompTranslate::getInstance()->mManip->handleMouseDownOnPart( XY_part, x, y, mask);
260		}
261	}
262	else
263	{
264		LLToolCompTranslate::getInstance()->setCurrentTool( LLToolCompTranslate::getInstance()->mSelectRect );
265		LLToolCompTranslate::getInstance()->mSelectRect->handlePick( pick_info );
266	}
267}
268
269BOOL LLToolCompTranslate::handleMouseUp(S32 x, S32 y, MASK mask)
270{
271	mMouseDown = FALSE;
272	return LLToolComposite::handleMouseUp(x, y, mask);
273}
274
275LLTool* LLToolCompTranslate::getOverrideTool(MASK mask)
276{
277	if (mask == MASK_CONTROL)
278	{
279		return LLToolCompRotate::getInstance();
280	}
281	else if (mask == (MASK_CONTROL | MASK_SHIFT))
282	{
283		return LLToolCompScale::getInstance();
284	}
285	return LLToolComposite::getOverrideTool(mask);
286}
287
288BOOL LLToolCompTranslate::handleDoubleClick(S32 x, S32 y, MASK mask)
289{
290	if (mManip->getSelection()->isEmpty() && mManip->getHighlightedPart() == LLManip::LL_NO_PART)
291	{
292		// You should already have an object selected from the mousedown.
293		// If so, show its properties
294		LLFloaterReg::showInstance("build", "Content");
295		return TRUE;
296	}
297	// Nothing selected means the first mouse click was probably
298	// bad, so try again.
299	return FALSE;
300}
301
302
303void LLToolCompTranslate::render()
304{
305	mCur->render(); // removing this will not draw the RGB arrows and guidelines
306
307	if( mCur != mManip )
308	{
309		LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
310		mManip->renderGuidelines();
311	}
312}
313
314
315//-----------------------------------------------------------------------
316// LLToolCompScale
317
318LLToolCompScale::LLToolCompScale()
319	: LLToolComposite(std::string("Stretch"))
320{
321	mManip = new LLManipScale(this);
322	mSelectRect = new LLToolSelectRect(this);
323
324	mCur = mManip;
325	mDefault = mManip;
326}
327
328LLToolCompScale::~LLToolCompScale()
329{
330	delete mManip;
331	delete mSelectRect;
332}
333
334BOOL LLToolCompScale::handleHover(S32 x, S32 y, MASK mask)
335{
336	if( !mCur->hasMouseCapture() )
337	{
338		setCurrentTool(mManip );
339	}
340	return mCur->handleHover( x, y, mask );
341}
342
343
344BOOL LLToolCompScale::handleMouseDown(S32 x, S32 y, MASK mask)
345{
346	mMouseDown = TRUE;
347	gViewerWindow->pickAsync(x, y, mask, pickCallback);
348	return TRUE;
349}
350
351void LLToolCompScale::pickCallback(const LLPickInfo& pick_info)
352{
353	LLViewerObject* hit_obj = pick_info.getObject();
354
355	LLToolCompScale::getInstance()->mManip->highlightManipulators(pick_info.mMousePt.mX, pick_info.mMousePt.mY);
356	if (!LLToolCompScale::getInstance()->mMouseDown)
357	{
358		// fast click on object, but mouse is already up...just do select
359		LLToolCompScale::getInstance()->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
360
361		return;
362	}
363
364	if( hit_obj || LLToolCompScale::getInstance()->mManip->getHighlightedPart() != LLManip::LL_NO_PART)
365	{
366		if (LLToolCompScale::getInstance()->mManip->getSelection()->getObjectCount())
367		{
368			LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
369		}
370		if(	LLManip::LL_NO_PART != LLToolCompScale::getInstance()->mManip->getHighlightedPart() )
371		{
372			LLToolCompScale::getInstance()->setCurrentTool( LLToolCompScale::getInstance()->mManip );
373			LLToolCompScale::getInstance()->mManip->handleMouseDownOnPart( pick_info.mMousePt.mX, pick_info.mMousePt.mY, pick_info.mKeyMask );
374		}
375		else
376		{
377			LLToolCompScale::getInstance()->setCurrentTool( LLToolCompScale::getInstance()->mSelectRect );
378			LLToolCompScale::getInstance()->mSelectRect->handlePick( pick_info );
379		}
380	}
381	else
382	{
383		LLToolCompScale::getInstance()->setCurrentTool( LLToolCompScale::getInstance()->mSelectRect );
384		LLToolCompScale::getInstance()->mSelectRect->handlePick( pick_info );
385	}
386}
387
388BOOL LLToolCompScale::handleMouseUp(S32 x, S32 y, MASK mask)
389{
390	mMouseDown = FALSE;
391	return LLToolComposite::handleMouseUp(x, y, mask);
392}
393
394LLTool* LLToolCompScale::getOverrideTool(MASK mask)
395{
396	if (mask == MASK_CONTROL)
397	{
398		return LLToolCompRotate::getInstance();
399	}
400
401	return LLToolComposite::getOverrideTool(mask);
402}
403
404
405BOOL LLToolCompScale::handleDoubleClick(S32 x, S32 y, MASK mask)
406{
407	if (!mManip->getSelection()->isEmpty() && mManip->getHighlightedPart() == LLManip::LL_NO_PART)
408	{
409		// You should already have an object selected from the mousedown.
410		// If so, show its properties
411		LLFloaterReg::showInstance("build", "Content");
412		return TRUE;
413	}
414	else
415	{
416		// Nothing selected means the first mouse click was probably
417		// bad, so try again.
418		return handleMouseDown(x, y, mask);
419	}
420}
421
422
423void LLToolCompScale::render()
424{
425	mCur->render();
426
427	if( mCur != mManip )
428	{
429		LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
430		mManip->renderGuidelines();
431	}
432}
433
434//-----------------------------------------------------------------------
435// LLToolCompCreate
436
437LLToolCompCreate::LLToolCompCreate()
438	: LLToolComposite(std::string("Create"))
439{
440	mPlacer = new LLToolPlacer();
441	mSelectRect = new LLToolSelectRect(this);
442
443	mCur = mPlacer;
444	mDefault = mPlacer;
445	mObjectPlacedOnMouseDown = FALSE;
446}
447
448
449LLToolCompCreate::~LLToolCompCreate()
450{
451	delete mPlacer;
452	delete mSelectRect;
453}
454
455
456BOOL LLToolCompCreate::handleMouseDown(S32 x, S32 y, MASK mask)
457{
458	BOOL handled = FALSE;
459	mMouseDown = TRUE;
460
461	if ( (mask == MASK_SHIFT) || (mask == MASK_CONTROL) )
462	{
463		gViewerWindow->pickAsync(x, y, mask, pickCallback);
464		handled = TRUE;
465	}
466	else
467	{
468		setCurrentTool( mPlacer );
469		handled = mPlacer->placeObject( x, y, mask );
470	}
471	
472	mObjectPlacedOnMouseDown = TRUE;
473
474	return TRUE;
475}
476
477void LLToolCompCreate::pickCallback(const LLPickInfo& pick_info)
478{
479	// *NOTE: We mask off shift and control, so you cannot
480	// multi-select multiple objects with the create tool.
481	MASK mask = (pick_info.mKeyMask & ~MASK_SHIFT);
482	mask = (mask & ~MASK_CONTROL);
483
484	LLToolCompCreate::getInstance()->setCurrentTool( LLToolCompCreate::getInstance()->mSelectRect );
485	LLToolCompCreate::getInstance()->mSelectRect->handlePick( pick_info );
486}
487
488BOOL LLToolCompCreate::handleDoubleClick(S32 x, S32 y, MASK mask)
489{
490	return handleMouseDown(x, y, mask);
491}
492
493BOOL LLToolCompCreate::handleMouseUp(S32 x, S32 y, MASK mask)
494{
495	BOOL handled = FALSE;
496
497	if ( mMouseDown && !mObjectPlacedOnMouseDown && !(mask == MASK_SHIFT) && !(mask == MASK_CONTROL) )
498	{
499		setCurrentTool( mPlacer );
500		handled = mPlacer->placeObject( x, y, mask );
501	}
502
503	mObjectPlacedOnMouseDown = FALSE;
504	mMouseDown = FALSE;
505
506	if (!handled)
507	{
508		handled = LLToolComposite::handleMouseUp(x, y, mask);
509	}
510
511	return handled;
512}
513
514//-----------------------------------------------------------------------
515// LLToolCompRotate
516
517LLToolCompRotate::LLToolCompRotate()
518	: LLToolComposite(std::string("Rotate"))
519{
520	mManip = new LLManipRotate(this);
521	mSelectRect = new LLToolSelectRect(this);
522
523	mCur = mManip;
524	mDefault = mManip;
525}
526
527
528LLToolCompRotate::~LLToolCompRotate()
529{
530	delete mManip;
531	delete mSelectRect;
532}
533
534BOOL LLToolCompRotate::handleHover(S32 x, S32 y, MASK mask)
535{
536	if( !mCur->hasMouseCapture() )
537	{
538		setCurrentTool( mManip );
539	}
540	return mCur->handleHover( x, y, mask );
541}
542
543
544BOOL LLToolCompRotate::handleMouseDown(S32 x, S32 y, MASK mask)
545{
546	mMouseDown = TRUE;
547	gViewerWindow->pickAsync(x, y, mask, pickCallback);
548	return TRUE;
549}
550
551void LLToolCompRotate::pickCallback(const LLPickInfo& pick_info)
552{
553	LLViewerObject* hit_obj = pick_info.getObject();
554
555	LLToolCompRotate::getInstance()->mManip->highlightManipulators(pick_info.mMousePt.mX, pick_info.mMousePt.mY);
556	if (!LLToolCompRotate::getInstance()->mMouseDown)
557	{
558		// fast click on object, but mouse is already up...just do select
559		LLToolCompRotate::getInstance()->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
560		return;
561	}
562	
563	if( hit_obj || LLToolCompRotate::getInstance()->mManip->getHighlightedPart() != LLManip::LL_NO_PART)
564	{
565		if (LLToolCompRotate::getInstance()->mManip->getSelection()->getObjectCount())
566		{
567			LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
568		}
569		if(	LLManip::LL_NO_PART != LLToolCompRotate::getInstance()->mManip->getHighlightedPart() )
570		{
571			LLToolCompRotate::getInstance()->setCurrentTool( LLToolCompRotate::getInstance()->mManip );
572			LLToolCompRotate::getInstance()->mManip->handleMouseDownOnPart( pick_info.mMousePt.mX, pick_info.mMousePt.mY, pick_info.mKeyMask );
573		}
574		else
575		{
576			LLToolCompRotate::getInstance()->setCurrentTool( LLToolCompRotate::getInstance()->mSelectRect );
577			LLToolCompRotate::getInstance()->mSelectRect->handlePick( pick_info );
578		}
579	}
580	else
581	{
582		LLToolCompRotate::getInstance()->setCurrentTool( LLToolCompRotate::getInstance()->mSelectRect );
583		LLToolCompRotate::getInstance()->mSelectRect->handlePick( pick_info );
584	}
585}
586
587BOOL LLToolCompRotate::handleMouseUp(S32 x, S32 y, MASK mask)
588{
589	mMouseDown = FALSE;
590	return LLToolComposite::handleMouseUp(x, y, mask);
591}
592
593LLTool* LLToolCompRotate::getOverrideTool(MASK mask)
594{
595	if (mask == (MASK_CONTROL | MASK_SHIFT))
596	{
597		return LLToolCompScale::getInstance();
598	}
599	return LLToolComposite::getOverrideTool(mask);
600}
601
602BOOL LLToolCompRotate::handleDoubleClick(S32 x, S32 y, MASK mask)
603{
604	if (!mManip->getSelection()->isEmpty() && mManip->getHighlightedPart() == LLManip::LL_NO_PART)
605	{
606		// You should already have an object selected from the mousedown.
607		// If so, show its properties
608		LLFloaterReg::showInstance("build", "Content");
609		return TRUE;
610	}
611	else
612	{
613		// Nothing selected means the first mouse click was probably
614		// bad, so try again.
615		return handleMouseDown(x, y, mask);
616	}
617}
618
619
620void LLToolCompRotate::render()
621{
622	mCur->render();
623
624	if( mCur != mManip )
625	{
626		LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
627		mManip->renderGuidelines();
628	}
629}
630
631
632//-----------------------------------------------------------------------
633// LLToolCompGun
634
635LLToolCompGun::LLToolCompGun()
636	: LLToolComposite(std::string("Mouselook"))
637{
638	mGun = new LLToolGun(this);
639	mGrab = new LLToolGrab(this);
640	mNull = sNullTool;
641
642	setCurrentTool(mGun);
643	mDefault = mGun;
644}
645
646
647LLToolCompGun::~LLToolCompGun()
648{
649	delete mGun;
650	mGun = NULL;
651
652	delete mGrab;
653	mGrab = NULL;
654
655	// don't delete a static object
656	// delete mNull;
657	mNull = NULL;
658}
659
660BOOL LLToolCompGun::handleHover(S32 x, S32 y, MASK mask)
661{
662	// *NOTE: This hack is here to make mouselook kick in again after
663	// item selected from context menu.
664	if ( mCur == mNull && !gPopupMenuView->getVisible() )
665	{
666		LLSelectMgr::getInstance()->deselectAll();
667		setCurrentTool( (LLTool*) mGrab );
668	}
669
670	// Note: if the tool changed, we can't delegate the current mouse event
671	// after the change because tools can modify the mouse during selection and deselection.
672	// Instead we let the current tool handle the event and then make the change.
673	// The new tool will take effect on the next frame.
674
675	mCur->handleHover( x, y, mask );
676
677	// If mouse button not down...
678	if( !gViewerWindow->getLeftMouseDown())
679	{
680		// let ALT switch from gun to grab
681		if ( mCur == mGun && (mask & MASK_ALT) )
682		{
683			setCurrentTool( (LLTool*) mGrab );
684		}
685		else if ( mCur == mGrab && !(mask & MASK_ALT) )
686		{
687			setCurrentTool( (LLTool*) mGun );
688			setMouseCapture(TRUE);
689		}
690	}
691
692	return TRUE; 
693}
694
695
696BOOL LLToolCompGun::handleMouseDown(S32 x, S32 y, MASK mask)
697{ 
698	// if the left button is grabbed, don't put up the pie menu
699	if (gAgent.leftButtonGrabbed())
700	{
701		gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN);
702		return FALSE;
703	}
704
705	// On mousedown, start grabbing
706	gGrabTransientTool = this;
707	LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool*) mGrab );
708
709	return LLToolGrab::getInstance()->handleMouseDown(x, y, mask);
710}
711
712
713BOOL LLToolCompGun::handleDoubleClick(S32 x, S32 y, MASK mask)
714{
715	// if the left button is grabbed, don't put up the pie menu
716	if (gAgent.leftButtonGrabbed())
717	{
718		gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN);
719		return FALSE;
720	}
721
722	// On mousedown, start grabbing
723	gGrabTransientTool = this;
724	LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool*) mGrab );
725
726	return LLToolGrab::getInstance()->handleDoubleClick(x, y, mask);
727}
728
729
730BOOL LLToolCompGun::handleRightMouseDown(S32 x, S32 y, MASK mask)
731{
732	/* JC - suppress context menu 8/29/2002
733
734	// On right mouse, go through some convoluted steps to
735	// make the build menu appear.
736	setCurrentTool( (LLTool*) mNull );
737
738	// This should return FALSE, meaning the context menu will
739	// be shown.
740	return FALSE;
741	*/
742
743	// Returning true will suppress the context menu
744	return TRUE;
745}
746
747
748BOOL LLToolCompGun::handleMouseUp(S32 x, S32 y, MASK mask)
749{
750	gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_UP);
751	setCurrentTool( (LLTool*) mGun );
752	return TRUE;
753}
754
755void LLToolCompGun::onMouseCaptureLost()
756{
757	if (mComposite)
758	{
759		mComposite->onMouseCaptureLost();
760		return;
761	}
762	mCur->onMouseCaptureLost();
763}
764
765void	LLToolCompGun::handleSelect()
766{
767	LLToolComposite::handleSelect();
768	setMouseCapture(TRUE);
769}
770
771void	LLToolCompGun::handleDeselect()
772{
773	LLToolComposite::handleDeselect();
774	setMouseCapture(FALSE);
775}
776
777
778BOOL LLToolCompGun::handleScrollWheel(S32 x, S32 y, S32 clicks)
779{
780	if (clicks > 0)
781	{
782		gAgentCamera.changeCameraToDefault();
783
784	}
785	return TRUE;
786}