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.

186 lines
5.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef BASEANIMSETATTRIBUTESLIDERPANEL_H
  7. #define BASEANIMSETATTRIBUTESLIDERPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "datamodel/dmehandle.h"
  12. #include "vgui_controls/EditablePanel.h"
  13. #include "dme_controls/AnimSetAttributeValue.h"
  14. #include "dme_controls/logpreview.h"
  15. #include "movieobjects/dmechannel.h"
  16. #include "dme_controls/BaseAnimSetPresetFaderPanel.h"
  17. using namespace vgui;
  18. //-----------------------------------------------------------------------------
  19. // Forward declarations
  20. //-----------------------------------------------------------------------------
  21. class CBaseAnimationSetEditor;
  22. class CDmeAnimationSet;
  23. class CAttributeSlider;
  24. class CDmElement;
  25. class CDmeChannel;
  26. class CDmeFilmClip;
  27. class CDmeTimeSelection;
  28. struct LogPreview_t;
  29. enum RecordingMode_t;
  30. class DmeLog_TimeSelection_t;
  31. class CPresetSideFilterSlider;
  32. struct FaderPreview_t;
  33. enum
  34. {
  35. FADER_NAME_CHANGED = ( 1<<0 ),
  36. FADER_DRAG_CHANGED = ( 1<<1 ),
  37. FADER_CTRLKEY_CHANGED = ( 1<<2 ),
  38. FADER_AMOUNT_CHANGED = ( 1<<3 ),
  39. FADER_PRESET_CHANGED = ( 1<< 4 ),
  40. };
  41. //-----------------------------------------------------------------------------
  42. // CBaseAnimSetAttributeSliderPanel
  43. //-----------------------------------------------------------------------------
  44. class CBaseAnimSetAttributeSliderPanel : public vgui::EditablePanel
  45. {
  46. DECLARE_CLASS_SIMPLE( CBaseAnimSetAttributeSliderPanel, vgui::EditablePanel );
  47. public:
  48. CBaseAnimSetAttributeSliderPanel( vgui::Panel *parent, const char *className, CBaseAnimationSetEditor *editor );
  49. public:
  50. void ChangeAnimationSet( CDmeAnimationSet *newAnimSet );
  51. void SetVisibleControlsForSelectionGroup( CUtlSymbolTable& visible );
  52. void ApplyPreset( float flScale, AttributeDict_t& values );
  53. bool GetAttributeSliderValue( AttributeValue_t *pValue, const char *name );
  54. void SetLogPreviewControlFromSlider( CAttributeSlider *pSlider );
  55. CDmElement *GetElementFromSlider( CAttributeSlider *pSlider );
  56. CDmElement *GetLogPreviewControl();
  57. CBaseAnimationSetEditor* GetEditor();
  58. void RecomputePreview();
  59. virtual void PerformRecomputePreview();
  60. virtual CDmeFilmClip *GetCurrentShot();
  61. virtual CDmeFilmClip *GetCurrentMovie();
  62. virtual void ApplySchemeSettings( vgui::IScheme *scheme );
  63. CUtlVector< LogPreview_t > *GetActiveTransforms();
  64. void GetChannelsForControl( CDmElement *control, CDmeChannel *channels[LOG_PREVIEW_MAX_CHANNEL_COUNT] );
  65. void SetTimeSelectionParametersForRecordingChannels( float flIntensity );
  66. void MoveToSlider( CAttributeSlider *pCurrentSlider, int nDirection );
  67. void SetLogPreviewControl( CDmElement *ctrl );
  68. void ClearSelectedControls();
  69. void SetControlSelected( CAttributeSlider *slider, bool state );
  70. void SetControlSelected( CDmElement *control, bool state );
  71. virtual int BuildVisibleControlList( CUtlVector< LogPreview_t >& list );
  72. virtual int BuildFullControlList( CUtlVector< LogPreview_t >& list );
  73. virtual void StampValueIntoLogs( CDmElement *control, AnimationControlType_t type, float flValue );
  74. struct VisItem_t
  75. {
  76. VisItem_t() :
  77. element( NULL ), selected( false ), index( 0 )
  78. {
  79. }
  80. CDmElement *element;
  81. bool selected;
  82. int index;
  83. };
  84. void GetVisibleControls( CUtlVector< VisItem_t >& list );
  85. // Returns true if slider is visible
  86. bool GetSliderValues( AttributeValue_t *pValue, int nIndex );
  87. virtual void SetupForPreset( FaderPreview_t &fader, int nChangeFlags );
  88. float GetBalanceSliderValue();
  89. protected:
  90. virtual void OnThink();
  91. virtual void OnCommand( const char *pCommand );
  92. virtual bool ApplySliderValues( bool force );
  93. virtual void PerformLayout();
  94. KEYBINDING_FUNC( deselectall, KEY_ESCAPE, 0, OnKBDeselectAll, "#deselectall_help", 0 );
  95. protected:
  96. struct ChannelToSliderLookup_t
  97. {
  98. ChannelToSliderLookup_t() : type( ANIM_CONTROL_VALUE ) {}
  99. CDmeHandle< CDmeChannel > ch;
  100. CDmeHandle< CDmElement > slider;
  101. AnimationControlType_t type;
  102. static bool Less( const ChannelToSliderLookup_t& lhs, const ChannelToSliderLookup_t& rhs );
  103. };
  104. void UpdatePreviewSliderTimes();
  105. void ActivateControlSetInMode( int mode, int otherChannelsMode, int hiddenChannelsMode, CAttributeSlider *whichSlider = NULL );
  106. void MaybeAddPreviewLog( CDmeFilmClip *shot, CUtlVector< LogPreview_t >& list, CDmElement *control, bool bDragging, bool isActiveLog, bool bSelected );
  107. CAttributeSlider *FindSliderForControl( CDmElement *control );
  108. virtual void GetActiveTimeSelectionParams( DmeLog_TimeSelection_t& params );
  109. vgui::DHANDLE< CBaseAnimationSetEditor > m_hEditor;
  110. // Visible slider list
  111. vgui::DHANDLE< vgui::PanelListPanel > m_Sliders;
  112. // All sliders
  113. CUtlVector< CAttributeSlider * > m_SliderList;
  114. vgui::Button *m_pLeftRightBoth[ 2 ];
  115. CPresetSideFilterSlider *m_pPresetSideFilter;
  116. CDmeHandle< CDmeAnimationSet > m_AnimSet;
  117. CDmeHandle< CDmElement > m_PreviewControl;
  118. CDmeHandle< CDmElement > m_CtrlKeyPreviewSliderElement;
  119. vgui::DHANDLE< CAttributeSlider > m_CtrlKeyPreviewSlider;
  120. float m_flEstimatedValue;
  121. CUtlString m_PreviousPreviewFader;
  122. FaderPreview_t m_Previous;
  123. int m_nFaderChangeFlags;
  124. bool m_bRequestedNewPreview : 1;
  125. int m_nActiveControlSetMode;
  126. CUtlRBTree< ChannelToSliderLookup_t, unsigned short > m_ChannelToSliderLookup;
  127. // list of bones/root transforms which are in the control set
  128. CUtlVector< LogPreview_t > m_ActiveTransforms;
  129. float m_flRecomputePreviewTime;
  130. CUtlVector< LogPreview_t > m_CurrentPreview;
  131. float m_flPrevTime;
  132. };
  133. inline CBaseAnimationSetEditor* CBaseAnimSetAttributeSliderPanel::GetEditor()
  134. {
  135. return m_hEditor;
  136. }
  137. #endif // BASEANIMSETATTRIBUTESLIDERPANEL_H