llpanelavatar.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. /**
  2. * @file llpanelavatar.h
  3. * @brief LLPanelAvatar and related class definitions
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewergpl$
  6. *
  7. * Copyright (c) 2004-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_LLPANELAVATAR_H
  33. #define LL_LLPANELAVATAR_H
  34. #include "llavatarnamecache.h"
  35. #include "llpanel.h"
  36. #include "llvector3d.h"
  37. #include "llavatarproperties.h"
  38. #include "llmediactrl.h"
  39. class LLButton;
  40. class LLCheckBoxCtrl;
  41. class LLDropTarget;
  42. class LLFlyoutButton;
  43. class LLLineEditor;
  44. class LLMessageSystem;
  45. class LLNameEditor;
  46. class LLPanelAvatar;
  47. class LLScrollListCtrl;
  48. class LLTabContainer;
  49. class LLTextBox;
  50. class LLTextEditor;
  51. class LLTextureCtrl;
  52. class LLUICtrl;
  53. enum EOnlineStatus
  54. {
  55. ONLINE_STATUS_NO = 0,
  56. ONLINE_STATUS_YES = 1
  57. };
  58. // Base class for all sub-tabs inside the avatar profile. Many of these panels
  59. // need to keep track of the parent panel (to get the avatar id) and only
  60. // request data from the database when they are first drawn. JC
  61. class LLPanelAvatarTab : public LLPanel
  62. {
  63. public:
  64. LLPanelAvatarTab(const std::string& name, const LLRect& rect,
  65. LLPanelAvatar* panel_avatar);
  66. // Calls refresh() once per frame when panel is visible
  67. void draw() override;
  68. LL_INLINE LLPanelAvatar* getPanelAvatar() const { return mPanelAvatar; }
  69. LL_INLINE void resetDataRequested() { mDataRequested = false; }
  70. // If the data for this tab has not yet been requested, send the request.
  71. // Used by tabs that are filled in only when they are first displayed.
  72. // 'method' is one of "avatarnotesrequest", "avatarpicksrequest",
  73. // or "avatarclassifiedsrequest"
  74. void sendAvatarProfileRequestIfNeeded(S32 type);
  75. private:
  76. LLPanelAvatar* mPanelAvatar;
  77. bool mDataRequested;
  78. };
  79. class LLPanelAvatarFirstLife final : public LLPanelAvatarTab
  80. {
  81. public:
  82. LLPanelAvatarFirstLife(const std::string& name,
  83. const LLRect& rect,
  84. LLPanelAvatar* panel_avatar);
  85. bool postBuild() override;
  86. void enableControls(bool own_avatar);
  87. public:
  88. LLTextureCtrl* m1stLifePicture;
  89. LLTextEditor* mAbout1stLifeText;
  90. };
  91. class LLPanelAvatarSecondLife final : public LLPanelAvatarTab
  92. {
  93. public:
  94. LLPanelAvatarSecondLife(const std::string& name,
  95. const LLRect& rect,
  96. LLPanelAvatar* panel_avatar);
  97. bool postBuild() override;
  98. void refresh() override;
  99. // Clear out the controls anticipating new network data.
  100. void clearControls();
  101. void enableControls(bool own_avatar);
  102. void updateOnlineText(bool online, bool have_calling_card);
  103. void updatePartnerName();
  104. LL_INLINE void setPartnerID(const LLUUID& id)
  105. {
  106. mPartnerID = id;
  107. mPartnerNamePending = true;
  108. }
  109. private:
  110. static void onDoubleClickGroup(void* userdata);
  111. static void onClickShowInSearchHelp(void* userdata);
  112. static void onClickPartnerHelp(void* userdata);
  113. static bool onClickPartnerHelpLoadURL(const LLSD& notification,
  114. const LLSD& response);
  115. static void onClickPartnerInfo(void* userdata);
  116. static void onCommitDisplayRatioCheck(LLUICtrl* ctrl, void* data);
  117. public:
  118. LLNameEditor* mLegacyName;
  119. LLNameEditor* mCompleteName;
  120. LLTextureCtrl* m2ndLifePicture;
  121. LLLineEditor* mBornText;
  122. LLTextBox* mOnlineText;
  123. LLTextBox* mAccountInfoText;
  124. LLTextBox* mAboutCharLimitText;
  125. LLScrollListCtrl* mGroupsListCtrl;
  126. LLTextEditor* mAbout2ndLifeText;
  127. LLCheckBoxCtrl* mShowInSearchCheck;
  128. LLButton* mShowInSearchHelpButton;
  129. LLButton* mFindOnMapButton;
  130. LLButton* mOfferTPButton;
  131. LLButton* mRequestTPButton;
  132. LLButton* mAddFriendButton;
  133. LLButton* mPayButton;
  134. LLButton* mIMButton;
  135. LLButton* mMuteButton;
  136. private:
  137. LLButton* mPartnerInfoButton;
  138. LLUUID mPartnerID;
  139. bool mPartnerNamePending;
  140. };
  141. // WARNING ! The order of the inheritance here matters ! Do not change. - KLW
  142. class LLPanelAvatarWeb final : public LLPanelAvatarTab,
  143. public LLViewerMediaObserver
  144. {
  145. public:
  146. LLPanelAvatarWeb(const std::string& name,
  147. const LLRect& rect,
  148. LLPanelAvatar* panel_avatar);
  149. bool postBuild() override;
  150. void refresh() override;
  151. void enableControls(bool own_avatar);
  152. void setWebURL(std::string url);
  153. LL_INLINE const std::string& getWebURL() const { return mHome; }
  154. void load(const std::string& url);
  155. static void onURLKeystroke(LLLineEditor* editor, void* data);
  156. static void onCommitLoad(LLUICtrl* ctrl, void* data);
  157. static void onCommitSLWebProfile(LLUICtrl* ctrl, void* data);
  158. static void onCommitURL(LLUICtrl* ctrl, void* data);
  159. static void onClickWebProfileHelp(void*);
  160. // Inherited from LLViewerMediaObserver
  161. void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent evt) override;
  162. private:
  163. bool mCanEditURL;
  164. std::string mHome;
  165. std::string mNavigateTo;
  166. LLFlyoutButton* mWebProfileBtn;
  167. LLMediaCtrl* mWebBrowser;
  168. };
  169. class LLPanelAvatarAdvanced final : public LLPanelAvatarTab
  170. {
  171. public:
  172. LLPanelAvatarAdvanced(const std::string& name,
  173. const LLRect& rect,
  174. LLPanelAvatar* panel_avatar);
  175. bool postBuild() override;
  176. void enableControls(bool own_avatar);
  177. void setWantSkills(U32 want_to_mask, const std::string& want_to_text,
  178. U32 skills_mask, const std::string& skills_text,
  179. const std::string& languages_text);
  180. void getWantSkills(U32& want_to_mask, std::string& want_to_text,
  181. U32& skills_mask, std::string& skills_text,
  182. std::string& languages_text);
  183. private:
  184. LLCheckBoxCtrl* mWantToCheck[8];
  185. LLLineEditor* mWantToEdit;
  186. LLCheckBoxCtrl* mSkillsCheck[8];
  187. LLLineEditor* mSkillsEdit;
  188. S32 mWantToCount;
  189. S32 mSkillsCount;
  190. };
  191. class LLPanelAvatarNotes final : public LLPanelAvatarTab
  192. {
  193. public:
  194. LLPanelAvatarNotes(const std::string& name, const LLRect& rect,
  195. LLPanelAvatar* panel_avatar);
  196. bool postBuild() override;
  197. void refresh() override;
  198. void clearControls();
  199. static void onCommitNotes(LLUICtrl* field, void* userdata);
  200. public:
  201. LLTextEditor* mNotesText;
  202. };
  203. class LLPanelAvatarClassified final : public LLPanelAvatarTab
  204. {
  205. public:
  206. LLPanelAvatarClassified(const std::string& name,
  207. const LLRect& rect,
  208. LLPanelAvatar* panel_avatar);
  209. bool postBuild() override;
  210. void refresh() override;
  211. // If can close, return true. If cannot close, pop save/discard dialog
  212. // and return false.
  213. bool canClose();
  214. void apply();
  215. bool titleIsValid();
  216. // Delete all the classified sub-panels from the tab container
  217. void deleteClassifiedPanels();
  218. // Unpack the outline of classified for this avatar (count, names, but not
  219. // actual data).
  220. void processAvatarClassifiedReply(LLAvatarClassifieds* data);
  221. private:
  222. static void onClickNew(void* data);
  223. static void onClickDelete(void* data);
  224. bool callbackDelete(const LLSD& notification, const LLSD& response);
  225. bool callbackNew(const LLSD& notification, const LLSD& response);
  226. private:
  227. LLTabContainer* mClassifiedTab;
  228. LLButton* mButtonNew;
  229. LLButton* mButtonDelete;
  230. LLTextBox* mLoadingText;
  231. };
  232. class LLPanelAvatarPicks final : public LLPanelAvatarTab
  233. {
  234. public:
  235. LLPanelAvatarPicks(const std::string& name,
  236. const LLRect& rect,
  237. LLPanelAvatar* panel_avatar);
  238. bool postBuild() override;
  239. void refresh() override;
  240. // Delete all the pick sub-panels from the tab container
  241. void deletePickPanels();
  242. // Unpack the outline of picks and classifieds for this avatar (count,
  243. // names, but not actual data).
  244. void processAvatarPicksReply(LLAvatarPicks* data);
  245. void processAvatarClassifiedReply(LLAvatarClassifieds* data);
  246. private:
  247. static void onClickNew(void* data);
  248. static void onClickDelete(void* data);
  249. bool callbackDelete(const LLSD& notification, const LLSD& response);
  250. private:
  251. LLTabContainer* mPicksTab;
  252. LLButton* mButtonNew;
  253. LLButton* mButtonDelete;
  254. LLTextBox* mLoadingText;
  255. };
  256. class LLPanelAvatar final : public LLPanel, LLAvatarPropertiesObserver
  257. {
  258. public:
  259. LLPanelAvatar(const std::string& name, const LLRect& rect,
  260. bool allow_edit);
  261. ~LLPanelAvatar() override;
  262. bool postBuild() override;
  263. // If can close, return true. If cannot close, pop save/discard dialog
  264. // and return false.
  265. bool canClose();
  266. // LLAvatarPropertiesObserver override
  267. void processProperties(S32 type, void* data) override;
  268. // Fill in the avatar ID and handle some field fill-in, as well as
  269. // button enablement.
  270. // Pass one of the ONLINE_STATUS_foo constants above.
  271. void setAvatarID(const LLUUID& avatar_id, const std::string& name,
  272. EOnlineStatus online_status);
  273. void setOnlineStatus(EOnlineStatus online_status);
  274. LL_INLINE const LLUUID& getAvatarID() const { return mAvatarID; }
  275. LL_INLINE const std::string& getAvatarUserName() const
  276. {
  277. return mAvatarUserName;
  278. }
  279. // Lists the agents groups, based on the info held in LLAgent, and flagging
  280. // hidden groups as such, via the use of an Italics font and an explanatory
  281. // tool tip. HB
  282. void listAgentGroups();
  283. void sendAvatarPropertiesUpdate();
  284. void sendAvatarNotesUpdate();
  285. void selectTab(S32 tabnum);
  286. void selectTabByName(std::string tab_name);
  287. LL_INLINE bool haveData() const { return mHaveProperties; }
  288. LL_INLINE bool isEditable() const { return mAllowEdit; }
  289. static void onClickTrack(void* userdata);
  290. static void onClickIM(void* userdata);
  291. static void onClickOfferTeleport(void* userdata);
  292. static void onClickRequestTeleport(void* userdata);
  293. static void onClickPay(void* userdata);
  294. static void onClickAddFriend(void* userdata);
  295. static void onClickOK(void* userdata);
  296. static void onClickCancel(void* userdata);
  297. static void onClickKick(void* userdata);
  298. static void onClickFreeze(void* userdata);
  299. static void onClickUnfreeze(void* userdata);
  300. static void onClickCSR(void* userdata);
  301. static void onClickMute(void* userdata);
  302. private:
  303. void enableOKIfReady();
  304. static void showProfileCallback(S32 option, void* userdata);
  305. static void completeNameCallback(const LLUUID& agent_id,
  306. const LLAvatarName& avatar_name,
  307. LLHandle<LLPanel> handle);
  308. static void* createPanelAvatar(void* data);
  309. static void* createFloaterAvatarInfo(void* data);
  310. static void* createPanelAvatarSecondLife(void* data);
  311. static void* createPanelAvatarWeb(void* data);
  312. static void* createPanelAvatarInterests(void* data);
  313. static void* createPanelAvatarPicks(void* data);
  314. static void* createPanelAvatarClassified(void* data);
  315. static void* createPanelAvatarFirstLife(void* data);
  316. static void* createPanelAvatarNotes(void* data);
  317. public:
  318. LLPanelAvatarSecondLife* mPanelSecondLife;
  319. LLPanelAvatarAdvanced* mPanelAdvanced;
  320. LLPanelAvatarClassified* mPanelClassified;
  321. LLPanelAvatarPicks* mPanelPicks;
  322. LLPanelAvatarNotes* mPanelNotes;
  323. LLPanelAvatarFirstLife* mPanelFirstLife;
  324. LLPanelAvatarWeb* mPanelWeb;
  325. LLDropTarget* mDropTarget;
  326. // Teen users are not allowed to see or enter data into the first life
  327. // page, or their own about/interests text entry fields.
  328. static bool sAllowFirstLife;
  329. // Tool tip and text strings, defined in panel_avatar.xml
  330. static std::string sLoading; // public
  331. private:
  332. static std::string sClickToEnlarge;
  333. static std::string sShowOnMapNonFriend;
  334. static std::string sShowOnMapFriendOffline;
  335. static std::string sShowOnMapFriendOnline;
  336. static std::string sTeleportGod;
  337. static std::string sTeleportPrelude;
  338. static std::string sTeleportNormal;
  339. LLUUID mAvatarID; // Which avatar's window is this ?
  340. std::string mAvatarUserName; // Known avatar user name
  341. LLButton* mOKButton;
  342. LLButton* mCancelButton;
  343. LLButton* mKickButton;
  344. LLButton* mFreezeButton;
  345. LLButton* mUnfreezeButton;
  346. LLButton* mCSRButton;
  347. LLTabContainer* mTab;
  348. // Only update note if data received from database and note is changed from
  349. // database version
  350. std::string mLastNotes;
  351. bool mHaveNotes;
  352. bool mHaveProperties;
  353. bool mHaveInterests;
  354. bool mIsFriend; // Are we friends ?
  355. bool mAllowEdit;
  356. };
  357. // helper funcs
  358. void add_left_label(LLPanel* panel, const std::string& name, S32 y);
  359. #endif // LL_LLPANELAVATAR_H