lltoolmgr.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /**
  2. * @file lltoolmgr.h
  3. * @brief LLToolMgr 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_TOOLMGR_H
  33. #define LL_TOOLMGR_H
  34. #include "llkeyboard.h"
  35. class LLTool;
  36. class LLToolset;
  37. // Key bindings for common operations
  38. const MASK MASK_VERTICAL = MASK_CONTROL;
  39. const MASK MASK_SPIN = MASK_CONTROL | MASK_SHIFT;
  40. const MASK MASK_ZOOM = MASK_NONE;
  41. const MASK MASK_ORBIT = MASK_CONTROL;
  42. const MASK MASK_PAN = MASK_CONTROL | MASK_SHIFT;
  43. const MASK MASK_COPY = MASK_SHIFT;
  44. class LLToolMgr
  45. {
  46. protected:
  47. LOG_CLASS(LLToolMgr);
  48. public:
  49. LLToolMgr();
  50. ~LLToolMgr();
  51. // Must be called after gSavedSettings set up.
  52. void initTools();
  53. // Returns active tool, taking into account keyboard state
  54. LLTool* getCurrentTool();
  55. LL_INLINE bool isCurrentTool(LLTool* tool)
  56. {
  57. return tool == getCurrentTool();
  58. }
  59. // Returns active tool when overrides are deactivated
  60. LL_INLINE LLTool* getBaseTool() { return mBaseTool; }
  61. bool inEdit();
  62. void toggleBuildMode();
  63. // Determines if we are in Build mode or not
  64. bool inBuildMode();
  65. void setTransientTool(LLTool* tool);
  66. void clearTransientTool();
  67. LL_INLINE bool usingTransientTool() { return mTransientTool != NULL; }
  68. void setCurrentToolset(LLToolset* current);
  69. LL_INLINE LLToolset* getCurrentToolset() { return mCurrentToolset; }
  70. void onAppFocusGained();
  71. void onAppFocusLost();
  72. LL_INLINE void clearSavedTool() { mSavedTool = NULL; }
  73. protected:
  74. friend class LLToolset; // To allow access to setCurrentTool();
  75. void setCurrentTool(LLTool* tool);
  76. // Calls getcurrenttool() to calculate active tool and call handleSelect()
  77. // and handleDeselect() immediately when active tool changes
  78. LL_INLINE void updateToolStatus() { getCurrentTool(); }
  79. protected:
  80. LLTool* mBaseTool;
  81. // The current tool at the time application focus was lost:
  82. LLTool* mSavedTool;
  83. LLTool* mTransientTool;
  84. LLTool* mOverrideTool; // Tool triggered by keyboard override
  85. LLTool* mSelectedTool; // Last known active tool
  86. LLToolset* mCurrentToolset;
  87. };
  88. // Sets of tools for various modes
  89. class LLToolset
  90. {
  91. public:
  92. LL_INLINE LLToolset()
  93. : mSelectedTool(NULL)
  94. {
  95. }
  96. LL_INLINE LLTool* getSelectedTool() { return mSelectedTool; }
  97. void addTool(LLTool* tool);
  98. void selectTool(LLTool* tool);
  99. void selectToolByIndex(U32 index);
  100. LL_INLINE void selectFirstTool() { selectToolByIndex(0); }
  101. void selectNextTool();
  102. void selectPrevTool();
  103. void handleScrollWheel(S32 clicks);
  104. #if 0 // Not used
  105. LL_INLINE bool isToolSelected(U32 idx)
  106. {
  107. return idx < (U32)mToolList.size() && mToolList[idx] == mSelectedTool;
  108. }
  109. #endif
  110. protected:
  111. LLTool* mSelectedTool;
  112. typedef std::vector<LLTool*> tool_list_t;
  113. tool_list_t mToolList;
  114. };
  115. // Globals
  116. extern LLToolMgr gToolMgr;
  117. extern LLTool* gToolNull;
  118. extern LLToolset* gBasicToolset;
  119. extern LLToolset* gCameraToolset;
  120. extern LLToolset* gMouselookToolset;
  121. extern LLToolset* gFaceEditToolset;
  122. #endif