From 9f3f6683d929d118b18e21b06a0b729586569e1a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 4 Apr 2011 20:07:07 +0000 Subject: Change the background color when hovering over widgets. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2320 --- textscreen/txt_window_action.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'textscreen/txt_window_action.c') diff --git a/textscreen/txt_window_action.c b/textscreen/txt_window_action.c index e593b7b6..81d3e94d 100644 --- a/textscreen/txt_window_action.c +++ b/textscreen/txt_window_action.c @@ -37,9 +37,10 @@ static void TXT_WindowActionSizeCalc(TXT_UNCAST_ARG(action)) TXT_GetKeyDescription(action->key, buf); - // Minimum width is the string length + two spaces for padding + // Width is label length, plus key description length, plus '=' + // and two surrounding spaces. - action->widget.w = strlen(action->label) + strlen(buf) + 1; + action->widget.w = strlen(action->label) + strlen(buf) + 3; action->widget.h = 1; } @@ -50,12 +51,24 @@ static void TXT_WindowActionDrawer(TXT_UNCAST_ARG(action), int selected) TXT_GetKeyDescription(action->key, buf); + if (TXT_HoveringOverWidget(action)) + { + TXT_BGColor(TXT_COLOR_BLACK, 0); + } + else + { + TXT_BGColor(TXT_WINDOW_BACKGROUND, 0); + } + + TXT_DrawString(" "); TXT_FGColor(TXT_COLOR_BRIGHT_GREEN); TXT_DrawString(buf); TXT_FGColor(TXT_COLOR_BRIGHT_CYAN); TXT_DrawString("="); + TXT_FGColor(TXT_COLOR_BRIGHT_WHITE); TXT_DrawString(action->label); + TXT_DrawString(" "); } static void TXT_WindowActionDestructor(TXT_UNCAST_ARG(action)) -- cgit v1.2.3