From cef6abcea6218c9638ba67edca9755f7d3fa359f Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 20 Jun 2006 18:48:21 +0000 Subject: Always add a bit of padding inside windows (removes the need to add padding explicitly in labels). Set the window title from the desktop title. Only draw widget selection highlight in the window with focus (top window). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 560 --- textscreen/examples/guitest.c | 16 ++++++++-------- textscreen/txt_button.c | 7 ++----- textscreen/txt_desktop.c | 3 ++- textscreen/txt_separator.c | 2 +- textscreen/txt_window.c | 16 ++++++++-------- 5 files changed, 21 insertions(+), 23 deletions(-) (limited to 'textscreen') diff --git a/textscreen/examples/guitest.c b/textscreen/examples/guitest.c index 73a3aa25..f3d27582 100644 --- a/textscreen/examples/guitest.c +++ b/textscreen/examples/guitest.c @@ -77,9 +77,9 @@ void SetupWindow(void) TXT_AddWidget(window, TXT_NewSeparator("Main section")); table = TXT_NewTable(3); - toplabel = TXT_NewLabel(" This is a multiline label.\n" - " A single label object contains \n" - " all three of these lines.\n"); + toplabel = TXT_NewLabel("This is a multiline label.\n" + "A single label object contains \n" + "all three of these lines.\n"); TXT_AddWidget(window, toplabel); TXT_SetWidgetAlign(toplabel, TXT_HORIZ_CENTER); @@ -87,11 +87,11 @@ void SetupWindow(void) for (i=0; i<5; ++i) { - sprintf(buf, " Option %i in a table:", i + 1); + sprintf(buf, "Option %i in a table:", i + 1); TXT_AddWidget(table, TXT_NewLabel(buf)); - sprintf(buf, "Button %i-1", i + 1); + sprintf(buf, " Button %i-1 ", i + 1); TXT_AddWidget(table, TXT_NewButton(buf)); - sprintf(buf, "Button %i-2", i + 1); + sprintf(buf, " Button %i-2 ", i + 1); TXT_AddWidget(table, TXT_NewButton(buf)); } @@ -153,9 +153,9 @@ void Window2(void) TXT_AddWidget(window, TXT_NewSeparator("Input boxes")); table = TXT_NewTable(2); TXT_AddWidget(window, table); - TXT_AddWidget(table, TXT_NewLabel(" String: ")); + TXT_AddWidget(table, TXT_NewLabel("String: ")); TXT_AddWidget(table, TXT_NewInputBox(&textbox_value, 30)); - TXT_AddWidget(table, TXT_NewLabel(" Int: ")); + TXT_AddWidget(table, TXT_NewLabel("Int: ")); TXT_AddWidget(table, TXT_NewIntInputBox(&numbox_value, 10)); } diff --git a/textscreen/txt_button.c b/textscreen/txt_button.c index 26e148b0..9cd20169 100644 --- a/textscreen/txt_button.c +++ b/textscreen/txt_button.c @@ -13,9 +13,7 @@ static void TXT_ButtonSizeCalc(TXT_UNCAST_ARG(button)) { TXT_CAST_ARG(txt_button_t, button); - // Minimum width is the string length + two spaces for padding - - button->widget.w = strlen(button->label) + 2; + button->widget.w = strlen(button->label); button->widget.h = 1; } @@ -29,7 +27,6 @@ static void TXT_ButtonDrawer(TXT_UNCAST_ARG(button), int selected) TXT_BGColor(TXT_COLOR_BLUE, 0); TXT_FGColor(TXT_COLOR_BRIGHT_WHITE); - TXT_DrawString(" "); if (selected) { @@ -38,7 +35,7 @@ static void TXT_ButtonDrawer(TXT_UNCAST_ARG(button), int selected) TXT_DrawString(button->label); - for (i=strlen(button->label); i < w-2; ++i) + for (i=strlen(button->label); i < w; ++i) { TXT_DrawString(" "); } diff --git a/textscreen/txt_desktop.c b/textscreen/txt_desktop.c index 72bda28a..e9673434 100644 --- a/textscreen/txt_desktop.c +++ b/textscreen/txt_desktop.c @@ -112,6 +112,7 @@ void TXT_SetDesktopTitle(char *title) { free(desktop_title); desktop_title = strdup(title); + SDL_WM_SetCaption(title, NULL); } void TXT_DrawDesktop(void) @@ -128,7 +129,7 @@ void TXT_DrawDesktop(void) for (i=0; ilabel != NULL) { diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index 5da2e008..d9a3abca 100644 --- a/textscreen/txt_window.c +++ b/textscreen/txt_window.c @@ -221,14 +221,14 @@ void TXT_LayoutWindow(txt_window_t *window) TXT_CalcWidgetSize(window); + // Widgets area: add one character of padding on each side + widgets_w = widgets->w + 2; + // Calculate the size of the action area + // Make window wide enough to action area actionarea_w = ActionAreaWidth(window); - // Which one is larger? - - widgets_w = widgets->w; - if (actionarea_w > widgets_w) widgets_w = actionarea_w; @@ -251,9 +251,9 @@ void TXT_LayoutWindow(txt_window_t *window) // Set the table size and position - widgets->w = widgets_w; + widgets->w = widgets_w - 2; // widgets->h (already set) - widgets->x = window->window_x + 1; + widgets->x = window->window_x + 2; widgets->y = window->window_y + window->window_h - widgets->h - 3; // Layout the table and action area @@ -262,7 +262,7 @@ void TXT_LayoutWindow(txt_window_t *window) TXT_LayoutWidget(widgets); } -void TXT_DrawWindow(txt_window_t *window) +void TXT_DrawWindow(txt_window_t *window, int selected) { txt_widget_t *widgets; int x, y; @@ -279,7 +279,7 @@ void TXT_DrawWindow(txt_window_t *window) // Draw all widgets - TXT_DrawWidget(window, 1); + TXT_DrawWidget(window, selected); // Separator for action area -- cgit v1.2.3