diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/panorama/controls/slider.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'public/panorama/controls/slider.h')
| -rw-r--r-- | public/panorama/controls/slider.h | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/public/panorama/controls/slider.h b/public/panorama/controls/slider.h new file mode 100644 index 0000000..6ac4d9f --- /dev/null +++ b/public/panorama/controls/slider.h @@ -0,0 +1,123 @@ +//=========== Copyright Valve Corporation, All rights reserved. ===============// +// +// Purpose: +//=============================================================================// + +#ifndef PANORAMA_SLIDER_H +#define PANORAMA_SLIDER_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "panorama/controls/panel2d.h" + +namespace panorama +{ + +DECLARE_PANEL_EVENT1( SliderValueChanged, float ); +DECLARE_PANEL_EVENT1( SlottedSliderValueChanged, int ); +DECLARE_PANEL_EVENT1( SliderFocusChanged, bool ); + +//----------------------------------------------------------------------------- +// Purpose: Slider control which includes track, progress & thumb +//----------------------------------------------------------------------------- +class CSlider: public CPanel2D +{ + DECLARE_PANEL2D( CSlider, CPanel2D ); + +public: + CSlider( CPanel2D *pParent, const char *pchID ); + virtual ~CSlider(); + + enum ESliderDirection + { + k_EDirectionVertical, + k_EDirectionHorizontal + }; + + void SetMin( float flMin ) { m_flMin = flMin; InvalidateSizeAndPosition(); } + void SetMax( float flMax ) { m_flMax = flMax; InvalidateSizeAndPosition(); } + void SetIncrement( float flValue ) { m_flIncrement = flValue; } + virtual void SetValue( float flValue ); + float GetValue() { return m_flCur; } + float GetDefaultValue() { return m_flDefault; } + void SetDefaultValue ( float flValue ) { m_flDefault = flValue; } + void SetShowDefaultValue( bool bShow ) { m_bShowDefault = bShow; } + void SetDirection( ESliderDirection eValue ); + + virtual bool BSetProperty( CPanoramaSymbol symName, const char *pchValue ); + + virtual bool OnMouseButtonDown( const MouseData_t &code ) OVERRIDE; + virtual bool OnMouseButtonUp( const MouseData_t &code ) OVERRIDE; + virtual void OnMouseMove( float flMouseX, float flMouseY ) OVERRIDE; + virtual bool OnMoveUp( int nRepeats ) OVERRIDE; + virtual bool OnMoveRight( int nRepeats ) OVERRIDE; + virtual bool OnMoveDown( int nRepeats ) OVERRIDE; + virtual bool OnMoveLeft( int nRepeats ) OVERRIDE; + + virtual bool OnActivate(panorama::EPanelEventSource_t eSource); + virtual bool OnCancel(panorama::EPanelEventSource_t eSource); + virtual void OnStyleFlagsChanged(); + virtual void OnResetToDefaultValue(); + + void SetRequiresSelection( bool bRequireSelection ) { m_bRequiresSelection = bRequireSelection; } + +protected: + bool EventPanelActivated( const CPanelPtr< IUIPanel > &pPanel, EPanelEventSource_t eSource ); + virtual void OnLayoutTraverse( float flFinalWidth, float flFinalHeight ); + void SetValueFromMouse( float x, float y ); + float GetMin() { return m_flMin; } + float GetMax() { return m_flMax; } + ESliderDirection GetDirection() { return m_eDirection; } + + CPanel2D *m_pThumb; + CPanel2D *m_pTrack; + CPanel2D *m_pProgress; + CPanel2D *m_pDefaultTick; + bool EventActivated( const panorama::CPanelPtr< panorama::IUIPanel > &pPanel, panorama::EPanelEventSource_t eSource ); + bool EventCancelled( const panorama::CPanelPtr< panorama::IUIPanel > &pPanel, panorama::EPanelEventSource_t eSource ); + bool EventStyleFlagsChanged( const panorama::CPanelPtr< panorama::IUIPanel > &pPanel ); + bool EventResetToDefault( const panorama::CPanelPtr< panorama::IUIPanel > &pPanel ); + +private: + bool AllowInteraction( void ); + bool ShouldShowDefault( void ) { return m_bShowDefault; } + + float m_flMin; + float m_flMax; + float m_flDefault; + float m_flCur; + float m_flLast; + float m_flIncrement; + bool m_bRequiresSelection; + bool m_bDraggingThumb; + bool m_bShowDefault; + ESliderDirection m_eDirection; + + float m_flLastMouseX; + float m_flLastMouseY; +}; + +class CSlottedSlider : public CSlider +{ + DECLARE_PANEL2D( CSlottedSlider, CSlider ); +public: + CSlottedSlider( CPanel2D *pParent, const char *pchID ); + virtual ~CSlottedSlider(); + + virtual bool BSetProperty( CPanoramaSymbol symName, const char *pchValue ); + virtual void SetValue( float flValue ); + void SetValue( int nValue ); + virtual void OnLayoutTraverse( float flFinalWidth, float flFinalHeight ); + int GetCurrentNotch() { return m_nCurNotch; } + +private: + int m_nNumNotches; + int m_nCurNotch; + CUtlVector< CPanel2D* > m_pNotches; +}; + +} // namespace panorama + +#endif // PANORAMA_SLIDER_H |