From 58232586e1ed65fc8a8e382796628aa087b5dc4c Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Thu, 25 Mar 2021 19:58:43 +0100 Subject: uievt added to view --- fw/fe310/eos/app/app_form.c | 26 +++++++------------------- fw/fe310/eos/app/app_form.h | 2 -- fw/fe310/eos/app/app_root.c | 8 +++++--- fw/fe310/eos/app/app_root.h | 2 ++ fw/fe310/eos/app/app_status.c | 3 +-- 5 files changed, 15 insertions(+), 26 deletions(-) (limited to 'fw/fe310/eos/app') diff --git a/fw/fe310/eos/app/app_form.c b/fw/fe310/eos/app/app_form.c index 5d59833..8daf09e 100644 --- a/fw/fe310/eos/app/app_form.c +++ b/fw/fe310/eos/app/app_form.c @@ -1,7 +1,5 @@ #include -#include "unicode.h" - #include "eve/eve.h" #include "eve/eve_kbd.h" #include "eve/eve_font.h" @@ -14,8 +12,6 @@ #include "app_form.h" -static EVEFont font; - static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) { int i; @@ -31,7 +27,6 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec s EVEWidget *widget; EVELabel *label; EVEForm *form; - EVEFont *_font; int w_size = 0; int i, r; @@ -42,6 +37,8 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec s if (form == NULL) { return NULL; } + if (destructor == NULL) destructor = app_form_destroy; + eve_form_init(form, window, stack, NULL, 0, action, destructor); widgets = eve_malloc(w_size); if (widgets == NULL) { @@ -51,8 +48,7 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec s widget = widgets; for (i=0; ig.w == 0) label->g.w = eve_font_str_w(_font, label->title); + if (label->g.w == 0) label->g.w = eve_font_str_w(font, label->title); } if (widget->label && (widget->label->g.w == 0)) eve_font_str_w(label->font, label->title) + APP_LABEL_MARGIN; if (widget->g.w == 0) widget->g.w = window->g.w - (widget->label ? widget->label->g.w : 0); widget = eve_widget_next(widget); } - - if (destructor == NULL) destructor = app_form_destroy; - eve_form_init(form, window, stack, widgets, spec_size, action, destructor); + eve_form_update(form, widgets, spec_size, NULL); return form; } @@ -89,9 +83,3 @@ void app_form_destroy(EVEForm *form) { eve_free(form->widget); eve_free(form); } - -void app_form_init(void) { - eve_spi_start(); - eve_font_init(&font, APP_FONT_HANDLE); - eve_spi_stop(); -} diff --git a/fw/fe310/eos/app/app_form.h b/fw/fe310/eos/app/app_form.h index 191e76d..ec0993c 100644 --- a/fw/fe310/eos/app/app_form.h +++ b/fw/fe310/eos/app/app_form.h @@ -1,8 +1,6 @@ #include -#define APP_FONT_HANDLE 31 #define APP_LABEL_MARGIN 10 EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor); void app_form_destroy(EVEForm *form); -void app_form_init(void); \ No newline at end of file diff --git a/fw/fe310/eos/app/app_root.c b/fw/fe310/eos/app/app_root.c index f30c8d4..7a6f5c3 100644 --- a/fw/fe310/eos/app/app_root.c +++ b/fw/fe310/eos/app/app_root.c @@ -1,7 +1,6 @@ #include #include "net.h" -#include "unicode.h" #include "eve/eve.h" #include "eve/eve_kbd.h" @@ -22,6 +21,7 @@ #define KBD_H 225 static EVEKbd kbd; +static EVEFont font; static EVEWindowRoot win_root; static EVEWindowKbd win_kbd; static EVEWindow win_status; @@ -46,11 +46,13 @@ void app_root_init(eve_view_constructor_t home_page) { eve_brightness(0x40); + eve_font_init(&font, APP_FONT_HANDLE); + g.x = 0; g.y = 0; g.w = APP_SCREEN_W; g.h = APP_SCREEN_H; - eve_window_init_root(&win_root, &g, "root"); + eve_window_init_root(&win_root, &g, "root", &font); g.x = KBD_X; g.y = KBD_Y; @@ -64,7 +66,7 @@ void app_root_init(eve_view_constructor_t home_page) { g.w = APP_SCREEN_W; g.h = APP_STATUS_H; eve_window_init(&win_status, &g, (EVEWindow *)&win_root, "status"); - eve_view_init(&view_status, &win_status, app_status_draw, app_status_touch, NULL); + eve_view_init(&view_status, &win_status, app_status_draw, app_status_touch, NULL, NULL); g.x = 0; g.y = APP_STATUS_H; diff --git a/fw/fe310/eos/app/app_root.h b/fw/fe310/eos/app/app_root.h index 2a51c77..a7907df 100644 --- a/fw/fe310/eos/app/app_root.h +++ b/fw/fe310/eos/app/app_root.h @@ -4,6 +4,8 @@ #define APP_SCREEN_H 800 #define APP_STATUS_H 60 +#define APP_FONT_HANDLE 31 + EVEWindow *app_root(void); void app_root_refresh(void); diff --git a/fw/fe310/eos/app/app_status.c b/fw/fe310/eos/app/app_status.c index 11cc36d..1d95728 100644 --- a/fw/fe310/eos/app/app_status.c +++ b/fw/fe310/eos/app/app_status.c @@ -1,9 +1,8 @@ #include -#include "unicode.h" - #include "eve/eve.h" #include "eve/eve_kbd.h" +#include "eve/eve_font.h" #include "eve/screen/window.h" -- cgit v1.2.3