PageRenderTime 35ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llfloatercamera.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 166 lines | 83 code | 32 blank | 51 comment | 0 complexity | 372064927fe27b09513bb9e5e1e76812 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llfloatercamera.h
  3. * @brief Container for camera control buttons (zoom, pan, orbit)
  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 LLFLOATERCAMERA_H
  27. #define LLFLOATERCAMERA_H
  28. #include "llfloater.h"
  29. #include "lliconctrl.h"
  30. #include "lltextbox.h"
  31. #include "llflatlistview.h"
  32. class LLJoystickCameraRotate;
  33. class LLJoystickCameraTrack;
  34. class LLFloaterReg;
  35. class LLPanelCameraZoom;
  36. enum ECameraControlMode
  37. {
  38. CAMERA_CTRL_MODE_MODES,
  39. CAMERA_CTRL_MODE_PAN,
  40. CAMERA_CTRL_MODE_FREE_CAMERA,
  41. CAMERA_CTRL_MODE_PRESETS
  42. };
  43. class LLFloaterCamera : public LLFloater
  44. {
  45. friend class LLFloaterReg;
  46. public:
  47. /* whether in free camera mode */
  48. static bool inFreeCameraMode();
  49. /* callback for camera items selection changing */
  50. static void onClickCameraItem(const LLSD& param);
  51. static void onLeavingMouseLook();
  52. /** resets current camera mode to orbit mode */
  53. static void resetCameraMode();
  54. /** Called when Avatar is entered/exited editing appearance mode */
  55. static void onAvatarEditingAppearance(bool editing);
  56. /* determines actual mode and updates ui */
  57. void update();
  58. /*switch to one of the camera presets (front, rear, side)*/
  59. static void switchToPreset(const std::string& name);
  60. /* move to CAMERA_CTRL_MODE_PRESETS from CAMERA_CTRL_MODE_FREE_CAMERA if we are on presets panel and
  61. are not in free camera mode*/
  62. void fromFreeToPresets();
  63. virtual void onOpen(const LLSD& key);
  64. virtual void onClose(bool app_quitting);
  65. LLJoystickCameraRotate* mRotate;
  66. LLPanelCameraZoom* mZoom;
  67. LLJoystickCameraTrack* mTrack;
  68. private:
  69. LLFloaterCamera(const LLSD& val);
  70. ~LLFloaterCamera() {};
  71. /* return instance if it exists - created by LLFloaterReg */
  72. static LLFloaterCamera* findInstance();
  73. /*virtual*/ BOOL postBuild();
  74. ECameraControlMode determineMode();
  75. /* resets to the previous mode */
  76. void toPrevMode();
  77. /* sets a new mode and performs related actions */
  78. void switchMode(ECameraControlMode mode);
  79. /* sets a new mode preserving previous one and updates ui*/
  80. void setMode(ECameraControlMode mode);
  81. /* updates the state (UI) according to the current mode */
  82. void updateState();
  83. /* update camera modes items selection and camera preset items selection according to the currently selected preset */
  84. void updateItemsSelection();
  85. void onClickBtn(ECameraControlMode mode);
  86. void assignButton2Mode(ECameraControlMode mode, const std::string& button_name);
  87. // fills flatlist with items from given panel
  88. void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel);
  89. void handleAvatarEditingAppearance(bool editing);
  90. // set to true when free camera mode is selected in modes list
  91. // remains true until preset camera mode is chosen, or pan button is clicked, or escape pressed
  92. static bool sFreeCamera;
  93. static bool sAppearanceEditing;
  94. BOOL mClosed;
  95. ECameraControlMode mPrevMode;
  96. ECameraControlMode mCurrMode;
  97. std::map<ECameraControlMode, LLButton*> mMode2Button;
  98. };
  99. /**
  100. * Class used to represent widgets from panel_camera_item.xml-
  101. * panels that contain pictures and text. Pictures are different
  102. * for selected and unselected state (this state is nor stored- icons
  103. * are changed in setValue()). This class doesn't implement selection logic-
  104. * it's items are used inside of flatlist.
  105. */
  106. class LLPanelCameraItem
  107. : public LLPanel
  108. {
  109. public:
  110. struct Params : public LLInitParam::Block<Params, LLPanel::Params>
  111. {
  112. Optional<LLIconCtrl::Params> icon_over;
  113. Optional<LLIconCtrl::Params> icon_selected;
  114. Optional<LLIconCtrl::Params> picture;
  115. Optional<LLIconCtrl::Params> selected_picture;
  116. Optional<LLTextBox::Params> text;
  117. Optional<CommitCallbackParam> mousedown_callback;
  118. Params();
  119. };
  120. /*virtual*/ BOOL postBuild();
  121. /** setting on/off background icon to indicate selected state */
  122. /*virtual*/ void setValue(const LLSD& value);
  123. // sends commit signal
  124. void onAnyMouseClick();
  125. protected:
  126. friend class LLUICtrlFactory;
  127. LLPanelCameraItem(const Params&);
  128. LLIconCtrl* mIconOver;
  129. LLIconCtrl* mIconSelected;
  130. LLIconCtrl* mPicture;
  131. LLIconCtrl* mPictureSelected;
  132. LLTextBox* mText;
  133. };
  134. #endif