From 86aa553093084f9c2f04a5fb3d744b56b656ea3a Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sat, 11 Jul 2020 03:58:45 +0200 Subject: screen/window/kbd window implemented; str widget tested --- code/fe310/eos/eve/screen/form.c | 51 +++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 27 deletions(-) (limited to 'code/fe310/eos/eve/screen/form.c') diff --git a/code/fe310/eos/eve/screen/form.c b/code/fe310/eos/eve/screen/form.c index f84b0d7..927f889 100644 --- a/code/fe310/eos/eve/screen/form.c +++ b/code/fe310/eos/eve/screen/form.c @@ -13,11 +13,9 @@ #include "widget/label.h" #include "widget/widget.h" -#define CH_EOF 0x1a - -int eve_form_init(EVEForm *form, EVEWidget *widget, uint16_t widget_size, eve_page_open_t open, eve_page_close_t close, EVEWindow *window) { +int eve_form_init(EVEForm *form, EVEWindow *window, EVEWidget *widget, uint16_t widget_size, eve_page_open_t open, eve_page_close_t close) { memset(form, 0, sizeof(EVEForm)); - eve_page_init(&form->p, eve_form_touch, eve_form_draw, open, close, eve_form_handle_evt, eve_form_update_g, window); + eve_page_init(&form->p, window, eve_form_touch, eve_form_draw, open, close, eve_form_handle_evt, eve_form_update_g); form->widget = widget; form->widget_size = widget_size; eve_form_update_g(&form->p, NULL); @@ -26,36 +24,29 @@ int eve_form_init(EVEForm *form, EVEWidget *widget, uint16_t widget_size, eve_pa int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx) { EVEForm *form = (EVEForm *)v; EVEWidget *widget = form->widget; - EVEWidget *widget_f = eve_page_get_focus(&form->p); - int i, ret = 0; + int i, r, ret = 0; EVERect focus = {0,0,0,0}; + if (touch_idx == 0) { + EVETouch *t; + uint16_t evt; + + t = eve_touch_evt(tag0, touch_idx, form->p.v.window->tag, 1, &evt); + if (t && evt) { + eve_form_handle_evt(&form->p, NULL, t, evt, tag0, touch_idx); + if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (t->eevt == 0)) eve_page_set_focus(&form->p, NULL, NULL); + ret = 1; + } + } for (i=0; iwidget_size; i++) { if (eve_page_rect_visible(&form->p, &widget->g)) { - int a; - - a = widget->touch(widget, &form->p, tag0, touch_idx, &focus); - ret = ret || a; - if (focus.w && focus.h && (widget_f != widget)) { - EVEKbd *kbd = eve_screen_get_kbd(form->p.window->screen); - - if (kbd) { - if (widget_f && widget_f->putc) { - eve_screen_hide_kbd(form->p.window->screen); - widget_f->putc(widget_f, CH_EOF); - } - eve_kbd_set_handler(kbd, widget->putc, &form->p); - if (widget->putc) { - eve_screen_show_kbd(form->p.window->screen); - } - } - widget_f = widget; - } + int r = widget->touch(widget, &form->p, tag0, touch_idx, &focus); + ret = ret || r; + if (focus.w && focus.h) eve_page_set_focus(&form->p, widget, &focus); } widget = eve_widget_next(widget); } - if (focus.w && focus.h) eve_page_set_focus(&form->p, widget_f, &focus); return ret; } @@ -65,7 +56,10 @@ uint8_t eve_form_draw(EVEView *v, uint8_t tag0) { int i; uint8_t tagN = tag0; + 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)); + eve_cmd_dl(VERTEX_TRANSLATE_Y(eve_page_scr_y(&form->p, 0) * 16)); for (i=0; iwidget_size; i++) { if (widget->label && eve_page_rect_visible(&form->p, &widget->label->g)) { @@ -77,9 +71,12 @@ uint8_t eve_form_draw(EVEView *v, uint8_t tag0) { widget = eve_widget_next(widget); } + eve_cmd_dl(RESTORE_CONTEXT()); + for (i=tag0; iwindow->tag != EVE_TAG_NOTAG) eve_touch_set_opt(v->window->tag, eve_touch_get_opt(v->window->tag) | EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT); return tagN; } @@ -103,7 +100,7 @@ void eve_form_update_g(EVEPage *page, EVEWidget *_widget) { for (i=0; iwidget_size; i++) { if (widget->label) { widget->label->g.y = h; - if (widget->label->g.w + widget->g.w > form->p.window->screen->w) h += widget->label->g.h; + if (widget->label->g.w + widget->g.w > form->p.v.window->g.w) h += widget->label->g.h; } widget->g.y = h; h += widget->g.h; -- cgit v1.2.3