llfloateranimpreview.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /**
  2. * @file llfloateranimpreview.h
  3. * @brief LLFloaterAnimPreview class definition
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewergpl$
  6. *
  7. * Copyright (c) 2004-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_LLFLOATERANIMPREVIEW_H
  33. #define LL_LLFLOATERANIMPREVIEW_H
  34. #include "llcharacter.h"
  35. #include "llextendedstatus.h"
  36. #include "llquaternion.h"
  37. #include "lldynamictexture.h"
  38. #include "hbfloateruploadasset.h"
  39. class LLButton;
  40. class LLKeyframeMotion;
  41. class LLViewerJointMesh;
  42. class LLVOAvatar;
  43. class LLPreviewAnimation final : public LLViewerDynamicTexture
  44. {
  45. protected:
  46. LOG_CLASS(LLPreviewAnimation);
  47. protected:
  48. ~LLPreviewAnimation() override;
  49. public:
  50. LLPreviewAnimation(S32 width, S32 height);
  51. S8 getType() const override;
  52. bool render() override;
  53. LL_INLINE bool needsRender() override { return mDummyAvatar.notNull(); }
  54. void rotate(F32 yaw_radians, F32 pitch_radians);
  55. void zoom(F32 zoom_delta);
  56. void setZoom(F32 zoom_amt);
  57. void pan(F32 right, F32 up);
  58. LL_INLINE LLVOAvatar* getDummyAvatar() { return mDummyAvatar; }
  59. protected:
  60. LLPointer<LLVOAvatar> mDummyAvatar;
  61. LLVector3 mCameraOffset;
  62. F32 mCameraDistance;
  63. F32 mCameraYaw;
  64. F32 mCameraPitch;
  65. F32 mCameraZoom;
  66. };
  67. class LLFloaterAnimPreview final : public HBFloaterUploadAsset
  68. {
  69. protected:
  70. LOG_CLASS(LLFloaterAnimPreview);
  71. public:
  72. LLFloaterAnimPreview(const std::string& filename);
  73. ~LLFloaterAnimPreview() override;
  74. protected:
  75. // LLFloater overrides
  76. bool postBuild() override;
  77. void draw() override;
  78. void refresh() override;
  79. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  80. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  81. bool handleHover(S32 x, S32 y, MASK mask) override;
  82. bool handleScrollWheel(S32 x, S32 y, S32 clicks) override;
  83. void onMouseCaptureLost() override;
  84. // HBFloaterUploadAsset override
  85. void uploadAsset() override;
  86. private:
  87. std::map <std::string, std::string> getJointAliases();
  88. void setAnimCallbacks();
  89. void resetMotion();
  90. LLVOAvatar* getAvatar();
  91. LLKeyframeMotion* getMotion();
  92. static void onBtnOK(void* userdata);
  93. static void onBtnPlay(void* userdata);
  94. static void onBtnStop(void* userdata);
  95. static void onSliderMove(LLUICtrl*, void* userdata);
  96. static void onCommitBaseAnim(LLUICtrl*, void* userdata);
  97. static void onCommitLoop(LLUICtrl*, void* userdata);
  98. static void onCommitLoopIn(LLUICtrl* ctrlp, void* userdata);
  99. static void onCommitLoopOut(LLUICtrl* ctrlp, void* userdata);
  100. static bool validateLoopIn(LLUICtrl*, void* userdata);
  101. static bool validateLoopOut(LLUICtrl*, void* userdata);
  102. static void onCommitName(LLUICtrl*, void* userdata);
  103. static void onCommitHandPose(LLUICtrl*, void* userdata);
  104. static void onCommitEmote(LLUICtrl*, void* userdata);
  105. static void onCommitPriority(LLUICtrl*, void* userdata);
  106. static void onCommitEaseIn(LLUICtrl*, void* userdata);
  107. static void onCommitEaseOut(LLUICtrl*, void* userdata);
  108. static bool validateEaseIn(LLUICtrl*, void* userdata);
  109. static bool validateEaseOut(LLUICtrl*, void* userdata);
  110. static void onSaveComplete(const LLUUID& asset_id, LLAssetType::EType type,
  111. void* userdata, S32 status, LLExtStat ext_stat);
  112. private:
  113. LLPointer<LLPreviewAnimation> mAnimPreview;
  114. LLButton* mPlayButton;
  115. LLButton* mStopButton;
  116. LLUIImagePtr mPlayImage;
  117. LLUIImagePtr mPlaySelectedImage;
  118. LLUIImagePtr mPauseImage;
  119. LLUIImagePtr mPauseSelectedImage;
  120. LLRect mPreviewRect;
  121. LLRectf mPreviewImageRect;
  122. LLAssetID mMotionID;
  123. LLTransactionID mTransactionID;
  124. LLAnimPauseRequest mPauseRequest;
  125. S32 mLastMouseX;
  126. S32 mLastMouseY;
  127. bool mInWorld;
  128. bool mBadAnimation;
  129. std::map<std::string, LLUUID> mIDList;
  130. };
  131. #endif // LL_LLFLOATERANIMPREVIEW_H