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.

125 lines
4.2 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef BASEANIMSETCONTROLGROUPPANEL_H
  7. #define BASEANIMSETCONTROLGROUPPANEL_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "dme_controls/BaseAnimationSetEditorController.h"
  12. #include "vgui_controls/EditablePanel.h"
  13. #include "datamodel/dmehandle.h"
  14. #include "tier1/utlntree.h"
  15. #include "tier1/utldict.h"
  16. //-----------------------------------------------------------------------------
  17. // Forward declarations
  18. //-----------------------------------------------------------------------------
  19. class CBaseAnimationSetEditor;
  20. class CBaseAnimationSetControl;
  21. class CDmeAnimationSet;
  22. class CDmeChannel;
  23. class CDmeControlGroup;
  24. class CDmeDag;
  25. class CDmElement;
  26. class CAnimGroupTree;
  27. namespace vgui
  28. {
  29. class TreeView;
  30. class IScheme;
  31. class Menu;
  32. };
  33. //-----------------------------------------------------------------------------
  34. // Animation set editor control/group tree item types. These types represent
  35. // the different types of items which can be added to the m_hGroupsTree. They
  36. // are used in determining the action to be taken when an item is selected and
  37. // to determine the content of the right click context menu for an item.
  38. //-----------------------------------------------------------------------------
  39. enum AnimTreeItemType_t
  40. {
  41. ANIMTREE_ITEM_ANIMSET,
  42. ANIMTREE_ITEM_GROUP,
  43. ANIMTREE_ITEM_CONTROL,
  44. ANIMTREE_ITEM_COMPONENT,
  45. };
  46. //-----------------------------------------------------------------------------
  47. // Panel which shows a tree of controls
  48. //-----------------------------------------------------------------------------
  49. class CBaseAnimSetControlGroupPanel : public vgui::EditablePanel, public IAnimationSetControlSelectionChangedListener
  50. {
  51. DECLARE_CLASS_SIMPLE( CBaseAnimSetControlGroupPanel, EditablePanel );
  52. public:
  53. CBaseAnimSetControlGroupPanel( vgui::Panel *parent, char const *className, CBaseAnimationSetEditor *editor, bool bControlStateInterface );
  54. virtual ~CBaseAnimSetControlGroupPanel();
  55. CBaseAnimationSetEditor *GetEditor() { return m_hEditor; }
  56. void ChangeAnimationSetClip( CDmeFilmClip *pFilmClip );
  57. void OnControlsAddedOrRemoved();
  58. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  59. CDmeDag *GetWorkCameraParent();
  60. // Rebuild the tree view from the current control selection hierarchy
  61. void RebuildTree( bool bRestoreExpansion );
  62. void UpdateSelection();
  63. // inherited from IAnimationSetControlSelectionChangedListener
  64. virtual void OnControlSelectionChanged();
  65. virtual void ExpandTreeToControl( const CDmElement *pSelection, TransformComponent_t nComponentFlags );
  66. // Create a new control group containing the selected controls
  67. void CreateGroupFromSelectedControls();
  68. protected:
  69. MESSAGE_FUNC_INT_INT( OnTreeViewItemSelected, "TreeViewItemSelected", itemIndex, replaceSelection );
  70. MESSAGE_FUNC_INT( OnTreeViewItemDeselected, "TreeViewItemDeselected", itemIndex );
  71. MESSAGE_FUNC( OnTreeViewStartRangeSelection, "TreeViewStartRangeSelection" );
  72. MESSAGE_FUNC( OnTreeViewFinishRangeSelection, "TreeViewFinishRangeSelection" );
  73. MESSAGE_FUNC( OnTreeViewItemSelectionCleared, "TreeViewItemSelectionCleared" );
  74. MESSAGE_FUNC_INT( OnTreeViewOpenContextMenu, "TreeViewOpenContextMenu", itemID );
  75. protected:
  76. void SelectAnimTreeItem( int itemIndex, ESelectionMode selectionMode );
  77. struct ElementExpansion_t
  78. {
  79. CDmElement *m_pElement;
  80. TransformComponent_t m_ComponentFlags;
  81. };
  82. // pre-order traversal so that we can ExpandItems linearly
  83. void CollectExpandedItems( CUtlVector< ElementExpansion_t > &expandedNodes, int nParentIndex );
  84. // assumes expandedNodes have parents before children (ie expandedNodes is a pre-order traversal)
  85. void ExpandItems( const CUtlVector< ElementExpansion_t > &expandedNodes );
  86. SelectionState_t UpdateSelection_R( int nParentIndex );
  87. vgui::DHANDLE< CBaseAnimationSetEditor > m_hEditor;
  88. vgui::DHANDLE< CAnimGroupTree > m_hGroups;
  89. CBaseAnimationSetControl *m_pController;
  90. Color m_FullSelectionColor;
  91. Color m_PartialSelectionColor;
  92. Color m_ContextMenuHighlightColor;
  93. friend class CAnimGroupTree;
  94. };
  95. #endif // BASEANIMSETCONTROLGROUPPANEL_H