From 3f913efda03fd840cd526ef72e6f397c7da61bd7 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Tue, 9 Aug 2022 22:23:08 +0200 Subject: code layout --- fw/fe310/eos/eve/widget/strw.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'fw/fe310/eos/eve/widget/strw.c') diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c index 55eeca4..ae9ccab 100644 --- a/fw/fe310/eos/eve/widget/strw.c +++ b/fw/fe310/eos/eve/widget/strw.c @@ -10,9 +10,7 @@ #include "screen/window.h" #include "screen/page.h" -#include "label.h" #include "widget.h" -#include "strw.h" #define STRW_TOUCH_OPT EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_X | EVE_TOUCH_OPT_TRACK_EXT_X | EVE_TOUCH_OPT_LPRESS @@ -29,20 +27,6 @@ #define CHAR_VALID_INPUT(c) ((c >= 0x20) && (c < 0x7f)) -int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEStrSpec *spec) { - EVEFont *font = spec->font ? spec->font : eve_window_font(page->v.window); - utf8_t *str; - uint16_t *line; - - str = eve_malloc(spec->str_size); - if (str == NULL) return EVE_ERR_NOMEM; - str[0] = '\0'; - - eve_strw_init(widget, g, page, font, str, spec->str_size); - - return EVE_OK; -} - void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *str, uint16_t str_size) { EVEWidget *_widget = &widget->w; int rv, str_len; @@ -75,7 +59,25 @@ int eve_strw_update(EVEStrWidget *widget) { return (rv == UTF_OK) ? EVE_OK : EVE_ERR; } -void eve_strw_destroy(EVEStrWidget *widget) { +int eve_strw_create(EVEWidget *_widget, EVEWidgetSpec *spec, EVEPage *page) { + EVEStrWidget *widget = (EVEStrWidget *)_widget; + EVEStrSpec *tspec = &spec->tspec.str; + EVEFont *font = tspec->font ? tspec->font : eve_window_font(page->v.window); + utf8_t *str; + uint16_t *line; + + str = eve_malloc(tspec->str_size); + if (str == NULL) return EVE_ERR_NOMEM; + str[0] = '\0'; + + eve_strw_init(widget, &spec->g, page, font, str, tspec->str_size); + + return EVE_OK; +} + +void eve_strw_destroy(EVEWidget *_widget) { + EVEStrWidget *widget = (EVEStrWidget *)_widget; + eve_free(widget->str); } @@ -87,7 +89,7 @@ static void set_focus(EVEStrWidget *widget) { focus.y = _widget->g.y; focus.w = _widget->g.w; focus.h = 2 * widget->font->h; - eve_widget_focus(_widget, &focus); + eve_widget_set_focus(_widget, &focus); } static EVEStrCursor *cursor_prox(EVEStrWidget *widget, EVEStrCursor *cursor, EVETouch *touch, short *dx) { @@ -216,8 +218,8 @@ uint8_t eve_strw_draw(EVEWidget *_widget, uint8_t tag0) { } int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) { - EVEPage *page = _widget->page; EVEStrWidget *widget = (EVEStrWidget *)_widget; + EVEPage *page = _widget->page; EVEStrCursor *t_cursor = NULL; short dx; int ret = 0; @@ -291,6 +293,7 @@ int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) { widget->track.dx = 0; } + if (ret) eve_widget_set_focus(_widget, NULL); return ret; } -- cgit v1.2.3