lltool.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /**
  2. * @file lltool.cpp
  3. * @brief LLTool class implementation
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "llviewerprecompiledheaders.h"
  33. #include "lltool.h"
  34. #include "llview.h"
  35. #include "llwindow.h" // For gDebugClicks
  36. #include "llagent.h"
  37. #include "lltoolcomp.h"
  38. #include "lltoolfocus.h"
  39. #include "llviewerjoystick.h"
  40. #include "llviewerwindow.h"
  41. //static
  42. const std::string LLTool::sNameNull("null");
  43. LLTool::LLTool(const std::string& name, LLToolComposite* composite)
  44. : mComposite(composite),
  45. mName(name)
  46. {
  47. }
  48. LLTool::~LLTool()
  49. {
  50. if (hasMouseCapture())
  51. {
  52. llwarns << "Tool deleted holding mouse capture. Mouse capture removed."
  53. << llendl;
  54. gFocusMgr.removeMouseCaptureWithoutCallback(this);
  55. }
  56. }
  57. bool LLTool::handleHover(S32 x, S32 y, MASK mask)
  58. {
  59. gWindowp->setCursor(UI_CURSOR_ARROW);
  60. LL_DEBUGS("UserInput") << "hover handled by a tool" << LL_ENDL;
  61. // by default, do nothing, say we handled it
  62. return true;
  63. }
  64. bool LLTool::handleMouseDown(S32 x, S32 y, MASK mask)
  65. {
  66. if (gDebugClicks)
  67. {
  68. llinfos << "Left mouse down" << llendl;
  69. }
  70. // by default, didn't handle it
  71. gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_DOWN);
  72. return true;
  73. }
  74. bool LLTool::handleMouseUp(S32 x, S32 y, MASK mask)
  75. {
  76. if (gDebugClicks)
  77. {
  78. llinfos << "Left mouse up" << llendl;
  79. }
  80. // by default, didn't handle it
  81. gAgent.setControlFlags(AGENT_CONTROL_LBUTTON_UP);
  82. return true;
  83. }
  84. void LLTool::setMouseCapture(bool b)
  85. {
  86. if (b)
  87. {
  88. gFocusMgr.setMouseCapture(mComposite ? mComposite : this);
  89. }
  90. else if (hasMouseCapture())
  91. {
  92. gFocusMgr.setMouseCapture(NULL);
  93. }
  94. }
  95. LLTool* LLTool::getOverrideTool(MASK mask)
  96. {
  97. // NOTE: if in flycam mode, ALT-ZOOM camera should be disabled
  98. if (LLViewerJoystick::getInstance()->getOverrideCamera())
  99. {
  100. return NULL;
  101. }
  102. if (mask & MASK_ALT)
  103. {
  104. return &gToolFocus;
  105. }
  106. return NULL;
  107. }