diff options
Diffstat (limited to 'fw/fe310/eos/eve/screen/view.c')
-rw-r--r-- | fw/fe310/eos/eve/screen/view.c | 137 |
1 files changed, 96 insertions, 41 deletions
diff --git a/fw/fe310/eos/eve/screen/view.c b/fw/fe310/eos/eve/screen/view.c index d6e9ede..a1290f0 100644 --- a/fw/fe310/eos/eve/screen/view.c +++ b/fw/fe310/eos/eve/screen/view.c @@ -15,7 +15,19 @@ void eve_view_init(EVEView *view, EVEWindow *window, eve_view_draw_t draw, eve_v view->window = window; view->color_bg = 0x000000; view->color_fg = 0xffffff; - window->view = view; +} + +void eve_view_attach(EVEView *view, EVEWindow *window, void *view_id) { + view->window = window; + eve_window_attach_view(window, view, view_id); +} + +void eve_view_detach(EVEView *view) { + eve_window_detach_view(view->window); +} + +void eve_view_set_param(EVEView *view, void *param) { + view->param = param; } void eve_view_set_color_bg(EVEView *view, uint8_t r, uint8_t g, uint8_t b) { @@ -29,78 +41,121 @@ 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) { EVEWindow *win_scroll = NULL; EVEWindow *window = view->window; - uint8_t _tag; + uint8_t scroll_tag; - win_scroll = eve_window_scroll(window->root, &_tag); + win_scroll = eve_window_scroll(window, &scroll_tag); eve_cmd_dl(CLEAR_COLOR_RGBC(view->color_bg)); eve_cmd_dl(COLOR_RGBC(view->color_fg)); if (win_scroll == window) { - view->tag = _tag; - eve_touch_set_opt(view->tag, tag_opt); - eve_cmd_dl(TAG(view->tag)); - eve_cmd_dl(CLEAR_TAG(view->tag)); + view->tag = scroll_tag; } else if (win_scroll) { view->tag = EVE_NOTAG; - eve_cmd_dl(TAG(view->tag)); - eve_cmd_dl(CLEAR_TAG(view->tag)); } else { view->tag = tag0; if (tag0 != EVE_NOTAG) { - eve_touch_set_opt(tag0, tag_opt); - eve_cmd_dl(CLEAR_TAG(tag0)); + eve_tag_set_opt(tag0, tag_opt); tag0++; } } + eve_cmd_dl(CLEAR_TAG(view->tag)); eve_cmd_dl(CLEAR(1,1,1)); return tag0; } -int eve_view_uievt_push(EVEView *view, uint16_t evt, void *param) { - if (view->uievt) return view->uievt(view, evt, param); - return 0; +uint8_t eve_view_tag(EVEView *view, uint8_t tag, uint8_t tag_opt) { + if (tag != EVE_NOTAG) { + eve_tag_set_opt(tag, tag_opt); + eve_cmd_dl(TAG(tag)); + tag++; + } + return tag; } -int eve_view_uievt_push_gest(EVEView *view, uint16_t evt, EVETouch *touch, uint16_t t_evt, uint8_t tag0) { - if (view->uievt) { - EVEUIEvtTouch param; +void eve_view_uievt_push(EVEView *view, uint16_t evt, void *param) { + if (view->uievt) view->uievt(view, evt, param); +} - param.touch = touch; - param.evt = t_evt; - param.tag0 = tag0; - return view->uievt(view, evt, ¶m); - } - return 0; +void eve_view_uievt_push_gest(EVEView *view, uint16_t evt, EVETouch *touch, uint16_t t_evt) { + EVEUIEvtTouch param; + + if (view->uievt == NULL) return; + + param.touch = touch; + param.evt = t_evt; + view->uievt(view, evt, ¶m); } -void eve_stack_init(EVEViewStack *stack) { - memset(stack, 0, sizeof(EVEViewStack)); +void eve_vstack_init(EVEVStack *stack) { + memset(stack, 0, sizeof(EVEVStack)); } -void eve_stack_create_view(EVEViewStack *stack, EVEWindow *window, eve_view_constructor_t constructor) { - int rv; +int eve_vstack_push(EVEVStack *stack, eve_view_constructor_t constructor) { + if (stack->level == EVE_VIEW_SIZE_STACK) return EVE_ERR_FULL; - 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); - } + stack->constructor[stack->level] = constructor; + stack->level++; + + return EVE_OK; } -void eve_stack_back(EVEViewStack *stack, EVEWindow *window) { +eve_view_constructor_t eve_vstack_pull(EVEVStack *stack) { eve_view_constructor_t constructor; - int rv = 1; - stack->dirty = 1; - while ((stack->level > 1) && rv) { + constructor = eve_vstack_get(stack); + if (stack->level) { stack->level--; - constructor = stack->constructor[stack->level - 1]; - rv = constructor(window, stack); + stack->constructor[stack->level] = NULL; } + return constructor; } -eve_view_constructor_t eve_stack_get(EVEViewStack *stack) { +eve_view_constructor_t eve_vstack_get(EVEVStack *stack) { if (stack->level) return stack->constructor[stack->level - 1]; return NULL; } + +int eve_vstack_empty(EVEVStack *stack) { + return (stack->level == 0); +} + +int eve_vstack_full(EVEVStack *stack) { + return (stack->level == EVE_VIEW_SIZE_STACK); +} + +int eve_vstack_level(EVEVStack *stack) { + return stack->level; +} + +int eve_vstack_create_view(EVEVStack *stack, EVEWindow *window, eve_view_constructor_t constructor) { + EVEView *view; + int rv; + + rv = eve_vstack_push(stack, constructor); + if (rv) return rv; + + view = constructor(window, stack); + if (view == NULL) { + eve_vstack_pull(stack); + return EVE_ERR; + } + + eve_view_attach(view, window, constructor); + + return EVE_OK; +} + +int eve_vstack_back(EVEVStack *stack, EVEWindow *window) { + EVEView *view; + eve_view_constructor_t constructor; + + eve_vstack_pull(stack); + constructor = eve_vstack_get(stack); + if (constructor == NULL) return EVE_ERR_EMPTY; + + view = constructor(window, stack); + if (view == NULL) return EVE_ERR; + + eve_view_attach(view, window, constructor); + + return EVE_OK; +} |