From 95f69d4f83ad8f7fbb56349f29e902928510362b Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 24 Mar 2021 23:13:42 +0100 Subject: window hierarchy --- fw/fe310/eos/app/Makefile | 2 +- fw/fe310/eos/app/app_form.c | 5 +- fw/fe310/eos/app/app_root.c | 86 ++++++++++++++++ fw/fe310/eos/app/app_root.h | 10 ++ fw/fe310/eos/app/app_screen.c | 94 ----------------- fw/fe310/eos/app/app_screen.h | 9 -- fw/fe310/eos/app/app_status.c | 10 +- fw/fe310/eos/eve/eve_kbd.c | 14 +-- fw/fe310/eos/eve/screen/Makefile | 2 +- fw/fe310/eos/eve/screen/form.c | 95 +++++++++--------- fw/fe310/eos/eve/screen/form.h | 1 + fw/fe310/eos/eve/screen/page.c | 21 ++-- fw/fe310/eos/eve/screen/page.h | 2 +- fw/fe310/eos/eve/screen/screen.c | 109 -------------------- fw/fe310/eos/eve/screen/screen.h | 21 ---- fw/fe310/eos/eve/screen/view.c | 26 ++++- fw/fe310/eos/eve/screen/view.h | 22 ++-- fw/fe310/eos/eve/screen/window.c | 206 ++++++++++++++++++++++++++++++++------ fw/fe310/eos/eve/screen/window.h | 43 ++++++-- fw/fe310/eos/eve/widget/freew.c | 2 - fw/fe310/eos/eve/widget/label.c | 2 - fw/fe310/eos/eve/widget/pagew.c | 2 - fw/fe310/eos/eve/widget/selectw.c | 6 +- fw/fe310/eos/eve/widget/spacerw.c | 2 - fw/fe310/eos/eve/widget/strw.c | 21 ++-- fw/fe310/eos/eve/widget/textw.c | 22 ++-- fw/fe310/eos/eve/widget/widget.c | 2 - fw/fe310/test/cell_pdp.c | 4 +- fw/fe310/test/main.c | 6 +- fw/fe310/test/modem.c | 37 ++++--- fw/fe310/test/phone.c | 4 +- fw/fe310/test/status.c | 15 ++- fw/fe310/test/wifi.c | 9 +- 33 files changed, 463 insertions(+), 449 deletions(-) create mode 100644 fw/fe310/eos/app/app_root.c create mode 100644 fw/fe310/eos/app/app_root.h delete mode 100644 fw/fe310/eos/app/app_screen.c delete mode 100644 fw/fe310/eos/app/app_screen.h delete mode 100644 fw/fe310/eos/eve/screen/screen.c delete mode 100644 fw/fe310/eos/eve/screen/screen.h (limited to 'fw') diff --git a/fw/fe310/eos/app/Makefile b/fw/fe310/eos/app/Makefile index f1dbf70..9560fd7 100644 --- a/fw/fe310/eos/app/Makefile +++ b/fw/fe310/eos/app/Makefile @@ -2,7 +2,7 @@ include ../../common.mk CFLAGS += -I.. -obj = app_screen.o app_status.o app_form.o +obj = app_root.o app_status.o app_form.o %.o: %.c %.h diff --git a/fw/fe310/eos/app/app_form.c b/fw/fe310/eos/app/app_form.c index c7056e0..5d59833 100644 --- a/fw/fe310/eos/app/app_form.c +++ b/fw/fe310/eos/app/app_form.c @@ -6,15 +6,12 @@ #include "eve/eve_kbd.h" #include "eve/eve_font.h" -#include "eve/screen/screen.h" #include "eve/screen/window.h" -#include "eve/screen/view.h" #include "eve/screen/page.h" #include "eve/screen/form.h" #include "eve/widget/widgets.h" -#include "app_screen.h" #include "app_form.h" static EVEFont font; @@ -77,7 +74,7 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec s if (label->g.w == 0) label->g.w = eve_font_str_w(_font, label->title); } if (widget->label && (widget->label->g.w == 0)) eve_font_str_w(label->font, label->title) + APP_LABEL_MARGIN; - if (widget->g.w == 0) widget->g.w = APP_SCREEN_W - (widget->label ? widget->label->g.w : 0); + if (widget->g.w == 0) widget->g.w = window->g.w - (widget->label ? widget->label->g.w : 0); widget = eve_widget_next(widget); } diff --git a/fw/fe310/eos/app/app_root.c b/fw/fe310/eos/app/app_root.c new file mode 100644 index 0000000..f30c8d4 --- /dev/null +++ b/fw/fe310/eos/app/app_root.c @@ -0,0 +1,86 @@ +#include + +#include "net.h" +#include "unicode.h" + +#include "eve/eve.h" +#include "eve/eve_kbd.h" +#include "eve/eve_font.h" + +#include "eve/screen/window.h" +#include "eve/screen/page.h" +#include "eve/screen/form.h" + +#include "eve/widget/widgets.h" + +#include "app_status.h" +#include "app_root.h" + +#define KBD_X 0 +#define KBD_Y 575 +#define KBD_W 480 +#define KBD_H 225 + +static EVEKbd kbd; +static EVEWindowRoot win_root; +static EVEWindowKbd win_kbd; +static EVEWindow win_status; +static EVEWindow win_main; +static EVEView view_status; +static EVEViewStack view_stack; + +EVEWindow *app_root(void) { + return (EVEWindow *)&win_root; +} + +void app_root_refresh(void) { + eve_spi_start(); + eve_window_root_draw(app_root()); + eve_spi_stop(); +} + +void app_root_init(eve_view_constructor_t home_page) { + EVERect g; + + eve_spi_start(); + + eve_brightness(0x40); + + g.x = 0; + g.y = 0; + g.w = APP_SCREEN_W; + g.h = APP_SCREEN_H; + eve_window_init_root(&win_root, &g, "root"); + + g.x = KBD_X; + g.y = KBD_Y; + g.w = KBD_W; + g.h = KBD_H; + eve_kbd_init(&kbd, &g, win_root.mem_next, &win_root.mem_next); + eve_window_init_kbd(&win_kbd, &g, &win_root, "kbd", &kbd); + + g.x = 0; + g.y = 0; + g.w = APP_SCREEN_W; + g.h = APP_STATUS_H; + eve_window_init(&win_status, &g, (EVEWindow *)&win_root, "status"); + eve_view_init(&view_status, &win_status, app_status_draw, app_status_touch, NULL); + + g.x = 0; + g.y = APP_STATUS_H; + g.w = APP_SCREEN_W; + g.h = APP_SCREEN_H - APP_STATUS_H; + eve_window_init(&win_main, &g, (EVEWindow *)&win_root, "main"); + + eve_view_stack_init(&view_stack); + eve_view_create(&win_main, &view_stack, home_page); + + eve_window_append(&win_status); + eve_window_append(&win_main); + + eve_window_root_draw((EVEWindow *)&win_root); + + eve_spi_stop(); + + eos_net_acquire_for_evt(EOS_EVT_UI | EVE_ETYPE_INTR, 1); +} diff --git a/fw/fe310/eos/app/app_root.h b/fw/fe310/eos/app/app_root.h new file mode 100644 index 0000000..2a51c77 --- /dev/null +++ b/fw/fe310/eos/app/app_root.h @@ -0,0 +1,10 @@ +#include + +#define APP_SCREEN_W 480 +#define APP_SCREEN_H 800 +#define APP_STATUS_H 60 + +EVEWindow *app_root(void); +void app_root_refresh(void); + +void app_root_init(eve_view_constructor_t home_page); diff --git a/fw/fe310/eos/app/app_screen.c b/fw/fe310/eos/app/app_screen.c deleted file mode 100644 index 9f3a236..0000000 --- a/fw/fe310/eos/app/app_screen.c +++ /dev/null @@ -1,94 +0,0 @@ -#include - -#include "net.h" -#include "unicode.h" - -#include "eve/eve.h" -#include "eve/eve_kbd.h" -#include "eve/eve_font.h" - -#include "eve/screen/screen.h" -#include "eve/screen/window.h" -#include "eve/screen/view.h" -#include "eve/screen/page.h" -#include "eve/screen/form.h" - -#include "eve/widget/widgets.h" - -#include "app_status.h" -#include "app_screen.h" - -static EVEKbd kbd; -static EVEScreen screen; -static EVEWindow win_status; -static EVEWindow win_main; -static EVEWindow win_kbd; -static EVEView view_kbd; -static EVEView view_status; -static EVEViewStack view_stack; - -EVEScreen *app_screen(void) { - return &screen; -} - -static int kbd_touch(EVEView *v, EVETouch *touch, uint16_t evt, uint8_t tag0) { - EVEKbd *kbd = v->param; - - return eve_kbd_touch(kbd, touch, evt, tag0); -} - -static uint8_t kbd_draw(EVEView *v, uint8_t tag0) { - EVEKbd *kbd = v->param; - - eve_kbd_draw(kbd); - return tag0; -} - -void app_screen_refresh(void) { - eve_spi_start(); - eve_screen_draw(app_screen()); - eve_spi_stop(); -} - -void app_screen_init(eve_view_constructor_t home_page) { - EVERect g; - - eve_spi_start(); - - eve_brightness(0x40); - - eve_screen_init(&screen, APP_SCREEN_W, APP_SCREEN_H); - - eve_kbd_init(&kbd, NULL, screen.mem_next, &screen.mem_next); - eve_screen_set_kbd(&screen, &kbd); - - g.x = 0; - g.y = 0; - g.w = APP_SCREEN_W; - g.h = APP_STATUS_H; - eve_window_init(&win_status, &g, &screen, "status"); - eve_view_init(&view_status, &win_status, app_status_touch, app_status_draw, NULL); - - g.x = 0; - g.y = APP_STATUS_H; - g.w = APP_SCREEN_W; - g.h = APP_SCREEN_H - APP_STATUS_H; - eve_window_init(&win_main, &g, &screen, "main"); - - eve_window_init(&win_kbd, &kbd.g, &screen, "kbd"); - eve_view_init(&view_kbd, &win_kbd, kbd_touch, kbd_draw, &kbd); - - eve_view_stack_init(&view_stack); - eve_view_create(&win_main, &view_stack, home_page); - - eve_window_append(&win_status); - eve_window_append(&win_main); - eve_window_append(&win_kbd); - - eve_screen_hide_kbd(&screen); - eve_screen_draw(&screen); - - eve_spi_stop(); - - eos_net_acquire_for_evt(EOS_EVT_UI | EVE_ETYPE_INTR, 1); -} diff --git a/fw/fe310/eos/app/app_screen.h b/fw/fe310/eos/app/app_screen.h deleted file mode 100644 index 1e266d4..0000000 --- a/fw/fe310/eos/app/app_screen.h +++ /dev/null @@ -1,9 +0,0 @@ -#include - -#define APP_SCREEN_W 480 -#define APP_SCREEN_H 800 -#define APP_STATUS_H 60 - -EVEScreen *app_screen(void); -void app_screen_init(eve_view_constructor_t home_page); -void app_screen_refresh(void); diff --git a/fw/fe310/eos/app/app_status.c b/fw/fe310/eos/app/app_status.c index 3fdb45a..11cc36d 100644 --- a/fw/fe310/eos/app/app_status.c +++ b/fw/fe310/eos/app/app_status.c @@ -5,16 +5,14 @@ #include "eve/eve.h" #include "eve/eve_kbd.h" -#include "eve/screen/screen.h" #include "eve/screen/window.h" -#include "eve/screen/view.h" #include "app_status.h" -int app_status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { - return 0; +uint8_t app_status_draw(EVEView *view, uint8_t tag0) { + return eve_view_clear(view, tag0); } -uint8_t app_status_draw(EVEView *view, uint8_t tag0) { - return tag0; +int app_status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { + return 0; } diff --git a/fw/fe310/eos/eve/eve_kbd.c b/fw/fe310/eos/eve/eve_kbd.c index a664ef2..c8c1362 100644 --- a/fw/fe310/eos/eve/eve_kbd.c +++ b/fw/fe310/eos/eve/eve_kbd.c @@ -4,11 +4,6 @@ #include "eve.h" #include "eve_kbd.h" -#define KBD_X 0 -#define KBD_Y 575 -#define KBD_W 480 -#define KBD_H 225 - #define KEY_SPACERX 3 #define KEY_SPACERY 5 #define KEY_FONT 29 @@ -28,14 +23,7 @@ void eve_kbd_init(EVEKbd *kbd, EVERect *g, uint32_t mem_addr, uint32_t *mem_next) { uint16_t mem_size; - if (g) { - kbd->g = *g; - } else { - kbd->g.x = KBD_X; - kbd->g.y = KBD_Y; - kbd->g.w = KBD_W; - kbd->g.h = KBD_H; - } + kbd->g = *g; kbd->mem_addr = mem_addr; kbd->key_modifier = 0; kbd->key_modifier_sticky = 0; diff --git a/fw/fe310/eos/eve/screen/Makefile b/fw/fe310/eos/eve/screen/Makefile index fc21670..cc4a81d 100644 --- a/fw/fe310/eos/eve/screen/Makefile +++ b/fw/fe310/eos/eve/screen/Makefile @@ -2,7 +2,7 @@ include ../../../common.mk CFLAGS += -I.. -I../.. -obj = screen.o window.o view.o page.o form.o +obj = window.o view.o page.o form.o %.o: %.c %.h diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c index 5d71d80..d3707fc 100644 --- a/fw/fe310/eos/eve/screen/form.c +++ b/fw/fe310/eos/eve/screen/form.c @@ -7,9 +7,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen.h" #include "window.h" -#include "view.h" #include "page.h" #include "form.h" @@ -24,30 +22,30 @@ static void form_update_g(EVEForm *form, EVEWidget *_widget) { int i; uint16_t w = 0; uint16_t h = 0; - uint16_t _h = 0; + uint16_t l_h = 0; for (i=0; iwidget_size; i++) { if (widget->label) { - h += _h; + h += l_h; w = widget->label->g.w; - _h = widget->label->g.h; + l_h = widget->label->g.h; widget->label->g.x = 0; widget->label->g.y = h; } if (w + widget->g.w > form->p.v.window->g.w) { - h += _h; + h += l_h; w = 0; - _h = 0; + l_h = 0; } widget->g.x = w; widget->g.y = h; - form->h = widget->g.y + widget->g.h; w += widget->g.w; - _h = MAX(_h, widget->g.h); + l_h = MAX(l_h, widget->g.h); widget = eve_widget_next(widget); } + form->h = h + l_h; } static int form_handle_evt(EVEForm *form, EVEWidget *widget, EVETouch *touch, uint16_t evt, uint8_t tag0) { @@ -67,15 +65,20 @@ static int form_handle_evt(EVEForm *form, EVEWidget *widget, EVETouch *touch, ui /* Scroll stop */ if (((evt & EVE_TOUCH_ETYPE_TRACK_STOP) && !(evt & EVE_TOUCH_ETYPE_TRACK_ABORT)) || ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (touch->eevt & EVE_TOUCH_EETYPE_ABORT) && !(touch->eevt & EVE_TOUCH_EETYPE_TRACK_XY))) { - int wmax_y; + int wmax_x, wmax_y; + int lho_x, lho_y; EVERect vg; eve_window_visible_g(page->v.window, &vg); + wmax_x = form->w > vg.w ? form->w - vg.w : 0; wmax_y = form->h > vg.h ? form->h - vg.h : 0; - if ((page->win_y < 0) || (page->win_y > wmax_y)) { + lho_x = page->win_x < 0 ? 0 : wmax_x; + lho_y = page->win_y < 0 ? 0 : wmax_y; + if ((page->win_x < 0) || (page->win_x > wmax_x) || + (page->win_y < 0) || (page->win_y > wmax_y)) { EVEPhyLHO *lho = &form->lho; - eve_phy_lho_init(lho, 0, page->win_y < 0 ? 0 : wmax_y, 1000, 0.5, 0); - eve_phy_lho_start(lho, 0, page->win_y); + eve_phy_lho_init(lho, lho_x, lho_y, 1000, 0.5, 0); + eve_phy_lho_start(lho, page->win_x, page->win_y); form->lho_t0 = eve_time_get_tick(); eve_touch_timer_start(tag0, 20); } else { @@ -120,7 +123,7 @@ static int form_handle_evt(EVEForm *form, EVEWidget *widget, EVETouch *touch, ui int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_form_action_t action, eve_form_destructor_t destructor) { memset(form, 0, sizeof(EVEForm)); - eve_page_init(&form->p, window, stack, eve_form_touch, eve_form_draw, (eve_page_destructor_t)destructor); + eve_page_init(&form->p, window, stack, eve_form_draw, eve_form_touch, (eve_page_destructor_t)destructor); form->widget = widget; form->widget_size = widget_size; @@ -128,36 +131,6 @@ int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidg form_update_g(form, NULL); } -int eve_form_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { - EVEForm *form = (EVEForm *)view; - EVEWidget *widget = form->widget; - int8_t touch_idx = eve_touch_get_idx(touch); - uint16_t _evt; - int i, ret; - - if (touch_idx > 0) return 0; - - _evt = eve_touch_evt(touch, evt, tag0, form->p.v.window->tag, 1); - if (_evt) { - ret = form_handle_evt(form, NULL, touch, _evt, tag0); - if (ret) return 1; - } - for (i=0; iwidget_size; i++) { - _evt = eve_touch_evt(touch, evt, tag0, widget->tag0, widget->tagN - widget->tag0); - if (_evt) { - if (!form->evt_lock) { - ret = widget->touch(widget, &form->p, touch, _evt); - if (ret) return 1; - } - ret = form_handle_evt(form, widget, touch, _evt, tag0); - if (ret) return 1; - } - widget = eve_widget_next(widget); - } - - return 0; -} - uint8_t eve_form_draw(EVEView *view, uint8_t tag0) { EVEForm *form = (EVEForm *)view; EVEWidget *widget = form->widget; @@ -165,6 +138,8 @@ uint8_t eve_form_draw(EVEView *view, uint8_t tag0) { uint8_t tagN = tag0; uint8_t tag_opt = EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT_Y; + tagN = eve_view_clear(view, tagN); + eve_cmd_dl(SAVE_CONTEXT()); eve_cmd_dl(VERTEX_FORMAT(0)); eve_cmd_dl(VERTEX_TRANSLATE_X(eve_page_scr_x(&form->p, 0) * 16)); @@ -188,11 +163,41 @@ uint8_t eve_form_draw(EVEView *view, uint8_t tag0) { for (i=tag0; iwindow->tag != EVE_TAG_NOTAG) eve_touch_set_opt(view->window->tag, eve_touch_get_opt(view->window->tag) | tag_opt); + if (view->tag != EVE_TAG_NOTAG) eve_touch_set_opt(view->tag, eve_touch_get_opt(view->tag) | tag_opt); return tagN; } +int eve_form_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { + EVEForm *form = (EVEForm *)view; + EVEWidget *widget = form->widget; + int8_t touch_idx = eve_touch_get_idx(touch); + uint16_t _evt; + int i, ret; + + if (touch_idx > 0) return 0; + + _evt = eve_touch_evt(touch, evt, tag0, form->p.v.tag, 1); + if (_evt) { + ret = form_handle_evt(form, NULL, touch, _evt, tag0); + if (ret) return 1; + } + for (i=0; iwidget_size; i++) { + _evt = eve_touch_evt(touch, evt, tag0, widget->tag0, widget->tagN - widget->tag0); + if (_evt) { + if (!form->evt_lock) { + ret = widget->touch(widget, &form->p, touch, _evt); + if (ret) return 1; + } + ret = form_handle_evt(form, widget, touch, _evt, tag0); + if (ret) return 1; + } + widget = eve_widget_next(widget); + } + + return 0; +} + EVEWidget *eve_form_widget(EVEForm *form, uint16_t idx) { EVEWidget *w = form->widget; int i; diff --git a/fw/fe310/eos/eve/screen/form.h b/fw/fe310/eos/eve/screen/form.h index 51b56b0..96c5930 100644 --- a/fw/fe310/eos/eve/screen/form.h +++ b/fw/fe310/eos/eve/screen/form.h @@ -13,6 +13,7 @@ typedef struct EVEForm { eve_form_action_t action; int win_x0; int win_y0; + uint16_t w; uint16_t h; uint8_t evt_lock; EVEPhyLHO lho; diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c index 51e2637..0951b1b 100644 --- a/fw/fe310/eos/eve/screen/page.c +++ b/fw/fe310/eos/eve/screen/page.c @@ -7,9 +7,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen.h" #include "window.h" -#include "view.h" #include "page.h" #include "widget/label.h" @@ -17,9 +15,9 @@ #define CH_EOF 0x1a -void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_destructor_t destructor) { +void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_draw_t draw, eve_view_touch_t touch, eve_page_destructor_t destructor) { memset(page, 0, sizeof(EVEPage)); - eve_view_init(&page->v, window, touch, draw, NULL); + eve_view_init(&page->v, window, draw, touch, NULL); page->destructor = destructor; page->stack = stack; page->widget_f = NULL; @@ -36,13 +34,12 @@ void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor) { void eve_page_close(EVEPage *page) { EVEWindow *window = page->v.window; - EVEScreen *screen = window->screen; EVEViewStack *stack = page->stack; eve_page_destructor_t destructor = page->destructor; if (stack->level > 1) { if (destructor) destructor(page); - eve_screen_hide_kbd(screen); + eve_window_kbd_detach(window); eve_view_destroy(window, stack); } } @@ -65,18 +62,20 @@ int16_t eve_page_scr_y(EVEPage *page, int16_t y) { void eve_page_set_focus(EVEPage *page, EVEWidget *widget, EVERect *f) { if (page->widget_f != widget) { - EVEScreen *screen = page->v.window->screen; + EVEWindow *window = page->v.window; EVEWidget *widget_f = page->widget_f; if (widget_f && widget_f->putc) { - eve_screen_hide_kbd(screen); + eve_window_kbd_detach(window); widget_f->putc(page, CH_EOF); } if (widget && widget->putc) { - EVEKbd *kbd = eve_screen_get_kbd(screen); + EVEKbd *kbd = eve_window_kbd(window); - if (kbd) eve_kbd_set_handler(kbd, widget->putc, page); - eve_screen_show_kbd(screen); + if (kbd) { + eve_kbd_set_handler(kbd, widget->putc, page); + eve_window_kbd_attach(window); + } } page->widget_f = widget; } diff --git a/fw/fe310/eos/eve/screen/page.h b/fw/fe310/eos/eve/screen/page.h index c198d94..cf6b8be 100644 --- a/fw/fe310/eos/eve/screen/page.h +++ b/fw/fe310/eos/eve/screen/page.h @@ -14,7 +14,7 @@ typedef struct EVEPage { struct EVEWidget *widget_f; } EVEPage; -void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_destructor_t destructor); +void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_draw_t draw, eve_view_touch_t touch, eve_page_destructor_t destructor); void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor); void eve_page_close(EVEPage *page); diff --git a/fw/fe310/eos/eve/screen/screen.c b/fw/fe310/eos/eve/screen/screen.c deleted file mode 100644 index 25a1a76..0000000 --- a/fw/fe310/eos/eve/screen/screen.c +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include - -#include "eve.h" -#include "eve_kbd.h" - -#include "screen.h" -#include "window.h" -#include "view.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) { - screen->kbd = kbd; -} - -EVEKbd *eve_screen_get_kbd(EVEScreen *screen) { - return screen->kbd; -} - -void eve_screen_show_kbd(EVEScreen *screen) { - EVEWindow *win = screen->win_tail; - EVEKbd *kbd = eve_screen_get_kbd(screen); - - if (win && kbd) win->g.y = screen->h - kbd->g.h; -} - -void eve_screen_hide_kbd(EVEScreen *screen) { - EVEWindow *win = screen->win_tail; - EVEKbd *kbd = eve_screen_get_kbd(screen); - - if (win && kbd) { - win->g.y = screen->h; - eve_kbd_close(kbd); - } -} - -void eve_screen_draw(EVEScreen *screen) { - EVEWindow *win; - uint8_t tagN = 0x80; - - eve_cmd_burst_start(); - eve_cmd_dl(CMD_DLSTART); - - 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()); - eve_cmd_dl(CMD_SWAP); - eve_cmd_burst_end(); - eve_cmd_exec(1); -} - -void eve_screen_handle_touch(EVETouch *touch, uint16_t evt, uint8_t tag0, void *s) { - EVEScreen *screen = s; - EVEWindow *win; - int h = 0; - - win = screen->win_tail; - while (win) { - if (eve_window_visible(win)) { - h = win->view->touch(win->view, touch, evt, tag0); - if (h) break; - } - win = win->prev; - } - - if (h) { - eve_touch_clear_opt(); - eve_screen_draw(screen); - } -} diff --git a/fw/fe310/eos/eve/screen/screen.h b/fw/fe310/eos/eve/screen/screen.h deleted file mode 100644 index 2f3f3ac..0000000 --- a/fw/fe310/eos/eve/screen/screen.h +++ /dev/null @@ -1,21 +0,0 @@ -#include - -struct EVEWindow; - -typedef struct EVEScreen { - uint16_t w; - uint16_t h; - uint32_t mem_next; - struct EVEWindow *win_head; - struct EVEWindow *win_tail; - EVEKbd *kbd; -} EVEScreen; - -int eve_screen_init(EVEScreen *screen, uint16_t w, uint16_t h); -void eve_screen_set_kbd(EVEScreen *screen, EVEKbd *kbd); -EVEKbd *eve_screen_get_kbd(EVEScreen *screen); -void eve_screen_show_kbd(EVEScreen *screen); -void eve_screen_hide_kbd(EVEScreen *screen); - -void eve_screen_draw(EVEScreen *screen); -void eve_screen_handle_touch(EVETouch *touch, uint16_t evt, uint8_t tag0, void *s); diff --git a/fw/fe310/eos/eve/screen/view.c b/fw/fe310/eos/eve/screen/view.c index 30229e5..ce4101f 100644 --- a/fw/fe310/eos/eve/screen/view.c +++ b/fw/fe310/eos/eve/screen/view.c @@ -4,18 +4,38 @@ #include "eve.h" #include "eve_kbd.h" -#include "screen.h" #include "window.h" -#include "view.h" -void eve_view_init(EVEView *view, EVEWindow *window, eve_view_touch_t touch, eve_view_draw_t draw, void *param) { +void eve_view_init(EVEView *view, EVEWindow *window, eve_view_draw_t draw, eve_view_touch_t touch, void *param) { view->touch = touch; view->draw = draw; view->param = param; view->window = window; + view->color_bg = 0x000000; + view->color_fg = 0xffffff; window->view = view; } +void eve_view_set_color_bg(EVEView *view, uint8_t r, uint8_t g, uint8_t b) { + view->color_bg = (r << 16) | (g << 8) | b; +} + +void eve_view_set_color_fg(EVEView *view, uint8_t r, uint8_t g, uint8_t b) { + view->color_fg = (r << 16) | (g << 8) | b; +} + +uint8_t eve_view_clear(EVEView *view, uint8_t tag0) { + eve_cmd_dl(CLEAR_COLOR_RGBC(view->color_bg)); + eve_cmd_dl(COLOR_RGBC(view->color_fg)); + view->tag = tag0; + if (tag0 != EVE_TAG_NOTAG) { + eve_cmd_dl(CLEAR_TAG(tag0)); + tag0++; + } + eve_cmd_dl(CLEAR(1,1,1)); + return tag0; +} + void eve_view_stack_init(EVEViewStack *stack) { memset(stack, 0, sizeof(EVEViewStack)); } diff --git a/fw/fe310/eos/eve/screen/view.h b/fw/fe310/eos/eve/screen/view.h index 6164a88..f0e2eb0 100644 --- a/fw/fe310/eos/eve/screen/view.h +++ b/fw/fe310/eos/eve/screen/view.h @@ -4,16 +4,20 @@ struct EVEView; struct EVEViewStack; +struct EVEWindow; -typedef int (*eve_view_touch_t) (struct EVEView *, EVETouch *, uint16_t, uint8_t); typedef uint8_t (*eve_view_draw_t) (struct EVEView *, uint8_t); -typedef void (*eve_view_constructor_t) (EVEWindow *window, struct EVEViewStack *); +typedef int (*eve_view_touch_t) (struct EVEView *, EVETouch *, uint16_t, uint8_t); +typedef void (*eve_view_constructor_t) (struct EVEWindow *window, struct EVEViewStack *); typedef struct EVEView { - eve_view_touch_t touch; eve_view_draw_t draw; - EVEWindow *window; + eve_view_touch_t touch; + struct EVEWindow *window; void *param; + uint32_t color_bg; + uint32_t color_fg; + uint8_t tag; } EVEView; typedef struct EVEViewStack { @@ -21,7 +25,11 @@ typedef struct EVEViewStack { uint8_t level; } EVEViewStack; -void eve_view_init(EVEView *view, EVEWindow *window, eve_view_touch_t touch, eve_view_draw_t draw, void *param); +void eve_view_init(EVEView *view, struct EVEWindow *window, eve_view_draw_t draw, eve_view_touch_t touch, void *param); +void eve_view_set_color_bg(EVEView *view, uint8_t r, uint8_t g, uint8_t b); +void eve_view_set_color_fg(EVEView *view, uint8_t r, uint8_t g, uint8_t b); +uint8_t eve_view_clear(EVEView *view, uint8_t tag0); + void eve_view_stack_init(EVEViewStack *stack); -void eve_view_create(EVEWindow *window, EVEViewStack *stack, eve_view_constructor_t constructor); -void eve_view_destroy(EVEWindow *window, EVEViewStack *stack); \ No newline at end of file +void eve_view_create(struct EVEWindow *window, EVEViewStack *stack, eve_view_constructor_t constructor); +void eve_view_destroy(struct EVEWindow *window, EVEViewStack *stack); \ No newline at end of file diff --git a/fw/fe310/eos/eve/screen/window.c b/fw/fe310/eos/eve/screen/window.c index bfa53d1..369c134 100644 --- a/fw/fe310/eos/eve/screen/window.c +++ b/fw/fe310/eos/eve/screen/window.c @@ -4,40 +4,68 @@ #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, EVEScreen *screen, char *name) { +void eve_window_init(EVEWindow *window, EVERect *g, EVEWindow *parent, char *name) { memset(window, 0, sizeof(EVEWindow)); if (g) window->g = *g; - window->screen = screen; + window->root = parent ? parent->root : NULL; + window->parent = parent; window->name = name; - window->color_fg = 0xffffff; } -void eve_window_set_color_bg(EVEWindow *window, uint8_t r, uint8_t g, uint8_t b) { - window->color_bg = (r << 16) | (g << 8) | b; +void eve_window_init_root(EVEWindowRoot *window, EVERect *g, char *name) { + EVEWindow *_window = &window->w; + + eve_window_init(_window, g, NULL, name); + _window->root = _window; + window->mem_next = EVE_RAM_G; + window->win_kbd = NULL; + eve_touch_set_handler(eve_window_root_touch, window); +} + +static uint8_t kbd_draw(EVEView *view, uint8_t tag0) { + EVEKbd *kbd = view->param; + + tag0 = eve_view_clear(view, tag0); + + eve_kbd_draw(kbd); + return tag0; +} + +static int kbd_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { + EVEKbd *kbd = view->param; + + return eve_kbd_touch(kbd, touch, evt, tag0); +} + +void eve_window_init_kbd(EVEWindowKbd *window, EVERect *g, EVEWindowRoot *root, char *name, EVEKbd *kbd) { + EVEWindow *_window = &window->w; + + eve_window_init(_window, g, NULL, name); + _window->root = (EVEWindow *)root; + window->kbd = kbd; + root->win_kbd = window; + eve_view_init(&window->v, _window, kbd_draw, kbd_touch, kbd); } -void eve_window_set_color_fg(EVEWindow *window, uint8_t r, uint8_t g, uint8_t b) { - window->color_fg = (r << 16) | (g << 8) | b; +void eve_window_set_parent(EVEWindow *window, EVEWindow *parent) { + window->parent = parent; + window->root = parent->root; } int eve_window_visible(EVEWindow *window) { - if (window->g.x >= window->screen->w) return 0; - if (window->g.y >= window->screen->h) return 0; + if (window->g.x >= window->root->g.w) return 0; + if (window->g.y >= window->root->g.h) return 0; if ((window->g.x + window->g.w) <= 0) return 0; if ((window->g.y + window->g.h) <= 0) return 0; return 1; } -void eve_window_visible_g(EVEWindow *window, EVERect *g) { - EVEWindow *w = window->next; - - *g = window->g; +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); @@ -53,24 +81,32 @@ void eve_window_visible_g(EVEWindow *window, EVERect *g) { g->h -= y0; } } + if (w->child_head) _window_visible_g(w->child_head, g); w = w->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_append(EVEWindow *window) { - EVEScreen *screen = window->screen; + EVEWindow *parent = window->parent; - window->prev = screen->win_tail; - if (screen->win_tail) { - screen->win_tail->next = window; + window->prev = parent->child_tail; + window->next = NULL; + if (parent->child_tail) { + parent->child_tail->next = window; } else { - screen->win_head = window; + parent->child_head = window; } - screen->win_tail = window; + parent->child_tail = window; } void eve_window_insert_above(EVEWindow *window, EVEWindow *win_prev) { - EVEScreen *screen = window->screen; + EVEWindow *parent = window->parent; window->prev = win_prev; window->next = win_prev->next; @@ -78,13 +114,13 @@ void eve_window_insert_above(EVEWindow *window, EVEWindow *win_prev) { if (window->next) { window->next->prev = window; } else { - screen->win_tail = window; + parent->child_tail = window; } win_prev->next = window; } void eve_window_insert_below(EVEWindow *window, EVEWindow *win_next) { - EVEScreen *screen = window->screen; + EVEWindow *parent = window->parent; window->prev = win_next->prev; window->next = win_next; @@ -93,32 +129,138 @@ void eve_window_insert_below(EVEWindow *window, EVEWindow *win_next) { if (window->prev) { window->prev->next = window; } else { - screen->win_head = window; + parent->child_head = window; } } void eve_window_remove(EVEWindow *window) { - EVEScreen *screen = window->screen; + EVEWindow *parent = window->parent; if (window->prev) { window->prev->next = window->next; } else { - screen->win_head = window->next; + parent->child_head = window->next; } if (window->next) { window->next->prev = window->prev; } else { - screen->win_tail = window->prev; + parent->child_tail = window->prev; } + window->parent = NULL; + window->prev = NULL; + window->next = NULL; } -EVEWindow *eve_window_get(EVEScreen *screen, char *name) { - EVEWindow *w = screen->win_head; +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; + } + window = window->next; + } - while (w) { - if (strcmp(name, w->name) == 0) return w; - w = w->next; + return NULL; +} + +uint8_t eve_window_draw(EVEWindow *window, uint8_t tag0) { + while (window) { + if (eve_window_visible(window) && window->view) { + int16_t s_x = window->g.x; + int16_t s_y = window->g.y; + uint16_t s_w = window->g.w; + uint16_t s_h = window->g.h; + + if (s_x < 0) { + s_w += s_x; + s_x = 0; + } + if (s_y < 0) { + s_h += s_y; + s_y = 0; + } + if (s_x + s_w > window->root->g.w) s_w = window->root->g.w - s_x; + if (s_y + s_h > window->root->g.h) s_h = window->root->g.h - s_y; + eve_cmd_dl(SCISSOR_XY(s_x, s_y)); + eve_cmd_dl(SCISSOR_SIZE(s_w, s_h)); + tag0 = window->view->draw(window->view, tag0); + } + if (window->child_head) tag0 = eve_window_draw(window->child_head, tag0); + window = window->next; + } + + return tag0; +} + +int eve_window_touch(EVEWindow *window, EVETouch *touch, uint16_t evt, uint8_t tag0) { + int ret = 0; + + while (window) { + if (window->child_tail) { + ret = eve_window_touch(window->child_tail, touch, evt, tag0); + if (ret) return 1; + } + if (eve_window_visible(window) && window->view) { + ret = window->view->touch(window->view, touch, evt, tag0); + if (ret) return 1; + } + window = window->prev; + } + + return 0; +} + +void eve_window_root_draw(EVEWindow *window) { + uint8_t tag0 = 0x80; + + eve_cmd_burst_start(); + eve_cmd_dl(CMD_DLSTART); + + eve_window_draw(window, tag0); + + eve_cmd_dl(DISPLAY()); + eve_cmd_dl(CMD_SWAP); + eve_cmd_burst_end(); + eve_cmd_exec(1); +} + +void eve_window_root_touch(EVETouch *touch, uint16_t evt, uint8_t tag0, void *win) { + EVEWindow *window = (EVEWindow *)win; + int ret = eve_window_touch(window, touch, evt, tag0); + + if (ret) { + eve_touch_clear_opt(); + eve_window_root_draw(window); } +} + +EVEKbd *eve_window_kbd(EVEWindow *window) { + EVEWindowRoot *win_root = (EVEWindowRoot *)window->root; + EVEWindowKbd *win_kbd = win_root->win_kbd; + if (win_kbd) return win_kbd->kbd; return NULL; } + +void eve_window_kbd_attach(EVEWindow *window) { + EVEWindowRoot *win_root = (EVEWindowRoot *)window->root; + EVEWindowKbd *win_kbd = win_root->win_kbd; + EVEKbd *kbd = win_kbd ? win_kbd->kbd : NULL; + + if (kbd) { + eve_window_set_parent(&win_kbd->w, window); + eve_window_append(&win_kbd->w); + } +} + +void eve_window_kbd_detach(EVEWindow *window) { + EVEWindowRoot *win_root = (EVEWindowRoot *)window->root; + EVEWindowKbd *win_kbd = win_root->win_kbd; + EVEKbd *kbd = win_kbd ? win_kbd->kbd : NULL; + + if (kbd && win_kbd->w.parent) { + eve_window_remove(&win_kbd->w); + eve_kbd_close(kbd); + } +} diff --git a/fw/fe310/eos/eve/screen/window.h b/fw/fe310/eos/eve/screen/window.h index 89c83eb..3e082d4 100644 --- a/fw/fe310/eos/eve/screen/window.h +++ b/fw/fe310/eos/eve/screen/window.h @@ -1,23 +1,35 @@ #include -struct EVEView; -struct EVEWindow; +#include "view.h" typedef struct EVEWindow { EVERect g; - EVEScreen *screen; char *name; - struct EVEView *view; + EVEView *view; + struct EVEWindow *root; + struct EVEWindow *parent; struct EVEWindow *next; struct EVEWindow *prev; - uint32_t color_bg; - uint32_t color_fg; - uint8_t tag; + struct EVEWindow *child_head; + struct EVEWindow *child_tail; } EVEWindow; -void eve_window_init(EVEWindow *window, EVERect *g, EVEScreen *screen, char *name); -void eve_window_set_color_bg(EVEWindow *window, uint8_t r, uint8_t g, uint8_t b); -void eve_window_set_color_fg(EVEWindow *window, uint8_t r, uint8_t g, uint8_t b); +typedef struct EVEWindowKbd { + EVEWindow w; + EVEView v; + EVEKbd *kbd; +} EVEWindowKbd; + +typedef struct EVEWindowRoot { + EVEWindow w; + uint32_t mem_next; + EVEWindowKbd *win_kbd; +} EVEWindowRoot; + +void eve_window_init(EVEWindow *window, EVERect *g, EVEWindow *parent, char *name); +void eve_window_init_root(EVEWindowRoot *window, EVERect *g, char *name); +void eve_window_init_kbd(EVEWindowKbd *window, EVERect *g, EVEWindowRoot *root, char *name, EVEKbd *kbd); +void eve_window_set_parent(EVEWindow *window, EVEWindow *parent); int eve_window_visible(EVEWindow *window); void eve_window_visible_g(EVEWindow *window, EVERect *g); @@ -26,4 +38,13 @@ void eve_window_append(EVEWindow *window); void eve_window_insert_above(EVEWindow *window, EVEWindow *win_prev); void eve_window_insert_below(EVEWindow *window, EVEWindow *win_next); void eve_window_remove(EVEWindow *window); -EVEWindow *eve_window_get(EVEScreen *screen, char *name); +EVEWindow *eve_window_search(EVEWindow *window, char *name); + +uint8_t eve_window_draw(EVEWindow *window, uint8_t tag0); +int eve_window_touch(EVEWindow *window, EVETouch *touch, uint16_t evt, uint8_t tag0); +void eve_window_root_draw(EVEWindow *window); +void eve_window_root_touch(EVETouch *touch, uint16_t evt, uint8_t tag0, void *win); + +EVEKbd *eve_window_kbd(EVEWindow *window); +void eve_window_kbd_attach(EVEWindow *window); +void eve_window_kbd_detach(EVEWindow *window); diff --git a/fw/fe310/eos/eve/widget/freew.c b/fw/fe310/eos/eve/widget/freew.c index 2100fce..f129af0 100644 --- a/fw/fe310/eos/eve/widget/freew.c +++ b/fw/fe310/eos/eve/widget/freew.c @@ -7,9 +7,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen/screen.h" #include "screen/window.h" -#include "screen/view.h" #include "screen/page.h" #include "label.h" diff --git a/fw/fe310/eos/eve/widget/label.c b/fw/fe310/eos/eve/widget/label.c index c52027c..cc05487 100644 --- a/fw/fe310/eos/eve/widget/label.c +++ b/fw/fe310/eos/eve/widget/label.c @@ -7,9 +7,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen/screen.h" #include "screen/window.h" -#include "screen/view.h" #include "screen/page.h" #include "label.h" diff --git a/fw/fe310/eos/eve/widget/pagew.c b/fw/fe310/eos/eve/widget/pagew.c index 51528da..6754338 100644 --- a/fw/fe310/eos/eve/widget/pagew.c +++ b/fw/fe310/eos/eve/widget/pagew.c @@ -7,9 +7,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen/screen.h" #include "screen/window.h" -#include "screen/view.h" #include "screen/page.h" #include "label.h" diff --git a/fw/fe310/eos/eve/widget/selectw.c b/fw/fe310/eos/eve/widget/selectw.c index 7157e85..35192a4 100644 --- a/fw/fe310/eos/eve/widget/selectw.c +++ b/fw/fe310/eos/eve/widget/selectw.c @@ -7,9 +7,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen/screen.h" #include "screen/window.h" -#include "screen/view.h" #include "screen/page.h" #include "label.h" @@ -134,9 +132,9 @@ uint8_t eve_selectw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { eve_cmd_dl(VERTEX2F(x2, y2)); } eve_cmd_dl(END()); - if (s) eve_cmd_dl(COLOR_RGBC(page->v.window->color_bg)); + if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_bg)); eve_cmd(CMD_TEXT, "hhhhs", x1, y1, _widget->font->id, 0, widget->option + o_curr); - if (s) eve_cmd_dl(COLOR_RGBC(page->v.window->color_fg)); + if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_fg)); o_curr += o_len + 1; i++; diff --git a/fw/fe310/eos/eve/widget/spacerw.c b/fw/fe310/eos/eve/widget/spacerw.c index 3affe24..992ab5b 100644 --- a/fw/fe310/eos/eve/widget/spacerw.c +++ b/fw/fe310/eos/eve/widget/spacerw.c @@ -7,9 +7,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen/screen.h" #include "screen/window.h" -#include "screen/view.h" #include "screen/page.h" #include "label.h" diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c index 65baf67..862d524 100644 --- a/fw/fe310/eos/eve/widget/strw.c +++ b/fw/fe310/eos/eve/widget/strw.c @@ -8,9 +8,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen/screen.h" #include "screen/window.h" -#include "screen/view.h" #include "screen/page.h" #include "label.h" @@ -172,7 +170,7 @@ int eve_strw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) return ret; } -static void _draw_str(EVEStrWidget *widget, EVEWindow *window, uint16_t ch, uint16_t len, uint16_t x1, uint16_t x2, char s) { +static void _draw_str(EVEStrWidget *widget, EVEPage *page, uint16_t ch, uint16_t len, uint16_t x1, uint16_t x2, char s) { int16_t x; EVEWidget *_widget = &widget->w; @@ -190,9 +188,9 @@ static void _draw_str(EVEStrWidget *widget, EVEWindow *window, uint16_t ch, uint } eve_cmd_dl(END()); if (len) { - if (s) eve_cmd_dl(COLOR_RGBC(window->color_bg)); + if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_bg)); eve_cmd(CMD_TEXT, "hhhhpb", x + x1, _widget->g.y, _widget->font->id, 0, widget->str + ch, len, 0); - if (s) eve_cmd_dl(COLOR_RGBC(window->color_fg)); + if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_fg)); } } } @@ -223,7 +221,6 @@ uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { if (cut) { EVEWindow *window = page->v.window; - EVEScreen *screen = window->screen; int16_t x = eve_page_scr_x(page, _widget->g.x); int16_t y = eve_page_scr_y(page, _widget->g.y); uint16_t w = _widget->g.w; @@ -235,8 +232,8 @@ uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { if (win_x1 < 0) win_x1 = 0; if (win_y1 < 0) win_y1 = 0; - if (win_x2 > screen->w) win_x2 = screen->w; - if (win_y2 > screen->h) win_y2 = screen->h; + if (win_x2 > window->root->g.w) win_x2 = window->root->g.w; + if (win_y2 > window->root->g.h) win_y2 = window->root->g.h; if (x < win_x1) { w += x - win_x1; x = win_x1; @@ -268,12 +265,12 @@ uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { l1 = c1->ch; l2 = c2->ch - c1->ch; l3 = widget->str_len - c2->ch; - _draw_str(widget, page->v.window, 0, l1, 0, c1->x, 0); - _draw_str(widget, page->v.window, c1->ch, l2, c1->x, c2->x, 1); - _draw_str(widget, page->v.window, c2->ch, l3, c2->x, widget->str_g.x + _widget->g.w, 0); + _draw_str(widget, page, 0, l1, 0, c1->x, 0); + _draw_str(widget, page, c1->ch, l2, c1->x, c2->x, 1); + _draw_str(widget, page, c2->ch, l3, c2->x, widget->str_g.x + _widget->g.w, 0); } else { if (widget->cursor1.on) _draw_cursor(widget, &widget->cursor1); - _draw_str(widget, page->v.window, 0, widget->str_len, 0, widget->str_g.x + _widget->g.w, 0); + _draw_str(widget, page, 0, widget->str_len, 0, widget->str_g.x + _widget->g.w, 0); } if (cut) { diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c index a650415..7e18475 100644 --- a/fw/fe310/eos/eve/widget/textw.c +++ b/fw/fe310/eos/eve/widget/textw.c @@ -8,9 +8,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen/screen.h" #include "screen/window.h" -#include "screen/view.h" #include "screen/page.h" #include "label.h" @@ -169,7 +167,7 @@ int eve_textw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt return ret; } -static void _draw_line(EVETextWidget *widget, EVEWindow *window, uint16_t l, uint16_t ch, uint16_t len, uint16_t x1, uint16_t x2, char s) { +static void _draw_line(EVETextWidget *widget, EVEPage *page, uint16_t l, uint16_t ch, uint16_t len, uint16_t x1, uint16_t x2, char s) { EVEWidget *_widget = &widget->w; if (x1 != x2) { @@ -185,9 +183,9 @@ static void _draw_line(EVETextWidget *widget, EVEWindow *window, uint16_t l, uin } eve_cmd_dl(END()); if (len) { - if (s) eve_cmd_dl(COLOR_RGBC(window->color_bg)); + if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_bg)); eve_cmd(CMD_TEXT, "hhhhpb", _widget->g.x + x1, _widget->g.y + l * _widget->font->h, _widget->font->id, 0, widget->text + ch, len, 0); - if (s) eve_cmd_dl(COLOR_RGBC(window->color_fg)); + if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_fg)); } } } @@ -258,10 +256,10 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { l3 = 0; s = 1; } - _draw_line(widget, page->v.window, i, LINE_START(widget, i), l1, 0, c1->x, 0); - _draw_line(widget, page->v.window, i, c1->ch, l2, c1->x, s ? _widget->g.w : c2->x, 1); + _draw_line(widget, page, i, LINE_START(widget, i), l1, 0, c1->x, 0); + _draw_line(widget, page, i, c1->ch, l2, c1->x, s ? _widget->g.w : c2->x, 1); if (!s) { - _draw_line(widget, page->v.window, i, c2->ch, l3, c2->x, _widget->g.w, 0); + _draw_line(widget, page, i, c2->ch, l3, c2->x, _widget->g.w, 0); c1 = NULL; c2 = NULL; } @@ -269,14 +267,14 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { int l1 = c2->ch - LINE_START(widget, i); int l2 = LINE_START(widget, i) + LINE_LEN(widget, i) - c2->ch; - _draw_line(widget, page->v.window, i, LINE_START(widget, i), l1, 0, c2->x, 1); - _draw_line(widget, page->v.window, i, c2->ch, l2, c2->x, _widget->g.w, 0); + _draw_line(widget, page, i, LINE_START(widget, i), l1, 0, c2->x, 1); + _draw_line(widget, page, i, c2->ch, l2, c2->x, _widget->g.w, 0); c1 = NULL; c2 = NULL; s = 0; } else { if (widget->cursor1.on && (widget->cursor1.line == i)) _draw_cursor(widget, &widget->cursor1); - _draw_line(widget, page->v.window, i, LINE_START(widget, i), LINE_LEN(widget, i), 0, _widget->g.w, s); + _draw_line(widget, page, i, LINE_START(widget, i), LINE_LEN(widget, i), 0, _widget->g.w, s); } } if (lineNvisible) { @@ -285,7 +283,7 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { eve_touch_set_opt(_widget->tagN, TEXTW_TOUCH_OPT); _widget->tagN++; } - _draw_line(widget, page->v.window, lineN, 0, 0, 0, _widget->g.w, 0); + _draw_line(widget, page, lineN, 0, 0, 0, _widget->g.w, 0); } } else { widget->line0 = 0; diff --git a/fw/fe310/eos/eve/widget/widget.c b/fw/fe310/eos/eve/widget/widget.c index 9f1e888..09894bc 100644 --- a/fw/fe310/eos/eve/widget/widget.c +++ b/fw/fe310/eos/eve/widget/widget.c @@ -7,9 +7,7 @@ #include "eve_kbd.h" #include "eve_font.h" -#include "screen/screen.h" #include "screen/window.h" -#include "screen/view.h" #include "screen/page.h" #include "widgets.h" diff --git a/fw/fe310/test/cell_pdp.c b/fw/fe310/test/cell_pdp.c index 2225f6a..b7580cc 100644 --- a/fw/fe310/test/cell_pdp.c +++ b/fw/fe310/test/cell_pdp.c @@ -16,15 +16,13 @@ #include #include -#include #include -#include #include #include #include -#include +#include #include #include "status.h" diff --git a/fw/fe310/test/main.c b/fw/fe310/test/main.c index 8ec7790..37d7a45 100644 --- a/fw/fe310/test/main.c +++ b/fw/fe310/test/main.c @@ -16,15 +16,13 @@ #include #include -#include #include -#include #include #include #include -#include +#include #include #include "status.h" @@ -71,7 +69,7 @@ int main() { eos_init(); app_form_init(); - app_screen_init(app_home_page); + app_root_init(app_home_page); app_status_init(); app_phone_init(); app_wifi_init(); diff --git a/fw/fe310/test/modem.c b/fw/fe310/test/modem.c index eb0368d..8c3a8a6 100644 --- a/fw/fe310/test/modem.c +++ b/fw/fe310/test/modem.c @@ -17,15 +17,13 @@ #include #include -#include #include -#include #include #include #include -#include +#include #include #include "modem.h" @@ -83,8 +81,8 @@ static void handle_uart(unsigned char type) { } static void handle_cell_msg(unsigned char type, unsigned char *buffer, uint16_t len) { - EVEScreen *screen = app_screen(); - EVEWindow *window = eve_window_get(screen, "main"); + EVEWindow *root = app_root(); + EVEWindow *window = eve_window_search(root, "main"); VParam *param = window->view->param; if (type == EOS_CELL_MTYPE_UART_DATA) { @@ -97,7 +95,7 @@ static void handle_cell_msg(unsigned char type, unsigned char *buffer, uint16_t } if (text->dirty) { text->dirty = 0; - eve_screen_draw(window->screen); + eve_window_root_draw(root); } eve_spi_stop(); eos_net_free(buffer, 0); @@ -106,38 +104,39 @@ static void handle_cell_msg(unsigned char type, unsigned char *buffer, uint16_t } } -static int modem_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { +static uint8_t modem_draw(EVEView *view, uint8_t tag0) { VParam *param = view->param; EVEText *text = ¶m->text; - return eve_text_touch(text, touch, evt, tag0); + tag0 = eve_view_clear(view, tag0); + return eve_text_draw(text, tag0); } -static uint8_t modem_draw(EVEView *view, uint8_t tag) { +static int modem_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { VParam *param = view->param; EVEText *text = ¶m->text; - return eve_text_draw(text, tag); + return eve_text_touch(text, touch, evt, tag0); } void app_modem(EVEWindow *window, EVEViewStack *stack) { unsigned char *buf; - EVEScreen *screen = window->screen; - EVEKbd *kbd = eve_screen_get_kbd(screen); + EVEWindowRoot *root = (EVEWindowRoot *)window->root; + EVEKbd *kbd = eve_window_kbd(window); EVERect g = {0, 60, 480, 512}; EVEView *view; VParam *param; view = eve_malloc(sizeof(EVEView)); param = eve_malloc(sizeof(VParam)); - param->mem = screen->mem_next; + param->mem = root->mem_next; param->stack = stack; param->cell_dev_handler = eos_cell_get_handler(EOS_CELL_MTYPE_DEV); - eve_text_init(¶m->text, &g, 30, 16, 200, screen->mem_next, &screen->mem_next); - eve_view_init(view, window, modem_touch, modem_draw, param); + eve_text_init(¶m->text, &g, 30, 16, 200, root->mem_next, &root->mem_next); + eve_view_init(view, window, modem_draw, modem_touch, param); eve_kbd_set_handler(kbd, key_down, view); - eve_screen_show_kbd(screen); + eve_window_kbd_attach(window); eos_uart_set_handler(EOS_UART_ETYPE_RX, handle_uart); eos_cell_set_handler(EOS_CELL_MTYPE_DEV, handle_cell_msg); @@ -153,7 +152,7 @@ void app_modem_close(EVEView *view) { unsigned char *buf = eos_net_alloc(); VParam *param = view->param; EVEWindow *window = view->window; - EVEScreen *screen = window->screen; + EVEWindowRoot *root = (EVEWindowRoot *)window->root; EVEViewStack *stack = param->stack; buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_RESET; @@ -163,10 +162,10 @@ void app_modem_close(EVEView *view) { eos_cell_set_handler(EOS_CELL_MTYPE_DEV, param->cell_dev_handler); eos_net_acquire_for_evt(EOS_EVT_UART | EOS_UART_ETYPE_RX, 0); - screen->mem_next = param->mem; + root->mem_next = param->mem; eve_free(param); eve_free(view); - eve_screen_hide_kbd(screen); + eve_window_kbd_detach(window); eve_view_destroy(window, stack); } diff --git a/fw/fe310/test/phone.c b/fw/fe310/test/phone.c index 442fcae..2d33760 100644 --- a/fw/fe310/test/phone.c +++ b/fw/fe310/test/phone.c @@ -16,15 +16,13 @@ #include #include -#include #include -#include #include #include #include -#include +#include #include #include "status.h" diff --git a/fw/fe310/test/status.c b/fw/fe310/test/status.c index cbce1c7..7d3eb73 100644 --- a/fw/fe310/test/status.c +++ b/fw/fe310/test/status.c @@ -16,15 +16,13 @@ #include #include -#include #include -#include #include #include #include -#include +#include #include #include "phone.h" @@ -38,7 +36,7 @@ static int status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t ta if (touch_idx != 0) return 0; - evt = eve_touch_evt(touch, evt, tag0, view->window->tag, 2); + evt = eve_touch_evt(touch, evt, tag0, view->tag, 2); if (touch && (evt & EVE_TOUCH_ETYPE_POINT_UP)) { if ((state == VOICE_STATE_RING) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_LEFT)) { unsigned char *buf = eos_net_alloc(); @@ -61,7 +59,9 @@ static int status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t ta static uint8_t status_draw(EVEView *view, uint8_t tag0) { uint8_t tag_opt = EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY; - if (view->window->tag != EVE_TAG_NOTAG) eve_touch_set_opt(view->window->tag, eve_touch_get_opt(view->window->tag) | tag_opt); + + tag0 = eve_view_clear(view, tag0); + if (view->tag != EVE_TAG_NOTAG) eve_touch_set_opt(view->tag, eve_touch_get_opt(view->tag) | tag_opt); if (tag0 != EVE_TAG_NOTAG) { eve_touch_set_opt(tag0, eve_touch_get_opt(tag0) | tag_opt); @@ -77,12 +77,11 @@ static uint8_t status_draw(EVEView *view, uint8_t tag0) { void app_status_msg_set(char *msg, int refresh) { strcpy(status_msg, msg); - if (refresh) app_screen_refresh(); + if (refresh) app_root_refresh(); } void app_status_init(void) { - EVEScreen *screen = app_screen(); - EVEWindow *status = eve_window_get(screen, "status"); + EVEWindow *status = eve_window_search(app_root(), "status"); status->view->touch = status_touch; status->view->draw = status_draw; } diff --git a/fw/fe310/test/wifi.c b/fw/fe310/test/wifi.c index cf2f0be..2ce3e87 100644 --- a/fw/fe310/test/wifi.c +++ b/fw/fe310/test/wifi.c @@ -16,15 +16,13 @@ #include #include -#include #include -#include #include #include #include -#include +#include #include #include "status.h" @@ -60,15 +58,14 @@ static void wifi_disconnect(void) { } void wifi_scan_handler(unsigned char type, unsigned char *buffer, uint16_t size) { - EVEScreen *screen = app_screen(); - EVEWindow *window = eve_window_get(screen, "main"); + EVEWindow *window = eve_window_search(app_root(), "main"); EVEForm *form = (EVEForm *)window->view; EVESelectWidget *select = (EVESelectWidget *)eve_form_widget(form, 0); eve_selectw_option_set(select, buffer + 1, size - 1); eos_net_free(buffer, 0); - app_screen_refresh(); + app_root_refresh(); } static void wifi_connect_handler(unsigned char type, unsigned char *buffer, uint16_t size) { -- cgit v1.2.3