From 98ecb00e9d480d6391417883e6f1f035fd2014b7 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 20 Sep 2011 22:06:12 +0000 Subject: Don't allow dropdown widget pop-up window to be placed outside the boundaries of the screen. Subversion-branch: /branches/v2-branch Subversion-revision: 2391 --- textscreen/txt_dropdown.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'textscreen/txt_dropdown.c') diff --git a/textscreen/txt_dropdown.c b/textscreen/txt_dropdown.c index c9a5d015..a6185a4c 100644 --- a/textscreen/txt_dropdown.c +++ b/textscreen/txt_dropdown.c @@ -49,14 +49,29 @@ static int ValidSelection(txt_dropdown_list_t *list) static int SelectorWindowY(txt_dropdown_list_t *list) { + int result; + if (ValidSelection(list)) { - return list->widget.y - 1 - *list->variable; + result = list->widget.y - 1 - *list->variable; } else { - return list->widget.y - 1 - (list->num_values / 2); + result = list->widget.y - 1 - (list->num_values / 2); + } + + // Keep dropdown inside the screen. + + if (result < 1) + { + result = 1; + } + else if (result + list->num_values > (TXT_SCREEN_H - 3)) + { + result = TXT_SCREEN_H - list->num_values - 3; } + + return result; } // Called when a button in the selector window is pressed -- cgit v1.2.3