summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/eve')
-rw-r--r--fw/fe310/eos/eve/eve.h4
-rw-r--r--fw/fe310/eos/eve/eve_kbd.c26
-rw-r--r--fw/fe310/eos/eve/eve_kbd.h1
-rw-r--r--fw/fe310/eos/eve/eve_platform.c13
-rw-r--r--fw/fe310/eos/eve/eve_platform.h9
-rw-r--r--fw/fe310/eos/eve/eve_text.c2
-rw-r--r--fw/fe310/eos/eve/eve_touch.c7
-rw-r--r--fw/fe310/eos/eve/eve_touch.h10
-rw-r--r--fw/fe310/eos/eve/screen/form.c84
-rw-r--r--fw/fe310/eos/eve/screen/form.h13
-rw-r--r--fw/fe310/eos/eve/screen/page.c39
-rw-r--r--fw/fe310/eos/eve/screen/page.h10
-rw-r--r--fw/fe310/eos/eve/screen/screen.c12
-rw-r--r--fw/fe310/eos/eve/widget/Makefile2
-rw-r--r--fw/fe310/eos/eve/widget/freew.c29
-rw-r--r--fw/fe310/eos/eve/widget/freew.h6
-rw-r--r--fw/fe310/eos/eve/widget/pagew.c28
-rw-r--r--fw/fe310/eos/eve/widget/pagew.h3
-rw-r--r--fw/fe310/eos/eve/widget/selectw.c24
-rw-r--r--fw/fe310/eos/eve/widget/selectw.h6
-rw-r--r--fw/fe310/eos/eve/widget/spacerw.c6
-rw-r--r--fw/fe310/eos/eve/widget/spacerw.h2
-rw-r--r--fw/fe310/eos/eve/widget/strw.c132
-rw-r--r--fw/fe310/eos/eve/widget/strw.h3
-rw-r--r--fw/fe310/eos/eve/widget/textw.c159
-rw-r--r--fw/fe310/eos/eve/widget/textw.h7
-rw-r--r--fw/fe310/eos/eve/widget/widget.c3
-rw-r--r--fw/fe310/eos/eve/widget/widget.h5
-rw-r--r--fw/fe310/eos/eve/widget/widgets.h2
29 files changed, 326 insertions, 321 deletions
diff --git a/fw/fe310/eos/eve/eve.h b/fw/fe310/eos/eve/eve.h
index e204158..e0583f0 100644
--- a/fw/fe310/eos/eve/eve.h
+++ b/fw/fe310/eos/eve/eve.h
@@ -7,6 +7,10 @@
#define EVE_OK 0
#define EVE_ERR -1
+
+#define EVE_ERR_FULL -10
+#define EVE_ERR_EMPTY -11
+
#define EVE_ERR_NOMEM -100
#define EVE_PSTATE_ACTIVE 0
diff --git a/fw/fe310/eos/eve/eve_kbd.c b/fw/fe310/eos/eve/eve_kbd.c
index 99210ce..5dd4d5a 100644
--- a/fw/fe310/eos/eve/eve_kbd.c
+++ b/fw/fe310/eos/eve/eve_kbd.c
@@ -38,24 +38,36 @@ void eve_kbd_init(EVEKbd *kbd, EVERect *g, uint32_t mem_addr, uint32_t *mem_next
}
kbd->mem_addr = mem_addr;
kbd->key_modifier = 0;
+ kbd->key_modifier_sticky = 0;
+ kbd->key_modifier_lock = 0;
kbd->key_count = 0;
kbd->key_down = 0;
kbd->putc = NULL;
kbd->param = NULL;
- kbd->active = 1;
+ kbd->key_down = 0xff;
eve_write16(REG_CMD_DL, 0);
eve_kbd_draw(kbd);
eve_cmd_exec(1);
mem_size = eve_read16(REG_CMD_DL);
eve_cmd(CMD_MEMCPY, "www", mem_addr, EVE_RAM_DL, mem_size);
eve_cmd_exec(1);
- kbd->active = 0;
+ kbd->key_down = 0;
kbd->mem_size = mem_size;
*mem_next = kbd->mem_addr + kbd->mem_size;
}
+void eve_kbd_close(EVEKbd *kbd) {
+ kbd->key_modifier = 0;
+ kbd->key_modifier_sticky = 0;
+ kbd->key_modifier_lock = 0;
+ kbd->key_count = 0;
+ kbd->key_down = 0;
+ kbd->putc = NULL;
+ kbd->param = NULL;
+}
+
void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc, void *param) {
kbd->putc = putc;
kbd->param = param;
@@ -64,9 +76,12 @@ void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc, void *param)
int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx) {
EVETouch *t;
uint16_t evt;
+ int ret;
t = eve_touch_evt(tag0, touch_idx, 1, 126, &evt);
if (t && evt) {
+ ret = 1;
+
if (evt & EVE_TOUCH_ETYPE_TAG) {
uint8_t _tag = t->tag;
@@ -117,16 +132,15 @@ int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx) {
}
}
}
- kbd->active = 1;
} else {
- kbd->active = 0;
+ ret = 0;
}
- return kbd->active;
+ return ret;
}
uint8_t eve_kbd_draw(EVEKbd *kbd) {
- if (kbd->active) {
+ if (kbd->key_down || kbd->key_modifier) {
int x = kbd->g.x;
int y = kbd->g.y;
int w = kbd->g.w;
diff --git a/fw/fe310/eos/eve/eve_kbd.h b/fw/fe310/eos/eve/eve_kbd.h
index b27f54d..7746472 100644
--- a/fw/fe310/eos/eve/eve_kbd.h
+++ b/fw/fe310/eos/eve/eve_kbd.h
@@ -17,6 +17,7 @@ typedef struct EVEKbd {
} EVEKbd;
void eve_kbd_init(EVEKbd *kbd, EVERect *g, uint32_t mem_addr, uint32_t *mem_next);
+void eve_kbd_close(EVEKbd *kbd);
void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc, void *param);
int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx);
uint8_t eve_kbd_draw(EVEKbd *kbd);
diff --git a/fw/fe310/eos/eve/eve_platform.c b/fw/fe310/eos/eve/eve_platform.c
index e64d326..7f1b775 100644
--- a/fw/fe310/eos/eve/eve_platform.c
+++ b/fw/fe310/eos/eve/eve_platform.c
@@ -61,3 +61,16 @@ void eve_platform_init(void) {
eos_spi_dev_set_div(EOS_DEV_DISP, 4);
}
+
+#include <stdio.h>
+
+void *eve_malloc(size_t size) {
+ void *p = malloc(size);
+ printf("MALLOC:%p %d\n", p, size);
+ return p;
+}
+
+void eve_free(void *p) {
+ printf("FREE:%p\n", p);
+ free(p);
+}
diff --git a/fw/fe310/eos/eve/eve_platform.h b/fw/fe310/eos/eve/eve_platform.h
index 514c4ee..7d085db 100644
--- a/fw/fe310/eos/eve/eve_platform.h
+++ b/fw/fe310/eos/eve/eve_platform.h
@@ -19,12 +19,15 @@
#define eve_spi_xchg24 eos_spi_xchg24
#define eve_spi_xchg32 eos_spi_xchg32
-#define eve_malloc malloc
-#define eve_free free
-
void eve_time_sleep(uint32_t ms);
void eve_timer_set(uint32_t ms);
void eve_timer_clear(void);
uint64_t eve_time_get_tick(void);
void eve_platform_init(void);
+
+//#define eve_malloc malloc
+//#define eve_free free
+
+void *eve_malloc(size_t);
+void eve_free(void *); \ No newline at end of file
diff --git a/fw/fe310/eos/eve/eve_text.c b/fw/fe310/eos/eve/eve_text.c
index 7a42a24..d23d012 100644
--- a/fw/fe310/eos/eve/eve_text.c
+++ b/fw/fe310/eos/eve/eve_text.c
@@ -151,7 +151,7 @@ uint8_t eve_text_draw(EVEText *box, uint8_t tag) {
box->tag = tag;
if (tag != EVE_TAG_NOTAG) {
eve_cmd_dl(TAG(tag));
- eve_touch_set_opt(tag, EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_EXT);
+ eve_touch_set_opt(tag, EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_EXT_Y);
tag++;
}
eve_cmd(CMD_APPEND, "ww", box->mem_addr + box->w * 2 * box->line_size, box->dl_size * 4);
diff --git a/fw/fe310/eos/eve/eve_touch.c b/fw/fe310/eos/eve/eve_touch.c
index a6db581..e3dae58 100644
--- a/fw/fe310/eos/eve/eve_touch.c
+++ b/fw/fe310/eos/eve/eve_touch.c
@@ -111,7 +111,7 @@ void eve_handle_touch(void) {
}
_touch_timer_clear();
}
- touch->evt = EVE_TOUCH_ETYPE_POINT | _eevt;
+ touch->evt = EVE_TOUCH_ETYPE_POINT | _evt;
touch->eevt = _eevt;
touch->tag0 = 0;
touch->tag = 0;
@@ -149,7 +149,10 @@ void eve_handle_touch(void) {
if (!_touch_timer.evt) _touch_timer_clear();
}
if (touch->tracker.tag && touch->tracker.track) {
- if (!_touch_timer.tag && (_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_EXT)) {
+ uint8_t opt = _tag_opt[touch->tracker.tag];
+ char track_ext = ((opt & EVE_TOUCH_OPT_TRACK_EXT_X) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_X)) ||
+ ((opt & EVE_TOUCH_OPT_TRACK_EXT_Y) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_Y));
+ if (!_touch_timer.tag && track_ext) {
_touch_timer_set(touch->tracker.tag, i, EVE_TOUCH_ETYPE_TRACK, touch->x, touch->y, EVE_TIMEOUT_TRACK);
if (_ext_tracker.init) _ext_tracker.init(&_touch_timer, touch);
} else {
diff --git a/fw/fe310/eos/eve/eve_touch.h b/fw/fe310/eos/eve/eve_touch.h
index 9f935bc..454dcc7 100644
--- a/fw/fe310/eos/eve/eve_touch.h
+++ b/fw/fe310/eos/eve/eve_touch.h
@@ -37,13 +37,15 @@
#define EVE_TOUCH_OPT_TRACK_REG EVE_TOUCH_ETYPE_TRACK_REG
#define EVE_TOUCH_OPT_TRACK_X 0x04
#define EVE_TOUCH_OPT_TRACK_Y 0x08
-#define EVE_TOUCH_OPT_TRACK_EXT 0x10
+#define EVE_TOUCH_OPT_TRACK_EXT_X 0x10
+#define EVE_TOUCH_OPT_TRACK_EXT_Y 0x20
#define EVE_TOUCH_OPT_LPRESS 0x40
#define EVE_TOUCH_OPT_DTAP 0x80
-#define EVE_TOUCH_OPT_TRACK_XY (EVE_TOUCH_OPT_TRACK_X | EVE_TOUCH_OPT_TRACK_Y)
-#define EVE_TOUCH_OPT_TRACK_MASK (EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_REG)
-#define EVE_TOUCH_OPT_TIMER_MASK (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_DTAP)
+#define EVE_TOUCH_OPT_TRACK_XY (EVE_TOUCH_OPT_TRACK_X | EVE_TOUCH_OPT_TRACK_Y)
+#define EVE_TOUCH_OPT_TRACK_EXT_XY (EVE_TOUCH_OPT_TRACK_EXT_X | EVE_TOUCH_OPT_TRACK_EXT_Y)
+#define EVE_TOUCH_OPT_TRACK_MASK (EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_REG)
+#define EVE_TOUCH_OPT_TIMER_MASK (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_DTAP)
typedef void (*eve_touch_handler_t) (void *, uint8_t, int);
diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c
index fe1bd0d..cf5653b 100644
--- a/fw/fe310/eos/eve/screen/form.c
+++ b/fw/fe310/eos/eve/screen/form.c
@@ -18,39 +18,45 @@
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
-int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_page_destructor_t destructor) {
+int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_form_action_t action, eve_form_destructor_t destructor) {
memset(form, 0, sizeof(EVEForm));
- eve_page_init(&form->p, window, stack, eve_form_touch, eve_form_draw, eve_form_handle_evt, eve_form_update_g, destructor);
+ eve_page_init(&form->p, window, stack, eve_form_touch, eve_form_draw, (eve_page_destructor_t)destructor);
+
form->widget = widget;
form->widget_size = widget_size;
- eve_form_update_g(&form->p, NULL);
+ form->action = action;
+ eve_form_update_g(form, NULL);
}
int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx) {
EVEForm *form = (EVEForm *)v;
EVEWidget *widget = form->widget;
+ EVETouch *t;
+ uint16_t evt;
int i, ret = 0;
- if (touch_idx == 0) {
- EVETouch *t;
- uint16_t evt;
+ if (touch_idx > 0) return 0;
- t = eve_touch_evt(tag0, touch_idx, form->p.v.window->tag, 1, &evt);
- if (t && evt) {
- eve_form_handle_evt(&form->p, NULL, t, evt, tag0, touch_idx);
- if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (t->eevt == 0)) eve_page_set_focus(&form->p, NULL, NULL);
- ret = 1;
- }
+ t = eve_touch_evt(tag0, touch_idx, form->p.v.window->tag, 1, &evt);
+ if (t && evt) {
+ ret = eve_form_handle_evt(form, NULL, t, evt);
+ if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (t->eevt == 0)) eve_page_set_focus(&form->p, NULL, NULL);
+ if (ret) return 1;
}
for (i=0; i<form->widget_size; i++) {
if (eve_page_rect_visible(&form->p, &widget->g)) {
- int r = widget->touch(widget, &form->p, tag0, touch_idx);
- ret = ret || r;
+ t = eve_touch_evt(tag0, touch_idx, widget->tag0, widget->tagN - widget->tag0, &evt);
+ if (t && evt) {
+ ret = widget->touch(widget, &form->p, t, evt);
+ if (ret) return 1;
+ ret = eve_form_handle_evt(form, widget, t, evt);
+ if (ret) return 1;
+ }
}
widget = eve_widget_next(widget);
}
- return ret;
+ return 0;
}
uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
@@ -58,6 +64,7 @@ uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
EVEWidget *widget = form->widget;
int i;
uint8_t tagN = tag0;
+ uint8_t tag_opt = EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT_Y;
eve_cmd_dl(SAVE_CONTEXT());
eve_cmd_dl(VERTEX_FORMAT(0));
@@ -70,32 +77,25 @@ uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
eve_label_draw(widget->label);
eve_cmd_dl(TAG_MASK(1));
}
- if (eve_page_rect_visible(&form->p, &widget->g)) tagN = widget->draw(widget, &form->p, tagN);
+ if (eve_page_rect_visible(&form->p, &widget->g)) {
+ uint16_t h = widget->g.h;
+ tagN = widget->draw(widget, &form->p, tagN);
+ if (h != widget->g.h) eve_form_update_g(form, widget);
+ }
widget = eve_widget_next(widget);
}
eve_cmd_dl(RESTORE_CONTEXT());
for (i=tag0; i<tagN; i++) {
- eve_touch_set_opt(i, eve_touch_get_opt(i) | EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT);
+ eve_touch_set_opt(i, eve_touch_get_opt(i) | tag_opt);
}
- if (v->window->tag != EVE_TAG_NOTAG) eve_touch_set_opt(v->window->tag, eve_touch_get_opt(v->window->tag) | EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT);
+ if (v->window->tag != EVE_TAG_NOTAG) eve_touch_set_opt(v->window->tag, eve_touch_get_opt(v->window->tag) | tag_opt);
return tagN;
}
-int eve_form_handle_evt(EVEPage *page, EVEWidget *widget, EVETouch *touch, uint16_t evt, uint8_t tag0, int touch_idx) {
- /*
- if (evt & EVE_TOUCH_ETYPE_TRACK_Y) {
- // do scroll
- } else {
- // go back / forward
- }
- */
-}
-
-void eve_form_update_g(EVEPage *page, EVEWidget *_widget) {
- EVEForm *form = (EVEForm *)page;
+void eve_form_update_g(EVEForm *form, EVEWidget *_widget) {
EVEWidget *widget = form->widget;
int i;
uint16_t w = 0;
@@ -125,10 +125,34 @@ void eve_form_update_g(EVEPage *page, EVEWidget *_widget) {
}
}
+int eve_form_handle_evt(EVEForm *form, EVEWidget *widget, EVETouch *touch, uint16_t evt) {
+ static int16_t start;
+
+ if ((evt & EVE_TOUCH_ETYPE_TRACK) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_Y)) {
+ if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
+ start = form->p.win_y;
+ }
+ form->p.win_y = start + touch->y0 - touch->y;
+ return 1;
+ }
+ if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_RIGHT)) {
+ eve_page_close((EVEPage *)form);
+ return 1;
+ }
+ if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_LEFT) && form->action) {
+ form->action(form);
+ return 1;
+ }
+
+ return 0;
+}
+
EVEWidget *eve_form_widget(EVEForm *form, uint16_t idx) {
EVEWidget *w = form->widget;
int i;
+ if (idx >= form->widget_size) return NULL;
+
for (i=0; i<idx; i++) {
w = eve_widget_next(w);
}
diff --git a/fw/fe310/eos/eve/screen/form.h b/fw/fe310/eos/eve/screen/form.h
index cab10b9..426a655 100644
--- a/fw/fe310/eos/eve/screen/form.h
+++ b/fw/fe310/eos/eve/screen/form.h
@@ -1,16 +1,23 @@
#include <stdint.h>
struct EVEWidget;
+struct EVEForm;
+
+typedef void (*eve_form_action_t) (struct EVEForm *);
+typedef void (*eve_form_destructor_t) (struct EVEForm *);
typedef struct EVEForm {
EVEPage p;
struct EVEWidget *widget;
uint16_t widget_size;
+ eve_form_action_t action;
} EVEForm;
-int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, eve_page_destructor_t destructor);
+int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, eve_form_action_t action, eve_form_destructor_t destructor);
+
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);
+
+void eve_form_update_g(EVEForm *form, struct EVEWidget *widget);
+int eve_form_handle_evt(EVEForm *form, struct EVEWidget *widget, EVETouch *touch, uint16_t evt);
struct EVEWidget *eve_form_widget(EVEForm *form, uint16_t idx);
diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c
index 9568ce6..980cf33 100644
--- a/fw/fe310/eos/eve/screen/page.c
+++ b/fw/fe310/eos/eve/screen/page.c
@@ -16,11 +16,9 @@
#define CH_EOF 0x1a
-void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_evt_handler_t handle_evt, eve_page_g_updater_t update_g, eve_page_destructor_t destructor) {
+void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_destructor_t destructor) {
memset(page, 0, sizeof(EVEPage));
eve_view_init(&page->v, window, touch, draw, NULL);
- page->handle_evt = handle_evt;
- page->update_g = update_g;
page->destructor = destructor;
page->stack = stack;
page->widget_f = NULL;
@@ -37,11 +35,15 @@ void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor) {
void eve_page_close(EVEPage *page) {
EVEWindow *window = page->v.window;
+ EVEScreen *screen = window->screen;
EVEViewStack *stack = page->stack;
eve_page_destructor_t destructor = page->destructor;
- if (destructor) destructor(page);
- eve_view_destroy(window, stack);
+ if (stack->level > 1) {
+ if (destructor) destructor(page);
+ eve_screen_hide_kbd(screen);
+ eve_view_destroy(window, stack);
+ }
}
int16_t eve_page_x(EVEPage *page, int16_t x) {
@@ -62,21 +64,18 @@ int16_t eve_page_scr_y(EVEPage *page, int16_t y) {
void eve_page_set_focus(EVEPage *page, EVEWidget *widget, EVERect *f) {
if (page->widget_f != widget) {
- EVEKbd *kbd = eve_screen_get_kbd(page->v.window->screen);
-
- if (kbd) {
- EVEWidget *widget_f = page->widget_f;
-
- if (widget_f && widget_f->putc) {
- eve_screen_hide_kbd(page->v.window->screen);
- widget_f->putc(page, CH_EOF);
- }
- if (widget && widget->putc) {
- eve_kbd_set_handler(kbd, widget->putc, page);
- eve_screen_show_kbd(page->v.window->screen);
- } else {
- eve_kbd_set_handler(kbd, NULL, NULL);
- }
+ EVEScreen *screen = page->v.window->screen;
+ EVEWidget *widget_f = page->widget_f;
+
+ if (widget_f && widget_f->putc) {
+ eve_screen_hide_kbd(screen);
+ widget_f->putc(page, CH_EOF);
+ }
+ if (widget && widget->putc) {
+ EVEKbd *kbd = eve_screen_get_kbd(screen);
+
+ if (kbd) eve_kbd_set_handler(kbd, widget->putc, page);
+ eve_screen_show_kbd(screen);
}
page->widget_f = widget;
}
diff --git a/fw/fe310/eos/eve/screen/page.h b/fw/fe310/eos/eve/screen/page.h
index 168a017..ed558ba 100644
--- a/fw/fe310/eos/eve/screen/page.h
+++ b/fw/fe310/eos/eve/screen/page.h
@@ -1,24 +1,20 @@
#include <stdint.h>
-struct EVEPage;
struct EVEWidget;
+struct EVEPage;
-typedef int (*eve_page_evt_handler_t) (struct EVEPage *, struct EVEWidget *, EVETouch *, uint16_t, uint8_t, int);
-typedef void (*eve_page_g_updater_t) (struct EVEPage *, struct EVEWidget *);
typedef void (*eve_page_destructor_t) (struct EVEPage *);
typedef struct EVEPage {
EVEView v;
int16_t win_x;
int16_t win_y;
- eve_page_evt_handler_t handle_evt;
- eve_page_g_updater_t update_g;
eve_page_destructor_t destructor;
- struct EVEViewStack *stack;
+ EVEViewStack *stack;
struct EVEWidget *widget_f;
} EVEPage;
-void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_evt_handler_t handle_evt, eve_page_g_updater_t update_g, eve_page_destructor_t destructor);
+void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_destructor_t destructor);
void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor);
void eve_page_close(EVEPage *page);
diff --git a/fw/fe310/eos/eve/screen/screen.c b/fw/fe310/eos/eve/screen/screen.c
index af5a91f..fa4a0aa 100644
--- a/fw/fe310/eos/eve/screen/screen.c
+++ b/fw/fe310/eos/eve/screen/screen.c
@@ -28,13 +28,17 @@ void eve_screen_show_kbd(EVEScreen *screen) {
EVEWindow *win = screen->win_tail;
EVEKbd *kbd = eve_screen_get_kbd(screen);
- if (win) win->g.y = screen->h - kbd->g.h;
+ if (win && kbd) win->g.y = screen->h - kbd->g.h;
}
void eve_screen_hide_kbd(EVEScreen *screen) {
EVEWindow *win = screen->win_tail;
+ EVEKbd *kbd = eve_screen_get_kbd(screen);
- if (win) win->g.y = screen->h;
+ if (win && kbd) {
+ win->g.y = screen->h;
+ eve_kbd_close(kbd);
+ }
}
void eve_screen_draw(EVEScreen *screen) {
@@ -87,6 +91,7 @@ void eve_screen_draw(EVEScreen *screen) {
void eve_screen_handle_touch(void *s, uint8_t tag0, int touch_idx) {
EVEScreen *screen = s;
EVEWindow *win;
+ int h;
eve_touch_clear_opt();
@@ -94,7 +99,8 @@ void eve_screen_handle_touch(void *s, uint8_t tag0, int touch_idx) {
win = screen->win_tail;
while (win) {
if (eve_window_visible(win)) {
- int a = win->view->touch(win->view, tag0, touch_idx);
+ h = win->view->touch(win->view, tag0, touch_idx);
+ if (h) break;
}
win = win->prev;
}
diff --git a/fw/fe310/eos/eve/widget/Makefile b/fw/fe310/eos/eve/widget/Makefile
index 720029e..fa5b41c 100644
--- a/fw/fe310/eos/eve/widget/Makefile
+++ b/fw/fe310/eos/eve/widget/Makefile
@@ -2,7 +2,7 @@ include ../../../common.mk
CFLAGS += -I.. -I../..
-obj = clipb.o font.o label.o widget.o freew.o spacerw.o pagew.o strw.o textw.o
+obj = clipb.o font.o label.o widget.o freew.o spacerw.o pagew.o strw.o textw.o selectw.o
%.o: %.c %.h
diff --git a/fw/fe310/eos/eve/widget/freew.c b/fw/fe310/eos/eve/widget/freew.c
index eaf982c..8fcc2f6 100644
--- a/fw/fe310/eos/eve/widget/freew.c
+++ b/fw/fe310/eos/eve/widget/freew.c
@@ -36,35 +36,26 @@ void eve_freew_update(EVEFreeWidget *widget, eve_freew_touch_t touch, eve_freew_
}
void eve_freew_tag(EVEFreeWidget *widget) {
- if (widget->tagN != EVE_TAG_NOTAG) {
- eve_cmd_dl(TAG(widget->tagN));
- widget->tagN++;
+ EVEWidget *_widget = &widget->w;
+
+ 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) {
+int eve_freew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVEFreeWidget *widget = (EVEFreeWidget *)_widget;
- EVETouch *t;
- uint16_t evt;
- int ret = 0;
-
- if (touch_idx > 0) return 0;
-
- t = eve_touch_evt(tag0, touch_idx, widget->tag0, widget->tagN - widget->tag0, &evt);
- if (t && evt) {
- ret = widget->_touch(widget, page, t, evt, tag0, touch_idx);
- if (!ret && page && page->handle_evt) ret = page->handle_evt(page, _widget, t, evt, tag0, touch_idx);
- }
- return ret;
+ return widget->_touch(widget, page, t, evt);
}
uint8_t eve_freew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
EVEFreeWidget *widget = (EVEFreeWidget *)_widget;
- widget->tag0 = tag0;
- widget->tagN = tag0;
+ _widget->tag0 = tag0;
+ _widget->tagN = tag0;
widget->_draw(widget, page);
- return widget->tagN;
+ return _widget->tagN;
}
diff --git a/fw/fe310/eos/eve/widget/freew.h b/fw/fe310/eos/eve/widget/freew.h
index 3347e68..c7d8076 100644
--- a/fw/fe310/eos/eve/widget/freew.h
+++ b/fw/fe310/eos/eve/widget/freew.h
@@ -2,15 +2,13 @@
struct EVEFreeWidget;
-typedef int (*eve_freew_touch_t) (struct EVEFreeWidget *, EVEPage *, EVETouch *, uint16_t, uint8_t, int);
+typedef int (*eve_freew_touch_t) (struct EVEFreeWidget *, EVEPage *, EVETouch *, uint16_t);
typedef void (*eve_freew_draw_t) (struct EVEFreeWidget *, EVEPage *);
typedef struct EVEFreeWidget {
EVEWidget w;
eve_freew_touch_t _touch;
eve_freew_draw_t _draw;
- uint8_t tag0;
- uint8_t tagN;
} EVEFreeWidget;
typedef struct EVEFreeSpec {
@@ -24,5 +22,5 @@ void eve_freew_init(EVEFreeWidget *widget, EVERect *g, eve_freew_touch_t touch,
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);
+int eve_freew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_freew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/pagew.c b/fw/fe310/eos/eve/widget/pagew.c
index 319e207..2142cb9 100644
--- a/fw/fe310/eos/eve/widget/pagew.c
+++ b/fw/fe310/eos/eve/widget/pagew.c
@@ -39,36 +39,28 @@ void eve_pagew_update(EVEPageWidget *widget, EVEFont *font, char *title, eve_vie
if (_widget->g.h == 0) _widget->g.h = eve_font_h(font);
}
-int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) {
+int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVEPageWidget *widget = (EVEPageWidget *)_widget;
- EVETouch *t;
- uint16_t evt;
- int ret = 0;
-
- if (touch_idx > 0) return 0;
-
- t = eve_touch_evt(tag0, touch_idx, widget->tag, 1, &evt);
- if (t && evt) {
- if (evt & EVE_TOUCH_ETYPE_TRACK_MASK) {
- if (page->handle_evt) ret = page->handle_evt(page, _widget, t, evt, tag0, touch_idx);
- } else if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
- eve_page_open(page, widget->constructor);
- ret = 1;
- }
+
+ if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
+ eve_page_open(page, widget->constructor);
+ return 1;
}
- return ret;
+ return 0;
}
uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
EVEPageWidget *widget = (EVEPageWidget *)_widget;
- widget->tag = tag0;
+ _widget->tag0 = tag0;
if (tag0 != EVE_TAG_NOTAG) {
eve_cmd_dl(TAG(tag0));
tag0++;
}
+ _widget->tagN = tag0;
+
eve_cmd(CMD_TEXT, "hhhhs", _widget->g.x, _widget->g.y, widget->font->id, 0, widget->title);
- return tag0;
+ return _widget->tagN;
}
diff --git a/fw/fe310/eos/eve/widget/pagew.h b/fw/fe310/eos/eve/widget/pagew.h
index 67b1199..6560654 100644
--- a/fw/fe310/eos/eve/widget/pagew.h
+++ b/fw/fe310/eos/eve/widget/pagew.h
@@ -5,7 +5,6 @@ typedef struct EVEPageWidget {
char *title;
EVEFont *font;
eve_view_constructor_t constructor;
- uint8_t tag;
} EVEPageWidget;
typedef struct EVEPageSpec {
@@ -18,5 +17,5 @@ int eve_pagew_create(EVEPageWidget *widget, EVERect *g, EVEPageSpec *spec);
void eve_pagew_init(EVEPageWidget *widget, EVERect *g, EVEFont *font, char *title, eve_view_constructor_t constructor);
void eve_pagew_update(EVEPageWidget *widget, EVEFont *font, char *title, eve_view_constructor_t constructor);
-int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx);
+int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/selectw.c b/fw/fe310/eos/eve/widget/selectw.c
index 48f7f6d..eeb956f 100644
--- a/fw/fe310/eos/eve/widget/selectw.c
+++ b/fw/fe310/eos/eve/widget/selectw.c
@@ -50,11 +50,11 @@ void eve_selectw_update(EVESelectWidget *widget, EVEFont *font, utf8_t *option,
if (option) {
widget->option = option;
widget->option_size = option_size;
+ widget->select = SELECTW_NOSELECT;
}
- widget->select = SELECTW_NOSELECT;
}
-int eve_selectw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt, uint8_t tag0, int touch_idx) {
+int eve_selectw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVESelectWidget *widget = (EVESelectWidget *)_widget;
if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
@@ -111,11 +111,7 @@ uint8_t eve_selectw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
}
} while (o_len);
- new_h = i * widget->font->h;
- if (_widget->g.h != new_h) {
- _widget->g.h = new_h;
- if (page && page->update_g) page->update_g(page, _widget);
- }
+ _widget->g.h = i * widget->font->h;
return _widget->tagN;
}
@@ -138,10 +134,8 @@ utf8_t *eve_selectw_option_get(EVESelectWidget *widget, int idx) {
return NULL;
}
-int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *opt, uint16_t size) {
- if (size > widget->option_size) return EVE_ERR_FULL;
- memcpy(widget->option, opt, size);
- memset(widget->option + size, 0, widget->option_size - size);
+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) {
@@ -162,6 +156,10 @@ int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *opt) {
return EVE_OK;
}
-utf8_t *eve_selectw_option_get_select(EVESelectWidget *widget) {
- return eve_selectw_option_get(widget, widget->select);
+int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *opt, uint16_t size) {
+ if (size > widget->option_size) return EVE_ERR_FULL;
+ memcpy(widget->option, opt, size);
+ memset(widget->option + size, 0, widget->option_size - size);
+
+ return EVE_OK;
}
diff --git a/fw/fe310/eos/eve/widget/selectw.h b/fw/fe310/eos/eve/widget/selectw.h
index 6e2c203..953ba4a 100644
--- a/fw/fe310/eos/eve/widget/selectw.h
+++ b/fw/fe310/eos/eve/widget/selectw.h
@@ -18,10 +18,10 @@ void eve_selectw_destroy(EVESelectWidget *widget);
void eve_selectw_init(EVESelectWidget *widget, EVERect *g, EVEFont *font, utf8_t *option, uint16_t option_size);
void eve_selectw_update(EVESelectWidget *widget, EVEFont *font, utf8_t *option, uint16_t option_size);
-int eve_selectw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt, uint8_t tag0, int touch_idx);
+int eve_selectw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_selectw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
utf8_t *eve_selectw_option_get(EVESelectWidget *widget, int idx);
-int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *opt, uint16_t size);
-int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *opt);
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);
diff --git a/fw/fe310/eos/eve/widget/spacerw.c b/fw/fe310/eos/eve/widget/spacerw.c
index e53c9c1..3a0216f 100644
--- a/fw/fe310/eos/eve/widget/spacerw.c
+++ b/fw/fe310/eos/eve/widget/spacerw.c
@@ -28,10 +28,12 @@ void eve_spacerw_init(EVESpacerWidget *widget, EVERect *g) {
eve_widget_init(_widget, EVE_WIDGET_TYPE_SPACER, g, eve_spacerw_touch, eve_spacerw_draw, NULL);
}
-int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) {
+int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
return 0;
}
uint8_t eve_spacerw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
- return tag0;
+ _widget->tag0 = tag0;
+ _widget->tagN = tag0;
+ return _widget->tagN;
}
diff --git a/fw/fe310/eos/eve/widget/spacerw.h b/fw/fe310/eos/eve/widget/spacerw.h
index cbde4e8..073f134 100644
--- a/fw/fe310/eos/eve/widget/spacerw.h
+++ b/fw/fe310/eos/eve/widget/spacerw.h
@@ -10,5 +10,5 @@ typedef struct EVESpacerSpec {
int eve_spacerw_create(EVESpacerWidget *widget, EVERect *g, EVESpacerSpec *spec);
void eve_spacerw_init(EVESpacerWidget *widget, EVERect *g);
-int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx);
+int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_spacerw_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 0e1c97f..fe71b89 100644
--- a/fw/fe310/eos/eve/widget/strw.c
+++ b/fw/fe310/eos/eve/widget/strw.c
@@ -24,9 +24,9 @@
#define CH_CTRLC 0x03
#define CH_CTRLV 0x16
-#define STRW_TMODE_CURSOR 1
-#define STRW_TMODE_SCROLL_X 2
-#define STRW_TMODE_SCROLL_Y 3
+#define STRW_TRACK_NONE 0
+#define STRW_TRACK_CRSR 1
+#define STRW_TRACK_TXT 2
#define CHAR_VALID_INPUT(c) ((c >= 0x20) && (c < 0x7f))
@@ -97,93 +97,76 @@ static EVEStrCursor *cursor_prox(EVEStrWidget *widget, EVEStrCursor *cursor, EVE
return NULL;
}
-int eve_strw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) {
+int eve_strw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVEStrWidget *widget = (EVEStrWidget *)_widget;
- EVETouch *t;
- uint16_t evt;
+ EVEStrCursor *t_cursor = NULL;
+ short dx;
+ int ret = 0;
- if (touch_idx > 0) return 0;
-
- t = eve_touch_evt(tag0, touch_idx, widget->tag, 1, &evt);
- if (t && evt) {
- EVEStrCursor *t_cursor = NULL;
- short dx;
-
- if (evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TRACK_START)) {
- if (widget->cursor2.on) {
- t_cursor = cursor_prox(widget, &widget->cursor2, page, t, &dx);
- }
- if ((t_cursor == NULL) && widget->cursor1.on) {
- t_cursor = cursor_prox(widget, &widget->cursor1, page, t, &dx);
- }
- if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
+ if (evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TRACK_START)) {
+ if (widget->cursor2.on) {
+ t_cursor = cursor_prox(widget, &widget->cursor2, page, t, &dx);
+ }
+ if ((t_cursor == NULL) && widget->cursor1.on) {
+ t_cursor = cursor_prox(widget, &widget->cursor1, page, t, &dx);
+ }
+ if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
+ if (t_cursor) {
+ widget->track.mode = STRW_TRACK_CRSR;
widget->track.cursor = t_cursor;
- if (t_cursor) {
- widget->track.mode = STRW_TMODE_CURSOR;
- widget->track.dx = dx;
- } else if (t->eevt & EVE_TOUCH_EETYPE_TRACK_X) {
- widget->track.mode = STRW_TMODE_SCROLL_X;
- } else if (t->eevt & EVE_TOUCH_EETYPE_TRACK_Y) {
- widget->track.mode = STRW_TMODE_SCROLL_Y;
- }
+ widget->track.dx = dx;
+ } else if (t->eevt & EVE_TOUCH_EETYPE_TRACK_X) {
+ widget->track.mode = STRW_TRACK_TXT;
}
}
+ }
- switch (widget->track.mode) {
- case STRW_TMODE_SCROLL_Y:
- if (page->handle_evt) page->handle_evt(page, _widget, t, evt, tag0, touch_idx);
- break;
+ if ((evt & EVE_TOUCH_ETYPE_TRACK) && widget->track.mode) {
+ int x, w1;
- case STRW_TMODE_SCROLL_X:
+ switch (widget->track.mode) {
+ case STRW_TRACK_TXT:
if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
widget->str_g.x0 = widget->str_g.x;
}
- if (evt & EVE_TOUCH_ETYPE_TRACK) {
- int x = widget->str_g.x0 + t->x0 - t->x;
- int w1 = widget->w.g.w - widget->font->w;
-
- if (x > widget->str_g.w - w1) x = widget->str_g.w - w1;
- if (x < 0) x = 0;
- widget->str_g.x = x;
- }
- break;
-
- case STRW_TMODE_CURSOR:
- if (evt & EVE_TOUCH_ETYPE_TRACK) eve_strw_cursor_set(widget, widget->track.cursor, eve_page_x(page, t->x) + widget->track.dx);
+ x = widget->str_g.x0 + t->x0 - t->x;
+ w1 = widget->w.g.w - widget->font->w;
+ if (x > widget->str_g.w - w1) x = widget->str_g.w - w1;
+ if (x < 0) x = 0;
+ widget->str_g.x = x;
break;
- default:
- if (evt & EVE_TOUCH_ETYPE_LPRESS) {
- if (widget->cursor2.on) {
- // copy
- } else if (widget->cursor1.on) {
- if (t_cursor) {
- // paste
- } else {
- eve_strw_cursor_set(widget, &widget->cursor2, eve_page_x(page, t->x));
- }
- } else {
- // select
- }
- }
- if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(t->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
- eve_strw_cursor_set(widget, &widget->cursor1, eve_page_x(page, t->x0));
- if (widget->cursor2.on) eve_strw_cursor_clear(widget, &widget->cursor2);
- set_focus(widget, page);
- }
+ case STRW_TRACK_CRSR:
+ eve_strw_cursor_set(widget, widget->track.cursor, eve_page_x(page, t->x) + widget->track.dx);
break;
}
-
- if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
- widget->track.mode = 0;
- widget->track.cursor = NULL;
- widget->track.dx = 0;
+ ret = 1;
+ } else if (evt & EVE_TOUCH_ETYPE_LPRESS) {
+ if (widget->cursor2.on) {
+ // copy
+ } else if (widget->cursor1.on) {
+ if (t_cursor) {
+ // paste
+ } else {
+ eve_strw_cursor_set(widget, &widget->cursor2, eve_page_x(page, t->x));
+ }
+ } else {
+ // select
}
+ ret = 1;
+ } else if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(t->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
+ eve_strw_cursor_set(widget, &widget->cursor1, eve_page_x(page, t->x0));
+ if (widget->cursor2.on) eve_strw_cursor_clear(widget, &widget->cursor2);
+ set_focus(widget, page);
+ }
- return 1;
+ if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
+ widget->track.mode = STRW_TRACK_NONE;
+ widget->track.cursor = NULL;
+ widget->track.dx = 0;
}
- return 0;
+ return ret;
}
static void _draw_str(EVEStrWidget *widget, EVEWindow *window, uint16_t ch, uint16_t len, uint16_t x1, uint16_t x2, char s) {
@@ -227,12 +210,13 @@ uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
EVEStrWidget *widget = (EVEStrWidget *)_widget;
char cut = widget->str_g.x || (widget->str_g.w > _widget->g.w);
- widget->tag = tag0;
+ _widget->tag0 = tag0;
if (tag0 != EVE_TAG_NOTAG) {
eve_cmd_dl(TAG(tag0));
eve_touch_set_opt(tag0, EVE_TOUCH_OPT_LPRESS);
tag0++;
}
+ _widget->tagN = tag0;
if (cut) {
EVEWindow *window = page->v.window;
@@ -293,7 +277,7 @@ uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
eve_cmd_dl(RESTORE_CONTEXT());
}
- return tag0;
+ return _widget->tagN;
}
void eve_strw_putc(void *_page, int c) {
diff --git a/fw/fe310/eos/eve/widget/strw.h b/fw/fe310/eos/eve/widget/strw.h
index 9456603..dcb34c1 100644
--- a/fw/fe310/eos/eve/widget/strw.h
+++ b/fw/fe310/eos/eve/widget/strw.h
@@ -19,7 +19,6 @@ typedef struct EVEStrWidget {
} str_g;
EVEStrCursor cursor1;
EVEStrCursor cursor2;
- uint8_t tag;
struct {
EVEStrCursor *cursor;
short dx;
@@ -37,7 +36,7 @@ void eve_strw_destroy(EVEStrWidget *widget);
void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEFont *font, utf8_t *str, uint16_t str_size);
void eve_strw_update(EVEStrWidget *widget, EVEFont *font, utf8_t *str, uint16_t str_size);
-int eve_strw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx);
+int eve_strw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
void eve_strw_putc(void *_page, int c);
void eve_strw_cursor_set(EVEStrWidget *widget, EVEStrCursor *cursor, int16_t x);
diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c
index c81031a..62cbeff 100644
--- a/fw/fe310/eos/eve/widget/textw.c
+++ b/fw/fe310/eos/eve/widget/textw.c
@@ -24,9 +24,6 @@
#define CH_CTRLC 0x03
#define CH_CTRLV 0x16
-#define TEXTW_TMODE_CURSOR 1
-#define TEXTW_TMODE_SCROLL 2
-
#define LINE_LEN(w,l) ((l) ? (w->line[l] ? w->line[l] - w->line[(l) - 1] - 1 : 0) : w->line[l])
#define LINE_START(w,l) ((l) ? w->line[(l) - 1] + 1 : 0)
#define LINE_END(w,l) (w->line[l])
@@ -88,7 +85,7 @@ void eve_textw_update(EVETextWidget *widget, EVEFont *font, utf8_t *text, uint16
widget->line_size = line_size;
}
memset(widget->line, 0xff, line_size * sizeof(uint16_t));
- eve_textw_text_update(widget, NULL, 0);
+ eve_textw_text_update(widget, 0);
}
static void set_focus(EVETextWidget *widget, EVETextCursor *cursor, EVEPage *page) {
@@ -105,7 +102,7 @@ static void set_focus(EVETextWidget *widget, EVETextCursor *cursor, EVEPage *pag
static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor, EVEPage *page, EVETouch *t, short *dx, short *dl) {
EVEWidget *_widget = &widget->w;
int x = eve_page_x(page, t->x0) - _widget->g.x;
- int l = (int)t->tag0 - widget->tag0 + widget->line0;
+ int l = (int)t->tag0 - _widget->tag0 + widget->line0;
int _dx, _dl;
*dx = cursor->x - x;
@@ -118,81 +115,55 @@ static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor,
return NULL;
}
-int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) {
+int eve_textw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVETextWidget *widget = (EVETextWidget *)_widget;
- EVETouch *t;
- uint16_t evt;
-
- if (touch_idx > 0) return 0;
+ EVETextCursor *t_cursor = NULL;
+ short dx, dl;
+ int ret = 0;
- t = eve_touch_evt(tag0, touch_idx, widget->tag0, widget->tagN - widget->tag0, &evt);
- if (t && evt) {
- EVETextCursor *t_cursor = NULL;
- short dx, dl;
-
- if (evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TRACK_START)) {
- if (widget->cursor2.on) {
- t_cursor = cursor_prox(widget, &widget->cursor2, page, t, &dx, &dl);
- }
- if ((t_cursor == NULL) && widget->cursor1.on) {
- t_cursor = cursor_prox(widget, &widget->cursor1, page, t, &dx, &dl);
- }
- if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
- widget->track.cursor = t_cursor;
- if (t_cursor) {
- widget->track.mode = TEXTW_TMODE_CURSOR;
- widget->track.dx = dx;
- widget->track.dl = dl;
- } else {
- widget->track.mode = TEXTW_TMODE_SCROLL;
- }
- }
+ if (evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TRACK_START)) {
+ if (widget->cursor2.on) {
+ t_cursor = cursor_prox(widget, &widget->cursor2, page, t, &dx, &dl);
}
-
- switch (widget->track.mode) {
- case TEXTW_TMODE_SCROLL:
- if (page->handle_evt) page->handle_evt(page, _widget, t, evt, tag0, touch_idx);
- break;
-
- case TEXTW_TMODE_CURSOR:
- if (evt & EVE_TOUCH_ETYPE_TRACK) {
- eve_textw_cursor_set(widget, widget->track.cursor, t->tag + widget->track.dl, eve_page_x(page, t->x) + widget->track.dx);
- }
- break;
-
- default:
- if (evt & EVE_TOUCH_ETYPE_LPRESS) {
- if (widget->cursor2.on) {
- // copy
- } else if (widget->cursor1.on) {
- if (t_cursor && (dl == 0)) {
- // paste
- } else {
- eve_textw_cursor_set(widget, &widget->cursor2, t->tag, eve_page_x(page, t->x));
- }
- } else {
- // select
- }
- }
- if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(t->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
- eve_textw_cursor_set(widget, &widget->cursor1, t->tag_up, eve_page_x(page, t->x0));
- if (widget->cursor2.on) eve_textw_cursor_clear(widget, &widget->cursor2);
- set_focus(widget, &widget->cursor1, page);
- }
- break;
+ if ((t_cursor == NULL) && widget->cursor1.on) {
+ t_cursor = cursor_prox(widget, &widget->cursor1, page, t, &dx, &dl);
}
+ if (t_cursor && (evt & EVE_TOUCH_ETYPE_TRACK_START)) {
+ widget->track.cursor = t_cursor;
+ widget->track.dx = dx;
+ widget->track.dl = dl;
+ }
+ }
- if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
- widget->track.mode = 0;
- widget->track.cursor = NULL;
- widget->track.dx = 0;
- widget->track.dl = 0;
+ if ((evt & EVE_TOUCH_ETYPE_TRACK) && widget->track.cursor) {
+ eve_textw_cursor_set(widget, widget->track.cursor, t->tag + widget->track.dl, eve_page_x(page, t->x) + widget->track.dx);
+ ret = 1;
+ } else if (evt & EVE_TOUCH_ETYPE_LPRESS) {
+ if (widget->cursor2.on) {
+ // copy
+ } else if (widget->cursor1.on) {
+ if (t_cursor && (dl == 0)) {
+ // paste
+ } else {
+ eve_textw_cursor_set(widget, &widget->cursor2, t->tag, eve_page_x(page, t->x));
+ }
+ } else {
+ // select
}
+ ret = 1;
+ } else if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(t->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
+ eve_textw_cursor_set(widget, &widget->cursor1, t->tag_up, eve_page_x(page, t->x0));
+ if (widget->cursor2.on) eve_textw_cursor_clear(widget, &widget->cursor2);
+ set_focus(widget, &widget->cursor1, page);
+ }
- return 1;
+ if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
+ widget->track.cursor = NULL;
+ widget->track.dx = 0;
+ widget->track.dl = 0;
}
- return 0;
+ return ret;
}
static void _draw_line(EVETextWidget *widget, EVEWindow *window, uint16_t l, uint16_t ch, uint16_t len, uint16_t x1, uint16_t x2, char s) {
@@ -250,8 +221,8 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
EVETextCursor *c1, *c2;
widget->line0 = line0;
- widget->tag0 = tag0;
- widget->tagN = tag0;
+ _widget->tag0 = tag0;
+ _widget->tagN = tag0;
if (widget->cursor2.on) {
if (widget->cursor1.ch <= widget->cursor2.ch) {
@@ -267,10 +238,10 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
}
for (i=line0; i<lineN; i++) {
- if (widget->tagN != EVE_TAG_NOTAG) {
- eve_cmd_dl(TAG(widget->tagN));
- eve_touch_set_opt(widget->tagN, EVE_TOUCH_OPT_LPRESS);
- widget->tagN++;
+ if (_widget->tagN != EVE_TAG_NOTAG) {
+ eve_cmd_dl(TAG(_widget->tagN));
+ eve_touch_set_opt(_widget->tagN, EVE_TOUCH_OPT_LPRESS);
+ _widget->tagN++;
}
if (!s && c1 && (c1->line == i)) {
int l1, l2, l3;
@@ -306,22 +277,22 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
}
}
if (lineNvisible) {
- if (widget->tagN != EVE_TAG_NOTAG) {
- eve_cmd_dl(TAG(widget->tagN));
- eve_touch_set_opt(widget->tagN, EVE_TOUCH_OPT_LPRESS);
- widget->tagN++;
+ if (_widget->tagN != EVE_TAG_NOTAG) {
+ eve_cmd_dl(TAG(_widget->tagN));
+ eve_touch_set_opt(_widget->tagN, EVE_TOUCH_OPT_LPRESS);
+ _widget->tagN++;
}
_draw_line(widget, page->v.window, lineN, 0, 0, 0, _widget->g.w, 0);
}
-
- return widget->tagN;
} else {
widget->line0 = 0;
- widget->tag0 = EVE_TAG_NOTAG;
- widget->tagN = EVE_TAG_NOTAG;
-
- return tag0;
+ _widget->tag0 = EVE_TAG_NOTAG;
+ _widget->tagN = EVE_TAG_NOTAG;
}
+
+ _widget->g.h = (widget->line_len + 1) * widget->font->h;
+
+ return _widget->tagN;
}
void eve_textw_putc(void *_page, int c) {
@@ -428,8 +399,8 @@ void eve_textw_putc(void *_page, int c) {
}
r = cursor1->line;
- if (cursor1->line) r = eve_textw_text_update(widget, page, cursor1->line - 1);
- if ((cursor1->line == 0) || (r == cursor1->line - 1)) r = eve_textw_text_update(widget, page, 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 && (cursor1->ch < LINE_START(widget, cursor1->line))) {
cursor1->line--;
@@ -444,7 +415,7 @@ void eve_textw_putc(void *_page, int c) {
}
}
-uint16_t eve_textw_text_update(EVETextWidget *widget, EVEPage *page, uint16_t line) {
+uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line) {
int i;
utf32_t ch;
uint8_t ch_w;
@@ -501,16 +472,10 @@ uint16_t eve_textw_text_update(EVETextWidget *widget, EVEPage *page, uint16_t li
}
widget->line_len = line;
- new_h = (line + 1) * widget->font->h;
for (i=line; i<widget->line_size; i++) {
widget->line[i] = LINE_EMPTY;
}
- if (_widget->g.h != new_h) {
- _widget->g.h = new_h;
- if (page && page->update_g) page->update_g(page, _widget);
- }
-
return line;
}
@@ -537,7 +502,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_TAG_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 36ab466..95f0091 100644
--- a/fw/fe310/eos/eve/widget/textw.h
+++ b/fw/fe310/eos/eve/widget/textw.h
@@ -19,13 +19,10 @@ typedef struct EVETextWidget {
EVETextCursor cursor1;
EVETextCursor cursor2;
uint16_t line0;
- uint8_t tag0;
- uint8_t tagN;
struct {
EVETextCursor *cursor;
short dx;
short dl;
- char mode;
} track;
} EVETextWidget;
@@ -40,10 +37,10 @@ void eve_textw_destroy(EVETextWidget *widget);
void eve_textw_init(EVETextWidget *widget, EVERect *g, 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);
-int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx);
+int eve_textw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
void eve_textw_putc(void *_w, int c);
-uint16_t eve_textw_text_update(EVETextWidget *widget, EVEPage *page, uint16_t line);
+uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line);
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 1d610bf..a223169 100644
--- a/fw/fe310/eos/eve/widget/widget.c
+++ b/fw/fe310/eos/eve/widget/widget.c
@@ -19,6 +19,7 @@ static const size_t _widget_size[] = {
sizeof(EVEPageWidget),
sizeof(EVEStrWidget),
sizeof(EVETextWidget),
+ sizeof(EVESelectWidget),
};
static const eve_widget_create_t _widget_create[] = {
@@ -28,6 +29,7 @@ static const eve_widget_create_t _widget_create[] = {
(eve_widget_create_t)eve_pagew_create,
(eve_widget_create_t)eve_strw_create,
(eve_widget_create_t)eve_textw_create,
+ (eve_widget_create_t)eve_selectw_create,
};
static const eve_widget_destroy_t _widget_destroy[] = {
@@ -37,6 +39,7 @@ static const eve_widget_destroy_t _widget_destroy[] = {
NULL,
(eve_widget_destroy_t)eve_strw_destroy,
(eve_widget_destroy_t)eve_textw_destroy,
+ (eve_widget_destroy_t)eve_selectw_destroy,
};
void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc) {
diff --git a/fw/fe310/eos/eve/widget/widget.h b/fw/fe310/eos/eve/widget/widget.h
index cff5c1d..3e04f3e 100644
--- a/fw/fe310/eos/eve/widget/widget.h
+++ b/fw/fe310/eos/eve/widget/widget.h
@@ -5,10 +5,11 @@
#define EVE_WIDGET_TYPE_PAGE 3
#define EVE_WIDGET_TYPE_STR 4
#define EVE_WIDGET_TYPE_TEXT 5
+#define EVE_WIDGET_TYPE_SELECT 6
struct EVEWidget;
-typedef int (*eve_widget_touch_t) (struct EVEWidget *, EVEPage *, uint8_t, int);
+typedef int (*eve_widget_touch_t) (struct EVEWidget *, EVEPage *, EVETouch *, uint16_t);
typedef uint8_t (*eve_widget_draw_t) (struct EVEWidget *, EVEPage *, uint8_t);
typedef struct EVEWidget {
@@ -18,6 +19,8 @@ typedef struct EVEWidget {
eve_kbd_input_handler_t putc;
EVELabel *label;
uint8_t type;
+ uint8_t tag0;
+ uint8_t tagN;
} EVEWidget;
void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc);
diff --git a/fw/fe310/eos/eve/widget/widgets.h b/fw/fe310/eos/eve/widget/widgets.h
index 4206894..542b350 100644
--- a/fw/fe310/eos/eve/widget/widgets.h
+++ b/fw/fe310/eos/eve/widget/widgets.h
@@ -7,6 +7,7 @@
#include "pagew.h"
#include "strw.h"
#include "textw.h"
+#include "selectw.h"
typedef union EVEWidgetSpec {
EVEFreeSpec free;
@@ -14,6 +15,7 @@ typedef union EVEWidgetSpec {
EVEPageSpec page;
EVEStrSpec str;
EVETextSpec text;
+ EVESelectSpec select;
} EVEWidgetSpec;
typedef int (*eve_widget_create_t) (EVEWidget *, EVERect *g, EVEWidgetSpec *);