diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-08-24 18:12:41 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-08-24 18:12:41 +0200 |
commit | d7bdbcf7e6881065200b21a02522a68cf4fb9881 (patch) | |
tree | 67712572568ae37a215d872bf1921939b7164a20 | |
parent | 1e5eb7cb910e6f23c69c2c986b6373e9f9abb980 (diff) |
fixed bug in form constructor; free widget improved
-rw-r--r-- | fw/fe310/eos/app/root.c | 15 | ||||
-rw-r--r-- | fw/fe310/eos/app/root.h | 5 | ||||
-rw-r--r-- | fw/fe310/eos/app/status.c | 2 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/form.c | 12 | ||||
-rw-r--r-- | fw/fe310/eos/eve/screen/form.h | 1 | ||||
-rw-r--r-- | fw/fe310/eos/eve/widget/freew.c | 10 | ||||
-rw-r--r-- | fw/fe310/eos/eve/widget/freew.h | 5 | ||||
-rw-r--r-- | fw/fe310/eos/eve/widget/strw.c | 7 | ||||
-rw-r--r-- | fw/fe310/eos/eve/widget/textw.c | 7 |
9 files changed, 46 insertions, 18 deletions
diff --git a/fw/fe310/eos/app/root.c b/fw/fe310/eos/app/root.c index 160316f..8f7ad94 100644 --- a/fw/fe310/eos/app/root.c +++ b/fw/fe310/eos/app/root.c @@ -17,9 +17,9 @@ #include "status.h" #include "root.h" -EVEFont _app_font_default; -extern eve_page_constructor_t _app_home_page; +EVEFont *_app_font_default; +static EVEFont font; static EVEScreen screen; static EVEWindow win_status; static EVEWindow win_main; @@ -51,7 +51,7 @@ EVEForm *app_form_create(EVEWindow *window, EVEPageStack *stack, APPWidgetSpec s for (i=0; i<spec_size; i++) { w_size += eve_widget_size(spec[i].widget.type); } - form = eve_malloc(sizeof(form)); + form = eve_malloc(sizeof(EVEForm)); if (form == NULL) { return NULL; } @@ -72,7 +72,7 @@ EVEForm *app_form_create(EVEWindow *window, EVEPageStack *stack, APPWidgetSpec s return NULL; } if (spec[i].label.title) { - label = eve_malloc(sizeof(label)); + label = eve_malloc(sizeof(EVELabel)); if (label == NULL) { eve_widget_destroy(widget); widgets_destroy(widgets, i); @@ -98,13 +98,14 @@ void app_form_destroy(EVEForm *form) { eve_free(form); } -void app_root_init(void) { +void app_root_init(eve_page_constructor_t home_page) { EVERect g; + _app_font_default = &font; eos_spi_dev_start(EOS_DEV_DISP); eve_brightness(0x40); - eve_font_init(&_app_font_default, APP_FONT_HANDLE); + eve_font_init(&font, APP_FONT_HANDLE); eve_screen_init(&screen, APP_SCREEN_W, APP_SCREEN_H); g.x = 0; @@ -120,7 +121,7 @@ void app_root_init(void) { eve_kbdwin_init(&win_kbd, &screen); eve_page_stack_init(&page_stack); - eve_page_create(&win_main, &page_stack, _app_home_page); + eve_page_create(&win_main, &page_stack, home_page); eve_window_append(&win_status); eve_window_append(&win_main); diff --git a/fw/fe310/eos/app/root.h b/fw/fe310/eos/app/root.h index 09284e2..37f1448 100644 --- a/fw/fe310/eos/app/root.h +++ b/fw/fe310/eos/app/root.h @@ -21,7 +21,6 @@ typedef struct APPWidgetSpec { } widget; } APPWidgetSpec; - -void app_root_init(void); +void app_root_init(eve_page_constructor_t home_page); EVEForm *app_form_create(EVEWindow *window, EVEPageStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_page_destructor_t destructor); -void app_form_destroy(EVEForm *form);
\ No newline at end of file +void app_form_destroy(EVEForm *form); diff --git a/fw/fe310/eos/app/status.c b/fw/fe310/eos/app/status.c index 39c471e..fb278be 100644 --- a/fw/fe310/eos/app/status.c +++ b/fw/fe310/eos/app/status.c @@ -19,5 +19,3 @@ int app_status_touch(EVEView *v, uint8_t tag0, int touch_idx) { uint8_t app_status_draw(EVEView *v, uint8_t tag0) { return tag0; } - - diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c index 52cfdc6..5837a99 100644 --- a/fw/fe310/eos/eve/screen/form.c +++ b/fw/fe310/eos/eve/screen/form.c @@ -109,7 +109,7 @@ void eve_form_update_g(EVEPage *page, EVEWidget *_widget) { widget->label->g.x = 0; widget->label->g.y = h; } - if (w + widget->g.w >= form->p.v.window->g.w) { + if (w + widget->g.w > form->p.v.window->g.w) { h += _h; w = 0; _h = 0; @@ -123,3 +123,13 @@ void eve_form_update_g(EVEPage *page, EVEWidget *_widget) { widget = eve_widget_next(widget); } } + +EVEWidget *eve_form_widget(EVEForm *form, uint16_t idx) { + EVEWidget *w = form->widget; + int i; + + for (i=0; i<idx; i++) { + w = eve_widget_next(w); + } + return w; +} diff --git a/fw/fe310/eos/eve/screen/form.h b/fw/fe310/eos/eve/screen/form.h index 91a4f8a..b6e59ff 100644 --- a/fw/fe310/eos/eve/screen/form.h +++ b/fw/fe310/eos/eve/screen/form.h @@ -13,3 +13,4 @@ int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx); uint8_t eve_form_draw(EVEView *v, uint8_t tag0); int eve_form_handle_evt(EVEPage *page, struct EVEWidget *widget, EVETouch *touch, uint16_t evt, uint8_t tag0, int touch_idx); void eve_form_update_g(EVEPage *page, struct EVEWidget *widget); +struct EVEWidget *eve_form_widget(EVEForm *form, uint16_t idx); diff --git a/fw/fe310/eos/eve/widget/freew.c b/fw/fe310/eos/eve/widget/freew.c index 55f91cb..51d1ead 100644 --- a/fw/fe310/eos/eve/widget/freew.c +++ b/fw/fe310/eos/eve/widget/freew.c @@ -34,6 +34,13 @@ void eve_freew_update(EVEFreeWidget *widget, eve_freew_touch_t touch, eve_freew_ if (putc) widget->w.putc = putc; } +void eve_freew_tag(EVEFreeWidget *widget) { + if (widget->tagN != EVE_TAG_NOTAG) { + eve_cmd_dl(TAG(widget->tagN)); + widget->tagN++; + } +} + int eve_freew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) { EVEFreeWidget *widget = (EVEFreeWidget *)_widget; EVETouch *t; @@ -55,7 +62,8 @@ uint8_t eve_freew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { EVEFreeWidget *widget = (EVEFreeWidget *)_widget; widget->tag0 = tag0; - widget->tagN = widget->_draw(widget, page, tag0); + widget->tagN = tag0; + widget->_draw(widget, page); return widget->tagN; } diff --git a/fw/fe310/eos/eve/widget/freew.h b/fw/fe310/eos/eve/widget/freew.h index 49f896f..3347e68 100644 --- a/fw/fe310/eos/eve/widget/freew.h +++ b/fw/fe310/eos/eve/widget/freew.h @@ -3,7 +3,7 @@ struct EVEFreeWidget; typedef int (*eve_freew_touch_t) (struct EVEFreeWidget *, EVEPage *, EVETouch *, uint16_t, uint8_t, int); -typedef uint8_t (*eve_freew_draw_t) (struct EVEFreeWidget *, EVEPage *, uint8_t); +typedef void (*eve_freew_draw_t) (struct EVEFreeWidget *, EVEPage *); typedef struct EVEFreeWidget { EVEWidget w; @@ -23,5 +23,6 @@ int eve_freew_create(EVEFreeWidget *widget, EVERect *g, EVEFreeSpec *spec); void eve_freew_init(EVEFreeWidget *widget, EVERect *g, eve_freew_touch_t touch, eve_freew_draw_t draw, eve_kbd_input_handler_t putc); void eve_freew_update(EVEFreeWidget *widget, eve_freew_touch_t touch, eve_freew_draw_t draw, eve_kbd_input_handler_t putc); +void eve_freew_tag(EVEFreeWidget *widget); int eve_freew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx); -uint8_t eve_freew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
\ No newline at end of file +uint8_t eve_freew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0); diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c index e973575..4344e7c 100644 --- a/fw/fe310/eos/eve/widget/strw.c +++ b/fw/fe310/eos/eve/widget/strw.c @@ -195,7 +195,12 @@ static void _draw_str(EVEStrWidget *widget, EVEWindow *window, uint16_t ch, uint if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0)); eve_cmd_dl(VERTEX2F(x + x1, _widget->g.y)); eve_cmd_dl(VERTEX2F(x + x2, _widget->g.y + widget->font->h)); - if (!s) eve_cmd_dl(COLOR_MASK(1 ,1 ,1 ,1)); + if (!s) { + eve_cmd_dl(COLOR_MASK(1 ,1 ,1 ,1)); + eve_cmd_dl(BEGIN(EVE_LINES)); + eve_cmd_dl(VERTEX2F(x + x1, _widget->g.y + widget->font->h)); + eve_cmd_dl(VERTEX2F(x + x2, _widget->g.y + widget->font->h)); + } eve_cmd_dl(END()); if (len) { if (s) eve_cmd_dl(COLOR_RGBC(window->color_bg)); diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c index 5835a57..dd11c11 100644 --- a/fw/fe310/eos/eve/widget/textw.c +++ b/fw/fe310/eos/eve/widget/textw.c @@ -202,7 +202,12 @@ static void _draw_line(EVETextWidget *widget, EVEWindow *window, uint16_t l, uin if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0)); eve_cmd_dl(VERTEX2F(_widget->g.x + x1, _widget->g.y + l * widget->font->h)); eve_cmd_dl(VERTEX2F(_widget->g.x + x2, _widget->g.y + (l + 1) * widget->font->h)); - if (!s) eve_cmd_dl(COLOR_MASK(1 ,1 ,1 ,1)); + if (!s) { + eve_cmd_dl(COLOR_MASK(1 ,1 ,1 ,1)); + eve_cmd_dl(BEGIN(EVE_LINES)); + eve_cmd_dl(VERTEX2F(_widget->g.x + x1, _widget->g.y + (l + 1) * widget->font->h)); + eve_cmd_dl(VERTEX2F(_widget->g.x + x2, _widget->g.y + (l + 1) * widget->font->h)); + } eve_cmd_dl(END()); if (len) { if (s) eve_cmd_dl(COLOR_RGBC(window->color_bg)); |