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.

86 lines
2.5 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef VUMETER_H
  6. #define VUMETER_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "panorama/controls/panel2d.h"
  11. namespace panorama
  12. {
  13. DECLARE_PANEL_EVENT1( VUMeterBarsChanged, int );
  14. //////////////////////////////////////////////////////////////////////////
  15. //
  16. // volume bars control for volume/mic levels
  17. //
  18. class CVUMeter: public panorama::CPanel2D
  19. {
  20. DECLARE_PANEL2D( CVUMeter, panorama::CPanel2D );
  21. public:
  22. CVUMeter( panorama::CPanel2D *pParent, const char *pchID );
  23. virtual ~CVUMeter();
  24. virtual bool BSetProperty( CPanoramaSymbol symName, const char *pchValue ) OVERRIDE;
  25. virtual void OnInitializedFromLayout();
  26. int GetNumActiveBars() const { return m_numActive; }
  27. void SetNumActiveBars( int numActive );
  28. int GetNumBarsTotal() const { return m_numBars; }
  29. virtual bool OnMoveLeft( int cRepeats );
  30. virtual bool OnMoveRight( int cRepeats );
  31. // Override these to avoid focus slipping away when setting with analog
  32. virtual bool OnMoveUp( int nRepeats );
  33. virtual bool OnMoveDown( int nRepeats );
  34. virtual bool OnMouseButtonUp(const MouseData_t &code);
  35. virtual bool OnMouseWheel(const MouseData_t &code);
  36. virtual void OnMouseMove(float flMouseX, float flMouseY);
  37. virtual bool OnActivate(panorama::EPanelEventSource_t eSource);
  38. virtual bool OnCancel(panorama::EPanelEventSource_t eSource);
  39. virtual void OnStyleFlagsChanged();
  40. // if VU meter is "writable," it will be a tab stop, and be focusable. when activated
  41. // it will enter a mode where you can set the bar with the dpad. if VU meter is not
  42. // writable, it just displays a value.
  43. void SetWritable( bool bWritable );
  44. bool EventActivated( const panorama::CPanelPtr< panorama::IUIPanel > &pPanel, panorama::EPanelEventSource_t eSource );
  45. bool EventCancelled( const panorama::CPanelPtr< panorama::IUIPanel > &pPanel, panorama::EPanelEventSource_t eSource );
  46. bool EventStyleFlagsChanged( const panorama::CPanelPtr< panorama::IUIPanel > &pPanel );
  47. #ifdef DBGFLAG_VALIDATE
  48. virtual void ValidateClientPanel( CValidator &validator, const tchar *pchName ) OVERRIDE;
  49. #endif
  50. protected:
  51. bool OnLeftRight( int dx );
  52. bool m_bWritable;
  53. int m_numBars, m_numActive;
  54. CPanoramaSymbol m_symBarPanelType;
  55. CPanoramaSymbol m_symBarPanelAddClass;
  56. CPanoramaSymbol m_symBarPanelActiveClass;
  57. CUtlVector< panorama::CPanel2D * > m_arrBars;
  58. float m_flLastMouseX;
  59. float m_flLastMouseY;
  60. };
  61. } // namespace panorama
  62. #endif // VUMETER_H