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.

201 lines
5.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef SCENERAMPTOOL_H
  7. #define SCENERAMPTOOL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include <mxtk/mx.h>
  12. #include "studio.h"
  13. #include "utlvector.h"
  14. #include "faceposertoolwindow.h"
  15. class CChoreoEvent;
  16. class CChoreoScene;
  17. class CChoreoWidgetDrawHelper;
  18. class CChoreoView;
  19. struct CExpressionSample;
  20. #define IDC_REDO_SRT 1000
  21. #define IDC_UNDO_SRT 1001
  22. #define IDC_SRT_DELETE 1002
  23. #define IDC_SRT_DESELECT 1003
  24. #define IDC_SRT_SELECTALL 1004
  25. #define IDC_SRT_CHANGESCALE 1005
  26. #define IDC_SRT_RAMPHSCROLL 1006
  27. #define IDC_SRT_EDGEPROPERTIES 1007
  28. #define FP_SRT_SELECTION_TOLERANCE 30.0f
  29. #define FP_SRT_SELECTION_RECTANGLE_TOLERANCE 5.0f
  30. #define FP_SRT_ADDSAMPLE_TOLERANCE 5.0f
  31. template< class T > class CCurveEditorHelper;
  32. class SceneRampTool : public mxWindow, public IFacePoserToolWindow
  33. {
  34. public:
  35. // Construction
  36. SceneRampTool( mxWindow *parent );
  37. ~SceneRampTool( void );
  38. virtual void Think( float dt );
  39. void ScrubThink( float dt, bool scrubbing );
  40. virtual bool IsScrubbing( void ) const;
  41. virtual bool IsProcessing( void );
  42. virtual int handleEvent( mxEvent *event );
  43. virtual void redraw( void );
  44. virtual bool PaintBackground();
  45. void GetScrubHandleRect( RECT& rcHandle, float scrub, bool clipped = false );
  46. void DrawScrubHandle( CChoreoWidgetDrawHelper& drawHelper, RECT& rcHandle, float scrub, bool reference );
  47. void DrawTimeLine( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, float left, float right );
  48. void DrawSceneEnd( CChoreoWidgetDrawHelper& drawHelper );
  49. void SetMouseOverPos( int x, int y );
  50. void GetMouseOverPos( int &x, int& y );
  51. void GetMouseOverPosRect( RECT& rcPos );
  52. void DrawMouseOverPos( CChoreoWidgetDrawHelper& drawHelper, RECT& rcPos );
  53. void DrawMouseOverPos();
  54. void DrawScrubHandles();
  55. CChoreoScene *GetSafeScene( void );
  56. bool IsMouseOverScrubHandle( mxEvent *event );
  57. void ForceScrubPosition( float newtime );
  58. void ForceScrubPositionFromSceneTime( float scenetime );
  59. void SetScrubTime( float t );
  60. void SetScrubTargetTime( float t );
  61. void DrawSamplesSimple( CChoreoWidgetDrawHelper& drawHelper, CChoreoScene *scene, bool clearbackground, COLORREF sampleColor, RECT &rcSamples );
  62. virtual void OnModelChanged();
  63. void SetMousePositionForEvent( mxEvent *event );
  64. int NumSamples();
  65. CExpressionSample *GetSample( int idx );
  66. void PreDataChanged( char const *undodescription );
  67. void PostDataChanged( char const *redodescription );
  68. CExpressionSample *GetSampleUnderMouse( int mx, int my, float tolerance = FP_SRT_SELECTION_TOLERANCE );
  69. void GetWorkList( bool reflect, CUtlVector< SceneRampTool * >& list );
  70. private:
  71. void GetSampleTrayRect( RECT& rc );
  72. void DrawSamples( CChoreoWidgetDrawHelper& drawHelper, RECT &rcSamples );
  73. void SelectPoints( void );
  74. void DeselectAll();
  75. void SelectAll();
  76. void Delete( void );
  77. int CountSelected( void );
  78. void MoveSelectedSamples( float dfdx, float dfdy );
  79. void StartDragging( int dragtype, int startx, int starty, HCURSOR cursor );
  80. void AddFocusRect( RECT& rc );
  81. void OnMouseMove( mxEvent *event );
  82. void DrawFocusRect( void );
  83. void ShowContextMenu( mxEvent *event, bool include_track_menus );
  84. void GetWorkspaceLeftRight( int& left, int& right );
  85. void SetClickedPos( int x, int y );
  86. float GetTimeForClickedPos( void );
  87. void DrawAutoHighlight( mxEvent *event );
  88. void ApplyBounds( int& mx, int& my );
  89. void CalcBounds( int movetype );
  90. void OnUndo( void );
  91. void OnRedo( void );
  92. void OnRevert( void );
  93. void OnEdgeProperties();
  94. void DrawTimingTags( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
  95. void DrawRelativeTagsForEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, CChoreoEvent *event, float starttime, float endtime );
  96. void DrawAbsoluteTagsForEvent( CChoreoWidgetDrawHelper& drawHelper, RECT &rc, CChoreoEvent *event, float starttime, float endtime );
  97. // Readjust slider
  98. void MoveTimeSliderToPos( int x );
  99. void OnChangeScale();
  100. int ComputeHPixelsNeeded( void );
  101. float GetPixelsPerSecond( void );
  102. void InvalidateLayout( void );
  103. void RepositionHSlider( void );
  104. void GetStartAndEndTime( float& st, float& ed );
  105. float GetEventEndTime();
  106. float GetTimeValueForMouse( int mx, bool clip = false );
  107. int GetPixelForTimeValue( float time, bool *clipped = NULL );
  108. float m_flScrub;
  109. float m_flScrubTarget;
  110. enum
  111. {
  112. DRAGTYPE_NONE = 0,
  113. DRAGTYPE_SCRUBBER,
  114. DRAGTYPE_MOVEPOINTS_VALUE,
  115. DRAGTYPE_MOVEPOINTS_TIME,
  116. DRAGTYPE_SELECTION,
  117. };
  118. int m_nMousePos[ 2 ];
  119. bool m_bUseBounds;
  120. int m_nMinX;
  121. int m_nMaxX;
  122. HCURSOR m_hPrevCursor;
  123. int m_nDragType;
  124. int m_nStartX;
  125. int m_nStartY;
  126. int m_nLastX;
  127. int m_nLastY;
  128. int m_nClickedX;
  129. int m_nClickedY;
  130. struct CFocusRect
  131. {
  132. RECT m_rcOrig;
  133. RECT m_rcFocus;
  134. };
  135. CUtlVector < CFocusRect > m_FocusRects;
  136. bool m_bSuppressLayout;
  137. // Height/width of scroll bars
  138. int m_nScrollbarHeight;
  139. float m_flLeftOffset;
  140. mxScrollbar *m_pHorzScrollBar;
  141. int m_nLastHPixelsNeeded;
  142. // How many pixels per second we are showing in the UI
  143. float m_flPixelsPerSecond;
  144. // Do we need to move controls?
  145. bool m_bLayoutIsValid;
  146. float m_flLastDuration;
  147. float m_flScrubberTimeOffset;
  148. int m_nUndoSetup;
  149. CCurveEditorHelper< SceneRampTool > *m_pHelper;
  150. friend class CChoreoView;
  151. };
  152. extern SceneRampTool *g_pSceneRampTool;
  153. #endif // SCENERAMPTOOL_H