123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934 |
- /**
- * @file lltoolcomp.cpp
- * @brief Composite tools
- *
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2009, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #include "llviewerprecompiledheaders.h"
- #include "lltoolcomp.h"
- #include "llmenugl.h" // For right-click menu hack
- #include "llgl.h"
- #include "llagent.h"
- #include "llfloatertools.h"
- #include "llmanip.h"
- #include "llmaniprotate.h"
- #include "llmanipscale.h"
- #include "llmaniptranslate.h"
- #include "llselectmgr.h"
- #include "lltoolfocus.h"
- #include "lltoolgrab.h"
- #include "lltoolmgr.h"
- #include "lltoolplacer.h"
- #include "lltoolselectrect.h"
- #include "llviewercontrol.h"
- #include "llviewermenu.h"
- #include "llviewerobject.h"
- #include "llviewerwindow.h"
- LLToolCompInspect gToolCompInspect;
- LLToolCompTranslate gToolCompTranslate;
- LLToolCompScale gToolCompScale;
- LLToolCompRotate gToolCompRotate;
- LLToolCompCreate gToolCompCreate;
- LLToolCompGun gToolCompGun;
- //-----------------------------------------------------------------------------
- // LLToolGun
- // Used to be in its own lltoolgun.h/cpp module, but is only used by LLToolComp
- // and therefore moved here. HB
- //-----------------------------------------------------------------------------
- class LLToolGun final : public LLTool
- {
- public:
- LLToolGun(LLToolComposite* composite)
- : LLTool("gun", composite),
- mIsSelected(false)
- {
- }
- void draw() override;
- void handleSelect() override;
- void handleDeselect() override;
- bool handleMouseDown(S32 x, S32 y, MASK mask) override;
- bool handleHover(S32 x, S32 y, MASK mask) override;
- LL_INLINE LLTool* getOverrideTool(MASK) override { return NULL; }
- LL_INLINE bool clipMouseWhenDown() override { return false; }
- private:
- bool mIsSelected;
- };
- void LLToolGun::handleSelect()
- {
- if (gViewerWindowp)
- {
- gViewerWindowp->hideCursor();
- gViewerWindowp->moveCursorToCenter();
- gWindowp->setMouseClipping(true);
- }
- mIsSelected = true;
- }
- void LLToolGun::handleDeselect()
- {
- if (gViewerWindowp)
- {
- gViewerWindowp->moveCursorToCenter();
- gViewerWindowp->showCursor();
- gWindowp->setMouseClipping(false);
- }
- mIsSelected = false;
- }
- bool LLToolGun::handleMouseDown(S32 x, S32 y, MASK mask)
- {
- gGrabTransientTool = this;
- gToolMgr.getCurrentToolset()->selectTool(&gToolGrab);
- return gToolGrab.handleMouseDown(x, y, mask);
- }
- bool LLToolGun::handleHover(S32 x, S32 y, MASK mask)
- {
- if (!gViewerWindowp) return false;
- if (mIsSelected && gAgent.cameraMouselook())
- {
- constexpr F32 NOMINAL_MOUSE_SENSITIVITY = 0.0025f;
- static LLCachedControl<F32> sensitivity(gSavedSettings,
- "MouseSensitivity");
- F32 mouse_sensitivity = clamp_rescale((F32)sensitivity,
- 0.f, 15.f, 0.5f, 2.75f)
- * NOMINAL_MOUSE_SENSITIVITY;
- // Move the view with the mouse
- // Get mouse movement delta
- S32 dx = -gViewerWindowp->getCurrentMouseDX();
- S32 dy = -gViewerWindowp->getCurrentMouseDY();
- if (dx != 0 || dy != 0)
- {
- // ...actually moved off center
- static LLCachedControl<bool> invert_mouse(gSavedSettings,
- "InvertMouse");
- if (invert_mouse)
- {
- gAgent.pitch(mouse_sensitivity * -dy);
- }
- else
- {
- gAgent.pitch(mouse_sensitivity * dy);
- }
- LLVector3 skyward = gAgent.getReferenceUpVector();
- gAgent.rotate(mouse_sensitivity * dx, skyward.mV[VX],
- skyward.mV[VY], skyward.mV[VZ]);
- gViewerWindowp->moveCursorToCenter();
- gViewerWindowp->hideCursor();
- }
- LL_DEBUGS("UserInput") << "hover handled by LLToolGun (mouselook)"
- << LL_ENDL;
- }
- else
- {
- LL_DEBUGS("UserInput") << "hover handled by LLToolGun (not mouselook)"
- << LL_ENDL;
- }
- // *HACK to avoid assert: error checking system makes sure that the cursor
- // is set during every handleHover. This is actually a no-op since the
- // cursor is hidden.
- gViewerWindowp->setCursor(UI_CURSOR_ARROW);
- return true;
- }
- void LLToolGun::draw()
- {
- if (!gViewerWindowp) return;
- static LLUIImagePtr crosshair = LLUI::getUIImage("UIImgCrosshairsUUID");
- if (crosshair.isNull())
- {
- llerrs << "Missing cross-hair image: verify the viewer installation !"
- << llendl;
- }
- static S32 image_width = crosshair->getWidth();
- static S32 image_height = crosshair->getHeight();
- static LLCachedControl<bool> show_crosshairs(gSavedSettings,
- "ShowCrosshairs");
- if (show_crosshairs)
- {
- crosshair->draw((gViewerWindowp->getWindowWidth() - image_width) / 2,
- (gViewerWindowp->getWindowHeight() -
- image_height) / 2);
- }
- }
- //-----------------------------------------------------------------------------
- // LLToolComposite
- //-----------------------------------------------------------------------------
- //static
- void LLToolComposite::setCurrentTool(LLTool* new_tool)
- {
- if (mCur != new_tool)
- {
- if (mSelected)
- {
- mCur->handleDeselect();
- mCur = new_tool;
- mCur->handleSelect();
- }
- else
- {
- mCur = new_tool;
- }
- }
- }
- LLToolComposite::LLToolComposite(const std::string& name)
- : LLTool(name),
- mCur(gToolNull),
- mDefault(gToolNull),
- mSelected(false),
- mMouseDown(false),
- mManip(NULL),
- mSelectRect(NULL)
- {
- }
- // Returns to the default tool
- bool LLToolComposite::handleMouseUp(S32 x, S32 y, MASK mask)
- {
- bool handled = mCur->handleMouseUp(x, y, mask);
- if (handled)
- {
- setCurrentTool(mDefault);
- }
- return handled;
- }
- void LLToolComposite::onMouseCaptureLost()
- {
- mCur->onMouseCaptureLost();
- setCurrentTool(mDefault);
- }
- bool LLToolComposite::isSelecting()
- {
- return mCur == mSelectRect;
- }
- void LLToolComposite::handleSelect()
- {
- if (!gSavedSettings.getBool("EditLinkedParts"))
- {
- gSelectMgr.promoteSelectionToRoot();
- }
- mCur = mDefault;
- mCur->handleSelect();
- mSelected = true;
- }
- //-----------------------------------------------------------------------------
- // LLToolCompInspect
- //-----------------------------------------------------------------------------
- LLToolCompInspect::LLToolCompInspect()
- : LLToolComposite("Inspect")
- {
- mSelectRect = new LLToolSelectRect(this);
- mDefault = mSelectRect;
- }
- LLToolCompInspect::~LLToolCompInspect()
- {
- delete mSelectRect;
- mSelectRect = NULL;
- }
- bool LLToolCompInspect::handleMouseDown(S32 x, S32 y, MASK mask)
- {
- mMouseDown = true;
- gViewerWindowp->pickAsync(x, y, mask, pickCallback);
- return true;
- }
- void LLToolCompInspect::pickCallback(const LLPickInfo& pick_info)
- {
- LLToolCompInspect* self = &gToolCompInspect;
- LLViewerObject* hit_obj = pick_info.getObject();
- if (!self->mMouseDown)
- {
- static LLCachedControl<bool> linked_parts(gSavedSettings,
- "EditLinkedParts");
- // Fast click on object, but mouse is already up... just do select
- self->mSelectRect->handleObjectSelection(pick_info, linked_parts,
- false);
- return;
- }
- if (hit_obj)
- {
- if (gSelectMgr.getSelection()->getObjectCount())
- {
- gEditMenuHandlerp = &gSelectMgr;
- }
- self->setCurrentTool(self->mSelectRect);
- self->mSelectRect->handlePick(pick_info);
- }
- else
- {
- self->setCurrentTool(self->mSelectRect);
- self->mSelectRect->handlePick(pick_info);
- }
- }
- bool LLToolCompInspect::handleDoubleClick(S32 x, S32 y, MASK mask)
- {
- return true;
- }
- //-----------------------------------------------------------------------------
- // LLToolCompTranslate
- //-----------------------------------------------------------------------------
- LLToolCompTranslate::LLToolCompTranslate()
- : LLToolComposite("Move")
- {
- mManip = new LLManipTranslate(this);
- mSelectRect = new LLToolSelectRect(this);
- mCur = mManip;
- mDefault = mManip;
- }
- LLToolCompTranslate::~LLToolCompTranslate()
- {
- delete mManip;
- mManip = NULL;
- delete mSelectRect;
- mSelectRect = NULL;
- }
- bool LLToolCompTranslate::handleHover(S32 x, S32 y, MASK mask)
- {
- if (!mCur->hasMouseCapture())
- {
- setCurrentTool(mManip);
- }
- return mCur->handleHover(x, y, mask);
- }
- bool LLToolCompTranslate::handleMouseDown(S32 x, S32 y, MASK mask)
- {
- mMouseDown = true;
- gViewerWindowp->pickAsync(x, y, mask, pickCallback, true);
- return true;
- }
- void LLToolCompTranslate::pickCallback(const LLPickInfo& pick_info)
- {
- LLToolCompTranslate* self = &gToolCompTranslate;
- LLViewerObject* hit_obj = pick_info.getObject();
- self->mManip->highlightManipulators(pick_info.mMousePt.mX,
- pick_info.mMousePt.mY);
- if (!self->mMouseDown)
- {
- static LLCachedControl<bool> linked_parts(gSavedSettings,
- "EditLinkedParts");
- // Fast click on object, but mouse is already up...just do select
- self->mSelectRect->handleObjectSelection(pick_info, linked_parts,
- false);
- return;
- }
- if (hit_obj || self->mManip->getHighlightedPart() != LLManip::LL_NO_PART)
- {
- if (self->mManip->getSelection()->getObjectCount())
- {
- gEditMenuHandlerp = &gSelectMgr;
- }
- bool can_move = self->mManip->canAffectSelection();
- if (can_move &&
- LLManip::LL_NO_PART != self->mManip->getHighlightedPart())
- {
- self->setCurrentTool(self->mManip);
- self->mManip->handleMouseDownOnPart(pick_info.mMousePt.mX,
- pick_info.mMousePt.mY,
- pick_info.mKeyMask);
- }
- else
- {
- self->setCurrentTool(self->mSelectRect);
- self->mSelectRect->handlePick(pick_info);
- #if 0 // *TODO: add toggle to trigger old click-drag functionality
- self->mManip->handleMouseDownOnPart(XY_part, x, y, mask);
- #endif
- }
- }
- else
- {
- self->setCurrentTool(self->mSelectRect);
- self->mSelectRect->handlePick(pick_info);
- }
- }
- bool LLToolCompTranslate::handleMouseUp(S32 x, S32 y, MASK mask)
- {
- mMouseDown = false;
- return LLToolComposite::handleMouseUp(x, y, mask);
- }
- LLTool* LLToolCompTranslate::getOverrideTool(MASK mask)
- {
- if (mask == MASK_CONTROL)
- {
- return &gToolCompRotate;
- }
- if (mask == (MASK_CONTROL | MASK_SHIFT))
- {
- return &gToolCompScale;
- }
- return LLToolComposite::getOverrideTool(mask);
- }
- bool LLToolCompTranslate::handleDoubleClick(S32 x, S32 y, MASK mask)
- {
- if (mManip->getSelection()->isEmpty() &&
- mManip->getHighlightedPart() == LLManip::LL_NO_PART)
- {
- // You should already have an object selected from the mousedown.
- // If so, show its properties
- if (gFloaterToolsp)
- {
- gFloaterToolsp->showPanel(LLFloaterTools::PANEL_CONTENTS);
- }
- return true;
- }
- // Nothing selected means the first mouse click was probably bad, so try
- // again. This also consumes the event to prevent things like double-click
- // teleport from triggering.
- return handleMouseDown(x, y, mask);
- }
- void LLToolCompTranslate::render()
- {
- mCur->render(); // removing this will not draw the RGB arrows and guidelines
- if (mCur != mManip)
- {
- LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
- mManip->renderGuidelines();
- }
- }
- //-----------------------------------------------------------------------------
- // LLToolCompScale
- //-----------------------------------------------------------------------------
- LLToolCompScale::LLToolCompScale()
- : LLToolComposite("Stretch")
- {
- mManip = new LLManipScale(this);
- mSelectRect = new LLToolSelectRect(this);
- mCur = mManip;
- mDefault = mManip;
- }
- LLToolCompScale::~LLToolCompScale()
- {
- delete mManip;
- delete mSelectRect;
- }
- bool LLToolCompScale::handleHover(S32 x, S32 y, MASK mask)
- {
- if (!mCur->hasMouseCapture())
- {
- setCurrentTool(mManip);
- }
- return mCur->handleHover(x, y, mask);
- }
- bool LLToolCompScale::handleMouseDown(S32 x, S32 y, MASK mask)
- {
- mMouseDown = true;
- gViewerWindowp->pickAsync(x, y, mask, pickCallback);
- return true;
- }
- void LLToolCompScale::pickCallback(const LLPickInfo& pick_info)
- {
- LLToolCompScale* self = &gToolCompScale;
- LLViewerObject* hit_obj = pick_info.getObject();
- self->mManip->highlightManipulators(pick_info.mMousePt.mX,
- pick_info.mMousePt.mY);
- if (!self->mMouseDown)
- {
- static LLCachedControl<bool> linked_parts(gSavedSettings,
- "EditLinkedParts");
- // Fast click on object, but mouse is already up... just do select
- self->mSelectRect->handleObjectSelection(pick_info, linked_parts,
- false);
- return;
- }
- if (hit_obj || self->mManip->getHighlightedPart() != LLManip::LL_NO_PART)
- {
- if (self->mManip->getSelection()->getObjectCount())
- {
- gEditMenuHandlerp = &gSelectMgr;
- }
- if (LLManip::LL_NO_PART != self->mManip->getHighlightedPart())
- {
- self->setCurrentTool(self->mManip);
- self->mManip->handleMouseDownOnPart(pick_info.mMousePt.mX,
- pick_info.mMousePt.mY,
- pick_info.mKeyMask);
- }
- else
- {
- self->setCurrentTool(self->mSelectRect);
- self->mSelectRect->handlePick(pick_info);
- }
- }
- else
- {
- self->setCurrentTool(self->mSelectRect);
- self->mSelectRect->handlePick(pick_info);
- }
- }
- bool LLToolCompScale::handleMouseUp(S32 x, S32 y, MASK mask)
- {
- mMouseDown = false;
- return LLToolComposite::handleMouseUp(x, y, mask);
- }
- LLTool* LLToolCompScale::getOverrideTool(MASK mask)
- {
- if (mask == MASK_CONTROL)
- {
- return &gToolCompRotate;
- }
- return LLToolComposite::getOverrideTool(mask);
- }
- bool LLToolCompScale::handleDoubleClick(S32 x, S32 y, MASK mask)
- {
- if (!mManip->getSelection()->isEmpty() &&
- mManip->getHighlightedPart() == LLManip::LL_NO_PART)
- {
- // You should already have an object selected from the mousedown.
- // If so, show its properties
- if (gFloaterToolsp)
- {
- gFloaterToolsp->showPanel(LLFloaterTools::PANEL_CONTENTS);
- }
- return true;
- }
- // Nothing selected means the first mouse click was probably bad, so try
- // again.
- return handleMouseDown(x, y, mask);
- }
- void LLToolCompScale::render()
- {
- mCur->render();
- if (mCur != mManip)
- {
- LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
- mManip->renderGuidelines();
- }
- }
- //-----------------------------------------------------------------------------
- // LLToolCompCreate
- //-----------------------------------------------------------------------------
- LLToolCompCreate::LLToolCompCreate()
- : LLToolComposite("Create")
- {
- mPlacer = new LLToolPlacer();
- mSelectRect = new LLToolSelectRect(this);
- mCur = mPlacer;
- mDefault = mPlacer;
- mObjectPlacedOnMouseDown = false;
- }
- LLToolCompCreate::~LLToolCompCreate()
- {
- delete mPlacer;
- delete mSelectRect;
- }
- bool LLToolCompCreate::handleMouseDown(S32 x, S32 y, MASK mask)
- {
- bool handled = false;
- mMouseDown = true;
- if (mask == MASK_SHIFT || mask == MASK_CONTROL)
- {
- gViewerWindowp->pickAsync(x, y, mask, pickCallback);
- handled = true;
- }
- else
- {
- setCurrentTool(mPlacer);
- handled = mPlacer->placeObject(x, y, mask);
- }
- mObjectPlacedOnMouseDown = true;
- return handled;
- }
- void LLToolCompCreate::pickCallback(const LLPickInfo& pick_info)
- {
- // *NOTE: We mask off shift and control, so you cannot select multiple
- // objects at once with the create tool.
- MASK mask = (pick_info.mKeyMask & ~MASK_SHIFT);
- mask = (mask & ~MASK_CONTROL);
- LLToolCompCreate* self = &gToolCompCreate;
- self->setCurrentTool(self->mSelectRect);
- self->mSelectRect->handlePick(pick_info);
- }
- bool LLToolCompCreate::handleDoubleClick(S32 x, S32 y, MASK mask)
- {
- return handleMouseDown(x, y, mask);
- }
- bool LLToolCompCreate::handleMouseUp(S32 x, S32 y, MASK mask)
- {
- bool handled = false;
- if (mMouseDown && !mObjectPlacedOnMouseDown && mask != MASK_SHIFT &&
- mask != MASK_CONTROL)
- {
- setCurrentTool(mPlacer);
- handled = mPlacer->placeObject(x, y, mask);
- }
- mObjectPlacedOnMouseDown = false;
- mMouseDown = false;
- if (!handled)
- {
- handled = LLToolComposite::handleMouseUp(x, y, mask);
- }
- return handled;
- }
- //-----------------------------------------------------------------------------
- // LLToolCompRotate
- //-----------------------------------------------------------------------------
- LLToolCompRotate::LLToolCompRotate()
- : LLToolComposite("Rotate")
- {
- mManip = new LLManipRotate(this);
- mSelectRect = new LLToolSelectRect(this);
- mCur = mManip;
- mDefault = mManip;
- }
- LLToolCompRotate::~LLToolCompRotate()
- {
- delete mManip;
- delete mSelectRect;
- }
- bool LLToolCompRotate::handleHover(S32 x, S32 y, MASK mask)
- {
- if (!mCur->hasMouseCapture())
- {
- setCurrentTool(mManip);
- }
- return mCur->handleHover(x, y, mask);
- }
- bool LLToolCompRotate::handleMouseDown(S32 x, S32 y, MASK mask)
- {
- mMouseDown = true;
- gViewerWindowp->pickAsync(x, y, mask, pickCallback);
- return true;
- }
- void LLToolCompRotate::pickCallback(const LLPickInfo& pick_info)
- {
- LLToolCompRotate* self = &gToolCompRotate;
- LLViewerObject* hit_obj = pick_info.getObject();
- self->mManip->highlightManipulators(pick_info.mMousePt.mX,
- pick_info.mMousePt.mY);
- if (!self->mMouseDown)
- {
- // Fast click on object, but mouse is already up... Just do select
- static LLCachedControl<bool> linked_parts(gSavedSettings,
- "EditLinkedParts");
- self->mSelectRect->handleObjectSelection(pick_info, linked_parts,
- false);
- return;
- }
- if (hit_obj || self->mManip->getHighlightedPart() != LLManip::LL_NO_PART)
- {
- if (self->mManip->getSelection()->getObjectCount())
- {
- gEditMenuHandlerp = &gSelectMgr;
- }
- if (LLManip::LL_NO_PART != self->mManip->getHighlightedPart())
- {
- self->setCurrentTool(self->mManip);
- self->mManip->handleMouseDownOnPart(pick_info.mMousePt.mX,
- pick_info.mMousePt.mY,
- pick_info.mKeyMask);
- }
- else
- {
- self->setCurrentTool(self->mSelectRect);
- self->mSelectRect->handlePick(pick_info);
- }
- }
- else
- {
- self->setCurrentTool(self->mSelectRect);
- self->mSelectRect->handlePick(pick_info);
- }
- }
- bool LLToolCompRotate::handleMouseUp(S32 x, S32 y, MASK mask)
- {
- mMouseDown = false;
- return LLToolComposite::handleMouseUp(x, y, mask);
- }
- LLTool* LLToolCompRotate::getOverrideTool(MASK mask)
- {
- if (mask == (MASK_CONTROL | MASK_SHIFT))
- {
- return &gToolCompScale;
- }
- return LLToolComposite::getOverrideTool(mask);
- }
- bool LLToolCompRotate::handleDoubleClick(S32 x, S32 y, MASK mask)
- {
- if (!mManip->getSelection()->isEmpty() &&
- mManip->getHighlightedPart() == LLManip::LL_NO_PART)
- {
- // You should already have an object selected from the mousedown.
- // If so, show its properties
- if (gFloaterToolsp)
- {
- gFloaterToolsp->showPanel(LLFloaterTools::PANEL_CONTENTS);
- }
- return true;
- }
- // Nothing selected means the first mouse click was probably bad, so try
- // again.
- return handleMouseDown(x, y, mask);
- }
- void LLToolCompRotate::render()
- {
- mCur->render();
- if (mCur != mManip)
- {
- LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
- mManip->renderGuidelines();
- }
- }
- //-----------------------------------------------------------------------------
- // LLToolCompGun
- //-----------------------------------------------------------------------------
- LLToolCompGun::LLToolCompGun()
- : LLToolComposite("Mouselook")
- {
- mGun = new LLToolGun(this);
- mGrab = new LLToolGrabBase(this);
- setCurrentTool(mGun);
- mDefault = mGun;
- }
- LLToolCompGun::~LLToolCompGun()
- {
- delete mGun;
- mGun = NULL;
- delete mGrab;
- mGrab = NULL;
- }
- bool LLToolCompGun::handleHover(S32 x, S32 y, MASK mask)
- {
- // Note: if the tool changed, we can't delegate the current mouse event
- // after the change because tools can modify the mouse during selection and
- // deselection.
- // Instead we let the current tool handle the event and then make the change.
- // The new tool will take effect on the next frame.
- mCur->handleHover(x, y, mask);
- // If mouse button not down...
- if (!gViewerWindowp->getLeftMouseDown())
- {
- // Let ALT switch from gun to grab
- if (mCur == mGun && (mask & MASK_ALT))
- {
- setCurrentTool((LLTool*)mGrab);
- }
- else if (mCur == mGrab && !(mask & MASK_ALT))
- {
- setCurrentTool((LLTool*)mGun);
- setMouseCapture(true);
- }
- }
- return true;
- }
- bool LLToolCompGun::handleMouseDown(S32 x, S32 y, MASK mask)
- {
- // if the left button is grabbed, don't put up the pie menu
- if (gAgent.leftButtonGrabbed())
- {
- gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN);
- return false;
- }
- // On mousedown, start grabbing
- gGrabTransientTool = this;
- gToolMgr.getCurrentToolset()->selectTool((LLTool*)mGrab);
- return gToolGrab.handleMouseDown(x, y, mask);
- }
- bool LLToolCompGun::handleDoubleClick(S32 x, S32 y, MASK mask)
- {
- // if the left button is grabbed, don't put up the pie menu
- if (gAgent.leftButtonGrabbed())
- {
- gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN);
- return false;
- }
- // On mousedown, start grabbing
- gGrabTransientTool = this;
- gToolMgr.getCurrentToolset()->selectTool((LLTool*)mGrab);
- return gToolGrab.handleDoubleClick(x, y, mask);
- }
- bool LLToolCompGun::handleRightMouseDown(S32 x, S32 y, MASK mask)
- {
- #if 0 // JC - suppress context menu 8/29/2002
- // On right mouse, go through some convoluted steps to make the build menu
- // appear.
- setCurrentTool(gToolNull);
- // This should return false, meaning the context menu will be shown.
- return false;
- #else
- // Returning true suppresses the context menu
- return true;
- #endif
- }
- bool LLToolCompGun::handleMouseUp(S32 x, S32 y, MASK mask)
- {
- gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_UP);
- setCurrentTool((LLTool*)mGun);
- return true;
- }
- void LLToolCompGun::onMouseCaptureLost()
- {
- if (mComposite)
- {
- mComposite->onMouseCaptureLost();
- return;
- }
- mCur->onMouseCaptureLost();
- }
- void LLToolCompGun::handleSelect()
- {
- LLToolComposite::handleSelect();
- setMouseCapture(true);
- }
- void LLToolCompGun::handleDeselect()
- {
- LLToolComposite::handleDeselect();
- setMouseCapture(false);
- }
- bool LLToolCompGun::handleScrollWheel(S32 x, S32 y, S32 clicks)
- {
- if (clicks > 0)
- {
- gAgent.changeCameraToDefault();
- }
- return true;
- }
|