PageRenderTime 1410ms CodeModel.GetById 8ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lltoolcomp.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 786 lines | 565 code | 132 blank | 89 comment | 84 complexity | 48eb4e8dc3a7e70278f7e9746705443c MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltoolcomp.cpp
  3. * @brief Composite tools
  4. *
  5. * $LicenseInfo:firstyear=2001&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. #include "llviewerprecompiledheaders.h"
  27. #include "lltoolcomp.h"
  28. #include "llfloaterreg.h"
  29. #include "llgl.h"
  30. #include "indra_constants.h"
  31. #include "llmanip.h"
  32. #include "llmaniprotate.h"
  33. #include "llmanipscale.h"
  34. #include "llmaniptranslate.h"
  35. #include "llmenugl.h" // for right-click menu hack
  36. #include "llselectmgr.h"
  37. #include "lltoolfocus.h"
  38. #include "lltoolgrab.h"
  39. #include "lltoolgun.h"
  40. #include "lltoolmgr.h"
  41. #include "lltoolselectrect.h"
  42. #include "lltoolplacer.h"
  43. #include "llviewermenu.h"
  44. #include "llviewerobject.h"
  45. #include "llviewerwindow.h"
  46. #include "llagent.h"
  47. #include "llagentcamera.h"
  48. #include "llfloatertools.h"
  49. #include "llviewercontrol.h"
  50. const S32 BUTTON_HEIGHT = 16;
  51. const S32 BUTTON_WIDTH_SMALL = 32;
  52. const S32 BUTTON_WIDTH_BIG = 48;
  53. const S32 HPAD = 4;
  54. extern LLControlGroup gSavedSettings;
  55. // we use this in various places instead of NULL
  56. static LLTool* sNullTool = new LLTool(std::string("null"), NULL);
  57. //-----------------------------------------------------------------------
  58. // LLToolComposite
  59. //static
  60. void LLToolComposite::setCurrentTool( LLTool* new_tool )
  61. {
  62. if( mCur != new_tool )
  63. {
  64. if( mSelected )
  65. {
  66. mCur->handleDeselect();
  67. mCur = new_tool;
  68. mCur->handleSelect();
  69. }
  70. else
  71. {
  72. mCur = new_tool;
  73. }
  74. }
  75. }
  76. LLToolComposite::LLToolComposite(const std::string& name)
  77. : LLTool(name),
  78. mCur(sNullTool),
  79. mDefault(sNullTool),
  80. mSelected(FALSE),
  81. mMouseDown(FALSE), mManip(NULL), mSelectRect(NULL)
  82. {
  83. }
  84. // Returns to the default tool
  85. BOOL LLToolComposite::handleMouseUp(S32 x, S32 y, MASK mask)
  86. {
  87. BOOL handled = mCur->handleMouseUp( x, y, mask );
  88. if( handled )
  89. {
  90. setCurrentTool( mDefault );
  91. }
  92. return handled;
  93. }
  94. void LLToolComposite::onMouseCaptureLost()
  95. {
  96. mCur->onMouseCaptureLost();
  97. setCurrentTool( mDefault );
  98. }
  99. BOOL LLToolComposite::isSelecting()
  100. {
  101. return mCur == mSelectRect;
  102. }
  103. void LLToolComposite::handleSelect()
  104. {
  105. if (!gSavedSettings.getBOOL("EditLinkedParts"))
  106. {
  107. LLSelectMgr::getInstance()->promoteSelectionToRoot();
  108. }
  109. mCur = mDefault;
  110. mCur->handleSelect();
  111. mSelected = TRUE;
  112. }
  113. //----------------------------------------------------------------------------
  114. // LLToolCompInspect
  115. //----------------------------------------------------------------------------
  116. LLToolCompInspect::LLToolCompInspect()
  117. : LLToolComposite(std::string("Inspect"))
  118. {
  119. mSelectRect = new LLToolSelectRect(this);
  120. mDefault = mSelectRect;
  121. }
  122. LLToolCompInspect::~LLToolCompInspect()
  123. {
  124. delete mSelectRect;
  125. mSelectRect = NULL;
  126. }
  127. BOOL LLToolCompInspect::handleMouseDown(S32 x, S32 y, MASK mask)
  128. {
  129. mMouseDown = TRUE;
  130. gViewerWindow->pickAsync(x, y, mask, pickCallback);
  131. return TRUE;
  132. }
  133. void LLToolCompInspect::pickCallback(const LLPickInfo& pick_info)
  134. {
  135. LLViewerObject* hit_obj = pick_info.getObject();
  136. if (!LLToolCompInspect::getInstance()->mMouseDown)
  137. {
  138. // fast click on object, but mouse is already up...just do select
  139. LLToolCompInspect::getInstance()->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
  140. return;
  141. }
  142. if( hit_obj )
  143. {
  144. if (LLSelectMgr::getInstance()->getSelection()->getObjectCount())
  145. {
  146. LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
  147. }
  148. LLToolCompInspect::getInstance()->setCurrentTool( LLToolCompInspect::getInstance()->mSelectRect );
  149. LLToolCompInspect::getInstance()->mSelectRect->handlePick( pick_info );
  150. }
  151. else
  152. {
  153. LLToolCompInspect::getInstance()->setCurrentTool( LLToolCompInspect::getInstance()->mSelectRect );
  154. LLToolCompInspect::getInstance()->mSelectRect->handlePick( pick_info );
  155. }
  156. }
  157. BOOL LLToolCompInspect::handleDoubleClick(S32 x, S32 y, MASK mask)
  158. {
  159. return TRUE;
  160. }
  161. //----------------------------------------------------------------------------
  162. // LLToolCompTranslate
  163. //----------------------------------------------------------------------------
  164. LLToolCompTranslate::LLToolCompTranslate()
  165. : LLToolComposite(std::string("Move"))
  166. {
  167. mManip = new LLManipTranslate(this);
  168. mSelectRect = new LLToolSelectRect(this);
  169. mCur = mManip;
  170. mDefault = mManip;
  171. }
  172. LLToolCompTranslate::~LLToolCompTranslate()
  173. {
  174. delete mManip;
  175. mManip = NULL;
  176. delete mSelectRect;
  177. mSelectRect = NULL;
  178. }
  179. BOOL LLToolCompTranslate::handleHover(S32 x, S32 y, MASK mask)
  180. {
  181. if( !mCur->hasMouseCapture() )
  182. {
  183. setCurrentTool( mManip );
  184. }
  185. return mCur->handleHover( x, y, mask );
  186. }
  187. BOOL LLToolCompTranslate::handleMouseDown(S32 x, S32 y, MASK mask)
  188. {
  189. mMouseDown = TRUE;
  190. gViewerWindow->pickAsync(x, y, mask, pickCallback, TRUE);
  191. return TRUE;
  192. }
  193. void LLToolCompTranslate::pickCallback(const LLPickInfo& pick_info)
  194. {
  195. LLViewerObject* hit_obj = pick_info.getObject();
  196. LLToolCompTranslate::getInstance()->mManip->highlightManipulators(pick_info.mMousePt.mX, pick_info.mMousePt.mY);
  197. if (!LLToolCompTranslate::getInstance()->mMouseDown)
  198. {
  199. // fast click on object, but mouse is already up...just do select
  200. LLToolCompTranslate::getInstance()->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
  201. return;
  202. }
  203. if( hit_obj || LLToolCompTranslate::getInstance()->mManip->getHighlightedPart() != LLManip::LL_NO_PART )
  204. {
  205. if (LLToolCompTranslate::getInstance()->mManip->getSelection()->getObjectCount())
  206. {
  207. LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
  208. }
  209. BOOL can_move = LLToolCompTranslate::getInstance()->mManip->canAffectSelection();
  210. if( LLManip::LL_NO_PART != LLToolCompTranslate::getInstance()->mManip->getHighlightedPart() && can_move)
  211. {
  212. LLToolCompTranslate::getInstance()->setCurrentTool( LLToolCompTranslate::getInstance()->mManip );
  213. LLToolCompTranslate::getInstance()->mManip->handleMouseDownOnPart( pick_info.mMousePt.mX, pick_info.mMousePt.mY, pick_info.mKeyMask );
  214. }
  215. else
  216. {
  217. LLToolCompTranslate::getInstance()->setCurrentTool( LLToolCompTranslate::getInstance()->mSelectRect );
  218. LLToolCompTranslate::getInstance()->mSelectRect->handlePick( pick_info );
  219. // *TODO: add toggle to trigger old click-drag functionality
  220. // LLToolCompTranslate::getInstance()->mManip->handleMouseDownOnPart( XY_part, x, y, mask);
  221. }
  222. }
  223. else
  224. {
  225. LLToolCompTranslate::getInstance()->setCurrentTool( LLToolCompTranslate::getInstance()->mSelectRect );
  226. LLToolCompTranslate::getInstance()->mSelectRect->handlePick( pick_info );
  227. }
  228. }
  229. BOOL LLToolCompTranslate::handleMouseUp(S32 x, S32 y, MASK mask)
  230. {
  231. mMouseDown = FALSE;
  232. return LLToolComposite::handleMouseUp(x, y, mask);
  233. }
  234. LLTool* LLToolCompTranslate::getOverrideTool(MASK mask)
  235. {
  236. if (mask == MASK_CONTROL)
  237. {
  238. return LLToolCompRotate::getInstance();
  239. }
  240. else if (mask == (MASK_CONTROL | MASK_SHIFT))
  241. {
  242. return LLToolCompScale::getInstance();
  243. }
  244. return LLToolComposite::getOverrideTool(mask);
  245. }
  246. BOOL LLToolCompTranslate::handleDoubleClick(S32 x, S32 y, MASK mask)
  247. {
  248. if (mManip->getSelection()->isEmpty() && mManip->getHighlightedPart() == LLManip::LL_NO_PART)
  249. {
  250. // You should already have an object selected from the mousedown.
  251. // If so, show its properties
  252. LLFloaterReg::showInstance("build", "Content");
  253. return TRUE;
  254. }
  255. // Nothing selected means the first mouse click was probably
  256. // bad, so try again.
  257. return FALSE;
  258. }
  259. void LLToolCompTranslate::render()
  260. {
  261. mCur->render(); // removing this will not draw the RGB arrows and guidelines
  262. if( mCur != mManip )
  263. {
  264. LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
  265. mManip->renderGuidelines();
  266. }
  267. }
  268. //-----------------------------------------------------------------------
  269. // LLToolCompScale
  270. LLToolCompScale::LLToolCompScale()
  271. : LLToolComposite(std::string("Stretch"))
  272. {
  273. mManip = new LLManipScale(this);
  274. mSelectRect = new LLToolSelectRect(this);
  275. mCur = mManip;
  276. mDefault = mManip;
  277. }
  278. LLToolCompScale::~LLToolCompScale()
  279. {
  280. delete mManip;
  281. delete mSelectRect;
  282. }
  283. BOOL LLToolCompScale::handleHover(S32 x, S32 y, MASK mask)
  284. {
  285. if( !mCur->hasMouseCapture() )
  286. {
  287. setCurrentTool(mManip );
  288. }
  289. return mCur->handleHover( x, y, mask );
  290. }
  291. BOOL LLToolCompScale::handleMouseDown(S32 x, S32 y, MASK mask)
  292. {
  293. mMouseDown = TRUE;
  294. gViewerWindow->pickAsync(x, y, mask, pickCallback);
  295. return TRUE;
  296. }
  297. void LLToolCompScale::pickCallback(const LLPickInfo& pick_info)
  298. {
  299. LLViewerObject* hit_obj = pick_info.getObject();
  300. LLToolCompScale::getInstance()->mManip->highlightManipulators(pick_info.mMousePt.mX, pick_info.mMousePt.mY);
  301. if (!LLToolCompScale::getInstance()->mMouseDown)
  302. {
  303. // fast click on object, but mouse is already up...just do select
  304. LLToolCompScale::getInstance()->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
  305. return;
  306. }
  307. if( hit_obj || LLToolCompScale::getInstance()->mManip->getHighlightedPart() != LLManip::LL_NO_PART)
  308. {
  309. if (LLToolCompScale::getInstance()->mManip->getSelection()->getObjectCount())
  310. {
  311. LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
  312. }
  313. if( LLManip::LL_NO_PART != LLToolCompScale::getInstance()->mManip->getHighlightedPart() )
  314. {
  315. LLToolCompScale::getInstance()->setCurrentTool( LLToolCompScale::getInstance()->mManip );
  316. LLToolCompScale::getInstance()->mManip->handleMouseDownOnPart( pick_info.mMousePt.mX, pick_info.mMousePt.mY, pick_info.mKeyMask );
  317. }
  318. else
  319. {
  320. LLToolCompScale::getInstance()->setCurrentTool( LLToolCompScale::getInstance()->mSelectRect );
  321. LLToolCompScale::getInstance()->mSelectRect->handlePick( pick_info );
  322. }
  323. }
  324. else
  325. {
  326. LLToolCompScale::getInstance()->setCurrentTool( LLToolCompScale::getInstance()->mSelectRect );
  327. LLToolCompScale::getInstance()->mSelectRect->handlePick( pick_info );
  328. }
  329. }
  330. BOOL LLToolCompScale::handleMouseUp(S32 x, S32 y, MASK mask)
  331. {
  332. mMouseDown = FALSE;
  333. return LLToolComposite::handleMouseUp(x, y, mask);
  334. }
  335. LLTool* LLToolCompScale::getOverrideTool(MASK mask)
  336. {
  337. if (mask == MASK_CONTROL)
  338. {
  339. return LLToolCompRotate::getInstance();
  340. }
  341. return LLToolComposite::getOverrideTool(mask);
  342. }
  343. BOOL LLToolCompScale::handleDoubleClick(S32 x, S32 y, MASK mask)
  344. {
  345. if (!mManip->getSelection()->isEmpty() && mManip->getHighlightedPart() == LLManip::LL_NO_PART)
  346. {
  347. // You should already have an object selected from the mousedown.
  348. // If so, show its properties
  349. LLFloaterReg::showInstance("build", "Content");
  350. return TRUE;
  351. }
  352. else
  353. {
  354. // Nothing selected means the first mouse click was probably
  355. // bad, so try again.
  356. return handleMouseDown(x, y, mask);
  357. }
  358. }
  359. void LLToolCompScale::render()
  360. {
  361. mCur->render();
  362. if( mCur != mManip )
  363. {
  364. LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
  365. mManip->renderGuidelines();
  366. }
  367. }
  368. //-----------------------------------------------------------------------
  369. // LLToolCompCreate
  370. LLToolCompCreate::LLToolCompCreate()
  371. : LLToolComposite(std::string("Create"))
  372. {
  373. mPlacer = new LLToolPlacer();
  374. mSelectRect = new LLToolSelectRect(this);
  375. mCur = mPlacer;
  376. mDefault = mPlacer;
  377. mObjectPlacedOnMouseDown = FALSE;
  378. }
  379. LLToolCompCreate::~LLToolCompCreate()
  380. {
  381. delete mPlacer;
  382. delete mSelectRect;
  383. }
  384. BOOL LLToolCompCreate::handleMouseDown(S32 x, S32 y, MASK mask)
  385. {
  386. BOOL handled = FALSE;
  387. mMouseDown = TRUE;
  388. if ( (mask == MASK_SHIFT) || (mask == MASK_CONTROL) )
  389. {
  390. gViewerWindow->pickAsync(x, y, mask, pickCallback);
  391. handled = TRUE;
  392. }
  393. else
  394. {
  395. setCurrentTool( mPlacer );
  396. handled = mPlacer->placeObject( x, y, mask );
  397. }
  398. mObjectPlacedOnMouseDown = TRUE;
  399. return TRUE;
  400. }
  401. void LLToolCompCreate::pickCallback(const LLPickInfo& pick_info)
  402. {
  403. // *NOTE: We mask off shift and control, so you cannot
  404. // multi-select multiple objects with the create tool.
  405. MASK mask = (pick_info.mKeyMask & ~MASK_SHIFT);
  406. mask = (mask & ~MASK_CONTROL);
  407. LLToolCompCreate::getInstance()->setCurrentTool( LLToolCompCreate::getInstance()->mSelectRect );
  408. LLToolCompCreate::getInstance()->mSelectRect->handlePick( pick_info );
  409. }
  410. BOOL LLToolCompCreate::handleDoubleClick(S32 x, S32 y, MASK mask)
  411. {
  412. return handleMouseDown(x, y, mask);
  413. }
  414. BOOL LLToolCompCreate::handleMouseUp(S32 x, S32 y, MASK mask)
  415. {
  416. BOOL handled = FALSE;
  417. if ( mMouseDown && !mObjectPlacedOnMouseDown && !(mask == MASK_SHIFT) && !(mask == MASK_CONTROL) )
  418. {
  419. setCurrentTool( mPlacer );
  420. handled = mPlacer->placeObject( x, y, mask );
  421. }
  422. mObjectPlacedOnMouseDown = FALSE;
  423. mMouseDown = FALSE;
  424. if (!handled)
  425. {
  426. handled = LLToolComposite::handleMouseUp(x, y, mask);
  427. }
  428. return handled;
  429. }
  430. //-----------------------------------------------------------------------
  431. // LLToolCompRotate
  432. LLToolCompRotate::LLToolCompRotate()
  433. : LLToolComposite(std::string("Rotate"))
  434. {
  435. mManip = new LLManipRotate(this);
  436. mSelectRect = new LLToolSelectRect(this);
  437. mCur = mManip;
  438. mDefault = mManip;
  439. }
  440. LLToolCompRotate::~LLToolCompRotate()
  441. {
  442. delete mManip;
  443. delete mSelectRect;
  444. }
  445. BOOL LLToolCompRotate::handleHover(S32 x, S32 y, MASK mask)
  446. {
  447. if( !mCur->hasMouseCapture() )
  448. {
  449. setCurrentTool( mManip );
  450. }
  451. return mCur->handleHover( x, y, mask );
  452. }
  453. BOOL LLToolCompRotate::handleMouseDown(S32 x, S32 y, MASK mask)
  454. {
  455. mMouseDown = TRUE;
  456. gViewerWindow->pickAsync(x, y, mask, pickCallback);
  457. return TRUE;
  458. }
  459. void LLToolCompRotate::pickCallback(const LLPickInfo& pick_info)
  460. {
  461. LLViewerObject* hit_obj = pick_info.getObject();
  462. LLToolCompRotate::getInstance()->mManip->highlightManipulators(pick_info.mMousePt.mX, pick_info.mMousePt.mY);
  463. if (!LLToolCompRotate::getInstance()->mMouseDown)
  464. {
  465. // fast click on object, but mouse is already up...just do select
  466. LLToolCompRotate::getInstance()->mSelectRect->handleObjectSelection(pick_info, gSavedSettings.getBOOL("EditLinkedParts"), FALSE);
  467. return;
  468. }
  469. if( hit_obj || LLToolCompRotate::getInstance()->mManip->getHighlightedPart() != LLManip::LL_NO_PART)
  470. {
  471. if (LLToolCompRotate::getInstance()->mManip->getSelection()->getObjectCount())
  472. {
  473. LLEditMenuHandler::gEditMenuHandler = LLSelectMgr::getInstance();
  474. }
  475. if( LLManip::LL_NO_PART != LLToolCompRotate::getInstance()->mManip->getHighlightedPart() )
  476. {
  477. LLToolCompRotate::getInstance()->setCurrentTool( LLToolCompRotate::getInstance()->mManip );
  478. LLToolCompRotate::getInstance()->mManip->handleMouseDownOnPart( pick_info.mMousePt.mX, pick_info.mMousePt.mY, pick_info.mKeyMask );
  479. }
  480. else
  481. {
  482. LLToolCompRotate::getInstance()->setCurrentTool( LLToolCompRotate::getInstance()->mSelectRect );
  483. LLToolCompRotate::getInstance()->mSelectRect->handlePick( pick_info );
  484. }
  485. }
  486. else
  487. {
  488. LLToolCompRotate::getInstance()->setCurrentTool( LLToolCompRotate::getInstance()->mSelectRect );
  489. LLToolCompRotate::getInstance()->mSelectRect->handlePick( pick_info );
  490. }
  491. }
  492. BOOL LLToolCompRotate::handleMouseUp(S32 x, S32 y, MASK mask)
  493. {
  494. mMouseDown = FALSE;
  495. return LLToolComposite::handleMouseUp(x, y, mask);
  496. }
  497. LLTool* LLToolCompRotate::getOverrideTool(MASK mask)
  498. {
  499. if (mask == (MASK_CONTROL | MASK_SHIFT))
  500. {
  501. return LLToolCompScale::getInstance();
  502. }
  503. return LLToolComposite::getOverrideTool(mask);
  504. }
  505. BOOL LLToolCompRotate::handleDoubleClick(S32 x, S32 y, MASK mask)
  506. {
  507. if (!mManip->getSelection()->isEmpty() && mManip->getHighlightedPart() == LLManip::LL_NO_PART)
  508. {
  509. // You should already have an object selected from the mousedown.
  510. // If so, show its properties
  511. LLFloaterReg::showInstance("build", "Content");
  512. return TRUE;
  513. }
  514. else
  515. {
  516. // Nothing selected means the first mouse click was probably
  517. // bad, so try again.
  518. return handleMouseDown(x, y, mask);
  519. }
  520. }
  521. void LLToolCompRotate::render()
  522. {
  523. mCur->render();
  524. if( mCur != mManip )
  525. {
  526. LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
  527. mManip->renderGuidelines();
  528. }
  529. }
  530. //-----------------------------------------------------------------------
  531. // LLToolCompGun
  532. LLToolCompGun::LLToolCompGun()
  533. : LLToolComposite(std::string("Mouselook"))
  534. {
  535. mGun = new LLToolGun(this);
  536. mGrab = new LLToolGrab(this);
  537. mNull = sNullTool;
  538. setCurrentTool(mGun);
  539. mDefault = mGun;
  540. }
  541. LLToolCompGun::~LLToolCompGun()
  542. {
  543. delete mGun;
  544. mGun = NULL;
  545. delete mGrab;
  546. mGrab = NULL;
  547. // don't delete a static object
  548. // delete mNull;
  549. mNull = NULL;
  550. }
  551. BOOL LLToolCompGun::handleHover(S32 x, S32 y, MASK mask)
  552. {
  553. // *NOTE: This hack is here to make mouselook kick in again after
  554. // item selected from context menu.
  555. if ( mCur == mNull && !gPopupMenuView->getVisible() )
  556. {
  557. LLSelectMgr::getInstance()->deselectAll();
  558. setCurrentTool( (LLTool*) mGrab );
  559. }
  560. // Note: if the tool changed, we can't delegate the current mouse event
  561. // after the change because tools can modify the mouse during selection and deselection.
  562. // Instead we let the current tool handle the event and then make the change.
  563. // The new tool will take effect on the next frame.
  564. mCur->handleHover( x, y, mask );
  565. // If mouse button not down...
  566. if( !gViewerWindow->getLeftMouseDown())
  567. {
  568. // let ALT switch from gun to grab
  569. if ( mCur == mGun && (mask & MASK_ALT) )
  570. {
  571. setCurrentTool( (LLTool*) mGrab );
  572. }
  573. else if ( mCur == mGrab && !(mask & MASK_ALT) )
  574. {
  575. setCurrentTool( (LLTool*) mGun );
  576. setMouseCapture(TRUE);
  577. }
  578. }
  579. return TRUE;
  580. }
  581. BOOL LLToolCompGun::handleMouseDown(S32 x, S32 y, MASK mask)
  582. {
  583. // if the left button is grabbed, don't put up the pie menu
  584. if (gAgent.leftButtonGrabbed())
  585. {
  586. gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN);
  587. return FALSE;
  588. }
  589. // On mousedown, start grabbing
  590. gGrabTransientTool = this;
  591. LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool*) mGrab );
  592. return LLToolGrab::getInstance()->handleMouseDown(x, y, mask);
  593. }
  594. BOOL LLToolCompGun::handleDoubleClick(S32 x, S32 y, MASK mask)
  595. {
  596. // if the left button is grabbed, don't put up the pie menu
  597. if (gAgent.leftButtonGrabbed())
  598. {
  599. gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_DOWN);
  600. return FALSE;
  601. }
  602. // On mousedown, start grabbing
  603. gGrabTransientTool = this;
  604. LLToolMgr::getInstance()->getCurrentToolset()->selectTool( (LLTool*) mGrab );
  605. return LLToolGrab::getInstance()->handleDoubleClick(x, y, mask);
  606. }
  607. BOOL LLToolCompGun::handleRightMouseDown(S32 x, S32 y, MASK mask)
  608. {
  609. /* JC - suppress context menu 8/29/2002
  610. // On right mouse, go through some convoluted steps to
  611. // make the build menu appear.
  612. setCurrentTool( (LLTool*) mNull );
  613. // This should return FALSE, meaning the context menu will
  614. // be shown.
  615. return FALSE;
  616. */
  617. // Returning true will suppress the context menu
  618. return TRUE;
  619. }
  620. BOOL LLToolCompGun::handleMouseUp(S32 x, S32 y, MASK mask)
  621. {
  622. gAgent.setControlFlags(AGENT_CONTROL_ML_LBUTTON_UP);
  623. setCurrentTool( (LLTool*) mGun );
  624. return TRUE;
  625. }
  626. void LLToolCompGun::onMouseCaptureLost()
  627. {
  628. if (mComposite)
  629. {
  630. mComposite->onMouseCaptureLost();
  631. return;
  632. }
  633. mCur->onMouseCaptureLost();
  634. }
  635. void LLToolCompGun::handleSelect()
  636. {
  637. LLToolComposite::handleSelect();
  638. setMouseCapture(TRUE);
  639. }
  640. void LLToolCompGun::handleDeselect()
  641. {
  642. LLToolComposite::handleDeselect();
  643. setMouseCapture(FALSE);
  644. }
  645. BOOL LLToolCompGun::handleScrollWheel(S32 x, S32 y, S32 clicks)
  646. {
  647. if (clicks > 0)
  648. {
  649. gAgentCamera.changeCameraToDefault();
  650. }
  651. return TRUE;
  652. }