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/eve/screen/form.c | 95 ++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 45 deletions(-) (limited to 'fw/fe310/eos/eve/screen/form.c') 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; -- cgit v1.2.3