diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-07-11 03:58:45 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-07-11 03:58:45 +0200 |
commit | 86aa553093084f9c2f04a5fb3d744b56b656ea3a (patch) | |
tree | ca2a6c735f1807956a1e4f4ae0826cdde120f668 /code/fe310/eos/eve/screen/screen.c | |
parent | d8ced7b070beaa010f557c4c244c5c386d4e6efd (diff) |
screen/window/kbd window implemented; str widget tested
Diffstat (limited to 'code/fe310/eos/eve/screen/screen.c')
-rw-r--r-- | code/fe310/eos/eve/screen/screen.c | 119 |
1 files changed, 62 insertions, 57 deletions
diff --git a/code/fe310/eos/eve/screen/screen.c b/code/fe310/eos/eve/screen/screen.c index 68b6fb8..f103b48 100644 --- a/code/fe310/eos/eve/screen/screen.c +++ b/code/fe310/eos/eve/screen/screen.c @@ -6,11 +6,14 @@ #include "screen.h" #include "window.h" +#include "kbdwin.h" int eve_screen_init(EVEScreen *screen, uint16_t w, uint16_t h) { memset(screen, 0, sizeof(EVEScreen)); screen->w = w; screen->h = h; + screen->mem_next = EVE_RAM_G; + eve_touch_set_handler(eve_screen_handle_touch, screen); } void eve_screen_set_kbd(EVEScreen *screen, EVEKbd *kbd) { @@ -22,74 +25,57 @@ EVEKbd *eve_screen_get_kbd(EVEScreen *screen) { } void eve_screen_show_kbd(EVEScreen *screen) { - if (screen->kbd && screen->kbd_win) screen->kbd_win->g.y = screen->h - screen->kbd->g.h; -} - -void eve_screen_hide_kbd(EVEScreen *screen) { - if (screen->kbd && screen->kbd_win) screen->kbd_win->g.y = screen->h; -} - -int eve_screen_win_insert(EVEScreen *screen, EVEWindow *window, int idx) { - if (idx) { - int i; - EVEWindow *h = screen->win_head; + EVEWindow *win = screen->win_tail; + EVEKbd *kbd = eve_screen_get_kbd(screen); - 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; + if (win) win->g.y = screen->h - kbd->g.h; } -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_hide_kbd(EVEScreen *screen) { + EVEWindow *win = screen->win_tail; -void eve_screen_win_append(EVEScreen *screen, EVEWindow *window) { - screen->win_tail->next = window; - screen->win_tail = window; + if (win) win->g.y = screen->h; } -void eve_screen_handle_touch(EVEScreen *screen, uint8_t tag0, int touch_idx) { - EVEWindow *w; - int a; +void eve_screen_draw(EVEScreen *screen) { + EVEWindow *win; uint8_t tagN = 0x80; - eve_touch_clear_opt(); - - w = screen->win_head; - while(w) { - if (eve_window_visible(w)) a = w->view->touch(w->view, tag0, touch_idx); - w = w->next; - } - eve_cmd_burst_start(); eve_cmd_dl(CMD_DLSTART); - eve_cmd_dl(CLEAR_COLOR_RGB(0,0,0)); - eve_cmd_dl(CLEAR(1,1,1)); - w = screen->win_head; - while(w) { - if (eve_window_visible(w)) tagN = w->view->draw(w->view, tagN); - w = w->next; + win = screen->win_head; + while (win) { + if (eve_window_visible(win)) { + int16_t x = win->g.x; + int16_t y = win->g.y; + uint16_t w = win->g.w; + uint16_t h = win->g.h; + + if (x < 0) { + w += x; + x = 0; + } + if (y < 0) { + h += y; + y = 0; + } + if (x + w > screen->w) w = screen->w - x; + if (y + h > screen->h) h = screen->h - y; + win->tag = tagN; + + if (tagN != EVE_TAG_NOTAG) { + eve_cmd_dl(CLEAR_TAG(tagN)); + tagN++; + } + eve_cmd_dl(CLEAR_COLOR_RGBC(win->color_bg)); + eve_cmd_dl(SCISSOR_XY(x, y)); + eve_cmd_dl(SCISSOR_SIZE(w, h)); + eve_cmd_dl(CLEAR(1,1,1)); + eve_cmd_dl(COLOR_RGBC(win->color_fg)); + tagN = win->view->draw(win->view, tagN); + } + win = win->next; } eve_cmd_dl(DISPLAY()); @@ -97,3 +83,22 @@ void eve_screen_handle_touch(EVEScreen *screen, uint8_t tag0, int touch_idx) { eve_cmd_burst_end(); eve_cmd_exec(1); } + +void eve_screen_handle_touch(void *s, uint8_t tag0, int touch_idx) { + EVEScreen *screen = s; + EVEWindow *win; + + eve_touch_clear_opt(); + + if (touch_idx >= 0) { + win = screen->win_tail; + while (win) { + if (eve_window_visible(win)) { + int a = win->view->touch(win->view, tag0, touch_idx); + } + win = win->prev; + } + } + + eve_screen_draw(screen); +} |