diff options
author | Simon Howard | 2011-09-20 22:06:12 +0000 |
---|---|---|
committer | Simon Howard | 2011-09-20 22:06:12 +0000 |
commit | 98ecb00e9d480d6391417883e6f1f035fd2014b7 (patch) | |
tree | 59bc760d6a02bea14dbb239901cee1d62937fedf | |
parent | 76a7eebc335c6f57da589ee66971b850f0ec4c50 (diff) | |
download | chocolate-doom-98ecb00e9d480d6391417883e6f1f035fd2014b7.tar.gz chocolate-doom-98ecb00e9d480d6391417883e6f1f035fd2014b7.tar.bz2 chocolate-doom-98ecb00e9d480d6391417883e6f1f035fd2014b7.zip |
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
-rw-r--r-- | textscreen/txt_dropdown.c | 19 |
1 files changed, 17 insertions, 2 deletions
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 |