hbfloaterareasearch.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /**
  2. * @file hbfloaterareasearch.h
  3. * @brief HBFloaterAreaSearch class definition
  4. *
  5. * This class implements a floater where all surroundind objects are listed.
  6. *
  7. * $LicenseInfo:firstyear=2009&license=viewergpl$
  8. *
  9. * Original code Copyright (c) 2009 Modular Systems Ltd. All rights reserved.
  10. * Rewritten/augmented code Copyright (c) 2010-2019 Henri Beauchamp.
  11. *
  12. * Second Life Viewer Source Code
  13. * The source code in this file ("Source Code") is provided by Linden Lab
  14. * to you under the terms of the GNU General Public License, version 2.0
  15. * ("GPL"), unless you have obtained a separate licensing agreement
  16. * ("Other License"), formally executed by you and Linden Lab. Terms of
  17. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  18. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  19. *
  20. * There are special exceptions to the terms and conditions of the GPL as
  21. * it is applied to this Source Code. View the full text of the exception
  22. * in the file doc/FLOSS-exception.txt in this software distribution, or
  23. * online at
  24. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  25. *
  26. * By copying, modifying or distributing this software, you acknowledge
  27. * that you have read and understood your obligations described above,
  28. * and agree to abide by those obligations.
  29. *
  30. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  31. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  32. * COMPLETENESS OR PERFORMANCE.
  33. * $/LicenseInfo$
  34. *
  35. * Revision history:
  36. * - Initial backport from Emerald viewer, modified, debugged, optimized and
  37. * improved by Henri Beauchamp - Feb 2010.
  38. * - Speed optimization by Henri Beauchamp - Jul 2011.
  39. * - Tracked object info added by Henri Beauchamp - Nov 2011.
  40. * - Further modified and augmented with mutes, derender, report & inspect
  41. * functions. Henri Beauchamp - May 2013.
  42. * - Full rewrite by Henri Beauchamp - Aug 2014.
  43. * - Another partial rewrite by Henri Beauchamp - Nov 2016.
  44. * - Yet another large rewrite, with proper exclusion of attachments and
  45. * viewer-side only objects to avoid fake "pending" requests and to prevent
  46. * sending to the server the bogus/spammy/useless messages corresponding to
  47. * them. Fixed the bug that caused group-owned objects to stay forever in the
  48. * "pending" requests list. Added the "Show", "Mute particles", "Mute owner"
  49. * and "Copy UUID" action. Changed input lines for search input lines.
  50. * Henri Beauchamp - Jan 2019.
  51. * - On "Refresh", clear the cached objects list so that any renamed object
  52. * will be properly refreshed. Henri Beauchamp - Apr 2021.
  53. */
  54. #ifndef LL_HBFLOATERAREASEARCH_H
  55. #define LL_HBFLOATERAREASEARCH_H
  56. #include "llfloater.h"
  57. class LLButton;
  58. class LLFlyoutButton;
  59. class LLMessageSystem;
  60. class LLScrollListCtrl;
  61. class LLSearchEditor;
  62. class LLTextBox;
  63. class LLViewerObject;
  64. class HBFloaterAreaSearch final : public LLFloater,
  65. public LLFloaterSingleton<HBFloaterAreaSearch>
  66. {
  67. friend class LLUISingleton<HBFloaterAreaSearch,
  68. VisibilityPolicy<LLFloater> >;
  69. protected:
  70. LOG_CLASS(HBFloaterAreaSearch);
  71. public:
  72. // Used in llappviewer.cpp to trigger idle updates to background object
  73. // properties fetches.
  74. static void idleUpdate();
  75. // Used in llviewermessage.cpp to inform us we changed region
  76. static void newRegion();
  77. // Called from llviewermessage.cpp, in the callback for the
  78. // RequestObjectPropertiesFamily message reply.
  79. static void processObjectPropertiesFamily(LLMessageSystem* msg);
  80. static void setDirty() { sIsDirty = true; }
  81. private:
  82. // Open only via LLFloaterSingleton interface, i.e. showInstance() or
  83. // toggleInstance().
  84. HBFloaterAreaSearch(const LLSD&);
  85. bool postBuild() override;
  86. void draw() override;
  87. enum OBJECT_COLUMN_ORDER
  88. {
  89. LIST_OBJECT_NAME,
  90. LIST_OBJECT_DESC,
  91. LIST_OBJECT_OWNER,
  92. LIST_OBJECT_GROUP
  93. };
  94. void addInResultsList(const LLUUID& object_id, bool match_filters);
  95. void setButtonsStatus();
  96. // Returns true when objectp is not NULL, not a viewer-side object (cloud,
  97. // particle, sky, surface patch, etc), not an avatar, a root primitive, not
  98. // temporary and not an attachment.
  99. static bool isObjectOfInterest(LLViewerObject* objectp);
  100. // Returns true if the object details are up to date, false otherwise and
  101. // in that latter case, sends an update request if needed.
  102. static bool checkObjectDetails(const LLUUID& object_id);
  103. static void onSelectResult(LLUICtrl*, void* userdata);
  104. static void onDoubleClickResult(void* userdata);
  105. static void onClickRefresh(void*);
  106. static void onClickClose(void* userdata);
  107. static void onClickDerender(void* userdata);
  108. static void onClickReport(void* userdata);
  109. static void onClickShow(void* userdata);
  110. static void onClickMute(LLUICtrl* ctrl, void* userdata);
  111. static void onClickInspect(LLUICtrl* ctrl, void* userdata);
  112. static void onSearchEdit(const std::string& search_string, void* userdata);
  113. class HBObjectDetails
  114. {
  115. public:
  116. HBObjectDetails()
  117. : time_stamp(-10000.f)
  118. {
  119. }
  120. LL_INLINE bool valid()
  121. {
  122. return owner_id.notNull() || group_id.notNull();
  123. }
  124. public:
  125. F32 time_stamp;
  126. LLUUID owner_id;
  127. LLUUID group_id;
  128. std::string name;
  129. std::string desc;
  130. };
  131. private:
  132. LLTextBox* mCounterText;
  133. LLScrollListCtrl* mResultsList;
  134. LLSearchEditor* mNameInputLine;
  135. LLSearchEditor* mDescInputLine;
  136. LLSearchEditor* mOwnerInputLine;
  137. LLSearchEditor* mGroupInputLine;
  138. LLFlyoutButton* mMuteFlyoutBtn;
  139. LLFlyoutButton* mInspectFlyoutBtn;
  140. LLButton* mDerenderBtn;
  141. LLButton* mReportBtn;
  142. LLButton* mShowBtn;
  143. LLButton* mRefreshBtn;
  144. LLUUID mSearchUUID;
  145. std::string mSearchedName;
  146. std::string mSearchedDesc;
  147. std::string mSearchedOwner;
  148. std::string mSearchedGroup;
  149. static F32 sLastUpdateTime;
  150. static bool sIsDirty;
  151. static bool sUpdateDone;
  152. static bool sTracking;
  153. static LLUUID sTrackingObjectID;
  154. static LLVector3d sTrackingLocation;
  155. static std::string sTrackingInfoLine;
  156. typedef fast_hmap<LLUUID, HBObjectDetails> object_details_map_t;
  157. static object_details_map_t sObjectDetails;
  158. };
  159. #endif // LL_HBFLOATERAREASEARCH_H