Counter Strike : Global Offensive Source Code
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.

207 lines
6.1 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef BASEANIMSETPRESETFADERPANEL_H
  7. #define BASEANIMSETPRESETFADERPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "movieobjects/animsetattributevalue.h"
  12. #include "dme_controls/dmecontrols_utils.h"
  13. #include "datamodel/dmehandle.h"
  14. #include "movieobjects/proceduralpresets.h"
  15. #include "vgui_controls/PropertyPage.h"
  16. #include "vgui_controls/PropertySheet.h"
  17. #include "vgui_controls/Slider.h"
  18. //-----------------------------------------------------------------------------
  19. // Forward declarations
  20. //-----------------------------------------------------------------------------
  21. class CBaseAnimationSetControl;
  22. class CPresetSlider;
  23. class CBaseAnimationSetEditor;
  24. class CSliderListPanel;
  25. class CAddPresetDialog;
  26. class CDmePreset;
  27. class CDmePresetGroup;
  28. class CDmePresetGroupEditorFrame;
  29. namespace vgui
  30. {
  31. class InputDialog;
  32. }
  33. struct FaderPreview_t
  34. {
  35. FaderPreview_t() :
  36. name( 0 ),
  37. amount( 0 ),
  38. isbeingdragged( false ),
  39. holdingPreviewKey( false ),
  40. values( 0 ),
  41. nProceduralType( PROCEDURAL_PRESET_NOT )
  42. {
  43. }
  44. const char *name;
  45. float amount;
  46. bool isbeingdragged;
  47. bool holdingPreviewKey;
  48. AttributeDict_t *values;
  49. int nProceduralType;
  50. };
  51. CDmePresetGroup *FindAnyPresetGroup( CDmeFilmClip *pFilmClip, const char *pPresetGroupName );
  52. CDmePreset *FindAnyPreset ( CDmeFilmClip *pFilmClip, const char *pPresetGroupName, const char *pPresetName );
  53. //-----------------------------------------------------------------------------
  54. // Base class for the preset fader panel
  55. //-----------------------------------------------------------------------------
  56. class CBaseAnimSetPresetFaderPanel : public vgui::EditablePanel
  57. {
  58. DECLARE_CLASS_SIMPLE( CBaseAnimSetPresetFaderPanel, vgui::EditablePanel );
  59. public:
  60. CBaseAnimSetPresetFaderPanel( vgui::Panel *parent, const char *className, CBaseAnimationSetEditor *editor );
  61. void GetPreviewFader( FaderPreview_t& fader );
  62. void UpdateProceduralPresetSlider( AttributeDict_t *values );
  63. void UpdateControlValues( bool bVisibleOnly = true );
  64. CBaseAnimationSetControl *GetController() { return m_pController; }
  65. void OnDeletePreset( const char *pPresetName );
  66. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  67. virtual void DispatchCurve( int nCurveType );
  68. CPresetSlider *FindPresetSlider( const char *pName );
  69. void SetActivePresetSlider( CPresetSlider *pSlider );
  70. CPresetSlider *GetActivePresetSlider();
  71. protected:
  72. MESSAGE_FUNC( OnShowAddPresetDialog, "ShowAddPresetDialog" );
  73. MESSAGE_FUNC( OnPresetsChanged, "PresetsChanged" );
  74. MESSAGE_FUNC( OnManagePresets, "ManagePresets" );
  75. MESSAGE_FUNC_PARAMS( OnPresetNameSelected, "PresetNameSelected", params );
  76. MESSAGE_FUNC( OnPageChanged, "PageChanged" );
  77. protected:
  78. CPresetSlider *GetSliderForRow( int nSlot );
  79. void UpdateOrCreatePresetSlider( int nSlot, const char *pPresetGroupName, const char *pPresetName );
  80. void RebuildPresetSliders( const char *pPresetGroupName, const CUtlVector< CUtlSymbolLarge > &presetNames );
  81. void AddPreset( const char *pPresetGroupName, const char *pPresetName, bool bAnimated );
  82. void PopulatePresetList( bool bChanged );
  83. CBaseAnimationSetControl *m_pController;
  84. vgui::PropertySheet *m_pSheet;
  85. CUtlVector< vgui::PropertyPage* > m_presetGroupPages;
  86. CSliderListPanel *m_pSliders;
  87. CUtlVector< CPresetSlider* > m_presetSliders;
  88. vgui::DHANDLE< CDmePresetGroupEditorFrame > m_hPresetEditor;
  89. vgui::DHANDLE< CPresetSlider > m_hActivePresetSlider;
  90. friend CBaseAnimationSetControl;
  91. friend CPresetSlider;
  92. };
  93. //-----------------------------------------------------------------------------
  94. //
  95. // CPresetSlider: The actual preset slider itself!
  96. //
  97. //-----------------------------------------------------------------------------
  98. class CPresetSlider : public vgui::Slider
  99. {
  100. DECLARE_CLASS_SIMPLE( CPresetSlider, vgui::Slider );
  101. public:
  102. CPresetSlider( vgui::Panel *parent, CBaseAnimSetPresetFaderPanel *pFaderPanel );
  103. ~CPresetSlider();
  104. void Init( const char *pPresetGroupName, const char *pPresetName );
  105. void Clear();
  106. void SetControlValues( );
  107. float GetCurrent();
  108. void SetPos( float frac );
  109. AttributeDict_t *GetAttributeDict();
  110. bool IsDragging();
  111. void IgnoreCursorMovedEvents( bool bIgnore );
  112. void Deactivate();
  113. const char *GetPresetName();
  114. const char *GetPresetGroupName();
  115. int GetProceduralPresetType() { return m_nProceduralType; }
  116. protected:
  117. virtual void Paint();
  118. virtual void PaintBackground();
  119. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  120. virtual void GetTrackRect( int &x, int &y, int &w, int &h );
  121. virtual void OnMousePressed(vgui::MouseCode code);
  122. virtual void OnMouseReleased(vgui::MouseCode code);
  123. virtual void OnCursorMoved( int x, int y );
  124. virtual void OnCursorEntered();
  125. virtual void OnCursorExited();
  126. MESSAGE_FUNC( OnShowContextMenu, "OnShowContextMenu" );
  127. MESSAGE_FUNC( OnRename, "OnRename" );
  128. MESSAGE_FUNC( OnDelete, "OnDelete" );
  129. MESSAGE_FUNC_PARAMS( OnInputCompleted, "InputCompleted", params );
  130. MESSAGE_FUNC( OnDeleteConfirmed, "OnDeleteConfirmed" );
  131. protected:
  132. KEYBINDING_FUNC( ts_curve_1, KEY_1, 0, OnCurve1, "#ts_curve1_help", 0 );
  133. KEYBINDING_FUNC( ts_curve_2, KEY_2, 0, OnCurve2, "#ts_curve2_help", 0 );
  134. KEYBINDING_FUNC( ts_curve_3, KEY_3, 0, OnCurve3, "#ts_curve3_help", 0 );
  135. KEYBINDING_FUNC( ts_curve_4, KEY_4, 0, OnCurve4, "#ts_curve4_help", 0 );
  136. private:
  137. void OnRenameCompleted( const char *pText, KeyValues *pContextKeyValues );
  138. void UpdateTickPos( int x, int y );
  139. CBaseAnimSetPresetFaderPanel *m_pPresetFaderPanel;
  140. Color m_GradientColor;
  141. Color m_ZeroColor;
  142. Color m_TextColor;
  143. Color m_TextColorFocus;
  144. vgui::TextImage *m_pName;
  145. vgui::DHANDLE< vgui::Menu > m_hContextMenu;
  146. AttributeDict_t m_AttributeLookup;
  147. CUtlSymbolLarge m_presetGroupName;
  148. CUtlSymbolLarge m_presetName;
  149. int m_nProceduralType;
  150. bool m_bReadOnly;
  151. bool m_bIgnoreCursorMovedEvents;
  152. static bool s_bResetMousePosOnMouseUp;
  153. static int s_nMousePosX;
  154. static int s_nMousePosY;
  155. };
  156. #endif // BASEANIMSETPRESETFADERPANEL_H