PageRenderTime 838ms CodeModel.GetById 47ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lltoolcomp.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 235 lines | 135 code | 53 blank | 47 comment | 0 complexity | 54b53e81c05cfa1c29534de76b41954c MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltoolcomp.h
  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. #ifndef LL_TOOLCOMP_H
  27. #define LL_TOOLCOMP_H
  28. #include "lltool.h"
  29. class LLManip;
  30. class LLToolSelectRect;
  31. class LLToolPlacer;
  32. class LLPickInfo;
  33. class LLView;
  34. class LLTextBox;
  35. //-----------------------------------------------------------------------
  36. // LLToolComposite
  37. class LLToolComposite : public LLTool
  38. {
  39. public:
  40. LLToolComposite(const std::string& name);
  41. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask) = 0; // Sets the current tool
  42. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); // Returns to the default tool
  43. virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask) = 0;
  44. // Map virtual functions to the currently active internal tool
  45. virtual BOOL handleHover(S32 x, S32 y, MASK mask) { return mCur->handleHover( x, y, mask ); }
  46. virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks) { return mCur->handleScrollWheel( x, y, clicks ); }
  47. virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask) { return mCur->handleRightMouseDown( x, y, mask ); }
  48. virtual LLViewerObject* getEditingObject() { return mCur->getEditingObject(); }
  49. virtual LLVector3d getEditingPointGlobal() { return mCur->getEditingPointGlobal(); }
  50. virtual BOOL isEditing() { return mCur->isEditing(); }
  51. virtual void stopEditing() { mCur->stopEditing(); mCur = mDefault; }
  52. virtual BOOL clipMouseWhenDown() { return mCur->clipMouseWhenDown(); }
  53. virtual void handleSelect();
  54. virtual void handleDeselect() { mCur->handleDeselect(); mCur = mDefault; mSelected = FALSE; }
  55. virtual void render() { mCur->render(); }
  56. virtual void draw() { mCur->draw(); }
  57. virtual BOOL handleKey(KEY key, MASK mask) { return mCur->handleKey( key, mask ); }
  58. virtual void onMouseCaptureLost();
  59. virtual void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const
  60. { mCur->screenPointToLocal(screen_x, screen_y, local_x, local_y); }
  61. virtual void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const
  62. { mCur->localPointToScreen(local_x, local_y, screen_x, screen_y); }
  63. BOOL isSelecting();
  64. protected:
  65. void setCurrentTool( LLTool* new_tool );
  66. LLTool* getCurrentTool() { return mCur; }
  67. // In hover handler, call this to auto-switch tools
  68. void setToolFromMask( MASK mask, LLTool *normal );
  69. protected:
  70. LLTool* mCur; // The tool to which we're delegating.
  71. LLTool* mDefault;
  72. BOOL mSelected;
  73. BOOL mMouseDown;
  74. LLManip* mManip;
  75. LLToolSelectRect* mSelectRect;
  76. public:
  77. static const std::string sNameComp;
  78. };
  79. //-----------------------------------------------------------------------
  80. // LLToolCompTranslate
  81. class LLToolCompInspect : public LLToolComposite, public LLSingleton<LLToolCompInspect>
  82. {
  83. public:
  84. LLToolCompInspect();
  85. virtual ~LLToolCompInspect();
  86. // Overridden from LLToolComposite
  87. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  88. virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  89. static void pickCallback(const LLPickInfo& pick_info);
  90. };
  91. //-----------------------------------------------------------------------
  92. // LLToolCompTranslate
  93. class LLToolCompTranslate : public LLToolComposite, public LLSingleton<LLToolCompTranslate>
  94. {
  95. public:
  96. LLToolCompTranslate();
  97. virtual ~LLToolCompTranslate();
  98. // Overridden from LLToolComposite
  99. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  100. virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  101. virtual BOOL handleHover(S32 x, S32 y, MASK mask);
  102. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); // Returns to the default tool
  103. virtual void render();
  104. virtual LLTool* getOverrideTool(MASK mask);
  105. static void pickCallback(const LLPickInfo& pick_info);
  106. };
  107. //-----------------------------------------------------------------------
  108. // LLToolCompScale
  109. class LLToolCompScale : public LLToolComposite, public LLSingleton<LLToolCompScale>
  110. {
  111. public:
  112. LLToolCompScale();
  113. virtual ~LLToolCompScale();
  114. // Overridden from LLToolComposite
  115. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  116. virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  117. virtual BOOL handleHover(S32 x, S32 y, MASK mask);
  118. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask); // Returns to the default tool
  119. virtual void render();
  120. virtual LLTool* getOverrideTool(MASK mask);
  121. static void pickCallback(const LLPickInfo& pick_info);
  122. };
  123. //-----------------------------------------------------------------------
  124. // LLToolCompRotate
  125. class LLToolCompRotate : public LLToolComposite, public LLSingleton<LLToolCompRotate>
  126. {
  127. public:
  128. LLToolCompRotate();
  129. virtual ~LLToolCompRotate();
  130. // Overridden from LLToolComposite
  131. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  132. virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  133. virtual BOOL handleHover(S32 x, S32 y, MASK mask);
  134. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  135. virtual void render();
  136. virtual LLTool* getOverrideTool(MASK mask);
  137. static void pickCallback(const LLPickInfo& pick_info);
  138. protected:
  139. };
  140. //-----------------------------------------------------------------------
  141. // LLToolCompCreate
  142. class LLToolCompCreate : public LLToolComposite, public LLSingleton<LLToolCompCreate>
  143. {
  144. public:
  145. LLToolCompCreate();
  146. virtual ~LLToolCompCreate();
  147. // Overridden from LLToolComposite
  148. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  149. virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  150. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  151. static void pickCallback(const LLPickInfo& pick_info);
  152. protected:
  153. LLToolPlacer* mPlacer;
  154. BOOL mObjectPlacedOnMouseDown;
  155. };
  156. //-----------------------------------------------------------------------
  157. // LLToolCompGun
  158. class LLToolGun;
  159. class LLToolGrab;
  160. class LLToolSelect;
  161. class LLToolCompGun : public LLToolComposite, public LLSingleton<LLToolCompGun>
  162. {
  163. public:
  164. LLToolCompGun();
  165. virtual ~LLToolCompGun();
  166. // Overridden from LLToolComposite
  167. virtual BOOL handleHover(S32 x, S32 y, MASK mask);
  168. virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask);
  169. virtual BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  170. virtual BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
  171. virtual BOOL handleMouseUp(S32 x, S32 y, MASK mask);
  172. virtual BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
  173. virtual void onMouseCaptureLost();
  174. virtual void handleSelect();
  175. virtual void handleDeselect();
  176. virtual LLTool* getOverrideTool(MASK mask) { return NULL; }
  177. protected:
  178. LLToolGun* mGun;
  179. LLToolGrab* mGrab;
  180. LLTool* mNull;
  181. };
  182. #endif // LL_TOOLCOMP_H