summaryrefslogtreecommitdiff
path: root/code
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
parent6ec81884f4c22f789a7b77f7eb77e01ada971464 (diff)
tile -> window; opverlapping windows added
Diffstat (limited to 'code')
-rw-r--r--code/fe310/eos/eve/screen/Makefile2
-rw-r--r--code/fe310/eos/eve/screen/form.c26
-rw-r--r--code/fe310/eos/eve/screen/form.h6
-rw-r--r--code/fe310/eos/eve/screen/page.c51
-rw-r--r--code/fe310/eos/eve/screen/page.h16
-rw-r--r--code/fe310/eos/eve/screen/screen.c42
-rw-r--r--code/fe310/eos/eve/screen/screen.h21
-rw-r--r--code/fe310/eos/eve/screen/tile.c32
-rw-r--r--code/fe310/eos/eve/screen/tile.h24
-rw-r--r--code/fe310/eos/eve/screen/window.c39
-rw-r--r--code/fe310/eos/eve/screen/window.h21
-rw-r--r--code/fe310/eos/eve/widget/page.c12
-rw-r--r--code/fe310/eos/eve/widget/page.h4
-rw-r--r--code/fe310/eos/eve/widget/text.c49
-rw-r--r--code/fe310/eos/eve/widget/text.h4
-rw-r--r--code/fe310/eos/eve/widget/widget.c10
-rw-r--r--code/fe310/eos/eve/widget/widget.h9
17 files changed, 195 insertions, 173 deletions
diff --git a/code/fe310/eos/eve/screen/Makefile b/code/fe310/eos/eve/screen/Makefile
index a579f8f..372cf9e 100644
--- a/code/fe310/eos/eve/screen/Makefile
+++ b/code/fe310/eos/eve/screen/Makefile
@@ -2,7 +2,7 @@ include ../../../common.mk
CFLAGS += -I. -I.. -I../..
-obj = font.o screen.o tile.o page.o form.o
+obj = font.o screen.o window.o page.o form.o
%.o: %.c %.h
diff --git a/code/fe310/eos/eve/screen/form.c b/code/fe310/eos/eve/screen/form.c
index 10f17ad..41105f6 100644
--- a/code/fe310/eos/eve/screen/form.c
+++ b/code/fe310/eos/eve/screen/form.c
@@ -5,7 +5,7 @@
#include "eve_kbd.h"
#include "screen.h"
-#include "tile.h"
+#include "window.h"
#include "page.h"
#include "form.h"
@@ -13,33 +13,33 @@
#define CH_EOF 0x1a
-int eve_form_init(EVEForm *form, EVETile *tile, eve_page_open_t open, eve_page_close_t close, EVEWidget *widget, uint16_t widget_size) {
+int eve_form_init(EVEForm *form, EVEWidget *widget, uint16_t widget_size, eve_page_open_t open, eve_page_close_t close, EVEWindow *window) {
memset(form, 0, sizeof(EVEForm));
- eve_page_init(&form->p, tile, eve_form_touch, eve_form_draw, open, close);
+ eve_page_init(&form->p, eve_form_touch, eve_form_draw, open, close, window);
form->widget = widget;
form->widget_size = widget_size;
-
}
-int eve_form_touch(EVECanvas *c, uint8_t tag0, int touch_idx) {
- EVEForm *form = (EVEForm *)c;
+
+int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx) {
+ EVEForm *form = (EVEForm *)v;
EVEWidget *widget = form->widget;
int a, i, ret = 0;
- EVEPageFocus focus = {NULL, {0,0,0,0}};
+ EVERect focus = {0,0,0,0};
for (i=0; i<form->widget_size; i++) {
a = widget->touch(widget, &form->p, tag0, touch_idx, &focus);
ret = ret || a;
- if (focus.w && (form->widget_f != focus.w)) {
- EVEKbd *kbd = eve_screen_get_kbd(form->p.tile->screen);
+ if (focus.w && focus.h && (form->widget_f != widget)) {
+ EVEKbd *kbd = eve_screen_get_kbd(form->p.window->screen);
if (kbd) {
if (form->widget_f && form->widget_f->putc) {
- eve_screen_hide_kbd(form->p.tile->screen);
+ eve_screen_hide_kbd(form->p.window->screen);
form->widget_f->putc(form->widget_f, CH_EOF);
}
eve_kbd_set_handler(kbd, widget->putc);
if (widget && widget->putc) {
- eve_screen_show_kbd(form->p.tile->screen);
+ eve_screen_show_kbd(form->p.window->screen);
}
}
form->widget_f = widget;
@@ -51,8 +51,8 @@ int eve_form_touch(EVECanvas *c, uint8_t tag0, int touch_idx) {
return ret;
}
-uint8_t eve_form_draw(EVECanvas *c, uint8_t tag0) {
- EVEForm *form = (EVEForm *)c;
+uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
+ EVEForm *form = (EVEForm *)v;
EVEWidget *widget = form->widget;
int i, j;
uint8_t tagN, _tagN = 0;
diff --git a/code/fe310/eos/eve/screen/form.h b/code/fe310/eos/eve/screen/form.h
index 3edafe8..e667fc8 100644
--- a/code/fe310/eos/eve/screen/form.h
+++ b/code/fe310/eos/eve/screen/form.h
@@ -9,6 +9,6 @@ typedef struct EVEForm {
uint16_t widget_size;
} EVEForm;
-int eve_form_init(EVEForm *form, EVETile *tile, eve_page_open_t open, eve_page_close_t close, struct EVEWidget *widget, uint16_t widget_size);
-int eve_form_touch(EVECanvas *c, uint8_t tag0, int touch_idx);
-uint8_t eve_form_draw(EVECanvas *c, uint8_t tag0);
+int eve_form_init(EVEForm *form, struct EVEWidget *widget, uint16_t widget_size, eve_page_open_t open, eve_page_close_t close, EVEWindow *window);
+int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx);
+uint8_t eve_form_draw(EVEView *v, uint8_t tag0);
diff --git a/code/fe310/eos/eve/screen/page.c b/code/fe310/eos/eve/screen/page.c
index f703bd6..b2ef091 100644
--- a/code/fe310/eos/eve/screen/page.c
+++ b/code/fe310/eos/eve/screen/page.c
@@ -5,54 +5,51 @@
#include "eve_kbd.h"
#include "screen.h"
-#include "tile.h"
+#include "window.h"
#include "page.h"
#include "widget/widget.h"
-void eve_page_init(EVEPage *page, EVETile *tile, eve_canvas_touch_t touch, eve_canvas_draw_t draw, eve_page_open_t open, eve_page_close_t close) {
+void eve_page_init(EVEPage *page, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_open_t open, eve_page_close_t close, EVEWindow *window) {
memset(page, 0, sizeof(EVEPage));
- page->tile = tile;
+ page->v.touch = touch;
+ page->v.draw = draw;
+ page->open = open;
+ page->close = close;
page->handle_evt = eve_page_handle_evt;
+ page->window = window;
}
-void eve_page_focus(EVEPage *page, EVEPageFocus *focus) {
- uint16_t tile_w, tile_h;
+void eve_page_focus(EVEPage *page, EVERect *f) {
+ EVERect g;
- if (focus->w == NULL) return;
- eve_tile_get_pos(page->tile, NULL, NULL, &tile_w, &tile_h);
+ eve_window_get_visible(page->window, &g);
+ g.x -= page->window->g.x;
+ g.y -= page->window->g.y;
- if (focus->f.x < page->win_x) {
- page->win_x -= page->win_x - focus->f.x;
+ if (f->x < page->win_x + g.x) {
+ page->win_x = f->x - g.x;
}
- if (focus->f.y < page->win_y) {
- page->win_y -= page->win_y - focus->f.y;
+ if (f->y < page->win_y + g.y) {
+ page->win_y = f->y - g.y;
}
- if ((focus->f.x + focus->f.w) > (page->win_x + tile_w)) {
- page->win_x += (focus->f.x + focus->f.w) - (page->win_x + tile_w);
+ if ((f->x + f->w) > (page->win_x + g.x + g.w)) {
+ page->win_x = (f->x + f->w) - (g.x + g.w);
}
- if ((focus->f.y + focus->f.h) > (page->win_y + tile_h)) {
- page->win_y += (focus->f.y + focus->f.h) - (page->win_y + tile_h);
+ if ((f->y + f->h) > (page->win_y + g.y + g.h)) {
+ page->win_y = (f->y + f->h) - (g.y + g.h);
}
}
-void eve_page_widget_focus(EVEPageFocus *focus, EVEWidget *widget) {
- focus->w = widget;
- focus->f.x = widget->x;
- focus->f.y = widget->y;
- focus->f.w = widget->w;
- focus->f.h = widget->h;
-}
-
int eve_page_widget_visible(EVEPage *page, EVEWidget *widget) {
- uint16_t tile_w, tile_h;
- eve_tile_get_pos(page->tile, NULL, NULL, &tile_w, &tile_h);
+ uint16_t w = page->window->g.w;
+ uint16_t h = page->window->g.h;
- if (((widget->x + widget->w) >= page->win_x) && ((widget->y + widget->h) >= page->win_y) && (widget->x <= (page->win_x + tile_w)) && (widget->y <= (page->win_y + tile_h))) return 1;
+ if (((widget->g.x + widget->g.w) >= page->win_x) && ((widget->g.y + widget->g.h) >= page->win_y) && (widget->g.x <= (page->win_x + w)) && (widget->g.y <= (page->win_y + h))) return 1;
return 0;
}
-void eve_page_handle_evt(EVEPage *page, struct EVEWidget *widget, EVETouch *touch, uint16_t evt, uint8_t tag0, int touch_idx) {
+void eve_page_handle_evt(EVEPage *page, EVEWidget *widget, EVETouch *touch, uint16_t evt, uint8_t tag0, int touch_idx) {
/*
if (evt & EVE_TOUCH_ETYPE_TRACK_Y) {
// do scroll
diff --git a/code/fe310/eos/eve/screen/page.h b/code/fe310/eos/eve/screen/page.h
index 453bfcf..42cae7d 100644
--- a/code/fe310/eos/eve/screen/page.h
+++ b/code/fe310/eos/eve/screen/page.h
@@ -8,22 +8,16 @@ typedef void (*eve_page_close_t) (struct EVEPage *);
typedef void (*eve_page_evt_handler_t) (struct EVEPage *, struct EVEWidget *, EVETouch *, uint16_t, uint8_t, int);
typedef struct EVEPage {
- EVECanvas c;
+ EVEView v;
int16_t win_x;
int16_t win_y;
- eve_page_evt_handler_t handle_evt;
eve_page_open_t open;
eve_page_close_t close;
- EVETile *tile;
+ eve_page_evt_handler_t handle_evt;
+ EVEWindow *window;
} EVEPage;
-typedef struct EVEPageFocus {
- struct EVEWidget *w;
- EVEWindow f;
-} EVEPageFocus;
-
-void eve_page_init(EVEPage *page, EVETile *tile, eve_canvas_touch_t touch, eve_canvas_draw_t draw, eve_page_open_t open, eve_page_close_t close);
-void eve_page_focus(EVEPage *page, EVEPageFocus *focus);
-void eve_page_widget_focus(EVEPageFocus *focus, struct EVEWidget *widget);
+void eve_page_init(EVEPage *page, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_open_t open, eve_page_close_t close, EVEWindow *window);
+void eve_page_focus(EVEPage *page, EVERect *focus);
int eve_page_widget_visible(EVEPage *page, struct EVEWidget *widget);
void eve_page_handle_evt(EVEPage *page, struct EVEWidget *widget, EVETouch *touch, uint16_t evt, uint8_t tag0, int touch_idx);
diff --git a/code/fe310/eos/eve/screen/screen.c b/code/fe310/eos/eve/screen/screen.c
index c65e8fc..52015be 100644
--- a/code/fe310/eos/eve/screen/screen.c
+++ b/code/fe310/eos/eve/screen/screen.c
@@ -5,7 +5,7 @@
#include "eve_kbd.h"
#include "screen.h"
-#include "tile.h"
+#include "window.h"
int eve_screen_init(EVEScreen *screen, uint16_t w, uint16_t h) {
memset(screen, 0, sizeof(EVEScreen));
@@ -29,11 +29,43 @@ void eve_screen_hide_kbd(EVEScreen *screen) {
screen->kbd_active = 0;
}
-void eve_screen_add_tile(EVEScreen *screen, EVETile *tile) {
- if (screen->tile_size < EVE_MAX_TILES) {
- screen->tile[screen->tile_size] = tile;
- screen->tile_size++;
+int eve_screen_win_insert(EVEScreen *screen, EVEWindow *window, int idx) {
+ if (idx) {
+ int i;
+ EVEWindow *h = screen->win_head;
+
+ for (i=1; i<idx; i++) {
+ h = h->next;
+ if (h == NULL) return EVE_ERR;
+ }
+ window->next = h->next;
+ h->next = window;
+ } else {
+ window->next = screen->win_head;
+ screen->win_head = window;
}
+ if (window->next == NULL) screen->win_tail = window;
+ return EVE_OK;
+}
+
+int eve_screen_win_remove(EVEScreen *screen, EVEWindow *window) {
+ EVEWindow *h = screen->win_head;
+ if (h == NULL) return EVE_ERR;
+ if (h == window) {
+ screen->win_head = window->next;
+ if (screen->win_head == NULL) screen->win_tail = NULL;
+ } else {
+ while (h->next && (h->next != window)) h = h->next;
+ if (h->next == NULL) return EVE_ERR;
+
+ h->next = window->next;
+ if (h->next == NULL) screen->win_tail = h;
+ }
+}
+
+void eve_screen_win_append(EVEScreen *screen, EVEWindow *window) {
+ screen->win_tail->next = window;
+ screen->win_tail = window;
}
void eve_screen_handle_touch(EVEScreen *screen, uint8_t tag0, int touch_idx) {
diff --git a/code/fe310/eos/eve/screen/screen.h b/code/fe310/eos/eve/screen/screen.h
index 8627517..ff634b4 100644
--- a/code/fe310/eos/eve/screen/screen.h
+++ b/code/fe310/eos/eve/screen/screen.h
@@ -1,22 +1,20 @@
#include <stdint.h>
-#define EVE_MAX_TILES 8
+struct EVEWindow;
-struct EVETile;
-
-typedef struct EVEWindow {
- uint16_t x;
- uint16_t y;
+typedef struct EVERect {
+ int16_t x;
+ int16_t y;
uint16_t w;
uint16_t h;
-} EVEWindow;
+} EVERect;
typedef struct EVEScreen {
uint16_t w;
uint16_t h;
EVEKbd *kbd;
- struct EVETile *tile[EVE_MAX_TILES];
- uint8_t tile_size;
+ struct EVEWindow *win_head;
+ struct EVEWindow *win_tail;
char kbd_active;
} EVEScreen;
@@ -26,5 +24,8 @@ EVEKbd *eve_screen_get_kbd(EVEScreen *screen);
void eve_screen_show_kbd(EVEScreen *screen);
void eve_screen_hide_kbd(EVEScreen *screen);
-void eve_screen_add_tile(EVEScreen *screen, struct EVETile *tile);
+int eve_screen_win_insert(EVEScreen *screen, struct EVEWindow *window, int idx);
+int eve_screen_win_remove(EVEScreen *screen, struct EVEWindow *window);
+void eve_screen_win_append(EVEScreen *screen, struct EVEWindow *window);
+
void eve_screen_handle_touch(EVEScreen *screen, uint8_t tag0, int touch_idx);
diff --git a/code/fe310/eos/eve/screen/tile.c b/code/fe310/eos/eve/screen/tile.c
deleted file mode 100644
index 3715f6d..0000000
--- a/code/fe310/eos/eve/screen/tile.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-
-#include "eve.h"
-#include "eve_kbd.h"
-
-#include "screen.h"
-#include "tile.h"
-
-#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
-
-void eve_tile_init(EVETile *tile, EVEScreen *screen, uint16_t x, uint16_t y, uint16_t w, uint16_t h, EVECanvas *canvas) {
- tile->screen = screen;
- tile->x = x;
- tile->y = y;
- tile->w = w;
- tile->h = h;
- tile->canvas = canvas;
-}
-
-void eve_tile_get_pos(EVETile *tile, uint16_t *x, uint16_t *y, uint16_t *w, uint16_t *h) {
- if (x) *x = tile->x;
- if (y) *y = tile->y;
- if (w) *w = tile->w;
- if (h) *h = MIN(tile->x + tile->h, tile->screen->h - (tile->screen->kbd && tile->screen->kbd_active ? tile->screen->kbd->h : 0));
-}
-
-void eve_canvas_init(EVECanvas *canvas, eve_canvas_touch_t touch, eve_canvas_draw_t draw) {
- canvas->touch = touch;
- canvas->draw = draw;
-}
-
diff --git a/code/fe310/eos/eve/screen/tile.h b/code/fe310/eos/eve/screen/tile.h
deleted file mode 100644
index 5fea8bf..0000000
--- a/code/fe310/eos/eve/screen/tile.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <stdint.h>
-
-struct EVECanvas;
-
-typedef int (*eve_canvas_touch_t) (struct EVECanvas *, uint8_t, int);
-typedef uint8_t (*eve_canvas_draw_t) (struct EVECanvas *, uint8_t);
-
-typedef struct EVECanvas {
- eve_canvas_touch_t touch;
- eve_canvas_draw_t draw;
-} EVECanvas;
-
-typedef struct EVETile {
- uint16_t x;
- uint16_t y;
- uint16_t w;
- uint16_t h;
- EVECanvas *canvas;
- EVEScreen *screen;
-} EVETile;
-
-void eve_tile_init(EVETile *tile, EVEScreen *screen, uint16_t x, uint16_t y, uint16_t w, uint16_t h, EVECanvas *canvas);
-void eve_tile_get_pos(EVETile *tile, uint16_t *x, uint16_t *y, uint16_t *w, uint16_t *h);
-void eve_canvas_init(EVECanvas *canvas, eve_canvas_touch_t touch, eve_canvas_draw_t draw);
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;
+ }
+}
diff --git a/code/fe310/eos/eve/screen/window.h b/code/fe310/eos/eve/screen/window.h
new file mode 100644
index 0000000..f3a1c77
--- /dev/null
+++ b/code/fe310/eos/eve/screen/window.h
@@ -0,0 +1,21 @@
+#include <stdint.h>
+
+struct EVEView;
+
+typedef int (*eve_view_touch_t) (struct EVEView *, uint8_t, int);
+typedef uint8_t (*eve_view_draw_t) (struct EVEView *, uint8_t);
+
+typedef struct EVEView {
+ eve_view_touch_t touch;
+ eve_view_draw_t draw;
+} EVEView;
+
+typedef struct EVEWindow {
+ EVERect g;
+ EVEView *view;
+ EVEScreen *screen;
+ struct EVEWindow *next;
+} EVEWindow;
+
+void eve_window_init(EVEWindow *window, EVERect *g, EVEView *view, EVEScreen *screen);
+void eve_window_get_visible(EVEWindow *window, EVERect *g);
diff --git a/code/fe310/eos/eve/widget/page.c b/code/fe310/eos/eve/widget/page.c
index 4b78b3b..07a59b4 100644
--- a/code/fe310/eos/eve/widget/page.c
+++ b/code/fe310/eos/eve/widget/page.c
@@ -5,21 +5,21 @@
#include "eve_kbd.h"
#include "screen/screen.h"
-#include "screen/tile.h"
+#include "screen/window.h"
#include "screen/page.h"
#include "widget.h"
#include "page.h"
-void eve_pagew_init(EVEPageWidget *widget, int16_t x, int16_t y, uint16_t w, uint16_t h, uint8_t font_id, char *title, EVEPage *page) {
+void eve_pagew_init(EVEPageWidget *widget, EVERect *g, uint8_t font_id, char *title, EVEPage *page) {
memset(widget, 0, sizeof(EVEPageWidget));
- eve_widget_init(&widget->w, EVE_WIDGET_TYPE_PAGE, x, y, w, h, eve_pagew_touch, eve_pagew_draw, NULL);
+ eve_widget_init(&widget->w, EVE_WIDGET_TYPE_PAGE, g, eve_pagew_touch, eve_pagew_draw, NULL);
widget->font_id = font_id;
widget->title = title;
widget->page = page;
}
-int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVEPageFocus *focus) {
+int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVERect *focus) {
EVEPageWidget *widget = (EVEPageWidget *)_widget;
EVETouch *t;
uint16_t evt;
@@ -33,7 +33,7 @@ int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_i
if (page && page->handle_evt) page->handle_evt(page, _widget, t, evt, tag0, touch_idx);
} else if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
widget->page->open(widget->page, page);
- if (focus) eve_page_widget_focus(focus, _widget);
+ if (focus) *focus = _widget->g;
}
ret = 1;
}
@@ -48,7 +48,7 @@ uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
if (draw) {
widget->tag = tag0;
if (widget->tag) eve_cmd_dl(TAG(widget->tag));
- eve_cmd(CMD_TEXT, "hhhhs", _widget->x, _widget->y, widget->font_id, 0, widget->title);
+ eve_cmd(CMD_TEXT, "hhhhs", _widget->g.x, _widget->g.y, widget->font_id, 0, widget->title);
}
return widget->tag;
diff --git a/code/fe310/eos/eve/widget/page.h b/code/fe310/eos/eve/widget/page.h
index 3b6be70..a0b3e02 100644
--- a/code/fe310/eos/eve/widget/page.h
+++ b/code/fe310/eos/eve/widget/page.h
@@ -8,6 +8,6 @@ typedef struct EVEPageWidget {
uint8_t font_id;
} EVEPageWidget;
-void eve_pagew_init(EVEPageWidget *widget, int16_t x, int16_t y, uint16_t w, uint16_t h, uint8_t font_id, char *title, EVEPage *page);
-int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVEPageFocus *focus);
+void eve_pagew_init(EVEPageWidget *widget, EVERect *g, uint8_t font_id, char *title, EVEPage *page);
+int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVERect *focus);
uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0); \ No newline at end of file
diff --git a/code/fe310/eos/eve/widget/text.c b/code/fe310/eos/eve/widget/text.c
index ecdfb32..2d80bbc 100644
--- a/code/fe310/eos/eve/widget/text.c
+++ b/code/fe310/eos/eve/widget/text.c
@@ -5,7 +5,7 @@
#include "eve_kbd.h"
#include "screen/screen.h"
-#include "screen/tile.h"
+#include "screen/window.h"
#include "screen/page.h"
#include "screen/font.h"
@@ -26,9 +26,9 @@
#define PAGE_WIN_X(p) (p ? p->win_x : 0)
-void eve_textw_init(EVETextWidget *widget, int16_t x, int16_t y, uint16_t w, uint16_t h, EVEFont *font, char *text, uint64_t text_size, uint16_t *line, uint16_t line_size) {
+void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEFont *font, char *text, uint64_t text_size, uint16_t *line, uint16_t line_size) {
memset(widget, 0, sizeof(EVETextWidget));
- eve_widget_init(&widget->w, EVE_WIDGET_TYPE_TEXT, x, y, w, h, eve_textw_touch, eve_textw_draw, eve_textw_putc);
+ eve_widget_init(&widget->w, EVE_WIDGET_TYPE_TEXT, g, eve_textw_touch, eve_textw_draw, eve_textw_putc);
widget->text = text;
widget->text_size = text_size;
widget->line = line;
@@ -39,7 +39,7 @@ void eve_textw_init(EVETextWidget *widget, int16_t x, int16_t y, uint16_t w, uin
static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor, EVEPage *page, EVETouch *t, short *dx, short *dl) {
EVEWidget *_widget = (EVEWidget *)widget;
- int x = t->x0 + PAGE_WIN_X(page) - _widget->x;
+ int x = t->x0 + PAGE_WIN_X(page) - _widget->g.x;
int l = (int)t->tag0 - widget->tag0 + widget->line0;
int _dx, _dl;
@@ -52,7 +52,7 @@ static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor,
return NULL;
}
-int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVEPageFocus *focus) {
+int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVERect *focus) {
EVETextWidget *widget = (EVETextWidget *)_widget;
EVETouch *t;
uint16_t evt;
@@ -123,11 +123,10 @@ int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_i
ret = 1;
}
if (widget->cursor_f && focus) {
- focus->f.x = _widget->x;
- focus->f.y = _widget->y + widget->cursor_f->line * widget->font->h;
- focus->f.w = _widget->w;
- focus->f.h = 2 * widget->font->h;
- focus->w = _widget;
+ focus->x = _widget->g.x;
+ focus->y = _widget->g.y + widget->cursor_f->line * widget->font->h;
+ focus->w = _widget->g.w;
+ focus->h = 2 * widget->font->h;
widget->cursor_f = NULL;
}
return ret;
@@ -143,12 +142,12 @@ static void _draw_line(EVETextWidget *widget, uint16_t l, uint16_t ch, uint16_t
}
eve_cmd_dl(BEGIN(EVE_RECTS));
if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0));
- eve_cmd_dl(VERTEX2F(_widget->x + x1, _widget->y + l * widget->font->h));
- eve_cmd_dl(VERTEX2F(_widget->x + x2, _widget->y + (l + 1) * widget->font->h));
+ eve_cmd_dl(VERTEX2F(_widget->g.x + x1, _widget->g.y + l * widget->font->h));
+ eve_cmd_dl(VERTEX2F(_widget->g.x + x2, _widget->g.y + (l + 1) * widget->font->h));
if (!s) eve_cmd_dl(COLOR_MASK(1 ,1 ,1 ,1));
if (len) {
if (s) eve_cmd_dl(COLOR_RGB(0, 0, 0));
- eve_cmd(CMD_TEXT, "hhhhpb", _widget->x, _widget->y + l * widget->font->h, widget->font->id, 0, widget->text + ch, len, 0);
+ eve_cmd(CMD_TEXT, "hhhhpb", _widget->g.x, _widget->g.y + l * widget->font->h, widget->font->id, 0, widget->text + ch, len, 0);
if (s) eve_cmd_dl(COLOR_RGB(255, 255, 255));
}
}
@@ -158,8 +157,8 @@ static void _draw_cursor(EVETextWidget *widget, EVETextCursor *cursor) {
uint16_t x, y;
EVEWidget *_widget = (EVEWidget *)widget;
- x = _widget->x + cursor->x;
- y = _widget->y + cursor->line * widget->font->h;
+ x = _widget->g.x + cursor->x;
+ y = _widget->g.y + cursor->line * widget->font->h;
eve_cmd_dl(BEGIN(EVE_LINES));
eve_cmd_dl(VERTEX2F(x, y));
eve_cmd_dl(VERTEX2F(x, y + widget->font->h));
@@ -189,8 +188,8 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
if (page) {
int _line0, _lineN;
- _line0 = line0 = ((int)page->win_y - _widget->y) / widget->font->h;
- _lineN = lineN = ((int)page->win_y + page->tile->h - _widget->y) / widget->font->h + 1;
+ _line0 = line0 = ((int)page->win_y - _widget->g.y) / widget->font->h;
+ _lineN = lineN = ((int)page->win_y + page->window->g.h - _widget->g.y) / widget->font->h + 1;
if (line0 < 0) line0 = 0;
if (lineN < 0) lineN = 0;
if (line0 > widget->line_len) line0 = widget->line_len;
@@ -226,9 +225,9 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
s = 1;
}
_draw_line(widget, i, LINE_START(widget, i), l1, 0, c1->x, 0);
- _draw_line(widget, i, c1->ch, l2, c1->x, s ? _widget->w : c2->x, 1);
+ _draw_line(widget, i, c1->ch, l2, c1->x, s ? _widget->g.w : c2->x, 1);
if (!s) {
- _draw_line(widget, i, c2->ch, l3, c2->x, _widget->w, 0);
+ _draw_line(widget, i, c2->ch, l3, c2->x, _widget->g.w, 0);
c1 = NULL;
c2 = NULL;
}
@@ -237,12 +236,12 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
int l2 = LINE_START(widget, i) + LINE_LEN(widget, i) - c2->ch;
_draw_line(widget, i, LINE_START(widget, i), l1, 0, c2->x, 1);
- _draw_line(widget, i, c2->ch, l2, c2->x, _widget->w, 0);
+ _draw_line(widget, i, c2->ch, l2, c2->x, _widget->g.w, 0);
c1 = NULL;
c2 = NULL;
s = 0;
} else {
- _draw_line(widget, i, LINE_START(widget, i), LINE_LEN(widget, i), 0, _widget->w, s);
+ _draw_line(widget, i, LINE_START(widget, i), LINE_LEN(widget, i), 0, _widget->g.w, s);
}
if (widget->tagN && (widget->tagN < 0xfe)) widget->tagN++;
}
@@ -250,7 +249,7 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
if (widget->cursor1.on && (widget->cursor1.line >= line0) && (widget->cursor1.line < lineN)) _draw_cursor(widget, &widget->cursor1);
if (widget->cursor2.on && (widget->cursor2.line >= line0) && (widget->cursor2.line < lineN)) _draw_cursor(widget, &widget->cursor2);
if (lineNvisible) {
- _draw_line(widget, lineN, 0, 0, 0, _widget->w, 0);
+ _draw_line(widget, lineN, 0, 0, 0, _widget->g.w, 0);
} else if (widget->tagN) {
widget->tagN--;
}
@@ -365,7 +364,7 @@ int eve_textw_update(EVETextWidget *widget, uint16_t line) {
} else {
return EVE_ERR_TEXT;
}
- if ((line_w > _widget->w) && (line_b != LINE_EMPTY)) {
+ if ((line_w > _widget->g.w) && (line_b != LINE_EMPTY)) {
if (widget->line[line] == line_b) return line;
widget->line[line] = line_b;
line++;
@@ -383,7 +382,7 @@ int eve_textw_update(EVETextWidget *widget, uint16_t line) {
widget->text_len = i;
widget->line_len = line;
- _widget->h = (line + 1) * widget->font->h;
+ _widget->g.h = (line + 1) * widget->font->h;
for (i=line; i<widget->line_size; i++) {
widget->line[i] = LINE_EMPTY;
}
@@ -417,7 +416,7 @@ void eve_textw_cursor_set(EVETextWidget *widget, EVETextCursor *cursor, uint8_t
return;
}
- x -= _widget->x;
+ x -= _widget->g.x;
_x = 0;
_d = x;
for (i=LINE_START(widget, cursor->line); i<LINE_END(widget, cursor->line); i++) {
diff --git a/code/fe310/eos/eve/widget/text.h b/code/fe310/eos/eve/widget/text.h
index 83b131d..57798ee 100644
--- a/code/fe310/eos/eve/widget/text.h
+++ b/code/fe310/eos/eve/widget/text.h
@@ -30,8 +30,8 @@ typedef struct EVETextWidget {
} track;
} EVETextWidget;
-void eve_textw_init(EVETextWidget *widget, int16_t x, int16_t y, uint16_t w, uint16_t h, EVEFont *font, char *text, uint64_t text_size, uint16_t *line, uint16_t line_size);
-int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVEPageFocus *focus);
+void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEFont *font, char *text, uint64_t text_size, uint16_t *line, uint16_t line_size);
+int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx, EVERect *focus);
uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
void eve_textw_putc(void *_w, int c);
int eve_textw_update(EVETextWidget *widget, uint16_t line);
diff --git a/code/fe310/eos/eve/widget/widget.c b/code/fe310/eos/eve/widget/widget.c
index 44de4c6..79a1b25 100644
--- a/code/fe310/eos/eve/widget/widget.c
+++ b/code/fe310/eos/eve/widget/widget.c
@@ -1,10 +1,11 @@
#include <stdlib.h>
+#include <string.h>
#include "eve.h"
#include "eve_kbd.h"
#include "screen/screen.h"
-#include "screen/tile.h"
+#include "screen/window.h"
#include "screen/page.h"
#include "screen/font.h"
@@ -18,12 +19,9 @@ static const size_t _eve_wsize[] = {
sizeof(EVEPageWidget)
};
-void eve_widget_init(EVEWidget *widget, uint8_t type, int16_t x, int16_t y, uint16_t w, uint16_t h, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc) {
+void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc) {
widget->type = type;
- widget->x = x;
- widget->y = y;
- widget->w = w;
- widget->h = h;
+ if (g) widget->g = *g;
widget->touch = touch;
widget->draw = draw;
widget->putc = putc;
diff --git a/code/fe310/eos/eve/widget/widget.h b/code/fe310/eos/eve/widget/widget.h
index 8960e63..e6ea7a7 100644
--- a/code/fe310/eos/eve/widget/widget.h
+++ b/code/fe310/eos/eve/widget/widget.h
@@ -5,19 +5,16 @@
struct EVEWidget;
-typedef int (*eve_widget_touch_t) (struct EVEWidget *, EVEPage *, uint8_t, int, EVEPageFocus *);
+typedef int (*eve_widget_touch_t) (struct EVEWidget *, EVEPage *, uint8_t, int, EVERect *);
typedef uint8_t (*eve_widget_draw_t) (struct EVEWidget *, EVEPage *, uint8_t);
typedef struct EVEWidget {
uint8_t type;
- int16_t x;
- int16_t y;
- uint16_t w;
- uint16_t h;
+ EVERect g;
eve_widget_touch_t touch;
eve_widget_draw_t draw;
eve_kbd_input_handler_t putc;
} EVEWidget;
-void eve_widget_init(EVEWidget *widget, uint8_t type, int16_t x, int16_t y, uint16_t w, uint16_t h, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc);
+void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc);
EVEWidget *eve_widget_next(EVEWidget *widget);