diff options
Diffstat (limited to 'fw/fe310/eos/eve/screen/window.c')
-rw-r--r-- | fw/fe310/eos/eve/screen/window.c | 125 |
1 files changed, 78 insertions, 47 deletions
diff --git a/fw/fe310/eos/eve/screen/window.c b/fw/fe310/eos/eve/screen/window.c index 34d265a..90f4e20 100644 --- a/fw/fe310/eos/eve/screen/window.c +++ b/fw/fe310/eos/eve/screen/window.c @@ -1,6 +1,5 @@ #include <stdlib.h> #include <string.h> -#include <stdio.h> #include "eve.h" #include "eve_kbd.h" @@ -28,7 +27,7 @@ void eve_window_init_root(EVEWindowRoot *root, EVERect *g, char *name, EVEFont * root->font = font; root->win_kbd = NULL; root->win_scroll = NULL; - root->tag0 = EVE_NOTAG; + root->tag_scroll = EVE_NOTAG; eve_touch_set_handler(eve_window_root_touch, root); } @@ -41,10 +40,10 @@ static uint8_t kbd_draw(EVEView *view, uint8_t tag0) { return tag0; } -static int kbd_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { +static int kbd_touch(EVEView *view, EVETouch *touch, uint16_t evt) { EVEKbd *kbd = view->param; - return eve_kbd_touch(kbd, touch, evt, tag0); + return eve_kbd_touch(kbd, touch, evt); } void eve_window_init_kbd(EVEWindowKbd *win_kbd, EVERect *g, EVEWindowRoot *root, char *name, EVEKbd *kbd) { @@ -55,6 +54,7 @@ void eve_window_init_kbd(EVEWindowKbd *win_kbd, EVERect *g, EVEWindowRoot *root, win_kbd->kbd = kbd; root->win_kbd = win_kbd; eve_view_init(&win_kbd->v, _window, kbd_draw, kbd_touch, NULL, kbd); + eve_view_attach(&win_kbd->v, _window, NULL); } void eve_window_set_parent(EVEWindow *window, EVEWindow *parent) { @@ -62,6 +62,26 @@ void eve_window_set_parent(EVEWindow *window, EVEWindow *parent) { window->root = parent->root; } +void eve_window_attach_view(EVEWindow *window, EVEView *view, void *view_id) { + if (window->view) window->dirty = 1; + window->view = view; + window->view_id = view_id; +} + +void eve_window_detach_view(EVEWindow *window) { + if (window->view) window->dirty = 1; + window->view = NULL; + window->view_id = NULL; +} + +int eve_window_dirty(EVEWindow *window) { + return window->dirty; +} + +void eve_window_clean(EVEWindow *window) { + window->dirty = 0; +} + int eve_window_visible(EVEWindow *window) { if (window->g.x >= window->root->w.g.w) return 0; if (window->g.y >= window->root->w.g.h) return 0; @@ -70,31 +90,32 @@ int eve_window_visible(EVEWindow *window) { return 1; } -static void window_visible_g(EVEWindow *w, EVERect *g) { - while (w) { - if (eve_window_visible(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; +static void window_visible_g(EVEWindow *win, EVERect *rect) { + while (win) { + if (eve_window_visible(win)) { + if (win->g.x > rect->x) rect->w = MIN(rect->w, win->g.x - rect->x); + if (win->g.y > rect->y) rect->h = MIN(rect->h, win->g.y - rect->y); + if (win->g.x + win->g.w < rect->x + rect->w) { + uint16_t x0 = rect->w - MIN(rect->w, (rect->x + rect->w) - (win->g.x + win->g.w)); + rect->x += x0; + rect->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; + if (win->g.y + win->g.h < rect->y + rect->h) { + uint16_t y0 = rect->h - MIN(rect->h, (rect->y + rect->h) - (win->g.y + win->g.h)); + rect->y += y0; + rect->h -= y0; } + if ((rect->w == 0) || (rect->h == 0)) return; } - if (w->child_head) window_visible_g(w->child_head, g); - w = w->next; + if (win->child_head) window_visible_g(win->child_head, rect); + win = win->next; } } -void eve_window_visible_g(EVEWindow *window, EVERect *g) { - *g = window->g; - if (window->child_head) window_visible_g(window->child_head, g); - window_visible_g(window->next, g); +void eve_window_visible_g(EVEWindow *window, EVERect *rect) { + *rect = window->g; + if (window->child_head) window_visible_g(window->child_head, rect); + window_visible_g(window->next, rect); } void eve_window_append(EVEWindow *window) { @@ -160,8 +181,8 @@ EVEWindow *eve_window_search(EVEWindow *window, char *name) { while (window) { if (window->name && (strcmp(name, window->name) == 0)) return window; if (window->child_head) { - EVEWindow *ret = eve_window_search(window->child_head, name); - if (ret) return ret; + EVEWindow *rv = eve_window_search(window->child_head, name); + if (rv) return rv; } window = window->next; } @@ -198,17 +219,18 @@ uint8_t eve_window_draw(EVEWindow *window, uint8_t tag0) { return tag0; } -int eve_window_touch(EVEWindow *window, EVETouch *touch, uint16_t evt, uint8_t tag0) { - int ret = 0; +int eve_window_touch(EVEWindow *window, EVETouch *touch, uint16_t evt) { + int rv = 0; while (window) { if (window->child_tail) { - ret = eve_window_touch(window->child_tail, touch, evt, tag0); - if (ret) return 1; + rv = eve_window_touch(window->child_tail, touch, evt); + if (rv) return 1; } if (eve_window_visible(window) && window->view) { - ret = window->view->touch(window->view, touch, evt, tag0); - if (ret) return 1; + rv = window->view->touch(window->view, touch, evt); + window->dirty = 0; + if (rv) return 1; } window = window->prev; } @@ -223,24 +245,31 @@ void eve_window_root_draw(EVEWindowRoot *root) { eve_cmd_burst_start(); eve_cmd_dl(CMD_DLSTART); - if (root->tag0 != EVE_NOTAG) tag0 = EVE_NOTAG; + if (root->tag_scroll != EVE_NOTAG) tag0 = EVE_NOTAG; eve_window_draw(&root->w, tag0); eve_cmd_dl(DISPLAY()); eve_cmd_dl(CMD_SWAP); eve_cmd_burst_end(); rv = eve_cmd_exec(1); - if (rv) printf("EVE EXEC ERR\n"); + if (rv) EVE_LOG(EVE_LOG_ERR, "EVE CMD EXEC ERR:%d\n", rv); } -void eve_window_root_touch(EVETouch *touch, uint16_t evt, uint8_t tag0, void *win) { +void eve_window_root_touch(EVETouch *touch, uint16_t evt, void *win) { EVEWindowRoot *root = (EVEWindowRoot *)win; - int ret; + int rv; - if (root->tag0 != EVE_NOTAG) tag0 = root->tag0; - ret = eve_window_touch(&root->w, touch, evt, tag0); - if (ret) { - eve_touch_clear_opt(); + rv = eve_window_touch(&root->w, touch, evt); + if (rv) { + uint8_t tag_opt = 0; + + if (root->tag_scroll != EVE_NOTAG) { + tag_opt = eve_tag_get_opt(root->tag_scroll); + } + eve_tag_clear_opt(); + if (root->tag_scroll != EVE_NOTAG) { + eve_tag_set_opt(root->tag_scroll, tag_opt); + } eve_window_root_draw(root); } } @@ -275,14 +304,10 @@ void eve_window_kbd_detach(EVEWindow *window) { } } -EVEFont *eve_window_font(EVEWindow *window) { +EVEWindow *eve_window_scroll(EVEWindow *window, uint8_t *tag) { EVEWindowRoot *root = window->root; - return root->font; -} - -EVEWindow *eve_window_scroll(EVEWindowRoot *root, uint8_t *tag) { - if (tag) *tag = root->tag0; + if (tag) *tag = root->tag_scroll; return root->win_scroll; } @@ -290,12 +315,18 @@ void eve_window_scroll_start(EVEWindow *window, uint8_t tag) { EVEWindowRoot *root = window->root; root->win_scroll = window; - root->tag0 = tag; + root->tag_scroll = tag; } void eve_window_scroll_stop(EVEWindow *window) { EVEWindowRoot *root = window->root; root->win_scroll = NULL; - root->tag0 = EVE_NOTAG; + root->tag_scroll = EVE_NOTAG; +} + +EVEFont *eve_window_font(EVEWindow *window) { + EVEWindowRoot *root = window->root; + + return root->font; } |