diff options
Diffstat (limited to 'fw/fe310/eos/eve/screen')
-rw-r--r-- | fw/fe310/eos/eve/screen/form.c | 22 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/form.h | 5 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/page.c | 17 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/page.h | 6 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/view.c | 10 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/view.h | 12 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/window.c | 12 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/window.h | 4 |
8 files changed, 60 insertions, 28 deletions
diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c index d3707fc..8ea53c8 100644 --- a/fw/fe310/eos/eve/screen/form.c +++ b/fw/fe310/eos/eve/screen/form.c @@ -1,8 +1,6 @@ #include <stdlib.h> #include <string.h> -#include "unicode.h" - #include "eve.h" #include "eve_kbd.h" #include "eve_font.h" @@ -45,6 +43,7 @@ static void form_update_g(EVEForm *form, EVEWidget *_widget) { widget = eve_widget_next(widget); } + form->w = form->p.v.window->g.w; form->h = h + l_h; } @@ -121,13 +120,18 @@ static int form_handle_evt(EVEForm *form, EVEWidget *widget, EVETouch *touch, ui return ret; } -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) { +void 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_draw, eve_form_touch, (eve_page_destructor_t)destructor); + eve_page_init(&form->p, window, stack, eve_form_draw, eve_form_touch, NULL, (eve_page_destructor_t)destructor); + eve_form_update(form, widget, widget_size, action); +} - form->widget = widget; - form->widget_size = widget_size; - form->action = action; +void eve_form_update(EVEForm *form, EVEWidget *widget, uint16_t widget_size, eve_form_action_t action) { + if (widget) { + form->widget = widget; + form->widget_size = widget_size; + } + if (action) form->action = action; form_update_g(form, NULL); } @@ -152,7 +156,7 @@ uint8_t eve_form_draw(EVEView *view, uint8_t tag0) { } if (eve_page_rect_visible(&form->p, &widget->g)) { uint16_t h = widget->g.h; - tagN = widget->draw(widget, &form->p, tagN); + tagN = widget->draw(widget, tagN); if (h != widget->g.h) form_update_g(form, widget); } widget = eve_widget_next(widget); @@ -186,7 +190,7 @@ int eve_form_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { _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); + ret = widget->touch(widget, touch, _evt); if (ret) return 1; } ret = form_handle_evt(form, widget, touch, _evt, tag0); diff --git a/fw/fe310/eos/eve/screen/form.h b/fw/fe310/eos/eve/screen/form.h index 96c5930..eb817e5 100644 --- a/fw/fe310/eos/eve/screen/form.h +++ b/fw/fe310/eos/eve/screen/form.h @@ -20,10 +20,11 @@ typedef struct EVEForm { uint64_t lho_t0; } EVEForm; -int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, eve_form_action_t action, eve_form_destructor_t destructor); +void eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, eve_form_action_t action, eve_form_destructor_t destructor); +void eve_form_update(EVEForm *form, struct EVEWidget *widget, uint16_t widget_size, eve_form_action_t action); -int eve_form_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0); uint8_t eve_form_draw(EVEView *view, uint8_t tag0); +int eve_form_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0); void eve_form_update_g(EVEForm *form, struct EVEWidget *widget); int eve_form_handle_evt(EVEForm *form, struct EVEWidget *widget, EVETouch *touch, uint16_t evt); diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c index 0951b1b..4b8799c 100644 --- a/fw/fe310/eos/eve/screen/page.c +++ b/fw/fe310/eos/eve/screen/page.c @@ -1,8 +1,6 @@ #include <stdlib.h> #include <string.h> -#include "unicode.h" - #include "eve.h" #include "eve_kbd.h" #include "eve_font.h" @@ -13,11 +11,9 @@ #include "widget/label.h" #include "widget/widget.h" -#define CH_EOF 0x1a - -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_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_draw_t draw, eve_view_touch_t touch, eve_view_uievt_t uievt, eve_page_destructor_t destructor) { memset(page, 0, sizeof(EVEPage)); - eve_view_init(&page->v, window, draw, touch, NULL); + eve_view_init(&page->v, window, draw, touch, uievt, NULL); page->destructor = destructor; page->stack = stack; page->widget_f = NULL; @@ -67,13 +63,13 @@ void eve_page_set_focus(EVEPage *page, EVEWidget *widget, EVERect *f) { if (widget_f && widget_f->putc) { eve_window_kbd_detach(window); - widget_f->putc(page, CH_EOF); + widget_f->putc(widget_f, EVE_PAGE_KBDCH_CLOSE); } if (widget && widget->putc) { EVEKbd *kbd = eve_window_kbd(window); if (kbd) { - eve_kbd_set_handler(kbd, widget->putc, page); + eve_kbd_set_handler(kbd, widget->putc, widget); eve_window_kbd_attach(window); } } @@ -113,3 +109,8 @@ int eve_page_rect_visible(EVEPage *page, EVERect *g) { if (((g->x + g->w) >= page->win_x) && ((g->y + g->h) >= page->win_y) && (g->x <= (page->win_x + w)) && (g->y <= (page->win_y + h))) return 1; return 0; } + +void eve_page_uievt_push(EVEPage *page, uint16_t evt, void *param) { + EVEView *view = &page->v; + eve_view_uievt_push(view, evt, param ? param : page); +} diff --git a/fw/fe310/eos/eve/screen/page.h b/fw/fe310/eos/eve/screen/page.h index cf6b8be..ded7185 100644 --- a/fw/fe310/eos/eve/screen/page.h +++ b/fw/fe310/eos/eve/screen/page.h @@ -1,5 +1,7 @@ #include <stdint.h> +#define EVE_PAGE_KBDCH_CLOSE 0x1a + struct EVEWidget; struct EVEPage; @@ -14,7 +16,7 @@ typedef struct EVEPage { struct EVEWidget *widget_f; } EVEPage; -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_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_draw_t draw, eve_view_touch_t touch, eve_view_uievt_t uievt, eve_page_destructor_t destructor); void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor); void eve_page_close(EVEPage *page); @@ -26,3 +28,5 @@ int16_t eve_page_scr_y(EVEPage *page, int16_t y); void eve_page_set_focus(EVEPage *page, struct EVEWidget *widget, EVERect *focus); struct EVEWidget *eve_page_get_focus(EVEPage *page); int eve_page_rect_visible(EVEPage *page, EVERect *g); + +void eve_page_uievt_push(EVEPage *page, uint16_t evt, void *param);
\ No newline at end of file diff --git a/fw/fe310/eos/eve/screen/view.c b/fw/fe310/eos/eve/screen/view.c index ce4101f..3f93c2f 100644 --- a/fw/fe310/eos/eve/screen/view.c +++ b/fw/fe310/eos/eve/screen/view.c @@ -3,12 +3,14 @@ #include "eve.h" #include "eve_kbd.h" +#include "eve_font.h" #include "window.h" -void eve_view_init(EVEView *view, EVEWindow *window, eve_view_draw_t draw, eve_view_touch_t touch, void *param) { - view->touch = touch; +void eve_view_init(EVEView *view, EVEWindow *window, eve_view_draw_t draw, eve_view_touch_t touch, eve_view_uievt_t uievt, void *param) { view->draw = draw; + view->touch = touch; + view->uievt = uievt; view->param = param; view->window = window; view->color_bg = 0x000000; @@ -57,3 +59,7 @@ void eve_view_destroy(EVEWindow *window, EVEViewStack *stack) { constructor(window, stack); } } + +void eve_view_uievt_push(EVEView *view, uint16_t evt, void *param) { + if (view->uievt) view->uievt(view, evt, param); +}
\ No newline at end of file diff --git a/fw/fe310/eos/eve/screen/view.h b/fw/fe310/eos/eve/screen/view.h index f0e2eb0..527282b 100644 --- a/fw/fe310/eos/eve/screen/view.h +++ b/fw/fe310/eos/eve/screen/view.h @@ -1,6 +1,8 @@ #include <stdint.h> -#define EVE_VIEW_SIZE_STACK 16 +#include "uievt.h" + +#define EVE_VIEW_SIZE_STACK 16 struct EVEView; struct EVEViewStack; @@ -8,11 +10,13 @@ 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 void (*eve_view_uievt_t) (struct EVEView *, uint16_t, void *); typedef void (*eve_view_constructor_t) (struct EVEWindow *window, struct EVEViewStack *); typedef struct EVEView { eve_view_draw_t draw; eve_view_touch_t touch; + eve_view_uievt_t uievt; struct EVEWindow *window; void *param; uint32_t color_bg; @@ -25,11 +29,13 @@ typedef struct EVEViewStack { uint8_t level; } EVEViewStack; -void eve_view_init(EVEView *view, struct EVEWindow *window, eve_view_draw_t draw, eve_view_touch_t touch, void *param); +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); 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(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 +void eve_view_destroy(struct EVEWindow *window, EVEViewStack *stack); + +void eve_view_uievt_push(EVEView *view, uint16_t evt, void *param);
\ 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 369c134..2971ab5 100644 --- a/fw/fe310/eos/eve/screen/window.c +++ b/fw/fe310/eos/eve/screen/window.c @@ -3,6 +3,7 @@ #include "eve.h" #include "eve_kbd.h" +#include "eve_font.h" #include "window.h" @@ -17,12 +18,13 @@ void eve_window_init(EVEWindow *window, EVERect *g, EVEWindow *parent, char *nam window->name = name; } -void eve_window_init_root(EVEWindowRoot *window, EVERect *g, char *name) { +void eve_window_init_root(EVEWindowRoot *window, EVERect *g, char *name, EVEFont *font) { EVEWindow *_window = &window->w; eve_window_init(_window, g, NULL, name); _window->root = _window; window->mem_next = EVE_RAM_G; + window->font = font; window->win_kbd = NULL; eve_touch_set_handler(eve_window_root_touch, window); } @@ -49,7 +51,7 @@ void eve_window_init_kbd(EVEWindowKbd *window, EVERect *g, EVEWindowRoot *root, _window->root = (EVEWindow *)root; window->kbd = kbd; root->win_kbd = window; - eve_view_init(&window->v, _window, kbd_draw, kbd_touch, kbd); + eve_view_init(&window->v, _window, kbd_draw, kbd_touch, NULL, kbd); } void eve_window_set_parent(EVEWindow *window, EVEWindow *parent) { @@ -264,3 +266,9 @@ void eve_window_kbd_detach(EVEWindow *window) { eve_kbd_close(kbd); } } + +EVEFont *eve_window_font(EVEWindow *window) { + EVEWindowRoot *win_root = (EVEWindowRoot *)window->root; + + return win_root->font; +} diff --git a/fw/fe310/eos/eve/screen/window.h b/fw/fe310/eos/eve/screen/window.h index 3e082d4..76ccee9 100644 --- a/fw/fe310/eos/eve/screen/window.h +++ b/fw/fe310/eos/eve/screen/window.h @@ -23,11 +23,12 @@ typedef struct EVEWindowKbd { typedef struct EVEWindowRoot { EVEWindow w; uint32_t mem_next; + EVEFont *font; 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_root(EVEWindowRoot *window, EVERect *g, char *name, EVEFont *font); void eve_window_init_kbd(EVEWindowKbd *window, EVERect *g, EVEWindowRoot *root, char *name, EVEKbd *kbd); void eve_window_set_parent(EVEWindow *window, EVEWindow *parent); @@ -48,3 +49,4 @@ void eve_window_root_touch(EVETouch *touch, uint16_t evt, uint8_t tag0, void *wi EVEKbd *eve_window_kbd(EVEWindow *window); void eve_window_kbd_attach(EVEWindow *window); void eve_window_kbd_detach(EVEWindow *window); +EVEFont *eve_window_font(EVEWindow *window);
\ No newline at end of file |