summaryrefslogtreecommitdiff
path: root/fw/fe310/eos
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-03-29 13:31:45 +0200
committerUros Majstorovic <majstor@majstor.org>2021-03-29 13:31:45 +0200
commitf5d49ec238769ca9c1fc58bf21e21f94a24f41ee (patch)
tree37240b5db3860f4612743f526f6966f0abdc3ad3 /fw/fe310/eos
parent3e04ab27bf9126a13ae692a3e5d930e791e87698 (diff)
added page touch ui event. added ui event handler to form create
Diffstat (limited to 'fw/fe310/eos')
-rw-r--r--fw/fe310/eos/eve/screen/form.c13
-rw-r--r--fw/fe310/eos/eve/screen/form.h7
-rw-r--r--fw/fe310/eos/eve/screen/page.c31
-rw-r--r--fw/fe310/eos/eve/screen/uievt.h11
-rw-r--r--fw/fe310/eos/eve/screen/view.c2
-rw-r--r--fw/fe310/eos/eve/screen/view.h2
6 files changed, 35 insertions, 31 deletions
diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c
index 81c1b86..8555158 100644
--- a/fw/fe310/eos/eve/screen/form.c
+++ b/fw/fe310/eos/eve/screen/form.c
@@ -57,7 +57,7 @@ static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) {
}
}
-EVEForm *eve_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor) {
+EVEForm *eve_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec spec[], uint16_t spec_size, eve_form_uievt_t uievt, eve_form_action_t action, eve_form_destructor_t destructor) {
EVEWidget *widgets;
EVEWidget *widget;
EVELabel *label;
@@ -72,8 +72,9 @@ EVEForm *eve_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec s
if (form == NULL) {
return NULL;
}
+ if (uievt == NULL) uievt = eve_form_uievt;
if (destructor == NULL) destructor = eve_form_destroy;
- eve_form_init(form, window, stack, NULL, 0, action, destructor);
+ eve_form_init(form, window, stack, NULL, 0, uievt, action, destructor);
widgets = eve_malloc(w_size);
if (widgets == NULL) {
@@ -113,9 +114,9 @@ EVEForm *eve_form_create(EVEWindow *window, EVEViewStack *stack, EVEWidgetSpec s
return form;
}
-void 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) {
+void eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_form_uievt_t uievt, eve_form_action_t action, eve_form_destructor_t destructor) {
memset(form, 0, sizeof(EVEForm));
- eve_page_init(&form->p, window, stack, NULL, 0, EVE_PAGE_OPT_SCROLL_Y | EVE_PAGE_OPT_SCROLL_BACK | EVE_PAGE_OPT_TRACK_EXT_Y, eve_page_draw, eve_page_touch, eve_form_uievt, (eve_page_destructor_t)destructor);
+ eve_page_init(&form->p, window, stack, NULL, 0, EVE_PAGE_OPT_SCROLL_Y | EVE_PAGE_OPT_SCROLL_BACK | EVE_PAGE_OPT_TRACK_EXT_Y, eve_page_draw, eve_page_touch, (eve_view_uievt_t)uievt, (eve_page_destructor_t)destructor);
form->action = action;
eve_form_update(form, widget, widget_size);
}
@@ -131,9 +132,7 @@ void eve_form_destroy(EVEForm *form) {
eve_free(form);
}
-int eve_form_uievt(EVEView *view, uint16_t evt, void *param) {
- EVEForm *form = (EVEForm *)view;
-
+int eve_form_uievt(EVEForm *form, uint16_t evt, void *param) {
switch (evt) {
case EVE_UIEVT_WIDGET_UPDATE_G:
form_update_g(form, (EVEWidget *)param);
diff --git a/fw/fe310/eos/eve/screen/form.h b/fw/fe310/eos/eve/screen/form.h
index 87da85c..272b6ed 100644
--- a/fw/fe310/eos/eve/screen/form.h
+++ b/fw/fe310/eos/eve/screen/form.h
@@ -6,6 +6,7 @@ struct EVEWidget;
struct EVEWidgetSpec;
struct EVEForm;
+typedef int (*eve_form_uievt_t) (struct EVEForm *, uint16_t, void *);
typedef void (*eve_form_action_t) (struct EVEForm *);
typedef void (*eve_form_destructor_t) (struct EVEForm *);
@@ -14,9 +15,9 @@ typedef struct EVEForm {
eve_form_action_t action;
} EVEForm;
-EVEForm *eve_form_create(EVEWindow *window, EVEViewStack *stack, struct EVEWidgetSpec *spec, uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor);
-void 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);
+EVEForm *eve_form_create(EVEWindow *window, EVEViewStack *stack, struct EVEWidgetSpec *spec, uint16_t spec_size, eve_form_uievt_t uievt, eve_form_action_t action, eve_form_destructor_t destructor);
+void eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, eve_form_uievt_t uievt, eve_form_action_t action, eve_form_destructor_t destructor);
void eve_form_update(EVEForm *form, struct EVEWidget *widget, uint16_t widget_size);
void eve_form_destroy(EVEForm *form);
-int eve_form_uievt(EVEView *view, uint16_t evt, void *param);
+int eve_form_uievt(EVEForm *form, uint16_t evt, void *param);
diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c
index 032d746..61af288 100644
--- a/fw/fe310/eos/eve/screen/page.c
+++ b/fw/fe310/eos/eve/screen/page.c
@@ -25,10 +25,8 @@ void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, EVEWid
}
void eve_page_update(EVEPage *page, EVEWidget *widget, uint16_t widget_size) {
- if (widget) {
- page->widget = widget;
- page->widget_size = widget_size;
- }
+ page->widget = widget;
+ page->widget_size = widget_size;
}
void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor) {
@@ -45,6 +43,8 @@ void eve_page_close(EVEPage *page) {
EVEViewStack *stack = page->stack;
eve_page_destructor_t destructor = page->destructor;
+ if (stack->level <= 1) return;
+
if (page->lho_t0) {
page->lho_t0 = 0;
eve_touch_timer_stop();
@@ -52,11 +52,10 @@ void eve_page_close(EVEPage *page) {
if (eve_window_scroll(window->root, NULL) == window) {
eve_window_scroll_stop(window);
}
- if (stack->level > 1) {
- if (destructor) destructor(page);
- eve_window_kbd_detach(window);
- eve_view_destroy(window, stack);
- }
+
+ if (destructor) destructor(page);
+ eve_window_kbd_detach(window);
+ eve_view_destroy(window, stack);
}
/* Screen to page coordinates */
@@ -168,7 +167,11 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0
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 (_ret) return _ret;
ret = 1;
}
@@ -179,10 +182,10 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0
if (scroll) {
page->track_mode = PAGE_TMODE_SCROLL;
eve_window_scroll_start(window, touch->tracker.tag);
- _ret = eve_view_uievt_tpush(view, EVE_UIEVT_PAGE_SCROLL_START, touch, evt, tag0);
+ _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_SCROLL_START, touch, evt, tag0);
} else {
page->track_mode = PAGE_TMODE_TRACK;
- _ret = eve_view_uievt_tpush(view, EVE_UIEVT_PAGE_TRACK_START, touch, evt, tag0);
+ _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_TRACK_START, touch, evt, tag0);
}
if (_ret) return _ret;
ret = 1;
@@ -221,10 +224,10 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0
if (page->track_mode == PAGE_TMODE_SCROLL) {
page->track_mode = PAGE_TMODE_NONE;
eve_window_scroll_stop(window);
- _ret = eve_view_uievt_tpush(view, EVE_UIEVT_PAGE_SCROLL_STOP, touch, evt, tag0);
+ _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_tpush(view, EVE_UIEVT_PAGE_TRACK_STOP, touch, evt, tag0);
+ _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_TRACK_STOP, touch, evt, tag0);
}
if (_ret) return _ret;
ret = 1;
@@ -263,7 +266,7 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0
eve_touch_timer_stop();
page->track_mode = PAGE_TMODE_NONE;
eve_window_scroll_stop(window);
- _ret = eve_view_uievt_tpush(view, EVE_UIEVT_PAGE_SCROLL_STOP, touch, evt, tag0);
+ _ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_SCROLL_STOP, touch, evt, tag0);
if (_ret) return _ret;
}
ret = 1;
diff --git a/fw/fe310/eos/eve/screen/uievt.h b/fw/fe310/eos/eve/screen/uievt.h
index 0a751ae..98f0d95 100644
--- a/fw/fe310/eos/eve/screen/uievt.h
+++ b/fw/fe310/eos/eve/screen/uievt.h
@@ -1,10 +1,11 @@
#define EVE_UIEVT_WIN_UPDATE_G 1
#define EVE_UIEVT_PAGE_UPDATE_G 2
-#define EVE_UIEVT_PAGE_SCROLL_START 3
-#define EVE_UIEVT_PAGE_SCROLL_STOP 4
-#define EVE_UIEVT_PAGE_TRACK_START 5
-#define EVE_UIEVT_PAGE_TRACK_STOP 6
-#define EVE_UIEVT_WIDGET_UPDATE_G 7
+#define EVE_UIEVT_PAGE_TOUCH 3
+#define EVE_UIEVT_PAGE_SCROLL_START 4
+#define EVE_UIEVT_PAGE_SCROLL_STOP 5
+#define EVE_UIEVT_PAGE_TRACK_START 6
+#define EVE_UIEVT_PAGE_TRACK_STOP 7
+#define EVE_UIEVT_WIDGET_UPDATE_G 8
typedef struct EVEUIEvtTouch {
EVETouch *touch;
diff --git a/fw/fe310/eos/eve/screen/view.c b/fw/fe310/eos/eve/screen/view.c
index 10a3ac1..ac9aef4 100644
--- a/fw/fe310/eos/eve/screen/view.c
+++ b/fw/fe310/eos/eve/screen/view.c
@@ -81,7 +81,7 @@ void eve_view_uievt_push(EVEView *view, uint16_t evt, void *param) {
if (view->uievt) view->uievt(view, evt, param);
}
-int eve_view_uievt_tpush(EVEView *view, uint16_t evt, EVETouch *touch, uint16_t t_evt, uint8_t tag0) {
+int eve_view_uievt_pusht(EVEView *view, uint16_t evt, EVETouch *touch, uint16_t t_evt, uint8_t tag0) {
if (view->uievt) {
EVEUIEvtTouch param;
diff --git a/fw/fe310/eos/eve/screen/view.h b/fw/fe310/eos/eve/screen/view.h
index 4f93627..65999d7 100644
--- a/fw/fe310/eos/eve/screen/view.h
+++ b/fw/fe310/eos/eve/screen/view.h
@@ -39,4 +39,4 @@ void eve_view_create(struct EVEWindow *window, EVEViewStack *stack, eve_view_con
void eve_view_destroy(struct EVEWindow *window, EVEViewStack *stack);
void eve_view_uievt_push(EVEView *view, uint16_t evt, void *param);
-int eve_view_uievt_tpush(EVEView *view, uint16_t evt, EVETouch *touch, uint16_t t_evt, uint8_t tag0);
+int eve_view_uievt_pusht(EVEView *view, uint16_t evt, EVETouch *touch, uint16_t t_evt, uint8_t tag0);