llpanelgroup.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /**
  2. * @file llpanelgroup.h
  3. *
  4. * $LicenseInfo:firstyear=2006&license=viewergpl$
  5. *
  6. * Copyright (c) 2006-2009, Linden Research, Inc.
  7. *
  8. * Second Life Viewer Source Code
  9. * The source code in this file ("Source Code") is provided by Linden Lab
  10. * to you under the terms of the GNU General Public License, version 2.0
  11. * ("GPL"), unless you have obtained a separate licensing agreement
  12. * ("Other License"), formally executed by you and Linden Lab. Terms of
  13. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  14. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  15. *
  16. * There are special exceptions to the terms and conditions of the GPL as
  17. * it is applied to this Source Code. View the full text of the exception
  18. * in the file doc/FLOSS-exception.txt in this software distribution, or
  19. * online at
  20. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  21. *
  22. * By copying, modifying or distributing this software, you acknowledge
  23. * that you have read and understood your obligations described above,
  24. * and agree to abide by those obligations.
  25. *
  26. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  27. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  28. * COMPLETENESS OR PERFORMANCE.
  29. * $/LicenseInfo$
  30. */
  31. #ifndef LL_LLPANELGROUP_H
  32. #define LL_LLPANELGROUP_H
  33. #include "llpanel.h"
  34. #include "lltimer.h"
  35. #include "llgroupmgr.h"
  36. constexpr F32 UPDATE_MEMBERS_SECONDS_PER_FRAME = 0.005f; // 5ms
  37. class LLOfferInfo;
  38. class LLPanelGroupTab;
  39. class LLTabContainer;
  40. class LLPanelGroupTabObserver
  41. {
  42. public:
  43. LLPanelGroupTabObserver() {}
  44. virtual ~LLPanelGroupTabObserver() {}
  45. virtual void tabChanged() = 0;
  46. };
  47. class LLPanelGroup : public LLPanel,
  48. public LLGroupMgrObserver,
  49. public LLPanelGroupTabObserver
  50. {
  51. public:
  52. LLPanelGroup(const std::string& filename, const std::string& name,
  53. const LLUUID& group_id,
  54. const std::string& initial_tab_selected = std::string());
  55. virtual ~LLPanelGroup();
  56. virtual bool postBuild();
  57. static void onBtnOK(void*);
  58. static void onBtnCancel(void*);
  59. static void onBtnApply(void*);
  60. static void onBtnRefresh(void*);
  61. static void onClickTab(void*,bool);
  62. void handleClickTab();
  63. void setGroupID(const LLUUID& group_id);
  64. void selectTab(std::string tab_name);
  65. // Called when embedded in a floater during a close attempt.
  66. bool canClose();
  67. // Checks if the current tab needs to be applied, and tries to switch to
  68. // the requested tab.
  69. bool attemptTransition();
  70. // Switches to the requested tab (will close() if requested is NULL)
  71. void transitionToTab();
  72. void updateTabVisibility();
  73. // Used by attemptTransition to query the user's response to a tab that
  74. // needs to apply.
  75. bool handleNotifyCallback(const LLSD& notification, const LLSD& response);
  76. bool apply();
  77. void refreshData();
  78. void close();
  79. void draw();
  80. // Group manager observer trigger.
  81. virtual void changed(LLGroupChange gc);
  82. // PanelGroupTab observer trigger
  83. virtual void tabChanged();
  84. void setAllowEdit(bool v) { mAllowEdit = v; }
  85. void showNotice(const std::string& subject, const std::string& message,
  86. bool has_inventory, const std::string& inventory_name,
  87. LLOfferInfo* inventory_offer);
  88. protected:
  89. LLPanelGroupTab* mCurrentTab;
  90. LLPanelGroupTab* mRequestedTab;
  91. LLTabContainer* mTabContainer;
  92. LLButton* mApplyBtn;
  93. LLButton* mRefreshBtn;
  94. LLTimer mRefreshTimer;
  95. bool mIgnoreTransition;
  96. bool mForceClose;
  97. bool mAllowEdit;
  98. bool mShowingNotifyDialog;
  99. std::string mInitialTab;
  100. std::string mFilename;
  101. std::string mDefaultNeedsApplyMesg;
  102. std::string mWantApplyMesg;
  103. };
  104. class LLPanelGroupTab : public LLPanel
  105. {
  106. public:
  107. LLPanelGroupTab(const std::string& name, const LLUUID& group_id)
  108. : LLPanel(name),
  109. mGroupID(group_id),
  110. mAllowEdit(true),
  111. mHasModal(false)
  112. {
  113. }
  114. virtual ~LLPanelGroupTab();
  115. // Factory that returns a new LLPanelGroupFoo tab.
  116. static void* createTab(void* data);
  117. // Triggered when the tab becomes active.
  118. virtual void activate() {}
  119. // Triggered when the tab becomes inactive.
  120. virtual void deactivate() {}
  121. // Asks if something needs to be applied.
  122. // If returning true, this function should modify the message to the user.
  123. virtual bool needsApply(std::string& mesg) { return false; }
  124. // Asks if there is currently a modal dialog being shown.
  125. virtual bool hasModal() { return mHasModal; }
  126. // Request to apply current data.
  127. // If returning fail, this function should modify the message to the user.
  128. virtual bool apply(std::string& mesg) { return true; }
  129. // Request a cancel of changes
  130. virtual void cancel() {}
  131. // Triggered when group information changes in the group manager.
  132. virtual void update(LLGroupChange gc) {}
  133. // This is the text to be displayed when a help button is pressed.
  134. virtual std::string getHelpText() const { return mHelpText; }
  135. // Display anything returned by getHelpText
  136. static void onClickHelp(void* data);
  137. void handleClickHelp();
  138. // This just connects the help button callback.
  139. virtual bool postBuild();
  140. virtual bool isVisibleByAgent();
  141. void setAllowEdit(bool v) { mAllowEdit = v; }
  142. void addObserver(LLPanelGroupTabObserver* obs);
  143. void removeObserver(LLPanelGroupTabObserver* obs);
  144. void notifyObservers();
  145. protected:
  146. LLUUID mGroupID;
  147. LLTabContainer* mTabContainer;
  148. std::string mHelpText;
  149. bool mAllowEdit;
  150. bool mHasModal;
  151. typedef std::set<LLPanelGroupTabObserver*> observer_list_t;
  152. observer_list_t mObservers;
  153. };
  154. #endif // LL_LLPANELGROUP_H