aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolobjpicker.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lltoolobjpicker.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/lltoolobjpicker.cpp')
-rw-r--r--linden/indra/newview/lltoolobjpicker.cpp181
1 files changed, 181 insertions, 0 deletions
diff --git a/linden/indra/newview/lltoolobjpicker.cpp b/linden/indra/newview/lltoolobjpicker.cpp
new file mode 100644
index 0000000..56eab5a
--- /dev/null
+++ b/linden/indra/newview/lltoolobjpicker.cpp
@@ -0,0 +1,181 @@
1/**
2 * @file lltoolobjpicker.cpp
3 * @brief LLToolObjPicker class implementation
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28// LLToolObjPicker is a transient tool, useful for a single object pick.
29
30#include "llviewerprecompiledheaders.h"
31
32#include "lltoolobjpicker.h"
33
34#include "llagent.h"
35#include "llselectmgr.h"
36#include "llworld.h"
37#include "viewer.h" // for gFPSClamped, pie menus
38#include "llviewercontrol.h"
39#include "llmenugl.h"
40#include "lltoolmgr.h"
41#include "llviewerobject.h"
42#include "llviewerobjectlist.h"
43#include "llviewermenu.h"
44#include "llviewercamera.h"
45#include "llviewerwindow.h"
46#include "lldrawable.h"
47
48LLToolObjPicker* gToolObjPicker = NULL;
49
50LLToolObjPicker::LLToolObjPicker()
51: LLTool( "ObjPicker", NULL ),
52 mPicked( FALSE ),
53 mHitObjectID( LLUUID::null ),
54 mExitCallback( NULL ),
55 mExitCallbackData( NULL )
56{ }
57
58
59// returns TRUE if an object was selected
60BOOL LLToolObjPicker::handleMouseDown(S32 x, S32 y, MASK mask)
61{
62 LLView* viewp = gViewerWindow->getRootView();
63 BOOL handled = viewp->handleMouseDown(x, y, mask);
64
65 mHitObjectID.setNull();
66
67 if (! handled)
68 {
69 // didn't click in any UI object, so must have clicked in the world
70 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback);
71 handled = TRUE;
72 }
73 else
74 {
75 if (hasMouseCapture())
76 {
77 setMouseCapture(FALSE);
78 }
79 else
80 {
81 llwarns << "PickerTool doesn't have mouse capture on mouseDown" << llendl;
82 }
83 }
84
85 // Pass mousedown to base class
86 LLTool::handleMouseDown(x, y, mask);
87
88 return handled;
89}
90
91void LLToolObjPicker::pickCallback(S32 x, S32 y, MASK mask)
92{
93 // You must hit the body for this tool to think you hit the object.
94 LLViewerObject* objectp = NULL;
95 objectp = gObjectList.findObject( gLastHitObjectID );
96 if (objectp)
97 {
98 gToolObjPicker->mHitObjectID = objectp->mID;
99 gToolObjPicker->mPicked = TRUE;
100 }
101}
102
103
104BOOL LLToolObjPicker::handleMouseUp(S32 x, S32 y, MASK mask)
105{
106 LLView* viewp = gViewerWindow->getRootView();
107 BOOL handled = viewp->handleHover(x, y, mask);
108 if (handled)
109 {
110 // let UI handle this
111 }
112
113 LLTool::handleMouseUp(x, y, mask);
114 if (hasMouseCapture())
115 {
116 setMouseCapture(FALSE);
117 }
118 else
119 {
120 llwarns << "PickerTool doesn't have mouse capture on mouseUp" << llendl;
121 }
122 return handled;
123}
124
125
126BOOL LLToolObjPicker::handleHover(S32 x, S32 y, MASK mask)
127{
128 LLView *viewp = gViewerWindow->getRootView();
129 BOOL handled = viewp->handleHover(x, y, mask);
130 if (!handled)
131 {
132 // Used to do pick on hover. Now we just always display the cursor.
133 ECursorType cursor = UI_CURSOR_ARROWLOCKED;
134
135 cursor = UI_CURSOR_TOOLPICKOBJECT3;
136
137 gViewerWindow->getWindow()->setCursor(cursor);
138 }
139 return handled;
140}
141
142
143void LLToolObjPicker::onMouseCaptureLost()
144{
145 if (mExitCallback)
146 {
147 mExitCallback(mExitCallbackData);
148
149 mExitCallback = NULL;
150 mExitCallbackData = NULL;
151 }
152
153 mPicked = FALSE;
154 mHitObjectID.setNull();
155}
156
157// virtual
158void LLToolObjPicker::setExitCallback(void (*callback)(void *), void *callback_data)
159{
160 mExitCallback = callback;
161 mExitCallbackData = callback_data;
162}
163
164// virtual
165void LLToolObjPicker::handleSelect()
166{
167 LLTool::handleSelect();
168 setMouseCapture(TRUE);
169}
170
171// virtual
172void LLToolObjPicker::handleDeselect()
173{
174 if (hasMouseCapture())
175 {
176 LLTool::handleDeselect();
177 setMouseCapture(FALSE);
178 }
179}
180
181