Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TIMELINEITEM_H
  8. #define TIMELINEITEM_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <mxtk/mx.h>
  13. #include "utlvector.h"
  14. #include "ExpressionSample.h"
  15. class CExpression;
  16. class ExpressionTool;
  17. class CFlexAnimationTrack;
  18. class CChoreoWidgetDrawHelper;
  19. class CChoreoView;
  20. template< class T > class CCurveEditorHelper;
  21. #define FP_TL_SELECTION_TOLERANCE 30.0f
  22. #define FP_TL_SELECTION_RECTANGLE_TOLERANCE 5.0f
  23. #define FP_TL_ADDSAMPLE_TOLERANCE 5.0f
  24. class TimelineItem
  25. {
  26. public:
  27. // Construction
  28. TimelineItem( mxWindow *workspace );
  29. ~TimelineItem( void );
  30. virtual int handleEvent( mxEvent *event );
  31. virtual void Draw( CChoreoWidgetDrawHelper& drawHelper );
  32. void DrawEventEnd( CChoreoWidgetDrawHelper& drawHelper );
  33. void DrawSelf( void );
  34. void SetExpressionInfo( CFlexAnimationTrack *track, int flexnum );
  35. void Clear( bool preserveundo );
  36. void SetCollapsed( bool state );
  37. bool IsCollapsed( void ) const;
  38. void SetActive( bool state );
  39. bool IsActive( void );
  40. int GetHeight( void );
  41. void ResetHeight();
  42. // If samples > 0
  43. bool IsValid( void );
  44. void SetEditType( int type );
  45. int GetEditType( void );
  46. void SetBounds( const RECT& rect );
  47. void GetBounds( RECT& rect );
  48. void SetVisible( bool vis );
  49. bool GetVisible( void ) const;
  50. int CountSelected( void );
  51. CFlexAnimationTrack *GetSafeTrack( void );
  52. int GetNumSelected( void );
  53. void Copy( void );
  54. void Paste( void );
  55. void SelectAll( void );
  56. void DeselectAll( void );
  57. void Delete( void );
  58. void GetLastMouse( int& mx, int& my )
  59. {
  60. mx = m_nLastX;
  61. my = m_nLastY;
  62. }
  63. void SnapAll();
  64. void SnapSelected();
  65. void DeletePoints( float start, float end );
  66. float GetTimeForMouse( int mx, bool clip = false );
  67. int GetMouseForTime( float t, bool *clipped = NULL );
  68. void SetMousePositionForEvent( mxEvent *event );
  69. int NumSamples();
  70. CExpressionSample *GetSample( int idx );
  71. void PreDataChanged( char const *undodescription );
  72. void PostDataChanged( char const *redodescription );
  73. CExpressionSample *GetSampleUnderMouse( int mx, int my, float tolerance = FP_TL_SELECTION_TOLERANCE );
  74. void GetWorkList( bool reflect, CUtlVector< TimelineItem * >& list );
  75. private:
  76. enum
  77. {
  78. DRAGTYPE_NONE = 0,
  79. DRAGTYPE_MOVEPOINTS_VALUE,
  80. DRAGTYPE_MOVEPOINTS_TIME,
  81. DRAGTYPE_SELECTION,
  82. DRAGTYPE_GROW,
  83. };
  84. bool CanHaveGrowHandle();
  85. void DrawGrowHandle( CChoreoWidgetDrawHelper& helper, RECT& handleRect );
  86. void GetGrowHandleRect( RECT& rc );
  87. bool IsMouseOverGrowHandle( int x, int y);
  88. void MouseDrag( int x, int y, int modifiers, bool snap = false );
  89. void DrawGrowRect();
  90. void DrawFocusRect( void );
  91. void SelectPoints( void );
  92. void OnDoubleClicked( void );
  93. void DrawAutoHighlight( mxEvent *event );
  94. int m_nDragging;
  95. int m_nLastX;
  96. int m_nLastY;
  97. int m_nStartX;
  98. int m_nStartY;
  99. void AddSample( CExpressionSample const& sample );
  100. void DrawRelativeTags( CChoreoWidgetDrawHelper& drawHelper );
  101. int m_nNumSelected;
  102. int m_nFlexNum;
  103. bool m_bCollapsed;
  104. char m_szTrackName[ 128 ];
  105. int m_nEditType;
  106. int m_nUndoSetup;
  107. RECT m_rcBounds;
  108. bool m_bVisible;
  109. mxWindow *m_pWorkspace;
  110. double m_flLastClickTime;
  111. int m_nCurrentHeight;
  112. CCurveEditorHelper< TimelineItem > *m_pHelper;
  113. };
  114. #endif // TIMELINEITEM_H