ref: 58fba3477da8fc6bdec3558489556c3439f90fc5
parent: 4a005eafa7faea031cf386d5aea53716d0864c69
author: Simon Howard <[email protected]>
date: Fri Aug 30 20:12:09 EDT 2013
Add textscreen functions to raise and lower windows. Subversion-branch: /branches/v2-branch Subversion-revision: 2628
--- a/textscreen/txt_desktop.c
+++ b/textscreen/txt_desktop.c
@@ -97,6 +97,58 @@
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;
--- a/textscreen/txt_desktop.h
+++ b/textscreen/txt_desktop.h
@@ -91,5 +91,25 @@
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 */