llfloatersnapshot.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /**
  2. * @file llfloatersnapshot.h
  3. * @brief Snapshot preview window, allowing saving, e-mailing, etc.
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewergpl$
  6. *
  7. * Copyright (c) 2004-2009, Linden Research, Inc.
  8. * Copyright (c) 2009-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_LLFLOATERSNAPSHOT_H
  34. #define LL_LLFLOATERSNAPSHOT_H
  35. #include "llfloater.h"
  36. #include "llselectmgr.h" // For LLAnimPauseRequest
  37. #include "llviewerwindow.h"
  38. class LLButton;
  39. class LLCheckBoxCtrl;
  40. class LLComboBox;
  41. class LLSnapshotLivePreview;
  42. class LLFlyoutButton;
  43. class LLRadioGroup;
  44. class LLSliderCtrl;
  45. class LLSpinCtrl;
  46. class LLTextBox;
  47. class LLToolset;
  48. class LLFloaterSnapshot final : public LLFloater,
  49. public LLFloaterSingleton<LLFloaterSnapshot>
  50. {
  51. friend class LLSnapshotLivePreview;
  52. friend class LLUISingleton<LLFloaterSnapshot,
  53. VisibilityPolicy<LLFloater> >;
  54. protected:
  55. LOG_CLASS(LLFloaterSnapshot);
  56. public:
  57. typedef enum e_snapshot_format : U32
  58. {
  59. SNAPSHOT_FORMAT_PNG,
  60. SNAPSHOT_FORMAT_JPEG,
  61. SNAPSHOT_FORMAT_BMP
  62. } ESnapshotFormat;
  63. bool postBuild() override;
  64. void draw() override;
  65. void onClose(bool app_quitting) override;
  66. // Returns true when temporary texture assets upload is possible and has
  67. // been choosen by the user of this snapshot. HB
  68. bool isTempAsset() const;
  69. static void show(void*);
  70. static void hide(void*);
  71. static void update();
  72. // Setup the floater to take a snapshot for a thumbnail of inventory object
  73. // which UUID is inv_obj_id. HB
  74. void setupForInventoryThumbnail(const LLUUID& inv_obj_id);
  75. private:
  76. // Use show() and hide() only !
  77. LLFloaterSnapshot(const LLSD&);
  78. ~LLFloaterSnapshot() override;
  79. S32 getTypeIndex();
  80. U32 getFormatIndex();
  81. U32 getLayerType();
  82. void updateControls();
  83. void updateLayout();
  84. void comboSetCustom(LLComboBox* combop);
  85. void checkAspectRatio(S32 index);
  86. void resetSnapshotSizeOnUI(S32 width, S32 height);
  87. static void updateResolution(LLUICtrl* ctrlp, void* datap,
  88. bool do_update = false);
  89. static void onClickDiscard(void* datap);
  90. static void onClickKeep(void* datap);
  91. static void onCommitSave(LLUICtrl* ctrlp, void* datap);
  92. static void onClickNewSnapshot(void* datap);
  93. static void onClickAutoSnap(LLUICtrl* ctrlp, void* datap);
  94. static void onClickLess(void* datap);
  95. static void onClickMore(void* datap);
  96. static void onClickUICheck(LLUICtrl* ctrlp, void* datap);
  97. static void onClickHUDCheck(LLUICtrl* ctrlp, void* datap);
  98. static void onClickKeepAspectCheck(LLUICtrl* ctrlp, void* datap);
  99. static void onCommitQuality(LLUICtrl* ctrlp, void* datap);
  100. static void onCommitResolution(LLUICtrl* ctrlp, void* datap);
  101. static void onCommitFreezeFrame(LLUICtrl* ctrlp, void* datap);
  102. static void onCommitLayerTypes(LLUICtrl* ctrlp, void* datap);
  103. static void onCommitSnapshotType(LLUICtrl*, void* datap);
  104. static void onCommitSnapshotFormat(LLUICtrl*, void* datap);
  105. static void onCommitCustomResolution(LLUICtrl* ctrlp, void* datap);
  106. private:
  107. LLButton* mMoreButton;
  108. LLButton* mLessButton;
  109. LLButton* mUploadButton;
  110. LLButton* mSendButton;
  111. LLTextBox* mFileSizeLabel;
  112. LLTextBox* mTypeLabel;
  113. LLTextBox* mFormatLabel;
  114. LLTextBox* mLayerLabel;
  115. LLComboBox* mPostcardSizeCombo;
  116. LLComboBox* mTextureSizeCombo;
  117. LLComboBox* mLocalSizeCombo;
  118. LLComboBox* mThumbnailSizeCombo;
  119. LLComboBox* mLocalFormatCombo;
  120. LLComboBox* mLayerTypeCombo;
  121. LLSpinCtrl* mImageWidthSpinner;
  122. LLSpinCtrl* mImageHeightSpinner;
  123. LLRadioGroup* mSnapshotTypeRadio;
  124. LLSliderCtrl* mImageQualitySlider;
  125. LLFlyoutButton* mSaveButton;
  126. LLCheckBoxCtrl* mUICheck;
  127. LLCheckBoxCtrl* mHUDCheck;
  128. LLCheckBoxCtrl* mAutoCloseCheck;
  129. LLCheckBoxCtrl* mKeepAspectCheck;
  130. LLCheckBoxCtrl* mAutoSnapCheck;
  131. LLCheckBoxCtrl* mFreezeFrameCheck;
  132. LLCheckBoxCtrl* mTempCheck;
  133. LLSnapshotLivePreview* mLivePreview;
  134. LLToolset* mLastToolset;
  135. std::vector<LLAnimPauseRequest> mAvatarPauseHandles;
  136. LLUUID mInventoryObjectId;
  137. static U32 sSavedLastSelectedType;
  138. static bool sAspectRatioCheckOff;
  139. };
  140. class LLSnapshotFloaterView : public LLFloaterView
  141. {
  142. public:
  143. LLSnapshotFloaterView(const std::string& name, const LLRect& rect);
  144. bool handleKey(KEY key, MASK mask, bool called_from_parent) override;
  145. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  146. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  147. bool handleHover(S32 x, S32 y, MASK mask) override;
  148. };
  149. extern LLSnapshotFloaterView* gSnapshotFloaterViewp;
  150. #endif // LL_LLFLOATERSNAPSHOT_H