/indra/newview/llmoveview.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 185 lines · 98 code · 29 blank · 58 comment · 0 complexity · d4be3845fd5452cba8cdab1b053ad0f0 MD5 · raw file

  1. /**
  2. * @file llmoveview.h
  3. * @brief Container for buttons for walking, turning, flying
  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_LLMOVEVIEW_H
  27. #define LL_LLMOVEVIEW_H
  28. // Library includes
  29. #include "llfloater.h"
  30. class LLButton;
  31. class LLJoystickAgentTurn;
  32. class LLJoystickAgentSlide;
  33. //
  34. // Classes
  35. //
  36. class LLFloaterMove
  37. : public LLFloater
  38. {
  39. LOG_CLASS(LLFloaterMove);
  40. friend class LLFloaterReg;
  41. private:
  42. LLFloaterMove(const LLSD& key);
  43. ~LLFloaterMove();
  44. public:
  45. /*virtual*/ BOOL postBuild();
  46. /*virtual*/ void setVisible(BOOL visible);
  47. static F32 getYawRate(F32 time);
  48. static void setFlyingMode(BOOL fly);
  49. void setFlyingModeImpl(BOOL fly);
  50. static void setAlwaysRunMode(bool run);
  51. void setAlwaysRunModeImpl(bool run);
  52. static void setSittingMode(BOOL bSitting);
  53. static void enableInstance(BOOL bEnable);
  54. /*virtual*/ void onOpen(const LLSD& key);
  55. static void sUpdateFlyingStatus();
  56. protected:
  57. void turnLeft();
  58. void turnRight();
  59. void moveUp();
  60. void moveDown();
  61. private:
  62. typedef enum movement_mode_t
  63. {
  64. MM_WALK,
  65. MM_RUN,
  66. MM_FLY
  67. } EMovementMode;
  68. void onWalkButtonClick();
  69. void onRunButtonClick();
  70. void onFlyButtonClick();
  71. void initMovementMode();
  72. void setMovementMode(const EMovementMode mode);
  73. void initModeTooltips();
  74. void setModeTooltip(const EMovementMode mode);
  75. void setModeTitle(const EMovementMode mode);
  76. void initModeButtonMap();
  77. void setModeButtonToggleState(const EMovementMode mode);
  78. void updateButtonsWithMovementMode(const EMovementMode newMode);
  79. void showModeButtons(BOOL bShow);
  80. public:
  81. LLJoystickAgentTurn* mForwardButton;
  82. LLJoystickAgentTurn* mBackwardButton;
  83. LLJoystickAgentSlide* mSlideLeftButton;
  84. LLJoystickAgentSlide* mSlideRightButton;
  85. LLButton* mTurnLeftButton;
  86. LLButton* mTurnRightButton;
  87. LLButton* mMoveUpButton;
  88. LLButton* mMoveDownButton;
  89. private:
  90. LLPanel* mModeActionsPanel;
  91. typedef std::map<LLView*, std::string> control_tooltip_map_t;
  92. typedef std::map<EMovementMode, control_tooltip_map_t> mode_control_tooltip_map_t;
  93. mode_control_tooltip_map_t mModeControlTooltipsMap;
  94. typedef std::map<EMovementMode, LLButton*> mode_control_button_map_t;
  95. mode_control_button_map_t mModeControlButtonMap;
  96. EMovementMode mCurrentMode;
  97. };
  98. /**
  99. * This class contains Stand Up and Stop Flying buttons displayed above Move button in bottom tray
  100. */
  101. class LLPanelStandStopFlying : public LLPanel
  102. {
  103. LOG_CLASS(LLPanelStandStopFlying);
  104. public:
  105. typedef enum stand_stop_flying_mode_t
  106. {
  107. SSFM_STAND,
  108. SSFM_STOP_FLYING
  109. } EStandStopFlyingMode;
  110. /**
  111. * Attach or detach the panel to/from the movement controls floater.
  112. *
  113. * Called when the floater gets opened/closed, user sits, stands up or starts/stops flying.
  114. *
  115. * @param move_view The floater to attach to (not always accessible via floater registry).
  116. * If NULL is passed, the panel gets reparented to its original container.
  117. *
  118. * @see mAttached
  119. * @see mOriginalParent
  120. */
  121. void reparent(LLFloaterMove* move_view);
  122. static LLPanelStandStopFlying* getInstance();
  123. static void setStandStopFlyingMode(EStandStopFlyingMode mode);
  124. static void clearStandStopFlyingMode(EStandStopFlyingMode mode);
  125. /*virtual*/ BOOL postBuild();
  126. /*virtual*/ void setVisible(BOOL visible);
  127. // *HACK: due to hard enough to have this control aligned with "Move" button while resizing
  128. // let update its position in each frame
  129. /*virtual*/ void draw(){updatePosition(); LLPanel::draw();}
  130. /*virtual*/ BOOL handleToolTip(S32 x, S32 y, MASK mask);
  131. protected:
  132. LLPanelStandStopFlying();
  133. private:
  134. static LLPanelStandStopFlying* getStandStopFlyingPanel();
  135. void onStandButtonClick();
  136. void onStopFlyingButtonClick();
  137. void updatePosition();
  138. LLButton* mStandButton;
  139. LLButton* mStopFlyingButton;
  140. /**
  141. * The original parent of the panel.
  142. *
  143. * Makes it possible to move (reparent) the panel to the movement controls floater and back.
  144. *
  145. * @see reparent()
  146. */
  147. LLHandle<LLPanel> mOriginalParent;
  148. /**
  149. * True if the panel is currently attached to the movement controls floater.
  150. *
  151. * @see reparent()
  152. * @see updatePosition()
  153. */
  154. bool mAttached;
  155. };
  156. #endif