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.

170 lines
4.2 KiB

  1. //========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VGUI_VPROFPANEL_H
  8. #define VGUI_VPROFPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/TreeViewListControl.h>
  13. #include <vgui_controls/Frame.h>
  14. #include <vgui/IScheme.h>
  15. //-----------------------------------------------------------------------------
  16. // Forward declarations
  17. //-----------------------------------------------------------------------------
  18. class CVProfNode;
  19. class CVProfile;
  20. class CProfileHierarchyPanel : public vgui::CTreeViewListControl
  21. {
  22. DECLARE_CLASS_SIMPLE( CProfileHierarchyPanel, vgui::CTreeViewListControl );
  23. public:
  24. CProfileHierarchyPanel(vgui::Panel *parent, const char *panelName);
  25. ~CProfileHierarchyPanel();
  26. struct PanelEntry_t
  27. {
  28. PanelEntry_t() :
  29. label( 0 ),
  30. dataname( UTL_INVAL_SYMBOL )
  31. {
  32. }
  33. vgui::Label *label;
  34. CUtlSymbol dataname;
  35. };
  36. struct ColumnPanels_t
  37. {
  38. ColumnPanels_t();
  39. ColumnPanels_t( const ColumnPanels_t& src );
  40. void AddColumn( int index, char const *name, vgui::Label *label );
  41. void Refresh( KeyValues *kv );
  42. int treeViewItem;
  43. CUtlVector< PanelEntry_t > m_Columns;
  44. };
  45. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  46. virtual int AddItem( KeyValues *data, int parentItemIndex, ColumnPanels_t& columnPanels );
  47. virtual void ModifyItem( KeyValues *data, int itemIndex );
  48. virtual void SetItemColors( int id, const Color& fg, const Color& bg );
  49. virtual void SetItemColumnColors( int id, int col, const Color& fg, const Color& bg );
  50. virtual void PerformLayout();
  51. virtual void RemoveAll();
  52. virtual void PostChildPaint();
  53. virtual void ExpandItem(int itemIndex, bool bExpand);
  54. virtual bool IsItemExpanded( int itemIndex );
  55. virtual KeyValues *GetItemData(int itemIndex);
  56. public:
  57. void HideAll();
  58. static bool PanelsLessFunc( const ColumnPanels_t& lhs, const ColumnPanels_t& rhs )
  59. {
  60. return lhs.treeViewItem < rhs.treeViewItem;
  61. }
  62. CUtlRBTree< ColumnPanels_t, int > m_Panels;
  63. vgui::HFont m_itemFont;
  64. };
  65. //-----------------------------------------------------------------------------
  66. // Purpose:
  67. //-----------------------------------------------------------------------------
  68. class CVProfPanel : public vgui::Frame
  69. {
  70. DECLARE_CLASS_SIMPLE( CVProfPanel, vgui::Frame );
  71. public:
  72. CVProfPanel( vgui::Panel *pParent, const char *pElementName );
  73. ~CVProfPanel();
  74. void UpdateProfile( float filteredtime );
  75. // Command handlers
  76. void UserCmd_ShowVProf( void );
  77. void UserCmd_HideVProf( void );
  78. // Inherited from vgui::Frame
  79. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  80. virtual void Close();
  81. virtual void Paint();
  82. virtual void OnTick( void );
  83. virtual void OnCommand( const char *command );
  84. void ExpandAll( void );
  85. void CollapseAll( void );
  86. void ExpandGroup( const char *pGroupName );
  87. void Reset();
  88. protected:
  89. virtual void PerformLayout();
  90. private:
  91. MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", data );
  92. MESSAGE_FUNC_PTR( OnCheckButtonChecked, "CheckButtonChecked", panel );
  93. private:
  94. void AddColumns( CProfileHierarchyPanel::ColumnPanels_t& cp );
  95. void ExpandGroupRecursive( int nBudgetGroupID, CVProfNode *pNode );
  96. void FillTree( KeyValues *pKeyValues, CVProfNode *pNode, int parent );
  97. int UpdateVProfTreeEntry( KeyValues *pKeyValues, CVProfNode *pNode, int parent );
  98. // Populates the budget group combo box
  99. void PopulateBudgetGroupComboBox();
  100. private:
  101. int m_fShowVprofHeld;
  102. CProfileHierarchyPanel *m_pHierarchy;
  103. int m_RootItem;
  104. vgui::ComboBox *m_pVProfCategory;
  105. vgui::ComboBox *m_pVProfSort;
  106. vgui::CheckButton *m_pHierarchicalView;
  107. vgui::CheckButton *m_pVerbose;
  108. int m_nLastBudgetGroupCount;
  109. int m_nCurrentBudgetGroup;
  110. bool m_bHierarchicalView;
  111. vgui::Button *m_pStepForward;
  112. vgui::Button *m_pStepBack;
  113. vgui::Button *m_pGotoButton;
  114. vgui::Label *m_pPlaybackLabel;
  115. vgui::Button *m_pRedoSort;
  116. vgui::ScrollBar *m_pPlaybackScroll;
  117. int m_iLastPlaybackTick;
  118. CVProfile *m_pVProfile;
  119. };
  120. //-----------------------------------------------------------------------------
  121. // Global accessor
  122. //-----------------------------------------------------------------------------
  123. CVProfPanel *GetVProfPanel();
  124. #endif // VGUI_VPROFPANEL_H