PageRenderTime 55ms CodeModel.GetById 49ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lltoolindividual.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 115 lines | 50 code | 15 blank | 50 comment | 3 complexity | 88c0f4d415e08ab7600e5a1df7c8bd57 MD5 | raw file
  1/** 
  2 * @file lltoolindividual.cpp
  3 * @brief LLToolIndividual class implementation
  4 *
  5 * $LicenseInfo:firstyear=2002&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//*****************************************************************************
 28//
 29// This is a tool for selecting individual object from the
 30// toolbox. Handy for when you want to deal with child object
 31// inventory...
 32//
 33//*****************************************************************************
 34
 35#include "llviewerprecompiledheaders.h"
 36#include "lltoolindividual.h"
 37
 38#include "llfloaterreg.h"
 39#include "llselectmgr.h"
 40#include "llviewerobject.h"
 41#include "llviewerwindow.h"
 42#include "llfloatertools.h"
 43
 44///----------------------------------------------------------------------------
 45/// Globals
 46///----------------------------------------------------------------------------
 47
 48
 49///----------------------------------------------------------------------------
 50/// Local function declarations, constants, enums, and typedefs
 51///----------------------------------------------------------------------------
 52
 53
 54///----------------------------------------------------------------------------
 55/// Class LLToolIndividual
 56///----------------------------------------------------------------------------
 57
 58// Default constructor
 59LLToolIndividual::LLToolIndividual()
 60: LLTool(std::string("Individual"))
 61{
 62}
 63
 64// Destroys the object
 65LLToolIndividual::~LLToolIndividual()
 66{
 67}
 68
 69BOOL LLToolIndividual::handleMouseDown(S32 x, S32 y, MASK mask)
 70{
 71	gViewerWindow->pickAsync(x, y, mask, pickCallback);
 72	return TRUE;
 73}
 74
 75void LLToolIndividual::pickCallback(const LLPickInfo& pick_info)
 76{
 77	LLViewerObject* obj = pick_info.getObject();
 78	LLSelectMgr::getInstance()->deselectAll();
 79	if(obj)
 80	{
 81		LLSelectMgr::getInstance()->selectObjectOnly(obj);
 82	}
 83}
 84
 85BOOL LLToolIndividual::handleDoubleClick(S32 x, S32 y, MASK mask)
 86{
 87	if(!LLSelectMgr::getInstance()->getSelection()->isEmpty())
 88	{
 89		// You should already have an object selected from the mousedown.
 90		// If so, show its inventory. 
 91		LLFloaterReg::showInstance("build", "Content");
 92		return TRUE;
 93	}
 94	else
 95	{
 96		// Nothing selected means the first mouse click was probably
 97		// bad, so try again.
 98		return FALSE;
 99	}
100}
101
102void LLToolIndividual::handleSelect()
103{
104	const BOOL children_ok = TRUE;
105	LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok);
106	LLSelectMgr::getInstance()->deselectAll();
107	if(obj)
108	{
109		LLSelectMgr::getInstance()->selectObjectOnly(obj);
110	}
111}
112
113///----------------------------------------------------------------------------
114/// Local function definitions
115///----------------------------------------------------------------------------