forked from nillerusr/source-engine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoolmenubar.cpp
132 lines (98 loc) · 3.43 KB
/
toolmenubar.cpp
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
124
125
126
127
128
129
130
131
132
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Core Movie Maker UI API
//
//=============================================================================
#include "toolutils/toolmenubar.h"
#include "vgui_controls/Label.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
using namespace vgui;
//-----------------------------------------------------------------------------
//
// Version that only has tool name and info
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
CToolMenuBar::CToolMenuBar( CBaseToolSystem *pParent, const char *pPanelName ) :
BaseClass( (Panel *)pParent, pPanelName ),
m_pToolSystem( pParent )
{
m_pInfo = new Label( this, "Info", "" );
m_pToolName = new Label( this, "ToolName", "" );
}
CBaseToolSystem *CToolMenuBar::GetToolSystem()
{
return m_pToolSystem;
}
//-----------------------------------------------------------------------------
// Sets the tool bar's name
//-----------------------------------------------------------------------------
void CToolMenuBar::SetToolName( const char *pName )
{
m_pToolName->SetText( pName );
InvalidateLayout();
}
//-----------------------------------------------------------------------------
// Sets the tool bar info
//-----------------------------------------------------------------------------
void CToolMenuBar::SetInfo( const char *pInfo )
{
m_pInfo->SetText( pInfo );
InvalidateLayout();
}
//-----------------------------------------------------------------------------
// Lays out the menu bar
//-----------------------------------------------------------------------------
void CToolMenuBar::PerformLayout()
{
BaseClass::PerformLayout();
int w, h;
GetSize( w, h );
int cw, ch;
m_pInfo->GetContentSize( cw, ch );
int right = w - cw - 20;
m_pInfo->SetBounds( right, 0, cw, h );
m_pToolName->GetContentSize( cw, ch );
m_pToolName->SetBounds( right - cw - 5, 0, cw, h );
}
//-----------------------------------------------------------------------------
//
// Version that only has tool name, info, and file name
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
CToolFileMenuBar::CToolFileMenuBar( CBaseToolSystem *parent, const char *panelName ) :
BaseClass( parent, panelName )
{
m_pFileName = new Label( this, "FileName", "" );
}
void CToolFileMenuBar::SetFileName( char const *name )
{
m_pFileName->SetText( name );
InvalidateLayout();
}
//-----------------------------------------------------------------------------
// Performs layout
//-----------------------------------------------------------------------------
void CToolFileMenuBar::PerformLayout()
{
BaseClass::PerformLayout();
int w, h;
GetSize( w, h );
int cw, ch;
m_pInfo->GetContentSize( cw, ch );
int right = w - cw - 20;
m_pToolName->GetContentSize( cw, ch );
int barx, bary;
GetContentSize( barx, bary );
int faredge = right - cw - 5- 2;
int nearedge = barx + 2;
int mid = ( nearedge + faredge ) * 0.5f;
m_pFileName->GetContentSize( cw, ch );
m_pFileName->SetBounds( mid - cw * 0.5f, 0, cw, h );
}