summaryrefslogtreecommitdiff
path: root/code/fe310/eos/eve/screen/window.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-06-06 22:58:53 +0200
committerUros Majstorovic <majstor@majstor.org>2020-06-06 22:58:53 +0200
commit4ed8eb19f573d15b1b0526b2588bf20758b4f374 (patch)
treeccc78f878103f76a84157fc5ad64e1d3f93cc2e0 /code/fe310/eos/eve/screen/window.c
parent6ec81884f4c22f789a7b77f7eb77e01ada971464 (diff)
tile -> window; opverlapping windows added
Diffstat (limited to 'code/fe310/eos/eve/screen/window.c')
-rw-r--r--code/fe310/eos/eve/screen/window.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/code/fe310/eos/eve/screen/window.c b/code/fe310/eos/eve/screen/window.c
new file mode 100644
index 0000000..8341e8a
--- /dev/null
+++ b/code/fe310/eos/eve/screen/window.c
@@ -0,0 +1,39 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include "eve.h"
+#include "eve_kbd.h"
+
+#include "screen.h"
+#include "window.h"
+
+#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
+
+void eve_window_init(EVEWindow *window, EVERect *g, EVEView *view, EVEScreen *screen) {
+ memset(window, 0, sizeof(EVEWindow));
+
+ if (g) window->g = *g;
+ window->view = view;
+ window->screen = screen;
+}
+
+void eve_window_get_visible(EVEWindow *window, EVERect *g) {
+ EVEWindow *w = window->next;
+
+ *g = window->g;
+ while (w) {
+ if (w->g.x > g->x) g->w = MIN(g->w, w->g.x - g->x);
+ if (w->g.y > g->y) g->h = MIN(g->h, w->g.y - g->y);
+ if (w->g.x + w->g.w < g->x + g->w) {
+ uint16_t x0 = g->w - MIN(g->w, (g->x + g->w) - (w->g.x + w->g.w));
+ g->x += x0;
+ g->w -= x0;
+ }
+ if (w->g.y + w->g.h < g->y + g->h) {
+ uint16_t y0 = g->h - MIN(g->h, (g->y + g->h) - (w->g.y + w->g.h));
+ g->y += y0;
+ g->h -= y0;
+ }
+ w = w->next;
+ }
+}