lltoolgrab.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. * @file lltoolgrab.h
  3. * @brief LLToolGrab class header file
  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. #ifndef LL_TOOLGRAB_H
  33. #define LL_TOOLGRAB_H
  34. #include "llquaternion.h"
  35. #include "lluuid.h"
  36. #include "llvector3.h"
  37. #include "lltool.h"
  38. #include "llviewerwindow.h" // For LLPickInfo
  39. class LLView;
  40. class LLTextBox;
  41. class LLViewerObject;
  42. class LLPickInfo;
  43. class LLToolGrabBase : public LLTool
  44. {
  45. protected:
  46. LOG_CLASS(LLToolGrabBase);
  47. public:
  48. LLToolGrabBase(LLToolComposite* composite = NULL);
  49. bool handleHover(S32 x, S32 y, MASK mask) override;
  50. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  51. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  52. bool handleDoubleClick(S32 x, S32 y, MASK mask) override;
  53. LL_INLINE void render() override {} // 3D elements
  54. LL_INLINE void draw() override {} // 2D elements
  55. void handleSelect() override;
  56. void handleDeselect() override;
  57. LLViewerObject* getEditingObject() override;
  58. LLVector3d getEditingPointGlobal() override;
  59. bool isEditing() override;
  60. void stopEditing() override;
  61. void onMouseCaptureLost() override;
  62. // Capture the mouse and start grabbing.
  63. bool handleObjectHit(const LLPickInfo& info);
  64. static void pickCallback(const LLPickInfo& pick_info);
  65. private:
  66. LLVector3d getGrabPointGlobal();
  67. void startGrab();
  68. void stopGrab();
  69. void startSpin();
  70. void stopSpin();
  71. void handleHoverSpin(S32 x, S32 y, MASK mask);
  72. void handleHoverActive(S32 x, S32 y, MASK mask);
  73. void handleHoverNonPhysical(S32 x, S32 y, MASK mask);
  74. void handleHoverInactive(S32 x, S32 y, MASK mask);
  75. void handleHoverFailed(S32 x, S32 y, MASK mask);
  76. private:
  77. enum EGrabMode { GRAB_INACTIVE, GRAB_ACTIVE_CENTER, GRAB_NONPHYSICAL,
  78. GRAB_LOCKED, GRAB_NOOBJECT };
  79. EGrabMode mMode;
  80. // Send simulator time between hover movements
  81. LLTimer mGrabTimer;
  82. // Meters from CG of object
  83. LLVector3 mGrabOffsetFromCenterInitial;
  84. // In cursor hidden drag, how far is grab offset from camera
  85. LLVector3d mGrabHiddenOffsetFromCamera;
  86. LLVector3d mDragStartPointGlobal; // Projected into world
  87. LLVector3d mDragStartFromCamera; // Drag start relative to camera
  88. LLPickInfo mGrabPick;
  89. S32 mLastMouseX;
  90. S32 mLastMouseY;
  91. // Since cursor hidden, how far have you moved ?
  92. S32 mAccumDeltaX;
  93. S32 mAccumDeltaY;
  94. S32 mLastFace;
  95. LLVector2 mLastUVCoords;
  96. LLVector2 mLastSTCoords;
  97. LLVector3 mLastIntersection;
  98. LLVector3 mLastNormal;
  99. LLVector3 mLastBinormal;
  100. LLVector3 mLastGrabPos;
  101. LLQuaternion mSpinRotation;
  102. // Has mouse moved off center at all ?
  103. bool mHasMoved;
  104. // Nas mouse moved outside center 5 pixels ?
  105. bool mOutsideSlop;
  106. bool mVerticalDragging;
  107. bool mSpinGrabbing;
  108. bool mClickedInMouselook;
  109. };
  110. class LLToolGrab final : public LLToolGrabBase
  111. {
  112. protected:
  113. LOG_CLASS(LLToolGrab);
  114. public:
  115. LLToolGrab() = default;
  116. };
  117. extern LLToolGrab gToolGrab;
  118. extern LLTool* gGrabTransientTool;
  119. extern bool gGrabBtnVertical;
  120. extern bool gGrabBtnSpin;
  121. #endif // LL_TOOLGRAB_H