forked from hitmen047/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplitter.h
98 lines (74 loc) · 2.48 KB
/
Splitter.h
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef SPLITTER_H
#define SPLITTER_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui_controls/EditablePanel.h>
namespace vgui
{
enum SplitterMode_t
{
SPLITTER_MODE_HORIZONTAL = 0,
SPLITTER_MODE_VERTICAL
};
class SplitterHandle;
class SplitterChildPanel;
//-----------------------------------------------------------------------------
// Purpose: Thin line used to divide sections, can be moved dragged!
//-----------------------------------------------------------------------------
class Splitter : public EditablePanel
{
DECLARE_CLASS_SIMPLE( Splitter, EditablePanel );
public:
// nCount is the number of splitters to create.
// NOTE: The constructor here will create (nCount+1) EditablePanel children
// and name them child0...childN for .res file purposes.
Splitter( Panel *parent, const char *name, SplitterMode_t mode, int nCount );
~Splitter();
// Evenly respace all splitters
void EvenlyRespaceSplitters();
// respace splitters using given fractions (must sum to 1)
void RespaceSplitters( float *flFractions );
// Inherited from Panel
virtual void ApplySettings(KeyValues *inResourceData);
virtual void GetSettings( KeyValues *outResourceData );
virtual void PerformLayout();
virtual void OnSizeChanged(int newWide, int newTall);
virtual void ApplyUserConfigSettings(KeyValues *userConfig);
virtual void GetUserConfigSettings(KeyValues *userConfig);
virtual bool HasUserConfigSettings() { return true; }
// Sets the splitter color
void SetSplitterColor( Color c );
// Enables borders on the splitters
void EnableBorders( bool bEnable );
// Locks the size of a particular child in pixels.
void LockChildSize( int nChildIndex, int nSize );
void UnlockChildSize( int nChildIndex );
private:
void RecreateSplitters( int nCount );
struct SplitterInfo_t
{
SplitterChildPanel *m_pPanel; // This panel is to the left or above the handle
SplitterHandle *m_pHandle;
float m_flPos;
bool m_bLocked;
int m_nLockedSize;
};
int GetPosRange();
int GetSplitterCount() const;
int GetSplitterPosition( int nIndex );
void SetSplitterPosition( int nIndex, int nPos );
int GetSubPanelCount() const;
int ComputeLockedSize( int nStartingIndex );
CUtlVector< SplitterInfo_t > m_Splitters;
SplitterMode_t m_Mode;
friend class SplitterHandle;
};
} // namespace vgui
#endif // SPLITTER_H