PageRenderTime 124ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llavatarlistitem.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 232 lines | 114 code | 37 blank | 81 comment | 0 complexity | e810baad14463918ee3b2b0413c2837f MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llavatarlistitem.h
  3. * @brief avatar list item 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_LLAVATARLISTITEM_H
  27. #define LL_LLAVATARLISTITEM_H
  28. #include "llpanel.h"
  29. #include "lloutputmonitorctrl.h"
  30. #include "llbutton.h"
  31. #include "lltextbox.h"
  32. #include "llstyle.h"
  33. #include "llcallingcard.h" // for LLFriendObserver
  34. class LLAvatarIconCtrl;
  35. class LLAvatarName;
  36. class LLIconCtrl;
  37. class LLAvatarListItem : public LLPanel, public LLFriendObserver
  38. {
  39. public:
  40. struct Params : public LLInitParam::Block<Params, LLPanel::Params>
  41. {
  42. Optional<LLStyle::Params> default_style,
  43. voice_call_invited_style,
  44. voice_call_joined_style,
  45. voice_call_left_style,
  46. online_style,
  47. offline_style;
  48. Optional<S32> name_right_pad;
  49. Params();
  50. };
  51. typedef enum e_item_state_type {
  52. IS_DEFAULT,
  53. IS_VOICE_INVITED,
  54. IS_VOICE_JOINED,
  55. IS_VOICE_LEFT,
  56. IS_ONLINE,
  57. IS_OFFLINE,
  58. } EItemState;
  59. /**
  60. * Creates an instance of LLAvatarListItem.
  61. *
  62. * It is not registered with LLDefaultChildRegistry. It is built via LLUICtrlFactory::buildPanel
  63. * or via registered LLCallbackMap depend on passed parameter.
  64. *
  65. * @param not_from_ui_factory if true instance will be build with LLUICtrlFactory::buildPanel
  66. * otherwise it should be registered via LLCallbackMap before creating.
  67. */
  68. LLAvatarListItem(bool not_from_ui_factory = true);
  69. virtual ~LLAvatarListItem();
  70. virtual BOOL postBuild();
  71. /**
  72. * Processes notification from speaker indicator to update children when indicator's visibility is changed.
  73. */
  74. virtual S32 notifyParent(const LLSD& info);
  75. virtual void onMouseLeave(S32 x, S32 y, MASK mask);
  76. virtual void onMouseEnter(S32 x, S32 y, MASK mask);
  77. virtual void setValue(const LLSD& value);
  78. virtual void changed(U32 mask); // from LLFriendObserver
  79. void setOnline(bool online);
  80. void updateAvatarName(); // re-query the name cache
  81. void setAvatarName(const std::string& name);
  82. void setAvatarToolTip(const std::string& tooltip);
  83. void setHighlight(const std::string& highlight);
  84. void setState(EItemState item_style);
  85. void setAvatarId(const LLUUID& id, const LLUUID& session_id, bool ignore_status_changes = false, bool is_resident = true);
  86. void setLastInteractionTime(U32 secs_since);
  87. //Show/hide profile/info btn, translating speaker indicator and avatar name coordinates accordingly
  88. void setShowProfileBtn(bool show);
  89. void setShowInfoBtn(bool show);
  90. void showSpeakingIndicator(bool show);
  91. void setShowPermissions(bool show) { mShowPermissions = show; };
  92. void showLastInteractionTime(bool show);
  93. void setAvatarIconVisible(bool visible);
  94. const LLUUID& getAvatarId() const;
  95. std::string getAvatarName() const;
  96. std::string getAvatarToolTip() const;
  97. void onInfoBtnClick();
  98. void onProfileBtnClick();
  99. /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
  100. protected:
  101. /**
  102. * Contains indicator to show voice activity.
  103. */
  104. LLOutputMonitorCtrl* mSpeakingIndicator;
  105. LLAvatarIconCtrl* mAvatarIcon;
  106. /// Indicator for permission to see me online.
  107. LLIconCtrl* mIconPermissionOnline;
  108. /// Indicator for permission to see my position on the map.
  109. LLIconCtrl* mIconPermissionMap;
  110. /// Indicator for permission to edit my objects.
  111. LLIconCtrl* mIconPermissionEditMine;
  112. /// Indicator for permission to edit their objects.
  113. LLIconCtrl* mIconPermissionEditTheirs;
  114. private:
  115. typedef enum e_online_status {
  116. E_OFFLINE,
  117. E_ONLINE,
  118. E_UNKNOWN,
  119. } EOnlineStatus;
  120. /**
  121. * Enumeration of item elements in order from right to left.
  122. *
  123. * updateChildren() assumes that indexes are in the such order to process avatar icon easier.
  124. *
  125. * @see updateChildren()
  126. */
  127. typedef enum e_avatar_item_child {
  128. ALIC_SPEAKER_INDICATOR,
  129. ALIC_PROFILE_BUTTON,
  130. ALIC_INFO_BUTTON,
  131. ALIC_PERMISSION_ONLINE,
  132. ALIC_PERMISSION_MAP,
  133. ALIC_PERMISSION_EDIT_MINE,
  134. ALIC_PERMISSION_EDIT_THEIRS,
  135. ALIC_INTERACTION_TIME,
  136. ALIC_NAME,
  137. ALIC_ICON,
  138. ALIC_COUNT,
  139. } EAvatarListItemChildIndex;
  140. void setNameInternal(const std::string& name, const std::string& highlight);
  141. void onAvatarNameCache(const LLAvatarName& av_name);
  142. std::string formatSeconds(U32 secs);
  143. typedef std::map<EItemState, LLColor4> icon_color_map_t;
  144. static icon_color_map_t& getItemIconColorMap();
  145. /**
  146. * Initializes widths of all children to use them while changing visibility of any of them.
  147. *
  148. * @see updateChildren()
  149. */
  150. static void initChildrenWidths(LLAvatarListItem* self);
  151. /**
  152. * Updates position and rectangle of visible children to fit all available item's width.
  153. */
  154. void updateChildren();
  155. /**
  156. * Update visibility of active permissions icons.
  157. *
  158. * Need to call updateChildren() afterwards to sort out their layout.
  159. */
  160. bool showPermissions(bool visible);
  161. /**
  162. * Gets child view specified by index.
  163. *
  164. * This method implemented via switch by all EAvatarListItemChildIndex values.
  165. * It is used to not store children in array or vector to avoid of increasing memory usage.
  166. */
  167. LLView* getItemChildView(EAvatarListItemChildIndex child_index);
  168. LLTextBox* mAvatarName;
  169. LLTextBox* mLastInteractionTime;
  170. LLStyle::Params mAvatarNameStyle;
  171. LLButton* mInfoBtn;
  172. LLButton* mProfileBtn;
  173. LLUUID mAvatarId;
  174. std::string mHighlihtSubstring; // substring to highlight
  175. EOnlineStatus mOnlineStatus;
  176. //Flag indicating that info/profile button shouldn't be shown at all.
  177. //Speaker indicator and avatar name coords are translated accordingly
  178. bool mShowInfoBtn;
  179. bool mShowProfileBtn;
  180. /// indicates whether to show icons representing permissions granted
  181. bool mShowPermissions;
  182. /// true when the mouse pointer is hovering over this item
  183. bool mHovered;
  184. static bool sStaticInitialized; // this variable is introduced to improve code readability
  185. static S32 sLeftPadding; // padding to first left visible child (icon or name)
  186. static S32 sNameRightPadding; // right padding from name to next visible child
  187. /**
  188. * Contains widths of each child specified by EAvatarListItemChildIndex
  189. * including padding to the next right one.
  190. *
  191. * @see initChildrenWidths()
  192. */
  193. static S32 sChildrenWidths[ALIC_COUNT];
  194. };
  195. #endif //LL_LLAVATARLISTITEM_H