diff options
Diffstat (limited to 'fw/fe310/eos/eve/screen/page.c')
-rw-r--r-- | fw/fe310/eos/eve/screen/page.c | 155 |
1 files changed, 83 insertions, 72 deletions
diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c index 65dd534..64fc473 100644 --- a/fw/fe310/eos/eve/screen/page.c +++ b/fw/fe310/eos/eve/screen/page.c @@ -8,7 +8,6 @@ #include "window.h" #include "page.h" -#include "widget/label.h" #include "widget/widget.h" #define PAGE_TMODE_NONE 0 @@ -21,10 +20,22 @@ void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, EVEWid page->stack = stack; page->opt = opt; page->destructor = destructor; - eve_page_update(page, widget, widget_size); + eve_page_set_widget(page, widget, widget_size); } -void eve_page_update(EVEPage *page, EVEWidget *widget, uint16_t widget_size) { +EVEWidget *eve_page_widget(EVEPage *page, uint16_t idx) { + EVEWidget *w = page->widget; + int i; + + if (idx >= page->widget_size) return NULL; + + for (i=0; i<idx; i++) { + w = eve_widget_next(w); + } + return w; +} + +void eve_page_set_widget(EVEPage *page, EVEWidget *widget, uint16_t widget_size) { page->widget = widget; page->widget_size = widget_size; } @@ -45,16 +56,16 @@ void eve_page_close(EVEPage *page) { if (stack->level <= 1) return; - if (page->lho_t0) { - page->lho_t0 = 0; - eve_touch_timer_stop(); + if (eve_timer_running()) { + eve_timer_stop(); } if (eve_window_scroll(window->root, NULL) == window) { eve_window_scroll_stop(window); } - if (destructor) destructor(page); eve_window_kbd_detach(window); + + if (destructor) destructor(page); eve_view_destroy(window, stack); } @@ -93,30 +104,32 @@ int eve_page_rect_visible(EVEPage *page, EVERect *g) { return 0; } -void eve_page_focus(EVEPage *page, EVERect *rect) { - if (rect) { - EVERect g; +void eve_page_rect_set_visible(EVEPage *page, EVERect *rect) { + EVERect g; - eve_window_visible_g(page->v.window, &g); - g.x -= page->v.window->g.x; - g.y -= page->v.window->g.y; + eve_window_visible_g(page->v.window, &g); + g.x -= page->v.window->g.x; + g.y -= page->v.window->g.y; - if (rect->x < page->g.x + g.x) { - page->g.x = rect->x - g.x; - } - if (rect->y < page->g.y + g.y) { - page->g.y = rect->y - g.y; - } - if ((rect->x + rect->w) > (page->g.x + g.x + g.w)) { - page->g.x = (rect->x + rect->w) - (g.x + g.w); - } - if ((rect->y + rect->h) > (page->g.y + g.y + g.h)) { - page->g.y = (rect->y + rect->h) - (g.y + g.h); - } + if (rect->x < page->g.x + g.x) { + page->g.x = rect->x - g.x; } + if (rect->y < page->g.y + g.y) { + page->g.y = rect->y - g.y; + } + if ((rect->x + rect->w) > (page->g.x + g.x + g.w)) { + page->g.x = (rect->x + rect->w) - (g.x + g.w); + } + if ((rect->y + rect->h) > (page->g.y + g.y + g.h)) { + page->g.y = (rect->y + rect->h) - (g.y + g.h); + } +} + +EVEWidget *eve_page_focus(EVEPage *page) { + return page->widget_f; } -void eve_page_focus_widget(EVEPage *page, EVEWidget *widget, EVERect *rect) { +void eve_page_set_focus(EVEPage *page, EVEWidget *widget, EVERect *rect) { if (page->widget_f != widget) { EVEWindow *window = page->v.window; EVEWidget *widget_f = page->widget_f; @@ -131,67 +144,59 @@ void eve_page_focus_widget(EVEPage *page, EVEWidget *widget, EVERect *rect) { if (kbd) eve_kbd_set_handler(kbd, widget->putc, widget); if (!(widget_f && widget_f->putc)) eve_window_kbd_attach(window); } + if (page->widget_f) eve_view_uievt_push(&page->v, EVE_UIEVT_WIDGET_FOCUS_OUT, page->widget_f); page->widget_f = widget; + if (page->widget_f) eve_view_uievt_push(&page->v, EVE_UIEVT_WIDGET_FOCUS_IN, page->widget_f); } - if (rect) eve_page_focus(page, rect); + if (rect) eve_page_rect_set_visible(page, rect); } -EVEWidget *eve_page_focus_widget_get(EVEPage *page) { - return page->widget_f; -} - -EVEWidget *eve_page_widget(EVEPage *page, uint16_t idx) { - EVEWidget *w = page->widget; - int i; - - if (idx >= page->widget_size) return NULL; - - for (i=0; i<idx; i++) { - w = eve_widget_next(w); - } - return w; -} +#include <stdio.h> static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0) { EVEView *view = &page->v; EVEWindow *window = view->window; - int scroll, scroll_x, scroll_y; + int scroll_x = 0, scroll_y = 0, scroll; int ret = 0; - scroll_x = page->opt & (EVE_PAGE_OPT_SCROLL_X | EVE_PAGE_OPT_SCROLL_XY); - if (scroll_x && touch) scroll_x = touch->eevt & ((page->opt & EVE_PAGE_OPT_SCROLL_XY) ? EVE_TOUCH_EETYPE_TRACK_XY : EVE_TOUCH_EETYPE_TRACK_X); - - scroll_y = page->opt & (EVE_PAGE_OPT_SCROLL_Y | EVE_PAGE_OPT_SCROLL_XY); - if (scroll_y && touch) scroll_y = touch->eevt & ((page->opt & EVE_PAGE_OPT_SCROLL_XY) ? EVE_TOUCH_EETYPE_TRACK_XY : EVE_TOUCH_EETYPE_TRACK_Y); + if (touch) { + if ((page->opt & EVE_PAGE_OPT_SCROLL_XY) == EVE_PAGE_OPT_SCROLL_XY) { + scroll_x = scroll_y = (touch->eevt & EVE_TOUCH_EETYPE_TRACK_XY); + } else if (page->opt & EVE_PAGE_OPT_SCROLL_X) { + scroll_x = (touch->eevt & EVE_TOUCH_EETYPE_TRACK_X); + } else if (page->opt & EVE_PAGE_OPT_SCROLL_Y) { + scroll_y = (touch->eevt & EVE_TOUCH_EETYPE_TRACK_Y); + } + } scroll = scroll_x || scroll_y; if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(touch->eevt & (EVE_TOUCH_EETYPE_TRACK_XY | EVE_TOUCH_EETYPE_ABORT))) { int _ret = 0; - if (page->widget_f) eve_page_focus_widget(page, NULL, NULL); - _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_TOUCH, touch, evt, tag0); + if (page->widget_f) eve_page_set_focus(page, NULL, NULL); + _ret = eve_view_uievt_push_gest(view, EVE_UIEVT_GEST_TOUCH, touch, evt, tag0); if (_ret) return _ret; ret = 1; } - /* Scroll start */ + /* Scroll / track start */ if ((evt & EVE_TOUCH_ETYPE_TRACK_START) && !(touch->eevt & EVE_TOUCH_EETYPE_ABORT)) { int _ret = 0; if (scroll) { page->track_mode = PAGE_TMODE_SCROLL; eve_window_scroll_start(window, touch->tracker.tag); - _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_SCROLL_START, touch, evt, tag0); + _ret = eve_view_uievt_push_gest(view, EVE_UIEVT_GEST_SCROLL_START, touch, evt, tag0); } else { page->track_mode = PAGE_TMODE_TRACK; - _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_TRACK_START, touch, evt, tag0); + _ret = eve_view_uievt_push_gest(view, EVE_UIEVT_GEST_TRACK_START, touch, evt, tag0); } if (_ret) return _ret; ret = 1; } - /* Scroll stop */ + /* Scroll / track stop */ if (((evt & EVE_TOUCH_ETYPE_TRACK_STOP) && !(evt & EVE_TOUCH_ETYPE_TRACK_ABORT)) || ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (touch->eevt & EVE_TOUCH_EETYPE_ABORT) && !(touch->eevt & EVE_TOUCH_EETYPE_TRACK_XY))) { if ((page->track_mode == PAGE_TMODE_SCROLL) && (page->opt & EVE_PAGE_OPT_SCROLL_BACK)) { @@ -211,23 +216,29 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0 eve_window_scroll(window->root, &_tag); - eve_phy_lho_init(lho, lho_x, lho_y, 1000, 0.5, 0); + page->lho_t0 = eve_get_tick(); + eve_phy_lho_init(lho, lho_x, lho_y, 100, 0.5, 0); eve_phy_lho_start(lho, page->g.x, page->g.y); - page->lho_t0 = eve_time_get_tick(); - eve_touch_timer_start(_tag, 20); + eve_timer_start(_tag, 20); } } - if (!page->lho_t0) { + if (!eve_timer_running()) { int _ret = 0; - if (page->track_mode == PAGE_TMODE_SCROLL) { - page->track_mode = PAGE_TMODE_NONE; - eve_window_scroll_stop(window); - _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_SCROLL_STOP, touch, evt, tag0); - } else if (!(touch->eevt & EVE_TOUCH_EETYPE_ABORT)) { - page->track_mode = PAGE_TMODE_NONE; - _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_TRACK_STOP, touch, evt, tag0); + switch (page->track_mode) { + case PAGE_TMODE_SCROLL: { + page->track_mode = PAGE_TMODE_NONE; + eve_window_scroll_stop(window); + _ret = eve_view_uievt_push_gest(view, EVE_UIEVT_GEST_SCROLL_STOP, touch, evt, tag0); + break; + } + + case PAGE_TMODE_TRACK: { + page->track_mode = PAGE_TMODE_NONE; + _ret = eve_view_uievt_push_gest(view, EVE_UIEVT_GEST_TRACK_STOP, touch, evt, tag0); + break; + } } if (_ret) return _ret; ret = 1; @@ -254,26 +265,26 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0 } if ((evt & EVE_TOUCH_ETYPE_TIMER) && (page->opt & EVE_PAGE_OPT_SCROLL_BACK)) { EVEPhyLHO *lho = &page->lho; + int scroll_x = page->opt & EVE_PAGE_OPT_SCROLL_X; + int scroll_y = page->opt & EVE_PAGE_OPT_SCROLL_Y; int x, y, more; - more = eve_phy_lho_tick(lho, eve_time_get_tick() - page->lho_t0, scroll_x ? &x : NULL, scroll_y ? &y : NULL); + more = eve_phy_lho_tick(lho, eve_get_tick() - page->lho_t0, scroll_x ? &x : NULL, scroll_y ? &y : NULL); if (scroll_x) page->g.x = x; if (scroll_y) page->g.y = y; + printf("TIMER: %d\n", y); if (!more) { int _ret = 0; - page->lho_t0 = 0; - eve_touch_timer_stop(); + printf("TIMER STOP!\n"); page->track_mode = PAGE_TMODE_NONE; + eve_timer_stop(); eve_window_scroll_stop(window); - _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_SCROLL_STOP, touch, evt, tag0); + _ret = eve_view_uievt_push_gest(view, EVE_UIEVT_GEST_SCROLL_STOP, touch, evt, tag0); if (_ret) return _ret; } ret = 1; } - if (evt & EVE_TOUCH_EETYPE_TIMER_ABORT) { - page->lho_t0 = 0; - } } return ret; |