llpreviewtexture.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * @file llpreviewtexture.h
  3. * @brief LLPreviewTexture class definition
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-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_LLPREVIEWTEXTURE_H
  33. #define LL_LLPREVIEWTEXTURE_H
  34. #include "llbutton.h"
  35. #include "hbfileselector.h"
  36. #include "llframetimer.h"
  37. #include "llpreview.h"
  38. #include "llviewertexture.h"
  39. class LLImageRaw;
  40. class LLPreviewTexture final : public LLPreview
  41. {
  42. public:
  43. LLPreviewTexture(const std::string& name,
  44. const LLRect& rect,
  45. const std::string& title,
  46. const LLUUID& item_uuid,
  47. const LLUUID& object_id,
  48. bool show_keep_discard = false);
  49. LLPreviewTexture(const std::string& name,
  50. const LLRect& rect,
  51. const std::string& title,
  52. const LLUUID& asset_id,
  53. bool copy_to_inv = false);
  54. ~LLPreviewTexture();
  55. void draw() override;
  56. bool canSaveAs() const override;
  57. void saveAs() override;
  58. void loadAsset() override;
  59. EAssetStatus getAssetStatus() override;
  60. LL_INLINE void setNotCopyable() { mIsCopyable = false; }
  61. static void saveAsCallback(HBFileSelector::ESaveFilter type,
  62. std::string& filename, void* user_data);
  63. static void onFileLoadedForSave(bool success,
  64. LLViewerFetchedTexture* src_vi,
  65. LLImageRaw* src,
  66. LLImageRaw* aux_src,
  67. S32 discard_level,
  68. bool is_final,
  69. void* userdata);
  70. LL_INLINE static S32 getPreviewCount() { return sList.size(); }
  71. protected:
  72. void init();
  73. bool setAspectRatio(F32 width, F32 height);
  74. static void onAspectRatioCommit(LLUICtrl*, void* userdata);
  75. static void onRefreshBtn(void* data);
  76. LL_INLINE const char* getTitleName() const override { return "Texture"; }
  77. private:
  78. void updateDimensions();
  79. private:
  80. LLPointer<LLViewerFetchedTexture> mImage;
  81. LLFrameTimer mSavedFileTimer;
  82. std::string mSaveFileName;
  83. LLUUID mImageID;
  84. uuid_list_t mCallbackTextureList;
  85. S32 mImageOldBoostLevel;
  86. S32 mLastHeight;
  87. S32 mLastWidth;
  88. F32 mAspectRatio; // 0 = Unconstrained
  89. bool mShowKeepDiscard;
  90. bool mCopyToInv;
  91. bool mLoadingFullImage;
  92. // This is stored off in a member variable, because the save-as
  93. // button and drag and drop functionality need to know.
  94. bool mIsCopyable;
  95. static std::set<LLPreviewTexture*> sList;
  96. };
  97. #endif // LL_LLPREVIEWTEXTURE_H