From b5aa60b256dd2b328515779883ba365aba3d995f Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Tue, 9 Jun 2020 00:32:34 +0200 Subject: EVEView iface fixed; screen keyboard window implemented --- code/fe310/eos/eve/eve.h | 9 +++ code/fe310/eos/eve/eve_kbd.c | 61 +++++++++-------- code/fe310/eos/eve/eve_kbd.h | 7 +- code/fe310/eos/eve/eve_text.c | 29 +++++--- code/fe310/eos/eve/eve_text.h | 5 +- code/fe310/eos/eve/eve_touch.c | 35 +++++----- code/fe310/eos/eve/eve_touch.h | 2 +- code/fe310/eos/eve/screen/form.c | 24 +++---- code/fe310/eos/eve/screen/page.c | 2 +- code/fe310/eos/eve/screen/screen.c | 20 +++++- code/fe310/eos/eve/screen/screen.h | 9 +-- code/fe310/eos/eve/screen/window.c | 34 ++++++---- code/fe310/eos/eve/screen/window.h | 3 +- code/fe310/eos/eve/widget/page.c | 12 ++-- code/fe310/eos/eve/widget/text.c | 131 +++++++++++++++++++------------------ 15 files changed, 214 insertions(+), 169 deletions(-) (limited to 'code/fe310/eos/eve') diff --git a/code/fe310/eos/eve/eve.h b/code/fe310/eos/eve/eve.h index 2ac93a2..c27d81f 100644 --- a/code/fe310/eos/eve/eve.h +++ b/code/fe310/eos/eve/eve.h @@ -13,6 +13,15 @@ #define EVE_PSTATE_STANDBY 1 #define EVE_PSTATE_SLEEP 3 +#define EVE_TAG_NOTAG 0 + +typedef struct EVERect { + int16_t x; + int16_t y; + uint16_t w; + uint16_t h; +} EVERect; + void eve_command(uint8_t command, uint8_t parameter); uint8_t eve_read8(uint32_t addr); diff --git a/code/fe310/eos/eve/eve_kbd.c b/code/fe310/eos/eve/eve_kbd.c index aa8406f..59cfa23 100644 --- a/code/fe310/eos/eve/eve_kbd.c +++ b/code/fe310/eos/eve/eve_kbd.c @@ -1,36 +1,41 @@ #include +#include #include "eve.h" #include "eve_kbd.h" -#define KBD_X 0 -#define KBD_Y 575 -#define KBD_W 480 -#define KBD_H 225 +#define KBD_X 0 +#define KBD_Y 575 +#define KBD_W 480 +#define KBD_H 225 -#define KEY_SPACERX 3 -#define KEY_SPACERY 5 -#define KEY_FONT 29 -#define MOD_FONT 21 +#define KEY_SPACERX 3 +#define KEY_SPACERY 5 +#define KEY_FONT 29 +#define MOD_FONT 21 -#define KEY_BS 0x08 -#define KEY_RET 0x0a +#define KEY_BS 0x08 +#define KEY_RET 0x0a -#define FLAG_SHIFT 0x01 -#define FLAG_CTRL 0x02 -#define FLAG_FN 0x04 +#define FLAG_SHIFT 0x01 +#define FLAG_CTRL 0x02 +#define FLAG_FN 0x04 -#define TAG_SHIFT 0x11 -#define TAG_CTRL 0x12 -#define TAG_FN 0x13 +#define TAG_SHIFT 0x11 +#define TAG_CTRL 0x12 +#define TAG_FN 0x13 -void eve_kbd_init(EVEKbd *kbd, uint32_t mem_addr, uint32_t *mem_next) { +void eve_kbd_init(EVEKbd *kbd, EVERect *g, uint32_t mem_addr, uint32_t *mem_next) { uint16_t mem_size; - kbd->x = KBD_X; - kbd->y = KBD_Y; - kbd->w = KBD_W; - kbd->h = KBD_H; + if (g) { + kbd->g = *g; + } else { + kbd->g.x = KBD_X; + kbd->g.y = KBD_Y; + kbd->g.w = KBD_W; + kbd->g.h = KBD_H; + } kbd->mem_addr = mem_addr; kbd->key_modifier = 0; kbd->key_count = 0; @@ -60,7 +65,7 @@ int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx) { EVETouch *t; uint16_t evt; - t = eve_touch_evt(tag0, touch_idx, 1, 0x7e, &evt); + t = eve_touch_evt(tag0, touch_idx, 1, 126, &evt); if (t && evt) { if (evt & EVE_TOUCH_ETYPE_TAG) { uint8_t _tag = t->tag; @@ -116,15 +121,16 @@ int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx) { } else { kbd->active = 0; } + return kbd->active; } uint8_t eve_kbd_draw(EVEKbd *kbd) { if (kbd->active) { - int x = kbd->x; - int y = kbd->y; - int w = kbd->w; - int row_h = kbd->h / 5; + int x = kbd->g.x; + int y = kbd->g.y; + int w = kbd->g.w; + int row_h = kbd->g.h / 5; int key_w = (w - 9 * KEY_SPACERX) / 10 + 1; int mod_w = key_w + key_w / 2; int key_h = row_h - KEY_SPACERY; @@ -151,5 +157,6 @@ uint8_t eve_kbd_draw(EVEKbd *kbd) { } else { eve_cmd(CMD_APPEND, "ww", kbd->mem_addr, kbd->mem_size); } - return 0x7e; + + return 0x80; } diff --git a/code/fe310/eos/eve/eve_kbd.h b/code/fe310/eos/eve/eve_kbd.h index 4711421..b27f54d 100644 --- a/code/fe310/eos/eve/eve_kbd.h +++ b/code/fe310/eos/eve/eve_kbd.h @@ -3,10 +3,7 @@ typedef void (*eve_kbd_input_handler_t) (void *, int); typedef struct EVEKbd { - int16_t x; - int16_t y; - uint16_t w; - uint16_t h; + EVERect g; uint32_t mem_addr; uint16_t mem_size; uint8_t key_count; @@ -19,7 +16,7 @@ typedef struct EVEKbd { void *param; } EVEKbd; -void eve_kbd_init(EVEKbd *kbd, uint32_t mem_addr, uint32_t *mem_next); +void eve_kbd_init(EVEKbd *kbd, EVERect *g, uint32_t mem_addr, uint32_t *mem_next); 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/code/fe310/eos/eve/eve_text.c b/code/fe310/eos/eve/eve_text.c index 5510f80..2ad4f6f 100644 --- a/code/fe310/eos/eve/eve_text.c +++ b/code/fe310/eos/eve/eve_text.c @@ -1,3 +1,6 @@ +#include +#include + #include "eve.h" #include "eve_text.h" @@ -17,14 +20,24 @@ static void scroll1(EVEText *box) { box->dirty = 1; } -void eve_text_init(EVEText *box, int16_t x, int16_t y, uint16_t w, uint16_t h, double scale_x, double scale_y, uint8_t tag, uint16_t line_size, uint32_t mem_addr, uint32_t *mem_next) { - box->x = x; - box->y = y; +void eve_text_init(EVEText *box, EVERect *g, uint16_t w, uint16_t h, uint8_t tag, uint16_t line_size, uint32_t mem_addr, uint32_t *mem_next) { + double scale_x, scale_y; + + if (g->w == 0) { + g->w = w * 8; + } + if (g->h == 0) { + g->h = h * 16; + } + + scale_x = (double)g->w / (w * 8); + scale_y = (double)g->h / (h * 16); + box->g = *g; box->w = w; box->h = h; box->tag = tag; - box->transform_a = 256/scale_x; - box->transform_e = 256/scale_y; + box->transform_a = 256 / scale_x; + box->transform_e = 256 / scale_y; box->ch_w = scale_x * 8; box->ch_h = scale_y * 16; box->dl_size = 17; @@ -55,7 +68,7 @@ int eve_text_touch(EVEText *box, uint8_t tag0, int touch_idx) { uint16_t evt; int ret = 0; - t = eve_touch_evt(tag0, touch_idx, box->tag, box->tag, &evt); + t = eve_touch_evt(tag0, touch_idx, box->tag, 1, &evt); if (t && evt) { if ((evt & EVE_TOUCH_ETYPE_TRACK_START) && (box->line_top < 0)) { box->line_top = box->line0; @@ -145,14 +158,14 @@ void eve_text_update(EVEText *box) { eve_dl_write(BITMAP_LAYOUT(EVE_TEXTVGA, box->w * 2, text_h1)); eve_dl_write(BITMAP_SIZE(EVE_NEAREST, EVE_BORDER, EVE_BORDER, box->w * box->ch_w, text_h1 * box->ch_h)); eve_dl_write(BITMAP_SIZE_H(box->w * box->ch_w, text_h1 * box->ch_h)); - eve_dl_write(VERTEX2F(box->x, box->y)); + eve_dl_write(VERTEX2F(box->g.x, box->g.y)); if (text_h2) { eve_dl_write(BITMAP_SOURCE(box->mem_addr)); eve_dl_write(BITMAP_LAYOUT(EVE_TEXTVGA, box->w * 2, text_h2)); eve_dl_write(BITMAP_SIZE(EVE_NEAREST, EVE_BORDER, EVE_BORDER, box->w * box->ch_w, text_h2 * box->ch_h)); eve_dl_write(BITMAP_SIZE_H(box->w * box->ch_w, text_h2 * box->ch_h)); - eve_dl_write(VERTEX2F(box->x, box->y + text_h1 * box->ch_h)); + eve_dl_write(VERTEX2F(box->g.x, box->g.y + text_h1 * box->ch_h)); } else { eve_dl_write(NOP()); eve_dl_write(NOP()); diff --git a/code/fe310/eos/eve/eve_text.h b/code/fe310/eos/eve/eve_text.h index 0ccf62a..141816c 100644 --- a/code/fe310/eos/eve/eve_text.h +++ b/code/fe310/eos/eve/eve_text.h @@ -1,8 +1,7 @@ #include typedef struct EVEText { - int16_t x; - int16_t y; + EVERect g; uint16_t w; uint16_t h; uint32_t mem_addr; @@ -20,7 +19,7 @@ typedef struct EVEText { char dirty; } EVEText; -void eve_text_init(EVEText *box, int16_t x, int16_t y, uint16_t w, uint16_t h, double scale_x, double scale_y, uint8_t tag, uint16_t line_size, uint32_t mem_addr, uint32_t *mem_next); +void eve_text_init(EVEText *box, EVERect *g, uint16_t w, uint16_t h, uint8_t tag, uint16_t line_size, uint32_t mem_addr, uint32_t *mem_next); int eve_text_touch(EVEText *box, uint8_t tag0, int touch_idx); uint8_t eve_text_draw(EVEText *box); int eve_text_putc(EVEText *box, int c); diff --git a/code/fe310/eos/eve/eve_touch.c b/code/fe310/eos/eve/eve_touch.c index 34cb79a..fb570bf 100644 --- a/code/fe310/eos/eve/eve_touch.c +++ b/code/fe310/eos/eve/eve_touch.c @@ -12,7 +12,6 @@ #define EVE_NOTOUCH 0x80000000 #define EVE_MAX_TOUCH 5 -#define EVE_TAG_SCREEN 0xff static int _intr_mask = EVE_INT_TAG | EVE_INT_TOUCH; static int _multitouch; @@ -24,7 +23,7 @@ static EVEExtTracker _ext_tracker; static eve_touch_handler_t _touch_handler; static void *_touch_handler_param; -static uint8_t _tag_opt[255]; +static uint8_t _tag_opt[256]; static const uint32_t _reg_touch[] = { REG_CTOUCH_TOUCH0_XY, @@ -166,20 +165,18 @@ void eve_handle_touch(void) { touch->tag0 = touch_tag; if (_tag_opt[touch_tag] & EVE_TOUCH_OPT_TRACK_MASK) { touch->tracker.tag = touch_tag; - } else if (_tag_opt[EVE_TAG_SCREEN] & EVE_TOUCH_OPT_TRACK_MASK) { - touch->tracker.tag = EVE_TAG_SCREEN; } if (touch->tracker.tag && !(_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_XY)) { touch->tracker.track = 1; touch->evt |= EVE_TOUCH_ETYPE_TRACK_START; touch->t = now; } - if (!_tag0 && ((_tag_opt[touch_tag] | _tag_opt[EVE_TAG_SCREEN]) & EVE_TOUCH_OPT_TIMER_MASK)) { - uint8_t _tag = _tag_opt[touch_tag] & EVE_TOUCH_OPT_TIMER_MASK ? touch_tag : EVE_TAG_SCREEN; + if (!_tag0 && (_tag_opt[touch_tag] & EVE_TOUCH_OPT_TIMER_MASK)) { uint16_t _evt = 0; - if (_tag_opt[_tag] & EVE_TOUCH_OPT_LPRESS) _evt |= EVE_TOUCH_ETYPE_LPRESS; - if (_tag_opt[_tag] & EVE_TOUCH_OPT_DTAP) _evt |= EVE_TOUCH_ETYPE_TAP1; - _touch_timer_set(_tag, 0, _evt, 0, 0, EVE_TIMEOUT_TAP); + + if (_tag_opt[touch_tag] & EVE_TOUCH_OPT_LPRESS) _evt |= EVE_TOUCH_ETYPE_LPRESS; + if (_tag_opt[touch_tag] & EVE_TOUCH_OPT_DTAP) _evt |= EVE_TOUCH_ETYPE_TAP1; + _touch_timer_set(touch_tag, 0, _evt, 0, 0, EVE_TIMEOUT_TAP); } } if (!_tag0) _tag0 = tag0 = touch_tag; @@ -312,15 +309,19 @@ void eve_touch_set_handler(eve_touch_handler_t handler, void *param) { _touch_handler_param = param; } -EVETouch *eve_touch_evt(uint8_t tag0, int touch_idx, uint8_t tag_min, uint8_t tag_max, uint16_t *evt) { +EVETouch *eve_touch_evt(uint8_t tag0, int touch_idx, uint8_t tag_min, uint8_t tag_n, uint16_t *evt) { + int tag_max; uint8_t _tag; uint16_t _evt; EVETouch *ret = NULL; *evt = 0; + if ((touch_idx < 0) || (touch_idx > 4)) return ret; - if ((tag_min == 0) || (tag_max == 0)) return ret; - if ((tag0 < tag_min) || (tag0 > tag_max)) return ret; + if (tag_min == EVE_TAG_NOTAG) return ret; + + tag_max = tag_min + tag_n; + if ((tag0 < tag_min) || (tag0 >= tag_max)) return ret; ret = &_touch[touch_idx]; _evt = ret->evt; @@ -328,23 +329,23 @@ EVETouch *eve_touch_evt(uint8_t tag0, int touch_idx, uint8_t tag_min, uint8_t ta *evt |= _evt & EVE_TOUCH_ETYPE_POINT_MASK; if (_evt & EVE_TOUCH_ETYPE_TAG) { _tag = ret->tag; - if ((_tag >= tag_min) && (_tag <= tag_max)) *evt |= EVE_TOUCH_ETYPE_TAG; + if ((_tag >= tag_min) && (_tag < tag_max)) *evt |= EVE_TOUCH_ETYPE_TAG; } if (_evt & EVE_TOUCH_ETYPE_TAG_UP) { _tag = ret->tag_up; - if ((_tag >= tag_min) && (_tag <= tag_max)) *evt |= EVE_TOUCH_ETYPE_TAG_UP; + if ((_tag >= tag_min) && (_tag < tag_max)) *evt |= EVE_TOUCH_ETYPE_TAG_UP; } if (_evt & EVE_TOUCH_ETYPE_TRACK_REG) { _tag = ret->tracker.tag; - if ((_tag >= tag_min) && (_tag <= tag_max)) *evt |= EVE_TOUCH_ETYPE_TRACK_REG; + if ((_tag >= tag_min) && (_tag < tag_max)) *evt |= EVE_TOUCH_ETYPE_TRACK_REG; } if (_evt & EVE_TOUCH_ETYPE_TRACK_MASK) { _tag = ret->tracker.tag; - if ((_tag >= tag_min) && (_tag <= tag_max)) *evt |= _evt & (EVE_TOUCH_ETYPE_TRACK_MASK | EVE_TOUCH_ETYPE_TRACK_XY); + if ((_tag >= tag_min) && (_tag < tag_max)) *evt |= _evt & (EVE_TOUCH_ETYPE_TRACK_MASK | EVE_TOUCH_ETYPE_TRACK_XY); } if (_evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TAP1 | EVE_TOUCH_ETYPE_TAP2)) { _tag = _touch_timer.tag; - if ((_tag >= tag_min) && (_tag <= tag_max)) *evt |= _evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TAP1 | EVE_TOUCH_ETYPE_TAP2); + if ((_tag >= tag_min) && (_tag < tag_max)) *evt |= _evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TAP1 | EVE_TOUCH_ETYPE_TAP2); } return ret; diff --git a/code/fe310/eos/eve/eve_touch.h b/code/fe310/eos/eve/eve_touch.h index 656dd2f..1d9d751 100644 --- a/code/fe310/eos/eve/eve_touch.h +++ b/code/fe310/eos/eve/eve_touch.h @@ -79,7 +79,7 @@ void eve_handle_time(void); void eve_touch_init(void); void eve_touch_set_handler(eve_touch_handler_t handler, void *handler_param); -EVETouch *eve_touch_evt(uint8_t tag0, int touch_idx, uint8_t tag_min, uint8_t tag_max, uint16_t *evt); +EVETouch *eve_touch_evt(uint8_t tag0, int touch_idx, uint8_t tag_min, uint8_t tag_n, uint16_t *evt); void eve_touch_set_opt(uint8_t tag, uint8_t opt); uint8_t eve_touch_get_opt(uint8_t tag); void eve_touch_clear_opt(void); diff --git a/code/fe310/eos/eve/screen/form.c b/code/fe310/eos/eve/screen/form.c index bdf910a..ae381e6 100644 --- a/code/fe310/eos/eve/screen/form.c +++ b/code/fe310/eos/eve/screen/form.c @@ -45,6 +45,7 @@ int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx) { form->widget_f = widget; } widget = eve_widget_next(widget); + memset(&focus, 0, sizeof(focus)); } eve_page_focus(&form->p, &focus); @@ -54,24 +55,17 @@ int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx) { uint8_t eve_form_draw(EVEView *v, uint8_t tag0) { EVEForm *form = (EVEForm *)v; EVEWidget *widget = form->widget; - int i, j; - uint8_t tagN, _tagN = 0; + int i; + uint8_t tagN = tag0; for (i=0; iwidget_size; i++) { - tagN = widget->draw(widget, &form->p, tag0); - if (tagN) { - for (j=tag0; j<=tagN; j++) { - eve_touch_set_opt(j, eve_touch_get_opt(j) | EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT); - } - if (tagN < 0xfe) { - tag0 = tagN + 1; - } else { - tag0 = 0; - } - _tagN = tagN; - } + tagN = widget->draw(widget, &form->p, tagN); widget = eve_widget_next(widget); } - return _tagN; + for (i=tag0; iwindow, &g); + eve_window_visible_g(page->window, &g); g.x -= page->window->g.x; g.y -= page->window->g.y; diff --git a/code/fe310/eos/eve/screen/screen.c b/code/fe310/eos/eve/screen/screen.c index 9827323..d31cd2c 100644 --- a/code/fe310/eos/eve/screen/screen.c +++ b/code/fe310/eos/eve/screen/screen.c @@ -22,11 +22,11 @@ EVEKbd *eve_screen_get_kbd(EVEScreen *screen) { } void eve_screen_show_kbd(EVEScreen *screen) { - screen->kbd_active = 1; + if (screen->kbd && screen->kbd_win) screen->kbd_win->g.y = screen->h - screen->kbd->g.h; } void eve_screen_hide_kbd(EVEScreen *screen) { - screen->kbd_active = 0; + if (screen->kbd && screen->kbd_win) screen->kbd_win->g.y = screen->h; } int eve_screen_win_insert(EVEScreen *screen, EVEWindow *window, int idx) { @@ -69,5 +69,21 @@ void eve_screen_win_append(EVEScreen *screen, EVEWindow *window) { } void eve_screen_handle_touch(EVEScreen *screen, uint8_t tag0, int touch_idx) { + EVEWindow *w; + int a; + uint8_t tagN = 0x80; + eve_touch_clear_opt(); + + w = screen->win_head; + while(w) { + if (eve_window_visible(w)) a = w->view->touch(w->view, tag0, touch_idx); + w = w->next; + } + + w = screen->win_head; + while(w) { + if (eve_window_visible(w)) tagN = w->view->draw(w->view, tagN); + w = w->next; + } } diff --git a/code/fe310/eos/eve/screen/screen.h b/code/fe310/eos/eve/screen/screen.h index 9fa155a..d6bc5e8 100644 --- a/code/fe310/eos/eve/screen/screen.h +++ b/code/fe310/eos/eve/screen/screen.h @@ -2,20 +2,13 @@ struct EVEWindow; -typedef struct EVERect { - int16_t x; - int16_t y; - uint16_t w; - uint16_t h; -} EVERect; - typedef struct EVEScreen { uint16_t w; uint16_t h; struct EVEWindow *win_head; struct EVEWindow *win_tail; EVEKbd *kbd; - char kbd_active; + struct EVEWindow *kbd_win; } EVEScreen; int eve_screen_init(EVEScreen *screen, uint16_t w, uint16_t h); diff --git a/code/fe310/eos/eve/screen/window.c b/code/fe310/eos/eve/screen/window.c index 8341e8a..5c329a9 100644 --- a/code/fe310/eos/eve/screen/window.c +++ b/code/fe310/eos/eve/screen/window.c @@ -17,22 +17,32 @@ void eve_window_init(EVEWindow *window, EVERect *g, EVEView *view, EVEScreen *sc window->screen = screen; } -void eve_window_get_visible(EVEWindow *window, EVERect *g) { +int eve_window_visible(EVEWindow *window) { + if (window->g.x >= window->screen->w) return 0; + if (window->g.y >= window->screen->h) return 0; + if ((window->g.x + window->g.w) <= 0) return 0; + if ((window->g.y + window->g.h) <= 0) return 0; + return 1; +} + +void eve_window_visible_g(EVEWindow *window, EVERect *g) { EVEWindow *w = window->next; *g = window->g; while (w) { - if (w->g.x > g->x) g->w = MIN(g->w, w->g.x - g->x); - if (w->g.y > g->y) g->h = MIN(g->h, w->g.y - g->y); - if (w->g.x + w->g.w < g->x + g->w) { - uint16_t x0 = g->w - MIN(g->w, (g->x + g->w) - (w->g.x + w->g.w)); - g->x += x0; - g->w -= x0; - } - if (w->g.y + w->g.h < g->y + g->h) { - uint16_t y0 = g->h - MIN(g->h, (g->y + g->h) - (w->g.y + w->g.h)); - g->y += y0; - g->h -= y0; + if (eve_window_visible(w)) { + if (w->g.x > g->x) g->w = MIN(g->w, w->g.x - g->x); + if (w->g.y > g->y) g->h = MIN(g->h, w->g.y - g->y); + if (w->g.x + w->g.w < g->x + g->w) { + uint16_t x0 = g->w - MIN(g->w, (g->x + g->w) - (w->g.x + w->g.w)); + g->x += x0; + g->w -= x0; + } + if (w->g.y + w->g.h < g->y + g->h) { + uint16_t y0 = g->h - MIN(g->h, (g->y + g->h) - (w->g.y + w->g.h)); + g->y += y0; + g->h -= y0; + } } w = w->next; } diff --git a/code/fe310/eos/eve/screen/window.h b/code/fe310/eos/eve/screen/window.h index f3a1c77..78aabde 100644 --- a/code/fe310/eos/eve/screen/window.h +++ b/code/fe310/eos/eve/screen/window.h @@ -18,4 +18,5 @@ typedef struct EVEWindow { } EVEWindow; void eve_window_init(EVEWindow *window, EVERect *g, EVEView *view, EVEScreen *screen); -void eve_window_get_visible(EVEWindow *window, EVERect *g); +int eve_window_visible(EVEWindow *window); +void eve_window_visible_g(EVEWindow *window, EVERect *g); diff --git a/code/fe310/eos/eve/widget/page.c b/code/fe310/eos/eve/widget/page.c index 07a59b4..89177ec 100644 --- a/code/fe310/eos/eve/widget/page.c +++ b/code/fe310/eos/eve/widget/page.c @@ -27,7 +27,7 @@ int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_i if (touch_idx > 0) return 0; - t = eve_touch_evt(tag0, touch_idx, widget->tag, widget->tag, &evt); + t = eve_touch_evt(tag0, touch_idx, widget->tag, 1, &evt); if (t && evt) { if (evt & EVE_TOUCH_ETYPE_TRACK_MASK) { if (page && page->handle_evt) page->handle_evt(page, _widget, t, evt, tag0, touch_idx); @@ -44,12 +44,14 @@ uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { EVEPageWidget *widget = (EVEPageWidget *)_widget; char draw = page ? eve_page_widget_visible(page, _widget) : 1; - widget->tag = 0; + widget->tag = tag0; if (draw) { - widget->tag = tag0; - if (widget->tag) eve_cmd_dl(TAG(widget->tag)); + if (tag0 != EVE_TAG_NOTAG) { + eve_cmd_dl(TAG(tag0)); + tag0++; + } eve_cmd(CMD_TEXT, "hhhhs", _widget->g.x, _widget->g.y, widget->font_id, 0, widget->title); } - return widget->tag; + return tag0; } diff --git a/code/fe310/eos/eve/widget/text.c b/code/fe310/eos/eve/widget/text.c index 8b3fcdb..f098a5b 100644 --- a/code/fe310/eos/eve/widget/text.c +++ b/code/fe310/eos/eve/widget/text.c @@ -48,6 +48,7 @@ static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor, _dx = *dx < 0 ? -(*dx) : *dx; _dl = *dl < 0 ? -(*dl) : *dl; + if ((_dx <= widget->font->h) && (_dl <= 1)) return cursor; return NULL; } @@ -60,7 +61,7 @@ int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_i if (touch_idx > 0) return 0; - t = eve_touch_evt(tag0, touch_idx, widget->tag0, widget->tagN, &evt); + t = eve_touch_evt(tag0, touch_idx, widget->tag0, widget->tagN - widget->tag0, &evt); if (t && evt) { EVETextCursor *t_cursor = NULL; short dx, dl; @@ -136,9 +137,9 @@ static void _draw_line(EVETextWidget *widget, uint16_t l, uint16_t ch, uint16_t EVEWidget *_widget = (EVEWidget *)widget; if (x1 != x2) { - if (widget->tagN) { + if (widget->tagN != EVE_TAG_NOTAG) { eve_cmd_dl(TAG(widget->tagN)); - eve_touch_set_opt(widget->tagN, EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_LPRESS); + eve_touch_set_opt(widget->tagN, EVE_TOUCH_OPT_LPRESS); } eve_cmd_dl(BEGIN(EVE_RECTS)); if (!s) eve_cmd_dl(COLOR_MASK(0 ,0 ,0 ,0)); @@ -166,24 +167,9 @@ static void _draw_cursor(EVETextWidget *widget, EVETextCursor *cursor) { } uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { - int i; int line0, lineN; - char s, w, lineNvisible; + char lineNvisible; EVETextWidget *widget = (EVETextWidget *)_widget; - EVETextCursor *c1, *c2; - - if (widget->cursor2.on) { - if (widget->cursor1.ch <= widget->cursor2.ch) { - c1 = &widget->cursor1; - c2 = &widget->cursor2; - } else { - c1 = &widget->cursor2; - c2 = &widget->cursor1; - } - } else { - c1 = NULL; - c2 = NULL; - } if (page) { int _line0, _lineN; @@ -200,66 +186,84 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) { lineN = widget->line_len; lineNvisible = 1; } - widget->line0 = line0; - widget->tag0 = tag0; - widget->tagN = tag0; - s = 0; - w = lineNvisible || (line0 < lineN); - if (w) { + if (lineNvisible || (line0 < lineN)) { + int i; + char s = 0; + EVETextCursor *c1, *c2; + + widget->line0 = line0; + widget->tag0 = tag0; + widget->tagN = tag0; + + if (widget->cursor2.on) { + if (widget->cursor1.ch <= widget->cursor2.ch) { + c1 = &widget->cursor1; + c2 = &widget->cursor2; + } else { + c1 = &widget->cursor2; + c2 = &widget->cursor1; + } + } else { + c1 = NULL; + c2 = NULL; + } + eve_cmd_dl(SAVE_CONTEXT()); eve_cmd_dl(VERTEX_FORMAT(0)); eve_cmd_dl(LINE_WIDTH(1)); - } - for (i=line0; iline == i)) { - int l1, l2, l3; - - l1 = c1->ch - LINE_START(widget, i); - if (c2->line == i) { - l2 = c2->ch - c1->ch; - l3 = LINE_START(widget, i) + LINE_LEN(widget, i) - c2->ch; - } else { - l2 = LINE_START(widget, i) + LINE_LEN(widget, i) - c1->ch; - l3 = 0; - s = 1; - } - _draw_line(widget, i, LINE_START(widget, i), l1, 0, c1->x, 0); - _draw_line(widget, i, c1->ch, l2, c1->x, s ? _widget->g.w : c2->x, 1); - if (!s) { - _draw_line(widget, i, c2->ch, l3, c2->x, _widget->g.w, 0); + + for (i=line0; iline == i)) { + int l1, l2, l3; + + l1 = c1->ch - LINE_START(widget, i); + if (c2->line == i) { + l2 = c2->ch - c1->ch; + l3 = LINE_START(widget, i) + LINE_LEN(widget, i) - c2->ch; + } else { + l2 = LINE_START(widget, i) + LINE_LEN(widget, i) - c1->ch; + l3 = 0; + s = 1; + } + _draw_line(widget, i, LINE_START(widget, i), l1, 0, c1->x, 0); + _draw_line(widget, i, c1->ch, l2, c1->x, s ? _widget->g.w : c2->x, 1); + if (!s) { + _draw_line(widget, i, c2->ch, l3, c2->x, _widget->g.w, 0); + c1 = NULL; + c2 = NULL; + } + } else if (s && (c2->line == i)) { + int l1 = c2->ch - LINE_START(widget, i); + int l2 = LINE_START(widget, i) + LINE_LEN(widget, i) - c2->ch; + + _draw_line(widget, i, LINE_START(widget, i), l1, 0, c2->x, 1); + _draw_line(widget, i, c2->ch, l2, c2->x, _widget->g.w, 0); c1 = NULL; c2 = NULL; + s = 0; + } else { + _draw_line(widget, i, LINE_START(widget, i), LINE_LEN(widget, i), 0, _widget->g.w, s); } - } else if (s && (c2->line == i)) { - int l1 = c2->ch - LINE_START(widget, i); - int l2 = LINE_START(widget, i) + LINE_LEN(widget, i) - c2->ch; - - _draw_line(widget, i, LINE_START(widget, i), l1, 0, c2->x, 1); - _draw_line(widget, i, c2->ch, l2, c2->x, _widget->g.w, 0); - c1 = NULL; - c2 = NULL; - s = 0; - } else { - _draw_line(widget, i, LINE_START(widget, i), LINE_LEN(widget, i), 0, _widget->g.w, s); + if (widget->tagN != EVE_TAG_NOTAG) widget->tagN++; } - if (widget->tagN && (widget->tagN < 0xfe)) widget->tagN++; - } - if (w) { + if (widget->cursor1.on && (widget->cursor1.line >= line0) && (widget->cursor1.line < lineN)) _draw_cursor(widget, &widget->cursor1); if (widget->cursor2.on && (widget->cursor2.line >= line0) && (widget->cursor2.line < lineN)) _draw_cursor(widget, &widget->cursor2); if (lineNvisible) { _draw_line(widget, lineN, 0, 0, 0, _widget->g.w, 0); - } else if (widget->tagN) { - widget->tagN--; + if (widget->tagN != EVE_TAG_NOTAG) widget->tagN++; } eve_cmd_dl(RESTORE_CONTEXT()); + + return widget->tagN; } else { widget->line0 = 0; - widget->tag0 = 0; - widget->tagN = 0; + widget->tag0 = EVE_TAG_NOTAG; + widget->tagN = EVE_TAG_NOTAG; + + return tag0; } - return widget->tagN; } void eve_textw_putc(void *_w, int c) { @@ -406,8 +410,7 @@ void eve_textw_cursor_set(EVETextWidget *widget, EVETextCursor *cursor, uint8_t uint16_t c_line = LINE_EMPTY; EVEWidget *_widget = (EVEWidget *)widget; - if (widget->tag0 == 0) return; - if ((tag >= widget->tag0 && 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) { -- cgit v1.2.3