1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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
|