summaryrefslogtreecommitdiff
path: root/indra/newview/lltoolcomp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltoolcomp.cpp')
-rwxr-xr-x[-rw-r--r--]indra/newview/lltoolcomp.cpp138
1 files changed, 90 insertions, 48 deletions
diff --git a/indra/newview/lltoolcomp.cpp b/indra/newview/lltoolcomp.cpp
index fff18df442..5a63f6e286 100644..100755
--- a/indra/newview/lltoolcomp.cpp
+++ b/indra/newview/lltoolcomp.cpp
@@ -2,31 +2,25 @@
* @file lltoolcomp.cpp
* @brief Composite tools
*
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
* 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
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * 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
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * 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.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -54,19 +48,14 @@
#include "llviewerobject.h"
#include "llviewerwindow.h"
#include "llagent.h"
+#include "llagentcamera.h"
#include "llfloatertools.h"
#include "llviewercontrol.h"
-const S32 BUTTON_HEIGHT = 16;
-const S32 BUTTON_WIDTH_SMALL = 32;
-const S32 BUTTON_WIDTH_BIG = 48;
-const S32 HPAD = 4;
-
extern LLControlGroup gSavedSettings;
-
// we use this in various places instead of NULL
-static LLTool* sNullTool = new LLTool(std::string("null"), NULL);
+static LLPointer<LLTool> sNullTool(new LLTool(std::string("null"), NULL));
//-----------------------------------------------------------------------
// LLToolComposite
@@ -131,12 +120,20 @@ void LLToolComposite::handleSelect()
mSelected = TRUE;
}
+void LLToolComposite::handleDeselect()
+{
+ mCur->handleDeselect();
+ mCur = mDefault;
+ mSelected = FALSE;
+}
+
//----------------------------------------------------------------------------
// LLToolCompInspect
//----------------------------------------------------------------------------
LLToolCompInspect::LLToolCompInspect()
-: LLToolComposite(std::string("Inspect"))
+: LLToolComposite(std::string("Inspect")),
+ mIsToolCameraActive(FALSE)
{
mSelectRect = new LLToolSelectRect(this);
mDefault = mSelectRect;
@@ -151,42 +148,87 @@ LLToolCompInspect::~LLToolCompInspect()
BOOL LLToolCompInspect::handleMouseDown(S32 x, S32 y, MASK mask)
{
- mMouseDown = TRUE;
- gViewerWindow->pickAsync(x, y, mask, pickCallback);
- return TRUE;
+ BOOL handled = FALSE;
+
+ if (mCur == LLToolCamera::getInstance())
+ {
+ handled = mCur->handleMouseDown(x, y, mask);
+ }
+ else
+ {
+ mMouseDown = TRUE;
+ gViewerWindow->pickAsync(x, y, mask, pickCallback);
+ handled = TRUE;
+ }
+
+ return handled;
+}
+
+BOOL LLToolCompInspect::handleMouseUp(S32 x, S32 y, MASK mask)
+{
+ BOOL handled = LLToolComposite::handleMouseUp(x, y, mask);
+ mIsToolCameraActive = getCurrentTool() == LLToolCamera::getInstance();
+ return handled;
}
void LLToolCompInspect::pickCallback(const LLPickInfo& pick_info)
{
LLViewerObject* hit_obj = pick_info.getObject();
+ LLToolCompInspect * tool_inspectp = LLToolCompInspect::getInstance();
- if (!LLToolCompInspect::getInstance()->mMouseDown)
+ if (!tool_inspectp->mMouseDown)
{
// fast click on object, but mouse is already up...just do select
- LLToolCompInspect::getInstance()->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
+ tool_inspectp->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
return;
}
- if( hit_obj )
- {
- if (LLSelectMgr::getInstance()->getSelection()->getObjectCount())
- {
- LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
- }
- LLToolCompInspect::getInstance()->setCurrentTool( LLToolCompInspect::getInstance()->mSelectRect );
- LLToolCompInspect::getInstance()->mSelectRect->handlePick( pick_info );
+ LLSelectMgr * mgr_selectp = LLSelectMgr::getInstance();
+ if( hit_obj && mgr_selectp->getSelection()->getObjectCount()) {
+ LLEditMenuHandler::gEditMenuHandler = mgr_selectp;
+ }
+
+ tool_inspectp->setCurrentTool( tool_inspectp->mSelectRect );
+ tool_inspectp->mIsToolCameraActive = FALSE;
+ tool_inspectp->mSelectRect->handlePick( pick_info );
+}
+
+BOOL LLToolCompInspect::handleDoubleClick(S32 x, S32 y, MASK mask)
+{
+ return TRUE;
+}
+
+BOOL LLToolCompInspect::handleKey(KEY key, MASK mask)
+{
+ BOOL handled = FALSE;
+ if(KEY_ALT == key)
+ {
+ setCurrentTool(LLToolCamera::getInstance());
+ mIsToolCameraActive = TRUE;
+ handled = TRUE;
}
else
{
- LLToolCompInspect::getInstance()->setCurrentTool( LLToolCompInspect::getInstance()->mSelectRect );
- LLToolCompInspect::getInstance()->mSelectRect->handlePick( pick_info );
+ handled = LLToolComposite::handleKey(key, mask);
}
+
+ return handled;
}
-BOOL LLToolCompInspect::handleDoubleClick(S32 x, S32 y, MASK mask)
+void LLToolCompInspect::onMouseCaptureLost()
{
- return TRUE;
+ LLToolComposite::onMouseCaptureLost();
+ mIsToolCameraActive = FALSE;
+}
+
+void LLToolCompInspect::keyUp(KEY key, MASK mask)
+{
+ if (KEY_ALT == key && mCur == LLToolCamera::getInstance())
+ {
+ setCurrentTool(mDefault);
+ mIsToolCameraActive = FALSE;
+ }
}
//----------------------------------------------------------------------------
@@ -476,7 +518,7 @@ BOOL LLToolCompCreate::handleMouseDown(S32 x, S32 y, MASK mask)
mObjectPlacedOnMouseDown = TRUE;
- return TRUE;
+ return handled;
}
void LLToolCompCreate::pickCallback(const LLPickInfo& pick_info)
@@ -784,7 +826,7 @@ BOOL LLToolCompGun::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
if (clicks > 0)
{
- gAgent.changeCameraToDefault();
+ gAgentCamera.changeCameraToDefault();
}
return TRUE;