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.

174 lines
4.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef GESTURETOOL_H
  8. #define GESTURETOOL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <mxtk/mx.h>
  13. #include "studio.h"
  14. #include "utlvector.h"
  15. #include "faceposertoolwindow.h"
  16. class CChoreoEvent;
  17. class CChoreoWidgetDrawHelper;
  18. class CChoreoView;
  19. class CEventAbsoluteTag;
  20. #define IDC_REDO_GT 1000
  21. #define IDC_UNDO_GT 1001
  22. #define IDC_GT_DELETE_TAG 1002
  23. #define IDC_GT_INSERT_TAG 1003
  24. #define IDC_GT_REVERT 1004
  25. #define IDC_GT_CHANGESCALE 1005
  26. #define IDC_GESTUREHSCROLL 1006
  27. class GestureTool : public mxWindow, public IFacePoserToolWindow
  28. {
  29. public:
  30. // Construction
  31. GestureTool( mxWindow *parent );
  32. ~GestureTool( void );
  33. virtual void Think( float dt );
  34. void ScrubThink( float dt, bool scrubbing );
  35. virtual bool IsScrubbing( void ) const;
  36. virtual bool IsProcessing( void );
  37. virtual int handleEvent( mxEvent *event );
  38. virtual void redraw( void );
  39. virtual bool PaintBackground();
  40. void SetEvent( CChoreoEvent *event );
  41. void GetScrubHandleRect( RECT& rcHandle, float scrub, bool clipped = false );
  42. void GetScrubHandleReferenceRect( RECT& rcHandle, float scrub, bool clipped = false );
  43. void DrawScrubHandle( CChoreoWidgetDrawHelper& drawHelper, RECT& rcHandle, float scrub, bool reference );
  44. void DrawTimeLine( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, float left, float right );
  45. void DrawEventEnd( CChoreoWidgetDrawHelper& drawHelper );
  46. void DrawAbsoluteTags( CChoreoWidgetDrawHelper& drawHelper );
  47. bool GetAbsTagRect( RECT& rcClient, CChoreoEvent *event, int tagtype, CEventAbsoluteTag *tag, RECT& rcTag );
  48. void GetTagTrayRect( RECT &rcClient, int tagtype, RECT& rcTray );
  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. CChoreoEvent *GetSafeEvent( 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. virtual void OnModelChanged();
  62. private:
  63. void StartDragging( int dragtype, int startx, int starty, HCURSOR cursor );
  64. void AddFocusRect( RECT& rc );
  65. void OnMouseMove( mxEvent *event );
  66. void DrawFocusRect( void );
  67. void ShowContextMenu( mxEvent *event, bool include_track_menus );
  68. void GetWorkspaceLeftRight( int& left, int& right );
  69. void SetClickedPos( int x, int y );
  70. float GetTimeForClickedPos( void );
  71. void ApplyBounds( int& mx, int& my );
  72. void CalcBounds( int movetype );
  73. void OnUndo( void );
  74. void OnRedo( void );
  75. CEventAbsoluteTag *IsMouseOverTag( int mx, int my );
  76. int GetTagTypeForMouse( int mx, int my );
  77. int GetTagTypeForTag( CEventAbsoluteTag const *tag );
  78. void OnInsertTag( void );
  79. void OnDeleteTag( void );
  80. void OnRevert( void );
  81. void DrawRelativeTags( CChoreoWidgetDrawHelper& drawHelper, RECT& rc );
  82. void DrawRelativeTagsForEvent( CChoreoWidgetDrawHelper& drawHelper, RECT& rc, CChoreoEvent *gesture, CChoreoEvent *event, float starttime, float endtime );
  83. // Readjust slider
  84. void MoveTimeSliderToPos( int x );
  85. void OnChangeScale();
  86. int ComputeHPixelsNeeded( void );
  87. float GetPixelsPerSecond( void );
  88. void InvalidateLayout( void );
  89. void RepositionHSlider( void );
  90. void GetStartAndEndTime( float& st, float& ed );
  91. float GetEventEndTime();
  92. float GetTimeValueForMouse( int mx, bool clip = false );
  93. int GetPixelForTimeValue( float time, bool *clipped = NULL );
  94. float m_flScrub;
  95. float m_flScrubTarget;
  96. enum
  97. {
  98. DRAGTYPE_NONE = 0,
  99. DRAGTYPE_SCRUBBER,
  100. DRAGTYPE_ABSOLUTE_TIMING_TAG,
  101. };
  102. int m_nFocusEventGlobalID;
  103. int m_nMousePos[ 2 ];
  104. bool m_bUseBounds;
  105. int m_nMinX;
  106. int m_nMaxX;
  107. HCURSOR m_hPrevCursor;
  108. int m_nDragType;
  109. int m_nStartX;
  110. int m_nStartY;
  111. int m_nLastX;
  112. int m_nLastY;
  113. int m_nClickedX;
  114. int m_nClickedY;
  115. struct CFocusRect
  116. {
  117. RECT m_rcOrig;
  118. RECT m_rcFocus;
  119. };
  120. CUtlVector < CFocusRect > m_FocusRects;
  121. CChoreoEvent *m_pLastEvent;
  122. bool m_bSuppressLayout;
  123. // Height/width of scroll bars
  124. int m_nScrollbarHeight;
  125. float m_flLeftOffset;
  126. mxScrollbar *m_pHorzScrollBar;
  127. int m_nLastHPixelsNeeded;
  128. // How many pixels per second we are showing in the UI
  129. float m_flPixelsPerSecond;
  130. // Do we need to move controls?
  131. bool m_bLayoutIsValid;
  132. float m_flLastDuration;
  133. bool m_bInSetEvent;
  134. float m_flScrubberTimeOffset;
  135. friend class CChoreoView;
  136. };
  137. extern GestureTool *g_pGestureTool;
  138. #endif // GESTURETOOL_H