diff options
author | Ben Millwood <thebenmachine@gmail.com> | 2009-10-03 13:06:17 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:16:28 +0000 |
commit | b8ba914fd60591858ab6e6177ba23d37e8cd2898 (patch) | |
tree | 70a0cc681f76aa19cba84975c7fee158cf63532c /src/ui | |
parent | 05c82406cb6782b4e6f91609d1f031896ec83ca5 (diff) |
* Prevent option controls and edit fields from twitching bizarrely when used
(caused by r1173)
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/ui_shared.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c index b8eb88ad..4befa326 100644 --- a/src/ui/ui_shared.c +++ b/src/ui/ui_shared.c @@ -4440,6 +4440,15 @@ void Rect_ToWindowCoords( rectDef_t *rect, windowDef_t *window ) void Item_SetTextExtents( itemDef_t *item, int *width, int *height, const char *text ) { const char *textPtr = ( text ) ? text : item->text; + qboolean cvarContent; + + // It's hard to make a policy on what should be aligned statically and what + // should be aligned dynamically; there are reasonable cases for both. If + // it continues to be a problem then there should probably be an item keyword + // for it; but for the moment only adjusting the alignment of ITEM_TYPE_TEXT + // seems to suffice. + cvarContent = ( item->cvar && item->textalignment != ALIGN_LEFT && + item->type == ITEM_TYPE_TEXT ); if( textPtr == NULL ) return; @@ -4449,15 +4458,15 @@ void Item_SetTextExtents( itemDef_t *item, int *width, int *height, const char * // as long as the item isn't dynamic content (ownerdraw or cvar), this // keeps us from computing the widths and heights more than once - if( *width == 0 || item->cvar || ( item->type == ITEM_TYPE_OWNERDRAW && + if( *width == 0 || cvarContent || ( item->type == ITEM_TYPE_OWNERDRAW && item->textalignment != ALIGN_LEFT ) ) { int originalWidth; - if( item->cvar && item->textalignment != ALIGN_LEFT ) + if( cvarContent ) { - char buff[256]; - DC->getCVarString( item->cvar, buff, 256 ); + char buff[ MAX_CVAR_VALUE_STRING ]; + DC->getCVarString( item->cvar, buff, sizeof( buff ) ); originalWidth = UI_Text_Width( item->text, item->textscale, 0 ) + UI_Text_Width( buff, item->textscale, 0 ); } |