diff options
Diffstat (limited to 'fw/fe310/eos/eve/screen')
-rw-r--r-- | fw/fe310/eos/eve/screen/form.c | 134 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/form.h | 25 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/page.c | 135 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/page.h | 15 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/view.c | 55 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/view.h | 12 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/window.c | 1 |
7 files changed, 222 insertions, 155 deletions
diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c index 13021a0..3e5b97c 100644 --- a/fw/fe310/eos/eve/screen/form.c +++ b/fw/fe310/eos/eve/screen/form.c @@ -12,39 +12,6 @@ #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) -static void form_update_g(EVEForm *form, EVEWidget *_widget) { - EVEPage *page = &form->p; - EVEWidget *widget = page->widget; - int i; - uint16_t w = 0; - uint16_t h = 0; - uint16_t l_h = 0; - - for (i=0; i<page->widget_size; i++) { - if (widget->label) { - h += l_h; - w = widget->label->g.w; - 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 += l_h; - w = 0; - l_h = 0; - } - widget->g.x = w; - widget->g.y = h; - - w += widget->g.w; - l_h = MAX(l_h, widget->g.h); - - widget = eve_widget_next(widget); - } - page->g.w = page->v.window->g.w; - page->g.h = h + l_h; -} - static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) { int i; @@ -55,38 +22,38 @@ static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) { } } -EVEForm *eve_form_create(EVEWindow *window, EVEViewStack *stack, EVEFormSpec spec[], uint16_t spec_size, eve_form_uievt_t uievt, eve_form_action_t action, eve_form_destructor_t destructor) { +EVEPage *eve_form_create(EVEWindow *window, EVEViewStack *stack, EVEFormSpec spec[], uint16_t spec_size, eve_page_uievt_t uievt, eve_page_destructor_t destructor) { EVEWidget *widgets; EVEWidget *widget; EVELabel *label; - EVEForm *form; + EVEPage *page; int w_size = 0; int i, r; if (uievt == NULL) uievt = eve_form_uievt; if (destructor == NULL) destructor = eve_form_destroy; - form = eve_malloc(sizeof(EVEForm)); - if (form == NULL) { + page = eve_malloc(sizeof(EVEPage)); + if (page == NULL) { return NULL; } - eve_form_init(form, window, stack, NULL, 0, uievt, action, destructor); + eve_form_init(page, window, stack, NULL, 0, uievt, destructor); for (i=0; i<spec_size; i++) { w_size += eve_widget_size(spec[i].widget.type); } widgets = eve_malloc(w_size); if (widgets == NULL) { - eve_free(form); + eve_free(page); return NULL; } widget = widgets; for (i=0; i<spec_size; i++) { - r = eve_widget_create(widget, &spec[i].widget, (EVEPage *)form); + r = eve_widget_create(widget, &spec[i].widget, page); if (r) { widgets_destroy(widgets, i); eve_free(widgets); - eve_free(form); + eve_free(page); return NULL; } if (spec[i].label.title) { @@ -95,42 +62,46 @@ EVEForm *eve_form_create(EVEWindow *window, EVEViewStack *stack, EVEFormSpec spe eve_widget_destroy(widget); widgets_destroy(widgets, i); eve_free(widgets); - eve_free(form); + eve_free(page); return NULL; } - eve_label_create(label, &spec[i].label, (EVEPage *)form); + eve_label_create(label, &spec[i].label, page); eve_widget_set_label(widget, label); } if (widget->g.w == 0) widget->g.w = window->g.w - (widget->label ? widget->label->g.w : 0); widget = eve_widget_next(widget); } - eve_form_set_widget(form, widgets, spec_size); + eve_form_set_widget(page, widgets, spec_size); - return form; + return page; } -void eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_form_uievt_t uievt, eve_form_action_t action, eve_form_destructor_t destructor) { - memset(form, 0, sizeof(EVEForm)); - eve_page_init(&form->p, window, stack, NULL, 0, EVE_PAGE_OPT_SCROLL_Y | EVE_PAGE_OPT_SCROLL_BACK | EVE_PAGE_OPT_TRACK_EXT_Y, eve_page_draw, eve_page_touch, (eve_view_uievt_t)uievt, (eve_page_destructor_t)destructor); - form->action = action; - eve_form_set_widget(form, widget, widget_size); +void eve_form_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_page_uievt_t uievt, eve_page_destructor_t destructor) { + eve_page_init(page, window, stack, NULL, 0, EVE_PAGE_OPT_SCROLL_Y | EVE_PAGE_OPT_SCROLL_BACK | EVE_PAGE_OPT_TRACK_EXT_Y, eve_page_draw, eve_page_touch, uievt, destructor); + if (widget) eve_form_set_widget(page, widget, widget_size); } -void eve_form_set_widget(EVEForm *form, EVEWidget *widget, uint16_t widget_size) { - eve_page_set_widget((EVEPage *)form, widget, widget_size); - form_update_g(form, NULL); +void eve_form_set_widget(EVEPage *page, EVEWidget *widget, uint16_t widget_size) { + eve_page_set_widget(page, widget, widget_size); + eve_form_update_g(page, NULL); } -void eve_form_destroy(EVEForm *form) { - widgets_destroy(form->p.widget, form->p.widget_size); - eve_free(form->p.widget); - eve_free(form); +void eve_form_destroy(EVEPage *page) { + widgets_destroy(page->widget, page->widget_size); + eve_free(page->widget); + eve_free(page); } -int eve_form_uievt(EVEForm *form, uint16_t evt, void *param) { +int eve_form_uievt(EVEPage *page, uint16_t evt, void *param) { switch (evt) { case EVE_UIEVT_WIDGET_UPDATE_G: - form_update_g(form, (EVEWidget *)param); + eve_form_update_g(page, (EVEWidget *)param); + break; + + case EVE_UIEVT_WIDGET_FOCUS_IN: + break; + + case EVE_UIEVT_WIDGET_FOCUS_OUT: break; case EVE_UIEVT_GEST_SCROLL_START: @@ -146,14 +117,51 @@ int eve_form_uievt(EVEForm *form, uint16_t evt, void *param) { EVEUIEvtTouch *touch_p = (EVEUIEvtTouch *)param; if (touch_p->touch->eevt & EVE_TOUCH_EETYPE_TRACK_RIGHT) { - eve_page_close((EVEPage *)form); + eve_page_close(page); return 1; } - if (touch_p->touch->eevt & EVE_TOUCH_EETYPE_TRACK_LEFT) { - if (form->action) form->action(form); - } break; } } return 0; } + +void eve_form_update_g(EVEPage *page, EVEWidget *_widget) { + EVEWidget *widget = page->widget; + EVEWidget *lastw = NULL; + int i; + uint16_t w = 0; + uint16_t h = 0; + uint16_t l_h = 0; + + for (i=0; i<page->widget_size; i++) { + if (widget->flags & EVE_WIDGET_FLAG_HIDDEN) goto update_g_nextw; + if (widget->label) { + h += l_h; + w = widget->label->g.w; + l_h = widget->label->g.h; + widget->label->g.x = 0; + widget->label->g.y = h; + } + if (w + widget->g.w > page->v.window->g.w) { + h += l_h; + w = 0; + l_h = 0; + } + widget->g.x = w; + widget->g.y = h; + + w += widget->g.w; + l_h = MAX(l_h, widget->g.h); + + lastw = widget; +update_g_nextw: + widget = eve_widget_next(widget); + } + page->g.w = page->v.window->g.w; + page->g.h = h + l_h; + + if (lastw && eve_page_oob(page, NULL, NULL)) { + eve_page_show_rect(page, &lastw->g); + } +} diff --git a/fw/fe310/eos/eve/screen/form.h b/fw/fe310/eos/eve/screen/form.h index 62e10f7..bc81d2d 100644 --- a/fw/fe310/eos/eve/screen/form.h +++ b/fw/fe310/eos/eve/screen/form.h @@ -2,28 +2,15 @@ #include "../widget/widget.h" -struct EVEWidget; -struct EVEForm; -struct EVEFormSpec; - -typedef int (*eve_form_uievt_t) (struct EVEForm *, uint16_t, void *); -typedef void (*eve_form_action_t) (struct EVEForm *); -typedef void (*eve_form_destructor_t) (struct EVEForm *); - -typedef struct EVEForm { - EVEPage p; - eve_form_action_t action; -} EVEForm; - typedef struct EVEFormSpec { EVELabelSpec label; EVEWidgetSpec widget; } EVEFormSpec; -EVEForm *eve_form_create(EVEWindow *window, EVEViewStack *stack, EVEFormSpec *spec, uint16_t spec_size, eve_form_uievt_t uievt, eve_form_action_t action, eve_form_destructor_t destructor); -void eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_form_uievt_t uievt, eve_form_action_t action, eve_form_destructor_t destructor); -void eve_form_set_widget(EVEForm *form, EVEWidget *widget, uint16_t widget_size); -void eve_form_destroy(EVEForm *form); - -int eve_form_uievt(EVEForm *form, uint16_t evt, void *param); +EVEPage *eve_form_create(EVEWindow *window, EVEViewStack *stack, EVEFormSpec spec[], uint16_t spec_size, eve_page_uievt_t uievt, eve_page_destructor_t destructor); +void eve_form_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_page_uievt_t uievt, eve_page_destructor_t destructor); +void eve_form_set_widget(EVEPage *page, EVEWidget *widget, uint16_t widget_size); +void eve_form_destroy(EVEPage *page); +int eve_form_uievt(EVEPage *page, uint16_t evt, void *param); +void eve_form_update_g(EVEPage *page, EVEWidget *_widget); diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c index 64fc473..9cbc638 100644 --- a/fw/fe310/eos/eve/screen/page.c +++ b/fw/fe310/eos/eve/screen/page.c @@ -14,25 +14,47 @@ #define PAGE_TMODE_TRACK 1 #define PAGE_TMODE_SCROLL 2 -void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, uint8_t opt, eve_view_draw_t draw, eve_view_touch_t touch, eve_view_uievt_t uievt, eve_page_destructor_t destructor) { +void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, uint8_t opt, eve_page_draw_t draw, eve_page_touch_t touch, eve_page_uievt_t uievt, eve_page_destructor_t destructor) { memset(page, 0, sizeof(EVEPage)); - eve_view_init(&page->v, window, draw, touch, uievt, NULL); + eve_view_init(&page->v, window, (eve_view_draw_t)draw, (eve_view_touch_t)touch, (eve_view_uievt_t)uievt, NULL); page->stack = stack; page->opt = opt; page->destructor = destructor; eve_page_set_widget(page, widget, widget_size); } -EVEWidget *eve_page_widget(EVEPage *page, uint16_t idx) { +EVEWidget *eve_page_widget(EVEPage *page, uint16_t _idx) { EVEWidget *w = page->widget; - int i; + int i, idx; + + if (_idx >= page->widget_size) return NULL; + + idx = 0; + for (i=0; i<page->widget_size; i++) { + if (!(w->flags & EVE_WIDGET_FLAG_SKIP)) { + if (idx == _idx) { + return w; + } + idx++; + } + w = eve_widget_next(w); + } + return NULL; +} - if (idx >= page->widget_size) return NULL; +EVEWidget *eve_page_widget_search(EVEPage *page, char *label) { + EVEWidget *w = page->widget; + int i; - for (i=0; i<idx; i++) { + for (i=0; i<page->widget_size; i++) { + if (!(w->flags & EVE_WIDGET_FLAG_SKIP)) { + if (w->label && (strcmp(w->label->title, label) == 0)) { + return w; + } + } w = eve_widget_next(w); } - return w; + return NULL; } void eve_page_set_widget(EVEPage *page, EVEWidget *widget, uint16_t widget_size) { @@ -45,8 +67,9 @@ void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor) { EVEViewStack *stack = parent->stack; eve_page_destructor_t destructor = parent->destructor; + eve_page_set_focus(parent, NULL); if (destructor) destructor(parent); - eve_view_create(window, stack, constructor); + eve_stack_create_view(stack, window, constructor); } void eve_page_close(EVEPage *page) { @@ -56,6 +79,7 @@ void eve_page_close(EVEPage *page) { if (stack->level <= 1) return; + eve_page_set_focus(page, NULL); if (eve_timer_running()) { eve_timer_stop(); } @@ -66,7 +90,7 @@ void eve_page_close(EVEPage *page) { eve_window_kbd_detach(window); if (destructor) destructor(page); - eve_view_destroy(window, stack); + eve_stack_back(stack, window); } /* Screen to page coordinates */ @@ -104,7 +128,7 @@ int eve_page_rect_visible(EVEPage *page, EVERect *g) { return 0; } -void eve_page_rect_set_visible(EVEPage *page, EVERect *rect) { +void eve_page_show_rect(EVEPage *page, EVERect *rect) { EVERect g; eve_window_visible_g(page->v.window, &g); @@ -125,11 +149,27 @@ void eve_page_rect_set_visible(EVEPage *page, EVERect *rect) { } } +/* returns true if x or y are out of page bounds for window */ +int eve_page_oob(EVEPage *page, int *_max_x, int *_max_y) { + int max_x, max_y; + EVERect vg; + + eve_window_visible_g(page->v.window, &vg); + max_x = page->g.w > vg.w ? page->g.w - vg.w : 0; + max_y = page->g.h > vg.h ? page->g.h - vg.h : 0; + + if (_max_x) *_max_x = max_x; + if (_max_y) *_max_y = max_y; + + return ((page->g.x < 0) || (page->g.x > max_x) || + (page->g.y < 0) || (page->g.y > max_y)); +} + EVEWidget *eve_page_focus(EVEPage *page) { return page->widget_f; } -void eve_page_set_focus(EVEPage *page, EVEWidget *widget, EVERect *rect) { +void eve_page_set_focus(EVEPage *page, EVEWidget *widget) { if (page->widget_f != widget) { EVEWindow *window = page->v.window; EVEWidget *widget_f = page->widget_f; @@ -148,11 +188,8 @@ void eve_page_set_focus(EVEPage *page, EVEWidget *widget, EVERect *rect) { page->widget_f = widget; if (page->widget_f) eve_view_uievt_push(&page->v, EVE_UIEVT_WIDGET_FOCUS_IN, page->widget_f); } - if (rect) eve_page_rect_set_visible(page, rect); } -#include <stdio.h> - static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0) { EVEView *view = &page->v; EVEWindow *window = view->window; @@ -174,7 +211,7 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0 if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(touch->eevt & (EVE_TOUCH_EETYPE_TRACK_XY | EVE_TOUCH_EETYPE_ABORT))) { int _ret = 0; - if (page->widget_f) eve_page_set_focus(page, NULL, NULL); + eve_page_set_focus(page, NULL); _ret = eve_view_uievt_push_gest(view, EVE_UIEVT_GEST_TOUCH, touch, evt, tag0); if (_ret) return _ret; ret = 1; @@ -200,20 +237,17 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0 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))) { if ((page->track_mode == PAGE_TMODE_SCROLL) && (page->opt & EVE_PAGE_OPT_SCROLL_BACK)) { - int wmax_x, wmax_y; - int lho_x, lho_y; - EVERect vg; - - eve_window_visible_g(page->v.window, &vg); - wmax_x = page->g.w > vg.w ? page->g.w - vg.w : 0; - wmax_y = page->g.h > vg.h ? page->g.h - vg.h : 0; - lho_x = page->g.x < 0 ? 0 : wmax_x; - lho_y = page->g.y < 0 ? 0 : wmax_y; - if ((page->g.x < 0) || (page->g.x > wmax_x) || - (page->g.y < 0) || (page->g.y > wmax_y)) { - EVEPhyLHO *lho = &page->lho; + int max_x, max_y; + int oob; + + oob = eve_page_oob(page, &max_x, &max_y); + if (oob) { + int lho_x, lho_y; uint8_t _tag; + EVEPhyLHO *lho = &page->lho; + lho_x = page->g.x < 0 ? 0 : max_x; + lho_y = page->g.y < 0 ? 0 : max_y; eve_window_scroll(window->root, &_tag); page->lho_t0 = eve_get_tick(); @@ -272,11 +306,9 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0 more = eve_phy_lho_tick(lho, eve_get_tick() - page->lho_t0, scroll_x ? &x : NULL, scroll_y ? &y : NULL); if (scroll_x) page->g.x = x; if (scroll_y) page->g.y = y; - printf("TIMER: %d\n", y); if (!more) { int _ret = 0; - printf("TIMER STOP!\n"); page->track_mode = PAGE_TMODE_NONE; eve_timer_stop(); eve_window_scroll_stop(window); @@ -290,8 +322,8 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0 return ret; } -uint8_t eve_page_draw(EVEView *view, uint8_t tag0) { - EVEPage *page = (EVEPage *)view; +uint8_t eve_page_draw(EVEPage *page, uint8_t tag0) { + EVEView *view = &page->v; EVEWidget *widget = page->widget; int i; uint8_t tagN = tag0; @@ -308,6 +340,8 @@ uint8_t eve_page_draw(EVEView *view, uint8_t tag0) { eve_cmd_dl(VERTEX_TRANSLATE_X(eve_page_scr_x(page, 0) * 16)); eve_cmd_dl(VERTEX_TRANSLATE_Y(eve_page_scr_y(page, 0) * 16)); for (i=0; i<page->widget_size; i++) { + if (widget->flags & EVE_WIDGET_FLAG_HIDDEN) goto draw_nextw; + if (widget->label && eve_page_rect_visible(page, &widget->label->g)) { eve_cmd_dl(TAG_MASK(0)); eve_label_draw(widget->label); @@ -316,6 +350,8 @@ uint8_t eve_page_draw(EVEView *view, uint8_t tag0) { if (eve_page_rect_visible(page, &widget->g)) { tagN = widget->draw(widget, tagN); } + +draw_nextw: widget = eve_widget_next(widget); } eve_cmd_dl(RESTORE_CONTEXT()); @@ -327,9 +363,9 @@ uint8_t eve_page_draw(EVEView *view, uint8_t tag0) { return tagN; } -int eve_page_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { - EVEPage *page = (EVEPage *)view; +int eve_page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0) { EVEWidget *widget = page->widget; + EVEViewStack *stack = page->stack; int8_t touch_idx = eve_touch_get_idx(touch); uint16_t _evt; int i, ret; @@ -339,20 +375,37 @@ int eve_page_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { _evt = eve_touch_evt(touch, evt, tag0, page->v.tag, 1); if (_evt) { ret = page_touch(page, touch, _evt, tag0); + if (stack->dirty) { + stack->dirty = 0; + return 1; + } if (ret) return 1; } for (i=0; i<page->widget_size; i++) { - if (eve_page_rect_visible(page, &widget->g)) { - _evt = eve_touch_evt(touch, evt, tag0, widget->tag0, widget->tagN - widget->tag0); - if (_evt) { - if (page->track_mode == PAGE_TMODE_NONE) { - ret = widget->touch(widget, touch, _evt); - if (ret) return 1; + if (!eve_page_rect_visible(page, &widget->g) || (widget->flags & (EVE_WIDGET_FLAG_SKIP | EVE_WIDGET_FLAG_RO | EVE_WIDGET_FLAG_HIDDEN))) goto touch_nextw; + + _evt = eve_touch_evt(touch, evt, tag0, widget->tag0, widget->tagN - widget->tag0); + if (_evt) { + if (page->track_mode == PAGE_TMODE_NONE) { + ret = widget->touch(widget, touch, _evt); + if (stack->dirty) { + stack->dirty = 0; + return 1; + } + if (ret) { + eve_widget_set_focus(widget); + return 1; } - ret = page_touch(page, touch, _evt, tag0); - if (ret) return 1; } + ret = page_touch(page, touch, _evt, tag0); + if (stack->dirty) { + stack->dirty = 0; + return 1; + } + if (ret) return 1; } + +touch_nextw: widget = eve_widget_next(widget); } diff --git a/fw/fe310/eos/eve/screen/page.h b/fw/fe310/eos/eve/screen/page.h index 7aa8c1d..6874a2d 100644 --- a/fw/fe310/eos/eve/screen/page.h +++ b/fw/fe310/eos/eve/screen/page.h @@ -14,6 +14,9 @@ struct EVEWidget; struct EVEPage; +typedef uint8_t (*eve_page_draw_t) (struct EVEPage *, uint8_t); +typedef int (*eve_page_touch_t) (struct EVEPage *, EVETouch *, uint16_t, uint8_t); +typedef int (*eve_page_uievt_t) (struct EVEPage *, uint16_t, void *); typedef void (*eve_page_destructor_t) (struct EVEPage *); typedef struct EVEPage { @@ -32,9 +35,10 @@ typedef struct EVEPage { uint8_t opt; } EVEPage; -void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, uint8_t opt,eve_view_draw_t draw, eve_view_touch_t touch, eve_view_uievt_t uievt, eve_page_destructor_t destructor); +void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, uint8_t opt, eve_page_draw_t draw, eve_page_touch_t touch, eve_page_uievt_t uievt, eve_page_destructor_t destructor); struct EVEWidget *eve_page_widget(EVEPage *page, uint16_t idx); +struct EVEWidget *eve_page_widget_search(EVEPage *page, char *label); void eve_page_set_widget(EVEPage *page, struct EVEWidget *widget, uint16_t widget_size); void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor); @@ -50,10 +54,11 @@ int16_t eve_page_win_y(EVEPage *page, int16_t y); int16_t eve_page_scr_x(EVEPage *page, int16_t x); int16_t eve_page_scr_y(EVEPage *page, int16_t y); int eve_page_rect_visible(EVEPage *page, EVERect *g); -void eve_page_rect_set_visible(EVEPage *page, EVERect *rect); +void eve_page_show_rect(EVEPage *page, EVERect *rect); +int eve_page_oob(EVEPage *page, int *_max_x, int *_max_y); struct EVEWidget *eve_page_focus(EVEPage *page); -void eve_page_set_focus(EVEPage *page, struct EVEWidget *widget, EVERect *rect); +void eve_page_set_focus(EVEPage *page, struct EVEWidget *widget); -uint8_t eve_page_draw(EVEView *view, uint8_t tag0); -int eve_page_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0); +uint8_t eve_page_draw(EVEPage *page, uint8_t tag0); +int eve_page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0); diff --git a/fw/fe310/eos/eve/screen/view.c b/fw/fe310/eos/eve/screen/view.c index 466644d..d6e9ede 100644 --- a/fw/fe310/eos/eve/screen/view.c +++ b/fw/fe310/eos/eve/screen/view.c @@ -55,28 +55,6 @@ uint8_t eve_view_clear(EVEView *view, uint8_t tag0, uint8_t tag_opt) { return tag0; } -void eve_view_stack_init(EVEViewStack *stack) { - memset(stack, 0, sizeof(EVEViewStack)); -} - -void eve_view_create(EVEWindow *window, EVEViewStack *stack, eve_view_constructor_t constructor) { - if (stack->level < EVE_VIEW_SIZE_STACK - 1) { - stack->constructor[stack->level] = constructor; - stack->level++; - constructor(window, stack); - } -} - -void eve_view_destroy(EVEWindow *window, EVEViewStack *stack) { - if (stack->level > 1) { - eve_view_constructor_t constructor; - - stack->level--; - constructor = stack->constructor[stack->level - 1]; - constructor(window, stack); - } -} - int eve_view_uievt_push(EVEView *view, uint16_t evt, void *param) { if (view->uievt) return view->uievt(view, evt, param); return 0; @@ -93,3 +71,36 @@ int eve_view_uievt_push_gest(EVEView *view, uint16_t evt, EVETouch *touch, uint1 } return 0; } + +void eve_stack_init(EVEViewStack *stack) { + memset(stack, 0, sizeof(EVEViewStack)); +} + +void eve_stack_create_view(EVEViewStack *stack, EVEWindow *window, eve_view_constructor_t constructor) { + int rv; + + stack->dirty = 1; + if (stack->level < EVE_VIEW_SIZE_STACK - 1) { + stack->constructor[stack->level] = constructor; + stack->level++; + rv = constructor(window, stack); + if (rv) eve_stack_back(stack, window); + } +} + +void eve_stack_back(EVEViewStack *stack, EVEWindow *window) { + eve_view_constructor_t constructor; + int rv = 1; + + stack->dirty = 1; + while ((stack->level > 1) && rv) { + stack->level--; + constructor = stack->constructor[stack->level - 1]; + rv = constructor(window, stack); + } +} + +eve_view_constructor_t eve_stack_get(EVEViewStack *stack) { + if (stack->level) return stack->constructor[stack->level - 1]; + return NULL; +} diff --git a/fw/fe310/eos/eve/screen/view.h b/fw/fe310/eos/eve/screen/view.h index c8be33a..3e8c0a0 100644 --- a/fw/fe310/eos/eve/screen/view.h +++ b/fw/fe310/eos/eve/screen/view.h @@ -11,7 +11,7 @@ struct EVEWindow; typedef uint8_t (*eve_view_draw_t) (struct EVEView *, uint8_t); typedef int (*eve_view_touch_t) (struct EVEView *, EVETouch *, uint16_t, uint8_t); typedef int (*eve_view_uievt_t) (struct EVEView *, uint16_t, void *); -typedef void (*eve_view_constructor_t) (struct EVEWindow *window, struct EVEViewStack *); +typedef int (*eve_view_constructor_t) (struct EVEWindow *window, struct EVEViewStack *); typedef struct EVEView { eve_view_draw_t draw; @@ -27,6 +27,7 @@ typedef struct EVEView { typedef struct EVEViewStack { eve_view_constructor_t constructor[EVE_VIEW_SIZE_STACK]; uint8_t level; + uint8_t dirty; } EVEViewStack; void eve_view_init(EVEView *view, struct EVEWindow *window, eve_view_draw_t draw, eve_view_touch_t touch, eve_view_uievt_t uievt, void *param); @@ -34,9 +35,10 @@ 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, uint8_t tag_opt); -void eve_view_stack_init(EVEViewStack *stack); -void eve_view_create(struct EVEWindow *window, EVEViewStack *stack, eve_view_constructor_t constructor); -void eve_view_destroy(struct EVEWindow *window, EVEViewStack *stack); - int eve_view_uievt_push(EVEView *view, uint16_t evt, void *param); int eve_view_uievt_push_gest(EVEView *view, uint16_t evt, EVETouch *touch, uint16_t t_evt, uint8_t tag0); + +void eve_stack_init(EVEViewStack *stack); +void eve_stack_create_view(EVEViewStack *stack, struct EVEWindow *window, eve_view_constructor_t constructor); +void eve_stack_back(EVEViewStack *stack, struct EVEWindow *window); +eve_view_constructor_t eve_stack_get(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 c259b19..34d265a 100644 --- a/fw/fe310/eos/eve/screen/window.c +++ b/fw/fe310/eos/eve/screen/window.c @@ -27,6 +27,7 @@ void eve_window_init_root(EVEWindowRoot *root, EVERect *g, char *name, EVEFont * root->mem_next = EVE_RAM_G; root->font = font; root->win_kbd = NULL; + root->win_scroll = NULL; root->tag0 = EVE_NOTAG; eve_touch_set_handler(eve_window_root_touch, root); } |