PageRenderTime 52ms CodeModel.GetById 11ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. // This is a tool for selecting individual object from the
  29. // toolbox. Handy for when you want to deal with child object
  30. // inventory...
  31. //
  32. //*****************************************************************************
  33. #include "llviewerprecompiledheaders.h"
  34. #include "lltoolindividual.h"
  35. #include "llfloaterreg.h"
  36. #include "llselectmgr.h"
  37. #include "llviewerobject.h"
  38. #include "llviewerwindow.h"
  39. #include "llfloatertools.h"
  40. ///----------------------------------------------------------------------------
  41. /// Globals
  42. ///----------------------------------------------------------------------------
  43. ///----------------------------------------------------------------------------
  44. /// Local function declarations, constants, enums, and typedefs
  45. ///----------------------------------------------------------------------------
  46. ///----------------------------------------------------------------------------
  47. /// Class LLToolIndividual
  48. ///----------------------------------------------------------------------------
  49. // Default constructor
  50. LLToolIndividual::LLToolIndividual()
  51. : LLTool(std::string("Individual"))
  52. {
  53. }
  54. // Destroys the object
  55. LLToolIndividual::~LLToolIndividual()
  56. {
  57. }
  58. BOOL LLToolIndividual::handleMouseDown(S32 x, S32 y, MASK mask)
  59. {
  60. gViewerWindow->pickAsync(x, y, mask, pickCallback);
  61. return TRUE;
  62. }
  63. void LLToolIndividual::pickCallback(const LLPickInfo& pick_info)
  64. {
  65. LLViewerObject* obj = pick_info.getObject();
  66. LLSelectMgr::getInstance()->deselectAll();
  67. if(obj)
  68. {
  69. LLSelectMgr::getInstance()->selectObjectOnly(obj);
  70. }
  71. }
  72. BOOL LLToolIndividual::handleDoubleClick(S32 x, S32 y, MASK mask)
  73. {
  74. if(!LLSelectMgr::getInstance()->getSelection()->isEmpty())
  75. {
  76. // You should already have an object selected from the mousedown.
  77. // If so, show its inventory.
  78. LLFloaterReg::showInstance("build", "Content");
  79. return TRUE;
  80. }
  81. else
  82. {
  83. // Nothing selected means the first mouse click was probably
  84. // bad, so try again.
  85. return FALSE;
  86. }
  87. }
  88. void LLToolIndividual::handleSelect()
  89. {
  90. const BOOL children_ok = TRUE;
  91. LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getFirstRootObject(children_ok);
  92. LLSelectMgr::getInstance()->deselectAll();
  93. if(obj)
  94. {
  95. LLSelectMgr::getInstance()->selectObjectOnly(obj);
  96. }
  97. }
  98. ///----------------------------------------------------------------------------
  99. /// Local function definitions
  100. ///----------------------------------------------------------------------------