diff options
author | Simon Howard | 2010-12-10 20:43:05 +0000 |
---|---|---|
committer | Simon Howard | 2010-12-10 20:43:05 +0000 |
commit | af3e4412d301cc27e04c352c0283ce6861f33f0c (patch) | |
tree | f9e0403b4eadc8bff6daeea56bdeee4b8adfce86 /textscreen | |
parent | 56824b130b786aab49876a71c6c768a17c5a4f1c (diff) | |
download | chocolate-doom-af3e4412d301cc27e04c352c0283ce6861f33f0c.tar.gz chocolate-doom-af3e4412d301cc27e04c352c0283ce6861f33f0c.tar.bz2 chocolate-doom-af3e4412d301cc27e04c352c0283ce6861f33f0c.zip |
Change alignment of actions in a window's action area so that there is
equal space either side of the center widget. This is more aesthetically
pleasing.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2208
Diffstat (limited to 'textscreen')
-rw-r--r-- | textscreen/txt_window.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index 33f53d4a..46e71d3a 100644 --- a/textscreen/txt_window.c +++ b/textscreen/txt_window.c @@ -140,6 +140,15 @@ static void CalcWindowPosition(txt_window_t *window) static void LayoutActionArea(txt_window_t *window) { txt_widget_t *widget; + int space_available; + int space_left_offset; + + // We need to calculate the available horizontal space for the center + // action widget, so that we can center it within it. + // To start with, we have the entire action area available. + + space_available = window->window_w; + space_left_offset = 0; // Left action @@ -151,29 +160,43 @@ static void LayoutActionArea(txt_window_t *window) widget->x = window->window_x + 2; widget->y = window->window_y + window->window_h - widget->h - 1; + + // Adjust available space: + + space_available -= widget->w; + space_left_offset += widget->w; } - // Draw the center action + // Draw the right action - if (window->actions[TXT_HORIZ_CENTER] != NULL) + if (window->actions[TXT_HORIZ_RIGHT] != NULL) { - widget = (txt_widget_t *) window->actions[TXT_HORIZ_CENTER]; + widget = (txt_widget_t *) window->actions[TXT_HORIZ_RIGHT]; TXT_CalcWidgetSize(widget); - widget->x = window->window_x + (window->window_w - widget->w - 2) / 2; + widget->x = window->window_x + window->window_w - 2 - widget->w; widget->y = window->window_y + window->window_h - widget->h - 1; + + // Adjust available space: + + space_available -= widget->w; } - // Draw the right action + // Draw the center action - if (window->actions[TXT_HORIZ_RIGHT] != NULL) + if (window->actions[TXT_HORIZ_CENTER] != NULL) { - widget = (txt_widget_t *) window->actions[TXT_HORIZ_RIGHT]; + widget = (txt_widget_t *) window->actions[TXT_HORIZ_CENTER]; TXT_CalcWidgetSize(widget); - widget->x = window->window_x + window->window_w - 2 - widget->w; + // The left and right widgets have left a space sandwiched between + // them. Center this widget within that space. + + widget->x = window->window_x + + space_left_offset + + (space_available - widget->w) / 2; widget->y = window->window_y + window->window_h - widget->h - 1; } } |