diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lltoolcomp.cpp | |
parent | README.txt (diff) | |
download | meta-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 '')
-rw-r--r-- | linden/indra/newview/lltoolcomp.cpp | 749 |
1 files changed, 749 insertions, 0 deletions
diff --git a/linden/indra/newview/lltoolcomp.cpp b/linden/indra/newview/lltoolcomp.cpp new file mode 100644 index 0000000..0ef710d --- /dev/null +++ b/linden/indra/newview/lltoolcomp.cpp | |||
@@ -0,0 +1,749 @@ | |||
1 | /** | ||
2 | * @file lltoolcomp.cpp | ||
3 | * @brief Composite tools | ||
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 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "lltoolcomp.h" | ||
31 | |||
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 "lltoolselect.h" | ||
46 | #include "lltoolselectrect.h" | ||
47 | #include "lltoolplacer.h" | ||
48 | #include "llviewermenu.h" | ||
49 | #include "llviewerobject.h" | ||
50 | #include "llviewerwindow.h" | ||
51 | #include "llagent.h" | ||
52 | #include "llfloatertools.h" | ||
53 | #include "llviewercontrol.h" | ||
54 | |||
55 | const S32 BUTTON_HEIGHT = 16; | ||
56 | const S32 BUTTON_WIDTH_SMALL = 32; | ||
57 | const S32 BUTTON_WIDTH_BIG = 48; | ||
58 | const S32 HPAD = 4; | ||
59 | |||
60 | // Globals | ||
61 | LLToolCompInspect *gToolInspect = NULL; | ||
62 | LLToolCompTranslate *gToolTranslate = NULL; | ||
63 | LLToolCompScale *gToolStretch = NULL; | ||
64 | LLToolCompRotate *gToolRotate = NULL; | ||
65 | LLToolCompCreate *gToolCreate = NULL; | ||
66 | LLToolCompGun *gToolGun = NULL; | ||
67 | |||
68 | extern LLControlGroup gSavedSettings; | ||
69 | |||
70 | |||
71 | //----------------------------------------------------------------------- | ||
72 | // LLToolComposite | ||
73 | |||
74 | //static | ||
75 | void LLToolComposite::setCurrentTool( LLTool* new_tool ) | ||
76 | { | ||
77 | if( mCur != new_tool ) | ||
78 | { | ||
79 | if( mSelected ) | ||
80 | { | ||
81 | mCur->handleDeselect(); | ||
82 | mCur = new_tool; | ||
83 | mCur->handleSelect(); | ||
84 | } | ||
85 | else | ||
86 | { | ||
87 | mCur = new_tool; | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | |||
92 | LLToolComposite::LLToolComposite(const LLString& name) | ||
93 | : LLTool(name), | ||
94 | mCur(NULL), mDefault(NULL), mSelected(FALSE), | ||
95 | mMouseDown(FALSE), mManip(NULL), mSelectRect(NULL) | ||
96 | { | ||
97 | } | ||
98 | |||
99 | // Returns to the default tool | ||
100 | BOOL LLToolComposite::handleMouseUp(S32 x, S32 y, MASK mask) | ||
101 | { | ||
102 | BOOL handled = mCur->handleMouseUp( x, y, mask ); | ||
103 | if( handled ) | ||
104 | { | ||
105 | setCurrentTool( mDefault ); | ||
106 | } | ||
107 | return handled; | ||
108 | } | ||
109 | |||
110 | void LLToolComposite::onMouseCaptureLost() | ||
111 | { | ||
112 | mCur->onMouseCaptureLost(); | ||
113 | setCurrentTool( mDefault ); | ||
114 | } | ||
115 | |||
116 | BOOL LLToolComposite::isSelecting() | ||
117 | { | ||
118 | return mCur == mSelectRect; | ||
119 | } | ||
120 | |||
121 | void LLToolComposite::handleSelect() | ||
122 | { | ||
123 | if (gSavedSettings.getBOOL("SelectLinkedSet")) | ||
124 | { | ||
125 | gSelectMgr->promoteSelectionToRoot(); | ||
126 | } | ||
127 | mCur = mDefault; | ||
128 | mCur->handleSelect(); | ||
129 | mSelected = TRUE; | ||
130 | } | ||
131 | |||
132 | //---------------------------------------------------------------------------- | ||
133 | // LLToolCompInspect | ||
134 | //---------------------------------------------------------------------------- | ||
135 | |||
136 | LLToolCompInspect::LLToolCompInspect() | ||
137 | : LLToolComposite("Inspect") | ||
138 | { | ||
139 | mSelectRect = new LLToolSelectRect(this); | ||
140 | mDefault = mSelectRect; | ||
141 | } | ||
142 | |||
143 | |||
144 | LLToolCompInspect::~LLToolCompInspect() | ||
145 | { | ||
146 | delete mSelectRect; | ||
147 | mSelectRect = NULL; | ||
148 | } | ||
149 | |||
150 | BOOL LLToolCompInspect::handleMouseDown(S32 x, S32 y, MASK mask) | ||
151 | { | ||
152 | mMouseDown = TRUE; | ||
153 | gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback); | ||
154 | return TRUE; | ||
155 | } | ||
156 | |||
157 | void LLToolCompInspect::pickCallback(S32 x, S32 y, MASK mask) | ||
158 | { | ||
159 | LLViewerObject* hit_obj = gViewerWindow->lastObjectHit(); | ||
160 | |||
161 | if (!gToolInspect->mMouseDown) | ||
162 | { | ||
163 | // fast click on object, but mouse is already up...just do select | ||
164 | gToolInspect->mSelectRect->handleObjectSelection(hit_obj, mask, !gSavedSettings.getBOOL("SelectLinkedSet"), FALSE); | ||
165 | return; | ||
166 | } | ||
167 | |||
168 | if( hit_obj ) | ||
169 | { | ||
170 | if (gSelectMgr->getObjectCount()) | ||
171 | { | ||
172 | gEditMenuHandler = gSelectMgr; | ||
173 | } | ||
174 | gToolInspect->setCurrentTool( gToolInspect->mSelectRect ); | ||
175 | gToolInspect->mSelectRect->handleMouseDown( x, y, mask ); | ||
176 | |||
177 | } | ||
178 | else | ||
179 | { | ||
180 | gToolInspect->setCurrentTool( gToolInspect->mSelectRect ); | ||
181 | gToolInspect->mSelectRect->handleMouseDown( x, y, mask); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | BOOL LLToolCompInspect::handleDoubleClick(S32 x, S32 y, MASK mask) | ||
186 | { | ||
187 | return TRUE; | ||
188 | } | ||
189 | |||
190 | //---------------------------------------------------------------------------- | ||
191 | // LLToolCompTranslate | ||
192 | //---------------------------------------------------------------------------- | ||
193 | |||
194 | LLToolCompTranslate::LLToolCompTranslate() | ||
195 | : LLToolComposite("Move") | ||
196 | { | ||
197 | mManip = new LLManipTranslate(this); | ||
198 | mSelectRect = new LLToolSelectRect(this); | ||
199 | |||
200 | mCur = mManip; | ||
201 | mDefault = mManip; | ||
202 | } | ||
203 | |||
204 | LLToolCompTranslate::~LLToolCompTranslate() | ||
205 | { | ||
206 | delete mManip; | ||
207 | mManip = NULL; | ||
208 | |||
209 | delete mSelectRect; | ||
210 | mSelectRect = NULL; | ||
211 | } | ||
212 | |||
213 | BOOL LLToolCompTranslate::handleHover(S32 x, S32 y, MASK mask) | ||
214 | { | ||
215 | if( !mCur->hasMouseCapture() ) | ||
216 | { | ||
217 | setCurrentTool( mManip ); | ||
218 | } | ||
219 | return mCur->handleHover( x, y, mask ); | ||
220 | } | ||
221 | |||
222 | |||
223 | BOOL LLToolCompTranslate::handleMouseDown(S32 x, S32 y, MASK mask) | ||
224 | { | ||
225 | mMouseDown = TRUE; | ||
226 | gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback); | ||
227 | return TRUE; | ||
228 | } | ||
229 | |||
230 | void LLToolCompTranslate::pickCallback(S32 x, S32 y, MASK mask) | ||
231 | { | ||
232 | LLViewerObject* hit_obj = gViewerWindow->lastObjectHit(); | ||
233 | |||
234 | gToolTranslate->mManip->highlightManipulators(x, y); | ||
235 | if (!gToolTranslate->mMouseDown) | ||
236 | { | ||
237 | // fast click on object, but mouse is already up...just do select | ||
238 | gToolTranslate->mSelectRect->handleObjectSelection(hit_obj, mask, !gSavedSettings.getBOOL("SelectLinkedSet"), FALSE); | ||
239 | return; | ||
240 | } | ||
241 | |||
242 | if( hit_obj || gToolTranslate->mManip->getHighlightedPart() != LLManip::LL_NO_PART ) | ||
243 | { | ||
244 | if (gSelectMgr->getObjectCount()) | ||
245 | { | ||
246 | gEditMenuHandler = gSelectMgr; | ||
247 | } | ||
248 | if( LLManip::LL_NO_PART != gToolTranslate->mManip->getHighlightedPart() ) | ||
249 | { | ||
250 | gToolTranslate->setCurrentTool( gToolTranslate->mManip ); | ||
251 | gToolTranslate->mManip->handleMouseDownOnPart( x, y, mask ); | ||
252 | } | ||
253 | else | ||
254 | { | ||
255 | gToolTranslate->setCurrentTool( gToolTranslate->mSelectRect ); | ||
256 | gToolTranslate->mSelectRect->handleMouseDown( x, y, mask ); | ||
257 | |||
258 | // *TODO: add toggle to trigger old click-drag functionality | ||
259 | // gToolTranslate->mManip->handleMouseDownOnPart( XY_part, x, y, mask); | ||
260 | } | ||
261 | } | ||
262 | else | ||
263 | { | ||
264 | gToolTranslate->setCurrentTool( gToolTranslate->mSelectRect ); | ||
265 | gToolTranslate->mSelectRect->handleMouseDown( x, y, mask); | ||
266 | } | ||
267 | } | ||
268 | |||
269 | BOOL LLToolCompTranslate::handleMouseUp(S32 x, S32 y, MASK mask) | ||
270 | { | ||
271 | mMouseDown = FALSE; | ||
272 | return LLToolComposite::handleMouseUp(x, y, mask); | ||
273 | } | ||
274 | |||
275 | BOOL LLToolCompTranslate::handleDoubleClick(S32 x, S32 y, MASK mask) | ||
276 | { | ||
277 | if (!gSelectMgr->isEmpty() && mManip->getHighlightedPart() == LLManip::LL_NO_PART) | ||
278 | { | ||
279 | // You should already have an object selected from the mousedown. | ||
280 | // If so, show its properties | ||
281 | gFloaterTools->showPanel(LLFloaterTools::PANEL_CONTENTS); | ||
282 | return TRUE; | ||
283 | } | ||
284 | // Nothing selected means the first mouse click was probably | ||
285 | // bad, so try again. | ||
286 | return FALSE; | ||
287 | } | ||
288 | |||
289 | |||
290 | void LLToolCompTranslate::render() | ||
291 | { | ||
292 | mCur->render(); | ||
293 | |||
294 | if( mCur != mManip ) | ||
295 | { | ||
296 | LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); | ||
297 | mManip->renderGuidelines(); | ||
298 | } | ||
299 | } | ||
300 | |||
301 | |||
302 | //----------------------------------------------------------------------- | ||
303 | // LLToolCompScale | ||
304 | |||
305 | LLToolCompScale::LLToolCompScale() | ||
306 | : LLToolComposite("Stretch") | ||
307 | { | ||
308 | mManip = new LLManipScale(this); | ||
309 | mSelectRect = new LLToolSelectRect(this); | ||
310 | |||
311 | mCur = mManip; | ||
312 | mDefault = mManip; | ||
313 | } | ||
314 | |||
315 | LLToolCompScale::~LLToolCompScale() | ||
316 | { | ||
317 | delete mManip; | ||
318 | delete mSelectRect; | ||
319 | } | ||
320 | |||
321 | BOOL LLToolCompScale::handleHover(S32 x, S32 y, MASK mask) | ||
322 | { | ||
323 | if( !mCur->hasMouseCapture() ) | ||
324 | { | ||
325 | setCurrentTool(mManip ); | ||
326 | } | ||
327 | return mCur->handleHover( x, y, mask ); | ||
328 | } | ||
329 | |||
330 | |||
331 | BOOL LLToolCompScale::handleMouseDown(S32 x, S32 y, MASK mask) | ||
332 | { | ||
333 | mMouseDown = TRUE; | ||
334 | gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback); | ||
335 | return TRUE; | ||
336 | } | ||
337 | |||
338 | void LLToolCompScale::pickCallback(S32 x, S32 y, MASK mask) | ||
339 | { | ||
340 | LLViewerObject* hit_obj = gViewerWindow->lastObjectHit(); | ||
341 | |||
342 | gToolStretch->mManip->highlightManipulators(x, y); | ||
343 | if (!gToolStretch->mMouseDown) | ||
344 | { | ||
345 | // fast click on object, but mouse is already up...just do select | ||
346 | gToolStretch->mSelectRect->handleObjectSelection(hit_obj, mask, !gSavedSettings.getBOOL("SelectLinkedSet"), FALSE); | ||
347 | |||
348 | return; | ||
349 | } | ||
350 | |||
351 | if( hit_obj || gToolStretch->mManip->getHighlightedPart() != LLManip::LL_NO_PART) | ||
352 | { | ||
353 | if (gSelectMgr->getObjectCount()) | ||
354 | { | ||
355 | gEditMenuHandler = gSelectMgr; | ||
356 | } | ||
357 | if( LLManip::LL_NO_PART != gToolStretch->mManip->getHighlightedPart() ) | ||
358 | { | ||
359 | gToolStretch->setCurrentTool( gToolStretch->mManip ); | ||
360 | gToolStretch->mManip->handleMouseDownOnPart( x, y, mask ); | ||
361 | } | ||
362 | else | ||
363 | { | ||
364 | gToolStretch->setCurrentTool( gToolStretch->mSelectRect ); | ||
365 | gToolStretch->mSelectRect->handleMouseDown( x, y, mask ); | ||
366 | } | ||
367 | } | ||
368 | else | ||
369 | { | ||
370 | gToolStretch->setCurrentTool( gToolStretch->mSelectRect ); | ||
371 | gToolStretch->mCur->handleMouseDown( x, y, mask ); | ||
372 | } | ||
373 | } | ||
374 | |||
375 | BOOL LLToolCompScale::handleMouseUp(S32 x, S32 y, MASK mask) | ||
376 | { | ||
377 | mMouseDown = FALSE; | ||
378 | return LLToolComposite::handleMouseUp(x, y, mask); | ||
379 | } | ||
380 | |||
381 | BOOL LLToolCompScale::handleDoubleClick(S32 x, S32 y, MASK mask) | ||
382 | { | ||
383 | if (!gSelectMgr->isEmpty() && mManip->getHighlightedPart() == LLManip::LL_NO_PART) | ||
384 | { | ||
385 | // You should already have an object selected from the mousedown. | ||
386 | // If so, show its properties | ||
387 | gFloaterTools->showPanel(LLFloaterTools::PANEL_CONTENTS); | ||
388 | //gBuildView->setPropertiesPanelOpen(TRUE); | ||
389 | return TRUE; | ||
390 | } | ||
391 | else | ||
392 | { | ||
393 | // Nothing selected means the first mouse click was probably | ||
394 | // bad, so try again. | ||
395 | return handleMouseDown(x, y, mask); | ||
396 | } | ||
397 | } | ||
398 | |||
399 | |||
400 | void LLToolCompScale::render() | ||
401 | { | ||
402 | mCur->render(); | ||
403 | |||
404 | if( mCur != mManip ) | ||
405 | { | ||
406 | LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); | ||
407 | mManip->renderGuidelines(); | ||
408 | } | ||
409 | } | ||
410 | |||
411 | //----------------------------------------------------------------------- | ||
412 | // LLToolCompCreate | ||
413 | |||
414 | LLToolCompCreate::LLToolCompCreate() | ||
415 | : LLToolComposite("Create") | ||
416 | { | ||
417 | mPlacer = new LLToolPlacer(); | ||
418 | mSelectRect = new LLToolSelectRect(this); | ||
419 | |||
420 | mCur = mPlacer; | ||
421 | mDefault = mPlacer; | ||
422 | mObjectPlacedOnMouseDown = FALSE; | ||
423 | } | ||
424 | |||
425 | |||
426 | LLToolCompCreate::~LLToolCompCreate() | ||
427 | { | ||
428 | delete mPlacer; | ||
429 | delete mSelectRect; | ||
430 | } | ||
431 | |||
432 | |||
433 | BOOL LLToolCompCreate::handleMouseDown(S32 x, S32 y, MASK mask) | ||
434 | { | ||
435 | BOOL handled = FALSE; | ||
436 | mMouseDown = TRUE; | ||
437 | |||
438 | if ( !(mask == MASK_SHIFT) && !(mask == MASK_CONTROL) ) | ||
439 | { | ||
440 | setCurrentTool( mPlacer ); | ||
441 | handled = mPlacer->placeObject( x, y, mask ); | ||
442 | } | ||
443 | else | ||
444 | { | ||
445 | gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback); | ||
446 | handled = TRUE; | ||
447 | } | ||
448 | |||
449 | mObjectPlacedOnMouseDown = TRUE; | ||
450 | |||
451 | return TRUE; | ||
452 | } | ||
453 | |||
454 | void LLToolCompCreate::pickCallback(S32 x, S32 y, MASK mask) | ||
455 | { | ||
456 | // *NOTE: We mask off shift and control, so you cannot | ||
457 | // multi-select multiple objects with the create tool. | ||
458 | mask = (mask & ~MASK_SHIFT); | ||
459 | mask = (mask & ~MASK_CONTROL); | ||
460 | |||
461 | gToolCreate->setCurrentTool( gToolCreate->mSelectRect ); | ||
462 | gToolCreate->mSelectRect->handleMouseDown( x, y, mask); | ||
463 | } | ||
464 | |||
465 | BOOL LLToolCompCreate::handleDoubleClick(S32 x, S32 y, MASK mask) | ||
466 | { | ||
467 | return handleMouseDown(x, y, mask); | ||
468 | } | ||
469 | |||
470 | BOOL LLToolCompCreate::handleMouseUp(S32 x, S32 y, MASK mask) | ||
471 | { | ||
472 | BOOL handled = FALSE; | ||
473 | |||
474 | if ( mMouseDown && !mObjectPlacedOnMouseDown && !(mask == MASK_SHIFT) && !(mask == MASK_CONTROL) ) | ||
475 | { | ||
476 | setCurrentTool( mPlacer ); | ||
477 | handled = mPlacer->placeObject( x, y, mask ); | ||
478 | } | ||
479 | |||
480 | mObjectPlacedOnMouseDown = FALSE; | ||
481 | mMouseDown = FALSE; | ||
482 | |||
483 | return handled; | ||
484 | } | ||
485 | |||
486 | //----------------------------------------------------------------------- | ||
487 | // LLToolCompRotate | ||
488 | |||
489 | LLToolCompRotate::LLToolCompRotate() | ||
490 | : LLToolComposite("Rotate") | ||
491 | { | ||
492 | mManip = new LLManipRotate(this); | ||
493 | mSelectRect = new LLToolSelectRect(this); | ||
494 | |||
495 | mCur = mManip; | ||
496 | mDefault = mManip; | ||
497 | } | ||
498 | |||
499 | |||
500 | LLToolCompRotate::~LLToolCompRotate() | ||
501 | { | ||
502 | delete mManip; | ||
503 | delete mSelectRect; | ||
504 | } | ||
505 | |||
506 | BOOL LLToolCompRotate::handleHover(S32 x, S32 y, MASK mask) | ||
507 | { | ||
508 | if( !mCur->hasMouseCapture() ) | ||
509 | { | ||
510 | setCurrentTool( mManip ); | ||
511 | } | ||
512 | return mCur->handleHover( x, y, mask ); | ||
513 | } | ||
514 | |||
515 | |||
516 | BOOL LLToolCompRotate::handleMouseDown(S32 x, S32 y, MASK mask) | ||
517 | { | ||
518 | mMouseDown = TRUE; | ||
519 | gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback); | ||
520 | return TRUE; | ||
521 | } | ||
522 | |||
523 | void LLToolCompRotate::pickCallback(S32 x, S32 y, MASK mask) | ||
524 | { | ||
525 | LLViewerObject* hit_obj = gViewerWindow->lastObjectHit(); | ||
526 | |||
527 | gToolRotate->mManip->highlightManipulators(x, y); | ||
528 | if (!gToolRotate->mMouseDown) | ||
529 | { | ||
530 | // fast click on object, but mouse is already up...just do select | ||
531 | gToolRotate->mSelectRect->handleObjectSelection(hit_obj, mask, !gSavedSettings.getBOOL("SelectLinkedSet"), FALSE); | ||
532 | return; | ||
533 | } | ||
534 | |||
535 | if( hit_obj || gToolRotate->mManip->getHighlightedPart() != LLManip::LL_NO_PART) | ||
536 | { | ||
537 | if (gSelectMgr->getObjectCount()) | ||
538 | { | ||
539 | gEditMenuHandler = gSelectMgr; | ||
540 | } | ||
541 | if( LLManip::LL_NO_PART != gToolRotate->mManip->getHighlightedPart() ) | ||
542 | { | ||
543 | gToolRotate->setCurrentTool( gToolRotate->mManip ); | ||
544 | gToolRotate->mManip->handleMouseDownOnPart( x, y, mask ); | ||
545 | } | ||
546 | else | ||
547 | { | ||
548 | gToolRotate->setCurrentTool( gToolRotate->mSelectRect ); | ||
549 | gToolRotate->mSelectRect->handleMouseDown( x, y, mask ); | ||
550 | } | ||
551 | } | ||
552 | else | ||
553 | { | ||
554 | gToolRotate->setCurrentTool( gToolRotate->mSelectRect ); | ||
555 | gToolRotate->mCur->handleMouseDown( x, y, mask ); | ||
556 | } | ||
557 | } | ||
558 | |||
559 | BOOL LLToolCompRotate::handleMouseUp(S32 x, S32 y, MASK mask) | ||
560 | { | ||
561 | mMouseDown = FALSE; | ||
562 | return LLToolComposite::handleMouseUp(x, y, mask); | ||
563 | } | ||
564 | |||
565 | |||
566 | BOOL LLToolCompRotate::handleDoubleClick(S32 x, S32 y, MASK mask) | ||
567 | { | ||
568 | if (!gSelectMgr->isEmpty() && mManip->getHighlightedPart() == LLManip::LL_NO_PART) | ||
569 | { | ||
570 | // You should already have an object selected from the mousedown. | ||
571 | // If so, show its properties | ||
572 | gFloaterTools->showPanel(LLFloaterTools::PANEL_CONTENTS); | ||
573 | //gBuildView->setPropertiesPanelOpen(TRUE); | ||
574 | return TRUE; | ||
575 | } | ||
576 | else | ||
577 | { | ||
578 | // Nothing selected means the first mouse click was probably | ||
579 | // bad, so try again. | ||
580 | return handleMouseDown(x, y, mask); | ||
581 | } | ||
582 | } | ||
583 | |||
584 | |||
585 | void LLToolCompRotate::render() | ||
586 | { | ||
587 | mCur->render(); | ||
588 | |||
589 | if( mCur != mManip ) | ||
590 | { | ||
591 | LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); | ||
592 | mManip->renderGuidelines(); | ||
593 | } | ||
594 | } | ||
595 | |||
596 | |||
597 | //----------------------------------------------------------------------- | ||
598 | // LLToolCompGun | ||
599 | |||
600 | LLToolCompGun::LLToolCompGun() | ||
601 | : LLToolComposite("Mouselook") | ||
602 | { | ||
603 | mGun = new LLToolGun(this); | ||
604 | mGrab = new LLToolGrab(this); | ||
605 | mNull = new LLTool("null", this); | ||
606 | |||
607 | setCurrentTool(mGun); | ||
608 | mDefault = mGun; | ||
609 | } | ||
610 | |||
611 | |||
612 | LLToolCompGun::~LLToolCompGun() | ||
613 | { | ||
614 | delete mGun; | ||
615 | mGun = NULL; | ||
616 | |||
617 | delete mGrab; | ||
618 | mGrab = NULL; | ||
619 | |||
620 | delete mNull; | ||
621 | mNull = NULL; | ||
622 | } | ||
623 | |||
624 | BOOL LLToolCompGun::handleHover(S32 x, S32 y, MASK mask) | ||
625 | { | ||
626 | // *NOTE: This hack is here to make mouselook kick in again after | ||
627 | // item selected from context menu. | ||
628 | if ( mCur == mNull && !gPopupMenuView->getVisible() ) | ||
629 | { | ||
630 | gSelectMgr->deselectAll(); | ||
631 | setCurrentTool( (LLTool*) mGrab ); | ||
632 | } | ||
633 | |||
634 | // Note: if the tool changed, we can't delegate the current mouse event | ||
635 | // after the change because tools can modify the mouse during selection and deselection. | ||
636 | // Instead we let the current tool handle the event and then make the change. | ||
637 | // The new tool will take effect on the next frame. | ||
638 | |||
639 | mCur->handleHover( x, y, mask ); | ||
640 | |||
641 | // If mouse button not down... | ||
642 | if( !gViewerWindow->getLeftMouseDown()) | ||
643 | { | ||
644 | // let ALT switch from gun to grab | ||
645 | if ( mCur == mGun && (mask & MASK_ALT) ) | ||
646 | { | ||
647 | setCurrentTool( (LLTool*) mGrab ); | ||
648 | } | ||
649 | else if ( mCur == mGrab && !(mask & MASK_ALT) ) | ||
650 | { | ||
651 | setCurrentTool( (LLTool*) mGun ); | ||
652 | setMouseCapture(TRUE); | ||
653 | } | ||
654 | } | ||
655 | |||
656 | return TRUE; | ||
657 | } | ||
658 | |||
659 | |||
660 | BOOL LLToolCompGun::handleMouseDown(S32 x, S32 y, MASK mask) | ||
661 | { | ||
662 | // if the left button is grabbed, don't put up the pie menu | ||
663 | if (gAgent.leftButtonGrabbed()) | ||
664 | { | ||
665 | gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN); | ||
666 | return FALSE; | ||
667 | } | ||
668 | |||
669 | // On mousedown, start grabbing | ||
670 | gGrabTransientTool = this; | ||
671 | gCurrentToolset->selectTool( (LLTool*) mGrab ); | ||
672 | |||
673 | return gToolGrab->handleMouseDown(x, y, mask); | ||
674 | } | ||
675 | |||
676 | |||
677 | BOOL LLToolCompGun::handleDoubleClick(S32 x, S32 y, MASK mask) | ||
678 | { | ||
679 | // if the left button is grabbed, don't put up the pie menu | ||
680 | if (gAgent.leftButtonGrabbed()) | ||
681 | { | ||
682 | gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN); | ||
683 | return FALSE; | ||
684 | } | ||
685 | |||
686 | // On mousedown, start grabbing | ||
687 | gGrabTransientTool = this; | ||
688 | gCurrentToolset->selectTool( (LLTool*) mGrab ); | ||
689 | |||
690 | return gToolGrab->handleDoubleClick(x, y, mask); | ||
691 | } | ||
692 | |||
693 | |||
694 | BOOL LLToolCompGun::handleRightMouseDown(S32 x, S32 y, MASK mask) | ||
695 | { | ||
696 | /* JC - suppress context menu 8/29/2002 | ||
697 | |||
698 | // On right mouse, go through some convoluted steps to | ||
699 | // make the build menu appear. | ||
700 | setCurrentTool( (LLTool*) mNull ); | ||
701 | |||
702 | // This should return FALSE, meaning the context menu will | ||
703 | // be shown. | ||
704 | return FALSE; | ||
705 | */ | ||
706 | |||
707 | // Returning true will suppress the context menu | ||
708 | return TRUE; | ||
709 | } | ||
710 | |||
711 | |||
712 | BOOL LLToolCompGun::handleMouseUp(S32 x, S32 y, MASK mask) | ||
713 | { | ||
714 | gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_UP); | ||
715 | setCurrentTool( (LLTool*) mGun ); | ||
716 | return TRUE; | ||
717 | } | ||
718 | |||
719 | void LLToolCompGun::onMouseCaptureLost() | ||
720 | { | ||
721 | mCur->onMouseCaptureLost(); | ||
722 | |||
723 | // JC - I don't know if this is necessary. Maybe we could lose capture | ||
724 | // if someone ALT-Tab's out when in mouselook. | ||
725 | setCurrentTool( (LLTool*) mGun ); | ||
726 | } | ||
727 | |||
728 | void LLToolCompGun::handleSelect() | ||
729 | { | ||
730 | LLToolComposite::handleSelect(); | ||
731 | setMouseCapture(TRUE); | ||
732 | } | ||
733 | |||
734 | void LLToolCompGun::handleDeselect() | ||
735 | { | ||
736 | LLToolComposite::handleDeselect(); | ||
737 | setMouseCapture(FALSE); | ||
738 | } | ||
739 | |||
740 | |||
741 | BOOL LLToolCompGun::handleScrollWheel(S32 x, S32 y, S32 clicks) | ||
742 | { | ||
743 | if (clicks > 0) | ||
744 | { | ||
745 | gAgent.changeCameraToDefault(); | ||
746 | |||
747 | } | ||
748 | return TRUE; | ||
749 | } | ||