hbfloaterthumbnail.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**
  2. * @file hbfloaterthumbnail.h
  3. * @author Henri Beauchamp
  4. * @brief HBFloaterThumbnail class declaration
  5. *
  6. * $LicenseInfo:firstyear=2023&license=viewergpl$
  7. *
  8. * Copyright (c) 2023-2024, Henri Beauchamp.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #ifndef LL_HBFLOATERTHUMBNAIL_H
  34. #define LL_HBFLOATERTHUMBNAIL_H
  35. #include "hbfastmap.h"
  36. #include "llfloater.h"
  37. class LLButton;
  38. class LLFetchedGLTFMaterial;
  39. class LLIconCtrl;
  40. class LLImageRaw;
  41. class LLInventoryObject;
  42. class LLTextBox;
  43. class LLScrollListItem;
  44. class HBThumbnailDropTarget;
  45. class LLView;
  46. class LLViewerFetchedTexture;
  47. class LLViewerInventoryItem;
  48. class LLViewerTexture;
  49. class HBFloaterThumbnail final : public LLFloater
  50. {
  51. friend class HBThumbnailDropTarget;
  52. protected:
  53. LOG_CLASS(HBFloaterThumbnail);
  54. public:
  55. LL_INLINE bool isForViewOnly() const { return mOwner != NULL; }
  56. // Note: here the 'id' is either the agent's inventory item Id, or the
  57. // inventory item Id XORed with its container object (task) Id.
  58. static HBFloaterThumbnail* findInstance(const LLUUID& id);
  59. // When 'ownerp' is not NULL, show the (unique) temporary floater without
  60. // controls, and parent it to the floater owning 'ownerp'.
  61. static void showInstance(const LLUUID& inv_obj_id,
  62. const LLUUID& task_id = LLUUID::null,
  63. LLView* ownerp = NULL);
  64. // Omitting 'id' (or passing a null UUID) causes this call to close the
  65. // (unique) temporary thumbnail view floater. If the floater is not the
  66. // temporary one and got unsaved changes, it is not closed. Note that 'id'
  67. // is either the agent's inventory object Id, or the task_id XORed with
  68. // the Id of the item it contains and with which the thumbnail is
  69. // associated.
  70. static void hideInstance(const LLUUID& id = LLUUID::null);
  71. // Note: the raw image may be modified (scaled down) by this method.
  72. static void uploadThumbnail(const LLUUID& inv_obj_id,
  73. LLPointer<LLImageRaw> rawp);
  74. private:
  75. // Use showInstance() only
  76. HBFloaterThumbnail(const LLUUID& inv_obj_id, const LLUUID& task_id,
  77. LLFloater* ownerp);
  78. ~HBFloaterThumbnail() override;
  79. void unregister();
  80. // LLFloater overrides
  81. bool postBuild() override;
  82. void draw() override;
  83. void updateDropTarget();
  84. void setInventoryObjectId(const LLUUID& inv_obj_id);
  85. LLInventoryObject* getInventoryObject();
  86. void setThumbTexture();
  87. void setThumbnail();
  88. void uploadFailure(const std::string& reason);
  89. static void uploadThumbnailCoro(std::string url, LLSD data, LLUUID id);
  90. void onChoosenTexture(LLViewerInventoryItem* itemp, bool final_choice);
  91. static void onBtnChange(LLUICtrl* ctrlp, void* userdata);
  92. static void onBtnCancel(void* userdata);
  93. static void onBtnClose(void* userdata);
  94. private:
  95. LLUUID mTaskId;
  96. LLUUID mInventoryObjectId;
  97. LLUUID mInitialThumbnailId;
  98. LLUUID mThumbnailId;
  99. LLUUID mTempThumbId;
  100. HBThumbnailDropTarget* mDropTarget;
  101. LLFloater* mOwner;
  102. LLIconCtrl* mIcon;
  103. LLTextBox* mInventoryObjectName;
  104. LLButton* mCancelButton;
  105. LLScrollListItem* mCopyThumbnail;
  106. LLScrollListItem* mPasteThumbnail;
  107. LLScrollListItem* mClearThumbnail;
  108. LLScrollListItem* mUndoThumbnail;
  109. LLPointer<LLFetchedGLTFMaterial> mMaterialp;
  110. LLPointer<LLViewerTexture> mMatTexturep;
  111. LLPointer<LLViewerFetchedTexture> mTexturep;
  112. LLRect mThumbnailRect;
  113. std::string mTempFilename;
  114. bool mMustClose;
  115. bool mIsCategory;
  116. bool mIsMaterialPreview;
  117. typedef fast_hmap<LLUUID, HBFloaterThumbnail*> instances_map_t;
  118. static instances_map_t sInstances;
  119. };
  120. #endif // LL_HBFLOATERTHUMBNAIL_H