PageRenderTime 54ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llbottomtray.h

https://github.com/HyangZhao/NaCl-main
C Header | 386 lines | 116 code | 56 blank | 214 comment | 0 complexity | 969aed165d4dea5a8c09936b39512e5f MD5 | raw file
  1. /**
  2. * @file llbottomtray.h
  3. * @brief LLBottomTray class header file
  4. *
  5. * $LicenseInfo:firstyear=2009&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_LLBOTTOMPANEL_H
  27. #define LL_LLBOTTOMPANEL_H
  28. #include "llmenugl.h"
  29. #include "llpanel.h"
  30. #include "llimview.h"
  31. #include "llcombobox.h"
  32. class LLChicletPanel;
  33. class LLLineEditor;
  34. class LLLayoutStack;
  35. class LLNotificationChiclet;
  36. class LLSpeakButton;
  37. class LLNearbyChatBar;
  38. class LLIMChiclet;
  39. class LLBottomTrayLite;
  40. // Build time optimization, generate once in .cpp file
  41. #ifndef LLBOTTOMTRAY_CPP
  42. extern template class LLBottomTray* LLSingleton<class LLBottomTray>::getInstance();
  43. #endif
  44. class LLBottomTray
  45. : public LLSingleton<LLBottomTray>
  46. , public LLPanel
  47. , public LLIMSessionObserver
  48. , public LLVoiceClientStatusObserver
  49. {
  50. LOG_CLASS(LLBottomTray);
  51. friend class LLSingleton<LLBottomTray>;
  52. friend class LLBottomTrayLite;
  53. public:
  54. ~LLBottomTray();
  55. BOOL postBuild();
  56. LLChicletPanel* getChicletPanel() {return mChicletPanel;}
  57. LLNearbyChatBar* getNearbyChatBar();
  58. void onCommitGesture(LLUICtrl* ctrl);
  59. // LLIMSessionObserver observe triggers
  60. virtual void sessionAdded(const LLUUID& session_id, const std::string& name, const LLUUID& other_participant_id);
  61. virtual void sessionRemoved(const LLUUID& session_id);
  62. void sessionIDUpdated(const LLUUID& old_session_id, const LLUUID& new_session_id);
  63. S32 getTotalUnreadIMCount();
  64. virtual void reshape(S32 width, S32 height, BOOL called_from_parent);
  65. virtual void setVisible(BOOL visible);
  66. /*virtual*/ S32 notifyParent(const LLSD& info);
  67. // Implements LLVoiceClientStatusObserver::onChange() to enable the speak
  68. // button when voice is available
  69. /*virtual*/ void onChange(EStatusType status, const std::string &channelURI, bool proximal);
  70. void showBottomTrayContextMenu(S32 x, S32 y, MASK mask);
  71. void showGestureButton(BOOL visible);
  72. void showMoveButton(BOOL visible);
  73. void showCameraButton(BOOL visible);
  74. void showSnapshotButton(BOOL visible);
  75. void toggleMovementControls();
  76. void toggleCameraControls();
  77. void onMouselookModeIn();
  78. void onMouselookModeOut();
  79. /**
  80. * Creates IM Chiclet based on session type (IM chat or Group chat)
  81. */
  82. LLIMChiclet* createIMChiclet(const LLUUID& session_id);
  83. private:
  84. typedef enum e_resize_status_type
  85. {
  86. RS_NORESIZE = 0x0000
  87. , RS_CHICLET_PANEL = 0x0001
  88. , RS_CHATBAR_INPUT = 0x0002
  89. , RS_BUTTON_SNAPSHOT = 0x0004
  90. , RS_BUTTON_CAMERA = 0x0008
  91. , RS_BUTTON_MOVEMENT = 0x0010
  92. , RS_BUTTON_GESTURES = 0x0020
  93. , RS_BUTTON_SPEAK = 0x0040
  94. , RS_IM_WELL = 0x0080
  95. , RS_NOTIFICATION_WELL = 0x0100
  96. , RS_BUTTON_BUILD = 0x0200
  97. , RS_BUTTON_SEARCH = 0x0400
  98. , RS_BUTTON_WORLD_MAP = 0x0800
  99. , RS_BUTTON_MINI_MAP = 0x1000
  100. /*
  101. Once new button that can be hidden on resize is added don't forget to update related places:
  102. - RS_BUTTONS_CAN_BE_HIDDEN enum value below.
  103. - initResizeStateContainers(): mStateProcessedObjectMap and mButtonsProcessOrder
  104. */
  105. /**
  106. * Specifies buttons which can be hidden when bottom tray is shrunk.
  107. * They are: Gestures, Movement (Move), Camera (View), Snapshot
  108. * new: Build, Search, Map, World Map, Mini-Map.
  109. */
  110. , RS_BUTTONS_CAN_BE_HIDDEN = RS_BUTTON_SNAPSHOT | RS_BUTTON_CAMERA | RS_BUTTON_MOVEMENT | RS_BUTTON_GESTURES
  111. | RS_BUTTON_BUILD | RS_BUTTON_SEARCH | RS_BUTTON_WORLD_MAP | RS_BUTTON_MINI_MAP
  112. }EResizeState;
  113. /**
  114. * Updates child controls size and visibility when it is necessary to reduce total width.
  115. *
  116. * Process order:
  117. * - reduce chiclet panel to its minimal width;
  118. * - reduce chatbar to its minimal width;
  119. * - reduce visible buttons from right to left to their minimal width;
  120. * - hide visible buttons from right to left;
  121. * When button is hidden chatbar extended to fill released space if it is necessary.
  122. *
  123. * @param[in] delta_width - value by which bottom tray should be shrunk. It is a negative value.
  124. * @return positive value which bottom tray can not process when it reaches its minimal width.
  125. * Zero if there was enough space to process delta_width.
  126. */
  127. S32 processWidthDecreased(S32 delta_width);
  128. /**
  129. * Updates child controls size and visibility when it is necessary to extend total width.
  130. *
  131. * Process order:
  132. * - show invisible buttons should be shown from left to right if possible;
  133. * - extend visible buttons from left to right to their default width;
  134. * - extend chatbar to its maximal width;
  135. * - extend chiclet panel to all available space;
  136. * When chatbar & chiclet panels are wider then their minimal width they can be reduced to allow
  137. * a button gets visible in case if passed delta_width is not enough (chatbar first).
  138. *
  139. * @param[in] delta_width - value by which bottom tray should be extended. It is a positive value.
  140. */
  141. void processWidthIncreased(S32 delta_width);
  142. /** helper function to log debug messages */
  143. void log(LLView* panel, const std::string& descr);
  144. /**
  145. * Tries to show hidden by resize buttons using available width.
  146. *
  147. * Gets buttons visible if there is enough space. Reduces available_width in this case.
  148. *
  149. * @params[in, out] available_width - reference to available width to be used to show buttons.
  150. * @see processShowButton()
  151. */
  152. void processShowButtons(S32& available_width);
  153. /**
  154. * Tries to show panel with specified button using available width.
  155. *
  156. * Shows button specified by type if there is enough space. Reduces available_width in this case.
  157. *
  158. * @params[in] shown_object_type - type of button to be shown.
  159. * @params[in, out] available_width - reference to available width to be used to show button.
  160. *
  161. * @return true if button can be shown, false otherwise
  162. */
  163. bool processShowButton(EResizeState shown_object_type, S32& available_width);
  164. /**
  165. * Hides visible panels with all buttons that may be hidden by resize if it is necessary.
  166. *
  167. * When button gets hidden some space is released in bottom tray.
  168. * This space is taken into account for several consecutive calls for several buttons.
  169. *
  170. * @params[in, out] required_width - reference to required width to be released. This is a negative value.
  171. * Its absolute value is decreased by shown panel width.
  172. * @params[in, out] buttons_freed_width - reference to value released over required one.
  173. * If panel's width is more than required difference is added to buttons_freed_width.
  174. * @see processHideButton()
  175. */
  176. void processHideButtons(S32& required_width, S32& buttons_freed_width);
  177. /**
  178. * Hides panel with specified button if it is visible.
  179. *
  180. * When button gets hidden some space is released in bottom tray.
  181. * This space is taken into account for several consecutive calls for several buttons.
  182. *
  183. * @params[in] processed_object_type - type of button to be hide.
  184. * @params[in, out] required_width - reference to required width to be released. This is a negative value.
  185. * Its absolute value is decreased by panel width.
  186. * @params[in, out] buttons_freed_width - reference to value released over required one.
  187. * If panel's width is more than required difference is added to buttons_freed_width.
  188. */
  189. void processHideButton(EResizeState processed_object_type, S32& required_width, S32& buttons_freed_width);
  190. /**
  191. * Shrinks shown buttons to reduce total taken space.
  192. *
  193. * Shrinks buttons that may be shrunk smoothly first. Then shrinks Speak button.
  194. *
  195. * @param[in, out] required_width - reference to width value which should be released when buttons are shrunk. It is a negative value.
  196. * It is increased on the value processed by buttons.
  197. * @params[in, out] buttons_freed_width - reference to value released over required one.
  198. * If width of panel with Speak button is more than required that difference is added
  199. * to buttons_freed_width.
  200. * This is because Speak button shrinks discretely unlike other buttons which are changed smoothly.
  201. */
  202. void processShrinkButtons(S32& required_width, S32& buttons_freed_width);
  203. /**
  204. * Shrinks panel with specified button if it is visible.
  205. *
  206. * @params[in] processed_object_type - type of button to be shrunk.
  207. * @param[in, out] required_width - reference to width value which should be released when button is shrunk. It is a negative value.
  208. * It is increased on the value released by the button.
  209. */
  210. void processShrinkButton(EResizeState processed_object_type, S32& required_width);
  211. /**
  212. * Extends shown buttons to increase total taken space.
  213. *
  214. * Extends buttons that may be extended smoothly first. Then extends Speak button.
  215. *
  216. * @param[in, out] available_width - reference to width value which buttons can use to be extended.
  217. * It is a positive value. It is decreased on the value processed by buttons.
  218. */
  219. void processExtendButtons(S32& available_width);
  220. /**
  221. * Extends shown button to increase total taken space.
  222. *
  223. * @params[in] processed_object_type - type of button to be extended.
  224. * @param[in, out] available_width - reference to width value which button can use to be extended.
  225. * It is a positive value. It is decreased on the value processed by buttons.
  226. */
  227. void processExtendButton(EResizeState processed_object_type, S32& available_width);
  228. /**
  229. * Determines if specified by type object can be shown. It should be hidden by shrink before.
  230. *
  231. * Processes buttons a such way to show buttons in constant order:
  232. * - Gestures, Move, View, Snapshot
  233. */
  234. bool canButtonBeShown(EResizeState processed_object_type) const;
  235. /**
  236. * Initializes all containers stored data related to children resize state.
  237. *
  238. * @see mStateProcessedObjectMap
  239. * @see mObjectDefaultWidthMap
  240. * @see mButtonsProcessOrder
  241. */
  242. void initResizeStateContainers();
  243. /**
  244. * Initializes buttons' visibility depend on stored Control Settings.
  245. */
  246. void initButtonsVisibility();
  247. /**
  248. * Initializes listeners of Control Settings to toggle appropriate buttons' visibility.
  249. *
  250. * @see toggleShowButton()
  251. */
  252. void setButtonsControlsAndListeners();
  253. /**
  254. * Toggles visibility of specified button depend on passed value.
  255. *
  256. * @param button_type - type of button to be toggled
  257. * @param new_visibility - new visibility of the button
  258. *
  259. * @see setButtonsControlsAndListeners()
  260. */
  261. static bool toggleShowButton(EResizeState button_type, const LLSD& new_visibility);
  262. /**
  263. * Sets passed visibility to object specified by resize type.
  264. */
  265. void setTrayButtonVisible(EResizeState shown_object_type, bool visible);
  266. /**
  267. * Sets passed visibility to object specified by resize type if it is possible.
  268. *
  269. * If it is impossible to show required button due to there is no enough room in bottom tray
  270. * it will no be shown. Is called via context menu commands.
  271. * In this case Alert Dialog will be shown to notify user about that.
  272. *
  273. * Method also stores resize state to be processed while future bottom tray extending:
  274. * - if hidden while resizing button should be hidden it will not be shown while extending;
  275. * - if hidden via context menu button should be shown but there is no enough room for now
  276. * it will be shown while extending.
  277. */
  278. void setTrayButtonVisibleIfPossible(EResizeState shown_object_type, bool visible, bool raise_notification = true);
  279. /**
  280. * Sets passed visibility to required button and fit widths of shown
  281. * buttons(notice that method can shrink widths to
  282. * allocate needed room in bottom tray).
  283. * Returns true if visibility of required button was set.
  284. */
  285. bool setVisibleAndFitWidths(EResizeState object_type, bool visible);
  286. /**
  287. * Shows/hides panel with specified well button (IM or Notification)
  288. *
  289. * @param[in] object_type - type of well button to be processed.
  290. * Must be one of RS_IM_WELL or RS_NOTIFICATION_WELL.
  291. * @param[in] visible - flag specified whether button should be shown or hidden.
  292. */
  293. void showWellButton(EResizeState object_type, bool visible);
  294. /**
  295. * Handles a customization of chatbar width.
  296. *
  297. * When chatbar gets wider layout stack will reduce chiclet panel (it is auto-resizable)
  298. * But once chiclet panel reaches its minimal width Stack will force to reduce buttons width.
  299. * including Speak button. The similar behavior is when chatbar gets narrowly.
  300. * This methods force resize behavior to resize buttons properly in these cases.
  301. */
  302. void processChatbarCustomization(S32 new_width);
  303. MASK mResizeState;
  304. typedef std::map<EResizeState, LLPanel*> state_object_map_t;
  305. state_object_map_t mStateProcessedObjectMap;
  306. typedef std::map<EResizeState, S32> state_object_width_map_t;
  307. state_object_width_map_t mObjectDefaultWidthMap;
  308. typedef std::vector<EResizeState> resize_state_vec_t;
  309. /**
  310. * Contains order in which child buttons should be processed in show/hide, extend/shrink methods.
  311. */
  312. resize_state_vec_t mButtonsProcessOrder;
  313. protected:
  314. LLBottomTray(const LLSD& key = LLSD());
  315. static void* createNearbyChatBar(void* userdata);
  316. void updateContextMenu(S32 x, S32 y, MASK mask);
  317. void onContextMenuItemClicked(const LLSD& userdata);
  318. bool onContextMenuItemEnabled(const LLSD& userdata);
  319. LLChicletPanel* mChicletPanel;
  320. LLPanel* mSpeakPanel;
  321. LLSpeakButton* mSpeakBtn;
  322. LLNearbyChatBar* mNearbyChatBar;
  323. LLLayoutStack* mToolbarStack;
  324. LLMenuGL* mBottomTrayContextMenu;
  325. LLButton* mCamButton;
  326. LLButton* mMovementButton;
  327. LLBottomTrayLite* mBottomTrayLite;
  328. bool mIsInLiteMode;
  329. };
  330. #endif // LL_LLBOTTOMPANEL_H