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.

132 lines
3.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Core Movie Maker UI API
  4. //
  5. //=============================================================================
  6. #include "toolutils/toolmenubar.h"
  7. #include "vgui_controls/Label.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. using namespace vgui;
  11. //-----------------------------------------------------------------------------
  12. //
  13. // Version that only has tool name and info
  14. //
  15. //-----------------------------------------------------------------------------
  16. //-----------------------------------------------------------------------------
  17. // Constructor
  18. //-----------------------------------------------------------------------------
  19. CToolMenuBar::CToolMenuBar( CBaseToolSystem *pParent, const char *pPanelName ) :
  20. BaseClass( (Panel *)pParent, pPanelName ),
  21. m_pToolSystem( pParent )
  22. {
  23. m_pInfo = new Label( this, "Info", "" );
  24. m_pToolName = new Label( this, "ToolName", "" );
  25. }
  26. CBaseToolSystem *CToolMenuBar::GetToolSystem()
  27. {
  28. return m_pToolSystem;
  29. }
  30. //-----------------------------------------------------------------------------
  31. // Sets the tool bar's name
  32. //-----------------------------------------------------------------------------
  33. void CToolMenuBar::SetToolName( const char *pName )
  34. {
  35. m_pToolName->SetText( pName );
  36. InvalidateLayout();
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Sets the tool bar info
  40. //-----------------------------------------------------------------------------
  41. void CToolMenuBar::SetInfo( const char *pInfo )
  42. {
  43. m_pInfo->SetText( pInfo );
  44. InvalidateLayout();
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Lays out the menu bar
  48. //-----------------------------------------------------------------------------
  49. void CToolMenuBar::PerformLayout()
  50. {
  51. BaseClass::PerformLayout();
  52. int w, h;
  53. GetSize( w, h );
  54. int cw, ch;
  55. m_pInfo->GetContentSize( cw, ch );
  56. int right = w - cw - 20;
  57. m_pInfo->SetBounds( right, 0, cw, h );
  58. m_pToolName->GetContentSize( cw, ch );
  59. m_pToolName->SetBounds( right - cw - 5, 0, cw, h );
  60. }
  61. //-----------------------------------------------------------------------------
  62. //
  63. // Version that only has tool name, info, and file name
  64. //
  65. //-----------------------------------------------------------------------------
  66. //-----------------------------------------------------------------------------
  67. // Constructor
  68. //-----------------------------------------------------------------------------
  69. CToolFileMenuBar::CToolFileMenuBar( CBaseToolSystem *parent, const char *panelName ) :
  70. BaseClass( parent, panelName )
  71. {
  72. m_pFileName = new Label( this, "FileName", "" );
  73. }
  74. void CToolFileMenuBar::SetFileName( char const *name )
  75. {
  76. m_pFileName->SetText( name );
  77. InvalidateLayout();
  78. }
  79. //-----------------------------------------------------------------------------
  80. // Performs layout
  81. //-----------------------------------------------------------------------------
  82. void CToolFileMenuBar::PerformLayout()
  83. {
  84. BaseClass::PerformLayout();
  85. int w, h;
  86. GetSize( w, h );
  87. int cw, ch;
  88. m_pInfo->GetContentSize( cw, ch );
  89. int right = w - cw - 20;
  90. m_pToolName->GetContentSize( cw, ch );
  91. int barx, bary;
  92. GetContentSize( barx, bary );
  93. int faredge = right - cw - 5- 2;
  94. int nearedge = barx + 2;
  95. int mid = ( nearedge + faredge ) * 0.5f;
  96. m_pFileName->GetContentSize( cw, ch );
  97. m_pFileName->SetBounds( mid - cw * 0.5f, 0, cw, h );
  98. }