diff options
author | Simon Howard | 2013-08-31 00:12:09 +0000 |
---|---|---|
committer | Simon Howard | 2013-08-31 00:12:09 +0000 |
commit | 58fba3477da8fc6bdec3558489556c3439f90fc5 (patch) | |
tree | 9bbc2e9c7d29f571e8ba8658c1d6fde10a25a25e /textscreen | |
parent | 4a005eafa7faea031cf386d5aea53716d0864c69 (diff) | |
download | chocolate-doom-58fba3477da8fc6bdec3558489556c3439f90fc5.tar.gz chocolate-doom-58fba3477da8fc6bdec3558489556c3439f90fc5.tar.bz2 chocolate-doom-58fba3477da8fc6bdec3558489556c3439f90fc5.zip |
Add textscreen functions to raise and lower windows.
Subversion-branch: /branches/v2-branch
Subversion-revision: 2628
Diffstat (limited to 'textscreen')
-rw-r--r-- | textscreen/txt_desktop.c | 52 | ||||
-rw-r--r-- | textscreen/txt_desktop.h | 20 |
2 files changed, 72 insertions, 0 deletions
diff --git a/textscreen/txt_desktop.c b/textscreen/txt_desktop.c index 09589688..2316145f 100644 --- a/textscreen/txt_desktop.c +++ b/textscreen/txt_desktop.c @@ -97,6 +97,58 @@ txt_window_t *TXT_GetActiveWindow(void) return all_windows[num_windows - 1]; } +int TXT_RaiseWindow(txt_window_t *window) +{ + int i; + + for (i = 0; i < num_windows - 1; ++i) + { + if (all_windows[i] == window) + { + all_windows[i] = all_windows[i + 1]; + all_windows[i + 1] = window; + + if (i == num_windows - 2) + { + TXT_SetWindowFocus(all_windows[i], 0); + TXT_SetWindowFocus(window, 1); + } + + return 1; + } + } + + // Window not in the list, or at the end of the list (top) already. + + return 0; +} + +int TXT_LowerWindow(txt_window_t *window) +{ + int i; + + for (i = 0; i < num_windows - 1; ++i) + { + if (all_windows[i + 1] == window) + { + all_windows[i + 1] = all_windows[i]; + all_windows[i] = window; + + if (i == num_windows - 2) + { + TXT_SetWindowFocus(window, 0); + TXT_SetWindowFocus(all_windows[i + 1], 1); + } + + return 1; + } + } + + // Window not in the list, or at the start of the list (bottom) already. + + return 0; +} + static void DrawDesktopBackground(const char *title) { int i; diff --git a/textscreen/txt_desktop.h b/textscreen/txt_desktop.h index 9e2a42c7..f98d4627 100644 --- a/textscreen/txt_desktop.h +++ b/textscreen/txt_desktop.h @@ -91,5 +91,25 @@ void TXT_SetPeriodicCallback(TxtIdleCallback callback, void *user_data, unsigned int period); +/** + * Raise the z-position of the given window relative to other windows. + * + * @param window The window to raise. + * @return Non-zero if the window was raised successfully, + * or zero if the window could not be raised further. + */ + +int TXT_RaiseWindow(txt_window_t *window); + +/** + * Lower the z-position of the given window relative to other windows. + * + * @param window The window to make inactive. + * @return Non-zero if the window was lowered successfully, + * or zero if the window could not be lowered further. + */ + +int TXT_LowerWindow(txt_window_t *window); + #endif /* #ifndef TXT_DESKTOP_H */ |