VGUIButton: only adjust button size on SetTitle() when button has no size

This commit is contained in:
Marco Cawthorne 2023-04-18 19:37:46 -07:00
parent 60bbe417ab
commit a34fd9c0e8
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
1 changed files with 12 additions and 3 deletions

View File

@ -105,9 +105,11 @@ VGUIButton::SetTitle(string strName)
//m_strTitle = sprintf("%s%s", Font_RGBtoHex(UI_MAINCOLOR), strName);
drawfont = g_fntDefault.iID;
newsize[0] = stringwidth(m_strTitle, TRUE, [g_fntDefault.iScaleX, g_fntDefault.iScaleY]) + 16;
newsize[1] = 24;
SetSize(newsize);
if (GetSize() == [0,0]) {
newsize[0] = stringwidth(m_strTitle, TRUE, [g_fntDefault.iScaleX, g_fntDefault.iScaleY]) + 16;
newsize[1] = 24;
SetSize(newsize);
}
}
string
@ -202,6 +204,11 @@ VGUIButton::Draw(void)
float textPadding = 8;
{
vector pos = m_parent.m_vecOrigin + m_vecOrigin;
drawsetcliparea(pos[0], pos[1], m_vecSize[0], m_vecSize[1]);
}
if (m_keyEquivalent >= 0) {
float length;
string keyText = GetKeyEquivalent();
@ -224,6 +231,8 @@ VGUIButton::Draw(void)
else
drawpic(m_parent.m_vecOrigin + m_vecOrigin + [2,2], m_strIcon, m_vecIMGSize, m_vecIconColor, 1.0f, 0);
}
drawresetcliparea();
#endif
}