vguiButton: Change behaviour under which a button acts as disabled.
vguiWidget: add generic Enable, Disable accessor methods.
This commit is contained in:
parent
b82d068065
commit
5e5b850ec1
3 changed files with 58 additions and 5 deletions
|
@ -57,6 +57,8 @@ public:
|
|||
/** Sets the command to execute when the button is pressed. */
|
||||
nonvirtual void SetExec(string);
|
||||
|
||||
nonvirtual bool ButtonDisabled(void);
|
||||
|
||||
/* overrides */
|
||||
virtual void Draw(void);
|
||||
virtual bool Input(float,float,float,float);
|
||||
|
@ -76,6 +78,7 @@ private:
|
|||
void
|
||||
vguiButton::vguiButton(void)
|
||||
{
|
||||
m_strExec = __NULL__;
|
||||
m_vecColor = UI_MAINCOLOR;
|
||||
m_flAlpha = 1.0f;
|
||||
m_vecIconColor = [1,1,1];
|
||||
|
@ -158,13 +161,26 @@ vguiButton::GetKeyEquivalent(void)
|
|||
return keynumtostring(m_keyEquivalent);
|
||||
}
|
||||
|
||||
bool
|
||||
vguiButton::ButtonDisabled(void)
|
||||
{
|
||||
if (STRING_SET(m_strExec)) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
if (tmpvguiButton1) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
void
|
||||
vguiButton::Draw(void)
|
||||
{
|
||||
vguiTheme theme = GetTheme();
|
||||
|
||||
if (!tmpvguiButton1) {
|
||||
if (IsEnabled() == false) {
|
||||
theme.DrawButton(m_parent.m_vecOrigin + m_vecOrigin, m_vecSize, VGUI_STATE_DISABLED);
|
||||
} else if (m_iFlags & BUTTON_DOWN) {
|
||||
theme.DrawButton(m_parent.m_vecOrigin + m_vecOrigin, m_vecSize, VGUI_STATE_ACTIVE);
|
||||
|
@ -207,11 +223,9 @@ bool
|
|||
vguiButton::Input(float flEVType, float flKey, float flChar, float flDevID)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
bool mouseHover = false;
|
||||
|
||||
|
||||
if (!tmpvguiButton1) {
|
||||
if (IsEnabled() == false) {
|
||||
return (false);
|
||||
}
|
||||
|
||||
|
@ -254,8 +268,9 @@ vguiButton::Input(float flEVType, float flKey, float flChar, float flDevID)
|
|||
if (tmpvguiButton1)
|
||||
tmpvguiButton1();
|
||||
|
||||
if (m_strExec)
|
||||
if (STRING_SET(m_strExec)) {
|
||||
localcmd(sprintf("%s\n", m_strExec));
|
||||
}
|
||||
|
||||
ret = true;
|
||||
}
|
||||
|
|
|
@ -64,6 +64,14 @@ public:
|
|||
virtual void NowVisible(void);
|
||||
virtual void NowHidden(void);
|
||||
|
||||
/** Enable the widget. */
|
||||
nonvirtual void Enable(void);
|
||||
/** Disable the widget. */
|
||||
nonvirtual void Disable(void);
|
||||
|
||||
virtual void NowEnabled(void);
|
||||
virtual void NowDisabled(void);
|
||||
|
||||
/** Called in order to draw the widget. */
|
||||
virtual void Draw(void);
|
||||
/** Called whenever the physical properties of the display change. */
|
||||
|
@ -87,5 +95,6 @@ private:
|
|||
vguiWidget m_children;
|
||||
int m_iFlags;
|
||||
bool m_bVisible;
|
||||
bool m_bEnabled;
|
||||
vguiTheme m_theme;
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@ vguiWidget::vguiWidget(void)
|
|||
m_parent = __NULL__;
|
||||
m_iFlags = 0i;
|
||||
m_bVisible = true;
|
||||
m_bEnabled = true;
|
||||
isVGUI = true;
|
||||
|
||||
Spawned();
|
||||
|
@ -20,6 +21,34 @@ vguiWidget::SetTheme(vguiTheme theme)
|
|||
m_theme = theme;
|
||||
}
|
||||
|
||||
bool
|
||||
vguiWidget::IsEnabled(void)
|
||||
{
|
||||
return (m_bEnabled);
|
||||
}
|
||||
|
||||
void
|
||||
vguiWidget::Enable(void)
|
||||
{
|
||||
m_bEnabled = true;
|
||||
}
|
||||
|
||||
void
|
||||
vguiWidget::Disable(void)
|
||||
{
|
||||
m_bEnabled = false;
|
||||
}
|
||||
|
||||
void
|
||||
vguiWidget::NowEnabled(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
vguiWidget::NowDisabled(void)
|
||||
{
|
||||
}
|
||||
|
||||
vguiTheme
|
||||
vguiWidget::GetTheme(void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue