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.

160 lines
4.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #if !defined( MXEXPRESSIONTRAY_H )
  8. #define MXEXPRESSIONTRAY_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #define IDC_TRAYSCROLL 1001
  13. #define IDC_CONTEXT_NEWEXP 1002
  14. #define IDC_CONTEXT_EDITEXP 1003
  15. #define IDC_CONTEXT_SAVEEXP 1004
  16. #define IDC_CONTEXT_DELETEXP 1005
  17. #define IDC_CONTEXT_REVERT 1012
  18. #define IDC_AB 1014
  19. #define IDC_THUMBNAIL_INCREASE 1015
  20. #define IDC_THUMBNAIL_DECREASE 1016
  21. #define IDC_CONTEXT_CREATEBITMAP 1017
  22. #define COLOR_TRAYBACKGROUND RGB( 240, 240, 220 )
  23. class ControlPanel;
  24. class FlexPanel;
  25. class mxScrollbar;
  26. class mxCheckBox;
  27. class CChoreoView;
  28. class CExpression;
  29. class CExpClass;
  30. class mxButton;
  31. class CChoreoWidgetDrawHelper;
  32. #include "faceposertoolwindow.h"
  33. #include "mxbitmaptools.h"
  34. //-----------------------------------------------------------------------------
  35. // Purpose:
  36. //-----------------------------------------------------------------------------
  37. class mxExpressionTray : public mxWindow, public IFacePoserToolWindow
  38. {
  39. public:
  40. mxExpressionTray( mxWindow *parent, int id = 0 );
  41. virtual ~mxExpressionTray ( void );
  42. virtual void redraw ();
  43. virtual bool PaintBackground( void );
  44. virtual int handleEvent (mxEvent *event);
  45. void ThumbnailIncrease( void );
  46. void ThumbnailDecrease( void );
  47. void RestoreThumbnailSize( void );
  48. void AB( void );
  49. void Select( int exp, bool deselect = true );
  50. void Deselect( void );
  51. int CountSelected( void );
  52. void SetCellSize( int cellsize );
  53. void ReloadBitmaps( void );
  54. virtual void OnModelChanged();
  55. private: // Data structures
  56. typedef void (mxExpressionTray::*ETMEMBERFUNC)( int cell );
  57. class mxETButton
  58. {
  59. public:
  60. mxETButton *next;
  61. char m_szName[ 32 ];
  62. bool m_bActive;
  63. RECT m_rc;
  64. char m_szToolTip[ 128 ];
  65. mxbitmapdata_t *m_pImage;
  66. ETMEMBERFUNC m_fnCallback;
  67. };
  68. private: // Methods
  69. void ChangeWeightOfExpressionInGroup( CExpClass *active, CExpression *exp, CExpression *group );
  70. int GetCellUnderPosition( int x, int y );
  71. bool ComputeRect( int cell, int& rcx, int& rcy, int& rcw, int& rch );
  72. int ComputePixelsNeeded( void );
  73. void RepositionSlider();
  74. void SetClickedCell( int cell );
  75. void ShowRightClickMenu( int mx, int my );
  76. void DrawThumbNail( CExpClass *active, CExpression *current, CChoreoWidgetDrawHelper& helper,
  77. int rcx, int rcy, int rcw, int rch, int c, int selected, bool updateselection );
  78. void DrawDirtyFlag( CChoreoWidgetDrawHelper& helper, CExpression *current, int rcx, int rcy, int rcw, int rch );
  79. void DrawExpressionFocusRect( CChoreoWidgetDrawHelper& helper, int x, int y, int w, int h, COLORREF clr );
  80. void DrawExpressionDescription( CChoreoWidgetDrawHelper& helper, int x, int y, int w, int h, const char *expressionname, const char *description );
  81. void CreateButtons( void );
  82. void DeleteAllButtons( void );
  83. void AddButton( const char *name, const char *tooltip, const char *bitmap,
  84. ETMEMBERFUNC pfnCallback, bool active, int x, int y, int w, int h );
  85. mxETButton *GetItemUnderCursor( int x, int y );
  86. void DrawButton( CChoreoWidgetDrawHelper& helper, int cell, mxETButton *btn );
  87. void ActivateButton( const char *name, bool active );
  88. mxETButton *FindButton( const char *name );
  89. void ET_Undo( int cell );
  90. void ET_Redo( int cell );
  91. void DrawFocusRect( void );
  92. private: // Data
  93. mxETButton *m_pButtons;
  94. mxScrollbar *slScrollbar;
  95. int m_nTopOffset;
  96. int m_nLastNumExpressions;
  97. int m_nGranularity;
  98. // For A/B
  99. int m_nPrevCell;
  100. int m_nCurCell;
  101. // For context menu
  102. int m_nClickedCell;
  103. // Formatting
  104. int m_nButtonSquare;
  105. int m_nGap;
  106. int m_nDescriptionHeight;
  107. int m_nSnapshotWidth;
  108. int m_nSnapshotHeight;
  109. // For detecting that the slider thumbs need to be recomputed
  110. int m_nPreviousExpressionCount;
  111. bool m_bDragging;
  112. RECT m_rcFocus;
  113. RECT m_rcOrig;
  114. int m_nDragCell;
  115. int m_nXStart;
  116. int m_nYStart;
  117. mxButton *m_pABButton;
  118. mxButton *m_pThumbnailIncreaseButton;
  119. mxButton *m_pThumbnailDecreaseButton;
  120. };
  121. extern mxExpressionTray *g_pExpressionTrayTool;
  122. #endif // MXEXPRESSIONTRAY_H