UIAnimation.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #ifndef __UIANIMATION_H__
  2. #define __UIANIMATION_H__
  3. #include "UIButton.h"
  4. #pragma once
  5. namespace DuiLib {
  6. class UILIB_API IUIAnimation
  7. {
  8. public:
  9. virtual ~IUIAnimation() { NULL; }
  10. virtual BOOL StartAnimation(int nElapse, int nTotalFrame, int nAnimationID = 0, BOOL bLoop = FALSE) = 0;
  11. virtual void StopAnimation(int nAnimationID = 0) = 0;
  12. virtual BOOL IsAnimationRunning(int nAnimationID) = 0;
  13. virtual int GetCurrentFrame(int nAnimationID = 0) = 0;
  14. virtual BOOL SetCurrentFrame(int nFrame, int nAnimationID = 0) = 0;
  15. virtual void OnAnimationStep(int nTotalFrame, int nCurFrame, int nAnimationID) = 0;
  16. virtual void OnAnimationStart(int nAnimationID, BOOL bFirstLoop) = 0;
  17. virtual void OnAnimationStop(int nAnimationID) = 0;
  18. virtual void OnAnimationElapse(int nAnimationID) = 0;
  19. };
  20. class UILIB_API CAnimationData
  21. {
  22. public:
  23. CAnimationData(int nElipse, int nFrame, int nID, BOOL bLoop)
  24. {
  25. m_bFirstLoop = TRUE;
  26. m_nCurFrame = 0;
  27. m_nElapse = nElipse;
  28. m_nTotalFrame = nFrame;
  29. m_bLoop = bLoop;
  30. m_nAnimationID = nID;
  31. }
  32. //protected:
  33. public:
  34. friend class CDUIAnimation;
  35. int m_nAnimationID;
  36. int m_nElapse;
  37. int m_nTotalFrame;
  38. int m_nCurFrame;
  39. BOOL m_bLoop;
  40. BOOL m_bFirstLoop;
  41. };
  42. class UILIB_API CUIAnimation: public IUIAnimation
  43. {
  44. struct Imp;
  45. public:
  46. CUIAnimation();
  47. ~CUIAnimation();
  48. public:
  49. void Attach(CControlUI* pOwner);
  50. virtual BOOL StartAnimation(int nElapse, int nTotalFrame, int nAnimationID = 0, BOOL bLoop = FALSE);
  51. virtual void StopAnimation(int nAnimationID = 0);
  52. virtual BOOL IsAnimationRunning(int nAnimationID);
  53. virtual int GetCurrentFrame(int nAnimationID = 0);
  54. virtual BOOL SetCurrentFrame(int nFrame, int nAnimationID = 0);
  55. virtual void OnAnimationStart(int nAnimationID, BOOL bFirstLoop) {};
  56. virtual void OnAnimationStep(int nTotalFrame, int nCurFrame, int nAnimationID) {};
  57. virtual void OnAnimationStop(int nAnimationID) {};
  58. virtual void OnAnimationElapse(int nAnimationID);
  59. protected:
  60. CAnimationData* GetAnimationDataByID(int nAnimationID);
  61. protected:
  62. CControlUI* m_pControl;
  63. Imp * m_pImp;
  64. };
  65. } // namespace DuiLib
  66. #endif // __UIANIMATION_H__