From 82a6206422ed658a99716fbd18e33942cebc833b Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 28 Feb 2021 21:00:13 +0100 Subject: font property moved to widget base --- fw/fe310/eos/app/root.c | 15 +++++++++------ fw/fe310/eos/app/root.h | 17 ++--------------- 2 files changed, 11 insertions(+), 21 deletions(-) (limited to 'fw/fe310/eos/app') diff --git a/fw/fe310/eos/app/root.c b/fw/fe310/eos/app/root.c index 43bab11..ec0e4ea 100644 --- a/fw/fe310/eos/app/root.c +++ b/fw/fe310/eos/app/root.c @@ -5,6 +5,7 @@ #include "eve/eve.h" #include "eve/eve_kbd.h" +#include "eve/eve_font.h" #include "eve/screen/screen.h" #include "eve/screen/window.h" @@ -17,8 +18,6 @@ #include "status.h" #include "root.h" -EVEFont *_app_font_default; - static EVEKbd kbd; static EVEFont font; static EVEScreen screen; @@ -49,7 +48,6 @@ static uint8_t kbd_draw(EVEView *v, uint8_t tag0) { void app_screen_init(eve_view_constructor_t home_page) { EVERect g; - _app_font_default = &font; eve_spi_start(); eve_brightness(0x40); @@ -107,11 +105,12 @@ static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) { } } -EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor) { +EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor) { EVEWidget *widgets; EVEWidget *widget; EVELabel *label; EVEForm *form; + EVEFont *_font; int w_size = 0; int i, r; @@ -131,7 +130,8 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec s widget = widgets; for (i=0; ilabel && (widget->label->g.w == 0)) eve_font_str_w(label->font, label->title) + APP_LABEL_MARGIN; + if (widget->g.w == 0) widget->g.w = APP_SCREEN_W - (widget->label ? widget->label->g.w : 0); widget = eve_widget_next(widget); } diff --git a/fw/fe310/eos/app/root.h b/fw/fe310/eos/app/root.h index 69624e7..9468e6e 100644 --- a/fw/fe310/eos/app/root.h +++ b/fw/fe310/eos/app/root.h @@ -6,24 +6,11 @@ #define APP_FONT_HANDLE 31 -typedef struct APPLabelSpec { - EVERect g; - EVEFont *font; - char *title; -} APPLabelSpec; - -typedef struct APPWidgetSpec { - APPLabelSpec label; - struct { - EVERect g; - EVEWidgetSpec spec; - uint8_t type; - } widget; -} APPWidgetSpec; +#define APP_LABEL_MARGIN 10 EVEScreen *app_screen(void); void app_screen_init(eve_view_constructor_t home_page); void app_screen_refresh(void); -EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor); +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); -- cgit v1.2.3