summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve/widget
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/eve/widget')
-rw-r--r--fw/fe310/eos/eve/widget/freew.c12
-rw-r--r--fw/fe310/eos/eve/widget/freew.h1
-rw-r--r--fw/fe310/eos/eve/widget/pagew.c14
-rw-r--r--fw/fe310/eos/eve/widget/pagew.h1
-rw-r--r--fw/fe310/eos/eve/widget/selectw.c132
-rw-r--r--fw/fe310/eos/eve/widget/selectw.h7
-rw-r--r--fw/fe310/eos/eve/widget/strw.c53
-rw-r--r--fw/fe310/eos/eve/widget/strw.h1
-rw-r--r--fw/fe310/eos/eve/widget/textw.c64
-rw-r--r--fw/fe310/eos/eve/widget/textw.h3
-rw-r--r--fw/fe310/eos/eve/widget/widget.c9
-rw-r--r--fw/fe310/eos/eve/widget/widget.h3
12 files changed, 137 insertions, 163 deletions
diff --git a/fw/fe310/eos/eve/widget/freew.c b/fw/fe310/eos/eve/widget/freew.c
index 1a55ea9..86c2686 100644
--- a/fw/fe310/eos/eve/widget/freew.c
+++ b/fw/fe310/eos/eve/widget/freew.c
@@ -23,19 +23,15 @@ void eve_freew_init(EVEFreeWidget *widget, EVERect *g, EVEPage *page, eve_freew_
memset(widget, 0, sizeof(EVEFreeWidget));
eve_widget_init(_widget, EVE_WIDGET_TYPE_FREE, g, page, eve_freew_draw, eve_freew_touch, putc);
- eve_freew_update(widget, draw, touch, NULL);
-}
-
-void eve_freew_update(EVEFreeWidget *widget, eve_freew_draw_t draw, eve_freew_touch_t touch, eve_kbd_input_handler_t putc) {
- if (draw) widget->_draw = draw;
- if (touch) widget->_touch = touch;
- if (putc) widget->w.putc = putc;
+ widget->_draw = draw;
+ widget->_touch = touch;
+ widget->w.putc = putc;
}
void eve_freew_tag(EVEFreeWidget *widget) {
EVEWidget *_widget = &widget->w;
- if (_widget->tagN != EVE_TAG_NOTAG) {
+ if (_widget->tagN != EVE_NOTAG) {
eve_cmd_dl(TAG(_widget->tagN));
_widget->tagN++;
}
diff --git a/fw/fe310/eos/eve/widget/freew.h b/fw/fe310/eos/eve/widget/freew.h
index d6d2bf7..7eda8c1 100644
--- a/fw/fe310/eos/eve/widget/freew.h
+++ b/fw/fe310/eos/eve/widget/freew.h
@@ -19,7 +19,6 @@ typedef struct EVEFreeSpec {
int eve_freew_create(EVEFreeWidget *widget, EVERect *g, EVEPage *page, EVEFreeSpec *spec);
void eve_freew_init(EVEFreeWidget *widget, EVERect *g, EVEPage *page, eve_freew_draw_t draw, eve_freew_touch_t touch, eve_kbd_input_handler_t putc);
-void eve_freew_update(EVEFreeWidget *widget, eve_freew_draw_t draw, eve_freew_touch_t touch, eve_kbd_input_handler_t putc);
void eve_freew_tag(EVEFreeWidget *widget);
uint8_t eve_freew_draw(EVEWidget *_widget, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/pagew.c b/fw/fe310/eos/eve/widget/pagew.c
index 4f59d2e..bd7819f 100644
--- a/fw/fe310/eos/eve/widget/pagew.c
+++ b/fw/fe310/eos/eve/widget/pagew.c
@@ -25,15 +25,9 @@ void eve_pagew_init(EVEPageWidget *widget, EVERect *g, EVEPage *page, EVEFont *f
memset(widget, 0, sizeof(EVEPageWidget));
eve_widget_init(_widget, EVE_WIDGET_TYPE_PAGE, g, page, eve_pagew_draw, eve_pagew_touch, NULL);
- eve_pagew_update(widget, font, title, constructor);
-}
-
-void eve_pagew_update(EVEPageWidget *widget, EVEFont *font, char *title, eve_view_constructor_t constructor) {
- EVEWidget *_widget = &widget->w;
-
- if (font) widget->font = font;
- if (title) widget->title = title;
- if (constructor) widget->constructor = constructor;
+ widget->font = font;
+ widget->title = title;
+ widget->constructor = constructor;
if (_widget->g.h == 0) _widget->g.h = eve_font_h(widget->font);
}
@@ -41,7 +35,7 @@ uint8_t eve_pagew_draw(EVEWidget *_widget, uint8_t tag0) {
EVEPageWidget *widget = (EVEPageWidget *)_widget;
_widget->tag0 = tag0;
- if (tag0 != EVE_TAG_NOTAG) {
+ if (tag0 != EVE_NOTAG) {
eve_cmd_dl(TAG(tag0));
tag0++;
}
diff --git a/fw/fe310/eos/eve/widget/pagew.h b/fw/fe310/eos/eve/widget/pagew.h
index ef34f48..76ac0d2 100644
--- a/fw/fe310/eos/eve/widget/pagew.h
+++ b/fw/fe310/eos/eve/widget/pagew.h
@@ -15,7 +15,6 @@ typedef struct EVEPageSpec {
int eve_pagew_create(EVEPageWidget *widget, EVERect *g, EVEPage *page, EVEPageSpec *spec);
void eve_pagew_init(EVEPageWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, char *title, eve_view_constructor_t constructor);
-void eve_pagew_update(EVEPageWidget *widget, EVEFont *font, char *title, eve_view_constructor_t constructor);
uint8_t eve_pagew_draw(EVEWidget *_widget, uint8_t tag0);
int eve_pagew_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt);
diff --git a/fw/fe310/eos/eve/widget/selectw.c b/fw/fe310/eos/eve/widget/selectw.c
index d1d1959..7873e95 100644
--- a/fw/fe310/eos/eve/widget/selectw.c
+++ b/fw/fe310/eos/eve/widget/selectw.c
@@ -12,16 +12,18 @@
#include "widget.h"
#include "selectw.h"
-#define SELECTW_NOSELECT 0xffffffff
+#define SELECTW_NOSELECT 0xffffffff
-static int _selectw_verify(utf8_t *opt, uint16_t size) {
+#define DIVC(x,y) ((x) / (y) + ((x) % (y) != 0))
+
+static int _selectw_verify(utf8_t *option, uint16_t option_size) {
int o_len;
uint16_t o_curr;
int rv;
o_curr = 0;
- while (o_curr < size) {
- rv = utf8_verify(opt + o_curr, size - o_curr, &o_len);
+ while (o_curr < option_size) {
+ rv = utf8_verify(option + o_curr, option_size - o_curr, &o_len);
if (rv) return EVE_ERR;
if (o_len == 0) return EVE_OK;
o_curr += o_len + 1;
@@ -49,12 +51,12 @@ static int _selectw_count(EVESelectWidget *widget) {
return i;
}
-static void _selectw_update_sz(EVESelectWidget *widget, int i) {
+static void _selectw_update_sz(EVESelectWidget *widget, int uievt) {
EVEWidget *_widget = &widget->w;
EVEPage *page = _widget->page;
- _widget->g.h = i * widget->font->h;
- eve_widget_uievt_push(_widget, EVE_UIEVT_WIDGET_UPDATE_G, NULL);
+ _widget->g.h = widget->option_count * widget->font->h;
+ if (uievt) eve_view_uievt_push(&page->v, EVE_UIEVT_WIDGET_UPDATE_G, _widget);
}
int eve_selectw_create(EVESelectWidget *widget, EVERect *g, EVEPage *page, EVESelectSpec *spec) {
@@ -74,30 +76,20 @@ int eve_selectw_create(EVESelectWidget *widget, EVERect *g, EVEPage *page, EVESe
void eve_selectw_init(EVESelectWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *option, uint16_t option_size, uint8_t multi) {
EVEWidget *_widget = &widget->w;
+ int rv;
memset(widget, 0, sizeof(EVESelectWidget));
eve_widget_init(_widget, EVE_WIDGET_TYPE_SELECT, g, page, eve_selectw_draw, eve_selectw_touch, NULL);
- eve_selectw_update(widget, font, option, option_size);
- widget->multi = multi;
-}
-
-void eve_selectw_update(EVESelectWidget *widget, EVEFont *font, utf8_t *option, uint16_t option_size) {
- int rv, text_len;
-
- if (font) widget->font = font;
- if (option) {
- int rv = _selectw_verify(option, option_size);
- if (rv == EVE_OK) {
- int i;
-
- widget->option = option;
- widget->option_size = option_size;
- widget->select = widget->multi ? 0 : SELECTW_NOSELECT;
-
- i = _selectw_count(widget);
- _selectw_update_sz(widget, i);
- }
+ widget->font = font;
+ rv = _selectw_verify(option, option_size);
+ if (rv == EVE_OK) {
+ widget->option = option;
+ widget->option_size = option_size;
+ widget->option_count = _selectw_count(widget);
+ _selectw_update_sz(widget, 0);
}
+ widget->multi = multi;
+ widget->select = widget->multi ? 0 : SELECTW_NOSELECT;
}
void eve_selectw_destroy(EVESelectWidget *widget) {
@@ -109,40 +101,53 @@ uint8_t eve_selectw_draw(EVEWidget *_widget, uint8_t tag0) {
EVESelectWidget *widget = (EVESelectWidget *)_widget;
int o_len;
int o_curr;
- int i = 0, s;
+ int i, s;
int16_t x1, x2, y1, y2;
uint16_t new_h;
+ int line0, lineN;
+
+ line0 = -((int)eve_page_win_y(page, _widget->g.y)) / widget->font->h;
+ lineN = DIVC((-((int)eve_page_win_y(page, _widget->g.y)) + page->v.window->g.h), widget->font->h);
+ if (line0 < 0) line0 = 0;
+ if (lineN < 0) lineN = 0;
+ if (line0 > widget->option_count) line0 = widget->option_count;
+ if (lineN > widget->option_count) lineN = widget->option_count;
+
_widget->tag0 = tag0;
_widget->tagN = tag0;
+ widget->line0 = line0;
+
o_curr = 0;
+ i = 0;
do {
o_len = strnlen(widget->option + o_curr, widget->option_size - o_curr);
if (!o_len || (o_len == widget->option_size - o_curr)) break;
-
- if (_widget->tagN != EVE_TAG_NOTAG) {
- eve_cmd_dl(TAG(_widget->tagN));
- _widget->tagN++;
- }
- s = widget->multi ? widget->select & (0x1 << i) : widget->select == i;
- x1 = _widget->g.x;
- x2 = x1 + _widget->g.w;
- y1 = _widget->g.y + i * widget->font->h;
- y2 = y1 + widget->font->h;
- eve_cmd_dl(BEGIN(EVE_RECTS));
- if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0));
- eve_cmd_dl(VERTEX2F(x1, y1));
- eve_cmd_dl(VERTEX2F(x2, y2));
- if (!s) {
- eve_cmd_dl(COLOR_MASK(1 ,1 ,1 ,1));
- eve_cmd_dl(BEGIN(EVE_LINES));
- eve_cmd_dl(VERTEX2F(x1, y2));
+ if ((i >= line0) && (i < lineN)) {
+ if (_widget->tagN != EVE_NOTAG) {
+ eve_cmd_dl(TAG(_widget->tagN));
+ _widget->tagN++;
+ }
+ s = widget->multi ? widget->select & (0x1 << i) : widget->select == i;
+ x1 = _widget->g.x;
+ x2 = x1 + _widget->g.w;
+ y1 = _widget->g.y + i * widget->font->h;
+ y2 = y1 + widget->font->h;
+ eve_cmd_dl(BEGIN(EVE_RECTS));
+ if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0));
+ eve_cmd_dl(VERTEX2F(x1, y1));
eve_cmd_dl(VERTEX2F(x2, y2));
+ if (!s) {
+ eve_cmd_dl(COLOR_MASK(1 ,1 ,1 ,1));
+ eve_cmd_dl(BEGIN(EVE_LINES));
+ eve_cmd_dl(VERTEX2F(x1, y2));
+ eve_cmd_dl(VERTEX2F(x2, y2));
+ }
+ eve_cmd_dl(END());
+ if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_bg));
+ eve_cmd(CMD_TEXT, "hhhhs", x1, y1, widget->font->id, 0, widget->option + o_curr);
+ if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_fg));
}
- eve_cmd_dl(END());
- if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_bg));
- eve_cmd(CMD_TEXT, "hhhhs", x1, y1, widget->font->id, 0, widget->option + o_curr);
- if (s) eve_cmd_dl(COLOR_RGBC(page->v.color_fg));
o_curr += o_len + 1;
i++;
@@ -155,7 +160,7 @@ int eve_selectw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
EVESelectWidget *widget = (EVESelectWidget *)_widget;
if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
- int i = touch->tag0 - _widget->tag0;
+ int i = touch->tag0 - _widget->tag0 + widget->line0;
if (widget->multi) {
uint32_t f = (0x1 << i);
@@ -198,12 +203,12 @@ utf8_t *eve_selectw_option_get_select(EVESelectWidget *widget) {
return eve_selectw_option_get(widget, widget->select);
}
-int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *opt) {
+int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *option) {
int o_len;
int o_curr;
int rv, i;
- rv = utf8_verify(opt, strlen(opt) + 1, NULL);
+ rv = utf8_verify(option, strlen(option) + 1, NULL);
if (rv) return EVE_ERR;
o_curr = 0;
@@ -217,26 +222,27 @@ int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *opt) {
}
} while (o_len);
- if (o_curr + strlen(opt) + 1 > widget->option_size) return EVE_ERR_FULL;
- strcpy(widget->option + o_curr, opt);
+ if (o_curr + strlen(option) + 1 > widget->option_size) return EVE_ERR_FULL;
+ strcpy(widget->option + o_curr, option);
- _selectw_update_sz(widget, i + 1);
+ widget->option_count = i + 1;
+ _selectw_update_sz(widget, 1);
return EVE_OK;
}
-int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *opt, uint16_t size) {
+int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *option, uint16_t option_size) {
int rv, i;
- rv = _selectw_verify(opt, size);
+ rv = _selectw_verify(option, option_size);
if (rv) return rv;
- if (size > widget->option_size) return EVE_ERR_FULL;
+ if (option_size > widget->option_size) return EVE_ERR_FULL;
- memcpy(widget->option, opt, size);
- memset(widget->option + size, 0, widget->option_size - size);
+ memcpy(widget->option, option, option_size);
+ memset(widget->option + option_size, 0, widget->option_size - option_size);
- i = _selectw_count(widget);
- _selectw_update_sz(widget, i);
+ widget->option_count = _selectw_count(widget);
+ _selectw_update_sz(widget, 1);
return EVE_OK;
}
diff --git a/fw/fe310/eos/eve/widget/selectw.h b/fw/fe310/eos/eve/widget/selectw.h
index 00623c1..939e362 100644
--- a/fw/fe310/eos/eve/widget/selectw.h
+++ b/fw/fe310/eos/eve/widget/selectw.h
@@ -5,7 +5,9 @@ typedef struct EVESelectWidget {
EVEFont *font;
utf8_t *option;
uint16_t option_size;
+ uint16_t option_count;
uint32_t select;
+ uint16_t line0;
uint8_t multi;
} EVESelectWidget;
@@ -17,7 +19,6 @@ typedef struct EVESelectSpec {
int eve_selectw_create(EVESelectWidget *widget, EVERect *g, EVEPage *page, EVESelectSpec *spec);
void eve_selectw_init(EVESelectWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *option, uint16_t option_size, uint8_t multi);
-void eve_selectw_update(EVESelectWidget *widget, EVEFont *font, utf8_t *option, uint16_t option_size);
void eve_selectw_destroy(EVESelectWidget *widget);
uint8_t eve_selectw_draw(EVEWidget *_widget, uint8_t tag0);
@@ -25,5 +26,5 @@ int eve_selectw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt);
utf8_t *eve_selectw_option_get(EVESelectWidget *widget, int idx);
utf8_t *eve_selectw_option_get_select(EVESelectWidget *widget);
-int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *opt);
-int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *opt, uint16_t size);
+int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *option);
+int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *option, uint16_t option_size);
diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c
index e65dd97..4e1e2c0 100644
--- a/fw/fe310/eos/eve/widget/strw.c
+++ b/fw/fe310/eos/eve/widget/strw.c
@@ -16,9 +16,9 @@
#define STRW_TOUCH_OPT EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_X | EVE_TOUCH_OPT_TRACK_EXT_X | EVE_TOUCH_OPT_LPRESS
-#define STRW_TRACK_NONE 0
-#define STRW_TRACK_CRSR 1
-#define STRW_TRACK_TXT 2
+#define STRW_TMODE_NONE 0
+#define STRW_TMODE_CRSR 1
+#define STRW_TMODE_TXT 2
#define CH_BS 0x08
#define CH_DEL 0x7f
@@ -45,28 +45,20 @@ int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEStrSpec
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;
memset(widget, 0, sizeof(EVEStrWidget));
eve_widget_init(_widget, EVE_WIDGET_TYPE_STR, g, page, eve_strw_draw, eve_strw_touch, eve_strw_putc);
- eve_strw_update(widget, font, str, str_size);
-}
-
-void eve_strw_update(EVEStrWidget *widget, EVEFont *font, utf8_t *str, uint16_t str_size) {
- int rv, str_len;
- EVEWidget *_widget = &widget->w;
-
- if (font) widget->font = font;
- if (str) {
- widget->str = str;
- widget->str_size = str_size;
- rv = utf8_verify(str, str_size, &str_len);
- if (rv != UTF_OK) {
- if (str_len >= str_size) str_len = 0;
- widget->str[str_len] = '\0';
- }
- widget->str_len = str_len;
- widget->str_g.w = eve_font_str_w(widget->font, str);
+ widget->font = font;
+ rv = utf8_verify(str, str_size, &str_len);
+ if (rv != UTF_OK) {
+ if (str_len >= str_size) str_len = 0;
+ str[str_len] = '\0';
}
+ widget->str = str;
+ widget->str_size = str_size;
+ widget->str_len = str_len;
+ widget->str_g.w = eve_font_str_w(widget->font, str);
if (_widget->g.h == 0) _widget->g.h = eve_font_h(widget->font);
}
@@ -76,14 +68,13 @@ void eve_strw_destroy(EVEStrWidget *widget) {
static void set_focus(EVEStrWidget *widget) {
EVEWidget *_widget = &widget->w;
- EVEPage *page = _widget->page;
EVERect focus;
focus.x = _widget->g.x;
focus.y = _widget->g.y;
focus.w = _widget->g.w;
focus.h = 2 * widget->font->h;
- eve_page_set_focus(page, _widget, &focus);
+ eve_widget_focus(_widget, &focus);
}
static EVEStrCursor *cursor_prox(EVEStrWidget *widget, EVEStrCursor *cursor, EVETouch *touch, short *dx) {
@@ -142,7 +133,7 @@ uint8_t eve_strw_draw(EVEWidget *_widget, uint8_t tag0) {
char cut = widget->str_g.x || (widget->str_g.w > _widget->g.w);
_widget->tag0 = tag0;
- if (tag0 != EVE_TAG_NOTAG) {
+ if (tag0 != EVE_NOTAG) {
eve_cmd_dl(TAG(tag0));
eve_touch_set_opt(tag0, STRW_TOUCH_OPT);
tag0++;
@@ -163,8 +154,8 @@ uint8_t eve_strw_draw(EVEWidget *_widget, uint8_t tag0) {
if (win_x1 < 0) win_x1 = 0;
if (win_y1 < 0) win_y1 = 0;
- if (win_x2 > window->root->g.w) win_x2 = window->root->g.w;
- if (win_y2 > window->root->g.h) win_y2 = window->root->g.h;
+ if (win_x2 > window->root->w.g.w) win_x2 = window->root->w.g.w;
+ if (win_y2 > window->root->w.g.h) win_y2 = window->root->w.g.h;
if (x < win_x1) {
w += x - win_x1;
x = win_x1;
@@ -227,11 +218,11 @@ int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
}
if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
if (t_cursor) {
- widget->track.mode = STRW_TRACK_CRSR;
+ widget->track.mode = STRW_TMODE_CRSR;
widget->track.cursor = t_cursor;
widget->track.dx = dx;
} else if (touch->eevt & EVE_TOUCH_EETYPE_TRACK_X) {
- widget->track.mode = STRW_TRACK_TXT;
+ widget->track.mode = STRW_TMODE_TXT;
}
}
}
@@ -240,7 +231,7 @@ int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
int x, w1;
switch (widget->track.mode) {
- case STRW_TRACK_TXT:
+ case STRW_TMODE_TXT:
if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
widget->str_g.x0 = widget->str_g.x;
}
@@ -251,7 +242,7 @@ int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
widget->str_g.x = x;
break;
- case STRW_TRACK_CRSR:
+ case STRW_TMODE_CRSR:
eve_strw_cursor_set(widget, widget->track.cursor, eve_page_x(page, touch->x) + widget->track.dx);
break;
}
@@ -277,7 +268,7 @@ int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
}
if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
- widget->track.mode = STRW_TRACK_NONE;
+ widget->track.mode = STRW_TMODE_NONE;
widget->track.cursor = NULL;
widget->track.dx = 0;
}
diff --git a/fw/fe310/eos/eve/widget/strw.h b/fw/fe310/eos/eve/widget/strw.h
index ae54700..aaa83fe 100644
--- a/fw/fe310/eos/eve/widget/strw.h
+++ b/fw/fe310/eos/eve/widget/strw.h
@@ -33,7 +33,6 @@ typedef struct EVEStrSpec {
int eve_strw_create(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEStrSpec *spec);
void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *str, uint16_t str_size);
-void eve_strw_update(EVEStrWidget *widget, EVEFont *font, utf8_t *str, uint16_t str_size);
void eve_strw_destroy(EVEStrWidget *widget);
uint8_t eve_strw_draw(EVEWidget *_widget, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c
index 4224f44..e17351c 100644
--- a/fw/fe310/eos/eve/widget/textw.c
+++ b/fw/fe310/eos/eve/widget/textw.c
@@ -55,32 +55,23 @@ int eve_textw_create(EVETextWidget *widget, EVERect *g, EVEPage *page, EVETextSp
void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size) {
EVEWidget *_widget = &widget->w;
+ int rv, text_len;
memset(widget, 0, sizeof(EVETextWidget));
eve_widget_init(_widget, EVE_WIDGET_TYPE_TEXT, g, page, eve_textw_draw, eve_textw_touch, eve_textw_putc);
- eve_textw_update(widget, font, text, text_size, line, line_size);
-}
-
-void eve_textw_update(EVETextWidget *widget, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size) {
- int rv, text_len;
-
- if (font) widget->font = font;
- if (text) {
- widget->text = text;
- widget->text_size = text_size;
- rv = utf8_verify(text, text_size, &text_len);
- if (rv != UTF_OK) {
- if (text_len >= text_size) text_len = 0;
- widget->text[text_len] = '\0';
- }
- widget->text_len = text_len;
- }
- if (line) {
- widget->line = line;
- widget->line_size = line_size;
+ widget->font = font;
+ rv = utf8_verify(text, text_size, &text_len);
+ if (rv != UTF_OK) {
+ if (text_len >= text_size) text_len = 0;
+ text[text_len] = '\0';
}
+ widget->text = text;
+ widget->text_size = text_size;
+ widget->text_len = text_len;
+ widget->line = line;
+ widget->line_size = line_size;
memset(widget->line, 0xff, line_size * sizeof(uint16_t));
- eve_textw_text_update(widget, 0);
+ eve_textw_text_update(widget, 0, 0);
}
void eve_textw_destroy(EVETextWidget *widget) {
@@ -90,14 +81,13 @@ void eve_textw_destroy(EVETextWidget *widget) {
static void set_focus(EVETextWidget *widget, EVETextCursor *cursor) {
EVEWidget *_widget = &widget->w;
- EVEPage *page = _widget->page;
EVERect focus;
focus.x = _widget->g.x;
focus.y = _widget->g.y + cursor->line * widget->font->h;
focus.w = _widget->g.w;
focus.h = 2 * widget->font->h;
- eve_page_set_focus(page, _widget, &focus);
+ eve_widget_focus(_widget, &focus);
}
static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor, EVETouch *touch, short *dx, short *dl) {
@@ -160,8 +150,8 @@ uint8_t eve_textw_draw(EVEWidget *_widget, uint8_t tag0) {
int _line0, _lineN;
char lineNvisible;
- _line0 = line0 = ((int)page->win_y - _widget->g.y) / widget->font->h;
- _lineN = lineN = DIVC(((int)page->win_y - _widget->g.y + page->v.window->g.h), widget->font->h);
+ _line0 = line0 = -((int)eve_page_win_y(page, _widget->g.y)) / widget->font->h;
+ _lineN = lineN = DIVC((-((int)eve_page_win_y(page, _widget->g.y)) + page->v.window->g.h), widget->font->h);
if (line0 < 0) line0 = 0;
if (lineN < 0) lineN = 0;
if (line0 > widget->line_len) line0 = widget->line_len;
@@ -191,7 +181,7 @@ uint8_t eve_textw_draw(EVEWidget *_widget, uint8_t tag0) {
}
for (i=line0; i<lineN; i++) {
- if (_widget->tagN != EVE_TAG_NOTAG) {
+ if (_widget->tagN != EVE_NOTAG) {
eve_cmd_dl(TAG(_widget->tagN));
eve_touch_set_opt(_widget->tagN, TEXTW_TOUCH_OPT);
_widget->tagN++;
@@ -230,7 +220,7 @@ uint8_t eve_textw_draw(EVEWidget *_widget, uint8_t tag0) {
}
}
if (lineNvisible) {
- if (_widget->tagN != EVE_TAG_NOTAG) {
+ if (_widget->tagN != EVE_NOTAG) {
eve_cmd_dl(TAG(_widget->tagN));
eve_touch_set_opt(_widget->tagN, TEXTW_TOUCH_OPT);
_widget->tagN++;
@@ -239,8 +229,8 @@ uint8_t eve_textw_draw(EVEWidget *_widget, uint8_t tag0) {
}
} else {
widget->line0 = 0;
- _widget->tag0 = EVE_TAG_NOTAG;
- _widget->tagN = EVE_TAG_NOTAG;
+ _widget->tag0 = EVE_NOTAG;
+ _widget->tagN = EVE_NOTAG;
}
return _widget->tagN;
@@ -403,8 +393,8 @@ void eve_textw_putc(void *w, int c) {
}
r = cursor1->line;
- if (cursor1->line) r = eve_textw_text_update(widget, cursor1->line - 1);
- if ((cursor1->line == 0) || (r == cursor1->line - 1)) r = eve_textw_text_update(widget, cursor1->line);
+ if (cursor1->line) r = eve_textw_text_update(widget, cursor1->line - 1, 1);
+ if ((cursor1->line == 0) || (r == cursor1->line - 1)) r = eve_textw_text_update(widget, cursor1->line, 1);
if (cursor1->line && (cursor1->ch < LINE_START(widget, cursor1->line))) {
cursor1->line--;
@@ -419,7 +409,7 @@ void eve_textw_putc(void *w, int c) {
}
}
-uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line) {
+uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line, int uievt) {
int i;
utf32_t ch;
uint8_t ch_w;
@@ -480,11 +470,11 @@ uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line) {
widget->line[i] = LINE_EMPTY;
}
- if (widget->line_len != line) {
- widget->line_len = line;
- _widget->g.h = (widget->line_len + 1) * widget->font->h;
- eve_widget_uievt_push(_widget, EVE_UIEVT_WIDGET_UPDATE_G, NULL);
+ if (uievt && (widget->line_len != line)) {
+ eve_view_uievt_push(&page->v, EVE_UIEVT_WIDGET_UPDATE_G, _widget);
}
+ widget->line_len = line;
+ _widget->g.h = (widget->line_len + 1) * widget->font->h;
return line;
}
@@ -513,7 +503,7 @@ void eve_textw_cursor_set(EVETextWidget *widget, EVETextCursor *cursor, uint8_t
uint8_t ch_l;
EVEWidget *_widget = &widget->w;
- if ((tag >= _widget->tag0) && ((_widget->tagN == EVE_TAG_NOTAG) || (tag < _widget->tagN))) c_line = tag - _widget->tag0 + widget->line0;
+ if ((tag >= _widget->tag0) && ((_widget->tagN == EVE_NOTAG) || (tag < _widget->tagN))) c_line = tag - _widget->tag0 + widget->line0;
if (c_line < widget->line_len) {
cursor->line = c_line;
} else if (c_line == widget->line_len) {
diff --git a/fw/fe310/eos/eve/widget/textw.h b/fw/fe310/eos/eve/widget/textw.h
index 59e6f8c..570bba8 100644
--- a/fw/fe310/eos/eve/widget/textw.h
+++ b/fw/fe310/eos/eve/widget/textw.h
@@ -34,14 +34,13 @@ typedef struct EVETextSpec {
int eve_textw_create(EVETextWidget *widget, EVERect *g, EVEPage *page, EVETextSpec *spec);
void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEPage *page, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size);
-void eve_textw_update(EVETextWidget *widget, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size);
void eve_textw_destroy(EVETextWidget *widget);
uint8_t eve_textw_draw(EVEWidget *_widget, uint8_t tag0);
int eve_textw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt);
void eve_textw_putc(void *_w, int c);
-uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line);
+uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line, int uievt);
void eve_textw_cursor_update(EVETextWidget *widget, EVETextCursor *cursor);
void eve_textw_cursor_set(EVETextWidget *widget, EVETextCursor *cursor, uint8_t tag, int16_t x);
void eve_textw_cursor_clear(EVETextWidget *widget, EVETextCursor *cursor);
diff --git a/fw/fe310/eos/eve/widget/widget.c b/fw/fe310/eos/eve/widget/widget.c
index 6f6a3ff..96d2ddf 100644
--- a/fw/fe310/eos/eve/widget/widget.c
+++ b/fw/fe310/eos/eve/widget/widget.c
@@ -70,7 +70,8 @@ void eve_widget_destroy(EVEWidget *widget) {
if (_widget_destroy[widget->type]) _widget_destroy[widget->type](widget);
}
-void eve_widget_uievt_push(EVEWidget *widget, uint16_t evt, void *param) {
- EVEView *view = &widget->page->v;
- eve_view_uievt_push(view, evt, param ? param : widget);
-} \ No newline at end of file
+void eve_widget_focus(EVEWidget *widget, EVERect *rect) {
+ EVEPage *page = widget->page;
+
+ eve_page_focus_widget(page, widget, rect);
+}
diff --git a/fw/fe310/eos/eve/widget/widget.h b/fw/fe310/eos/eve/widget/widget.h
index 0f76799..f081b4c 100644
--- a/fw/fe310/eos/eve/widget/widget.h
+++ b/fw/fe310/eos/eve/widget/widget.h
@@ -28,5 +28,4 @@ void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, EVEPage *page,
size_t eve_widget_size(uint8_t type);
void eve_widget_set_label(EVEWidget *widget, EVELabel *label);
EVEWidget *eve_widget_next(EVEWidget *widget);
-
-void eve_widget_uievt_push(EVEWidget *widget, uint16_t evt, void *param); \ No newline at end of file
+void eve_widget_focus(EVEWidget *widget, EVERect *rect); \ No newline at end of file