summaryrefslogtreecommitdiff
path: root/textscreen/txt_window.c
diff options
context:
space:
mode:
authorSimon Howard2010-12-10 23:46:22 +0000
committerSimon Howard2010-12-10 23:46:22 +0000
commitd1a3967194323b08227b20822acedb837e05281a (patch)
tree39e4f4da91717159f4f82e6eb37c9fb32d306892 /textscreen/txt_window.c
parent6a2d4763a9080cf88ca9f0b588b8187963eeacf5 (diff)
parente225e0c93ce58bb0e33c174847305d39800fd755 (diff)
downloadchocolate-doom-d1a3967194323b08227b20822acedb837e05281a.tar.gz
chocolate-doom-d1a3967194323b08227b20822acedb837e05281a.tar.bz2
chocolate-doom-d1a3967194323b08227b20822acedb837e05281a.zip
Merge from trunk.
Subversion-branch: /branches/raven-branch Subversion-revision: 2214
Diffstat (limited to 'textscreen/txt_window.c')
-rw-r--r--textscreen/txt_window.c39
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;
}
}