summaryrefslogtreecommitdiff
path: root/fw
diff options
context:
space:
mode:
Diffstat (limited to 'fw')
-rw-r--r--fw/fe310/eos/eve/screen/form.c130
-rw-r--r--fw/fe310/eos/eve/screen/form.h3
2 files changed, 74 insertions, 59 deletions
diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c
index cf5653b..4aef803 100644
--- a/fw/fe310/eos/eve/screen/form.c
+++ b/fw/fe310/eos/eve/screen/form.c
@@ -18,6 +18,69 @@
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
+static void form_update_g(EVEForm *form, EVEWidget *_widget) {
+ EVEWidget *widget = form->widget;
+ int i;
+ uint16_t w = 0;
+ uint16_t h = 0;
+ uint16_t _h = 0;
+
+ for (i=0; i<form->widget_size; i++) {
+ if (widget->label) {
+ h += _h;
+ w = widget->label->g.w;
+ _h = widget->label->g.h;
+ widget->label->g.x = 0;
+ widget->label->g.y = h;
+ }
+ if (w + widget->g.w > form->p.v.window->g.w) {
+ h += _h;
+ w = 0;
+ _h = 0;
+ }
+ widget->g.x = w;
+ widget->g.y = h;
+
+ w += widget->g.w;
+ _h = MAX(_h, widget->g.h);
+
+ widget = eve_widget_next(widget);
+ }
+}
+
+static int form_handle_evt(EVEForm *form, EVEWidget *widget, EVETouch *touch, uint16_t evt) {
+ if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
+ form->win_x0 = form->p.win_x;
+ form->win_y0 = form->p.win_y;
+ form->evt_lock = 1;
+ }
+ if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
+ form->win_x0 = 0;
+ form->win_y0 = 0;
+ form->evt_lock = 0;
+ }
+ if (evt & EVE_TOUCH_ETYPE_POINT_UP) {
+ if ((touch->eevt & EVE_TOUCH_EETYPE_TRACK_XY) == 0) {
+ if (form->p.widget_f) eve_page_set_focus(&form->p, NULL, NULL);
+ return 1;
+ }
+ if (touch->eevt & EVE_TOUCH_EETYPE_TRACK_RIGHT) {
+ eve_page_close((EVEPage *)form);
+ return 1;
+ }
+ if (touch->eevt & EVE_TOUCH_EETYPE_TRACK_LEFT) {
+ form->action(form);
+ return 1;
+ }
+ }
+ if ((evt & EVE_TOUCH_ETYPE_TRACK) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_Y)) {
+ form->p.win_y = form->win_y0 + touch->y0 - touch->y;
+ return 1;
+ }
+
+ return 0;
+}
+
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_page_destructor_t)destructor);
@@ -25,7 +88,7 @@ int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidg
form->widget = widget;
form->widget_size = widget_size;
form->action = action;
- eve_form_update_g(form, NULL);
+ form_update_g(form, NULL);
}
int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx) {
@@ -39,17 +102,18 @@ int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx) {
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);
+ ret = form_handle_evt(form, NULL, t, evt);
if (ret) return 1;
}
for (i=0; i<form->widget_size; i++) {
if (eve_page_rect_visible(&form->p, &widget->g)) {
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 (!form->evt_lock) {
+ ret = widget->touch(widget, &form->p, t, evt);
+ if (ret) return 1;
+ }
+ ret = form_handle_evt(form, widget, t, evt);
if (ret) return 1;
}
}
@@ -80,7 +144,7 @@ uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
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);
+ if (h != widget->g.h) form_update_g(form, widget);
}
widget = eve_widget_next(widget);
}
@@ -95,58 +159,6 @@ uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
return tagN;
}
-void eve_form_update_g(EVEForm *form, EVEWidget *_widget) {
- EVEWidget *widget = form->widget;
- int i;
- uint16_t w = 0;
- uint16_t h = 0;
- uint16_t _h = 0;
-
- for (i=0; i<form->widget_size; i++) {
- if (widget->label) {
- h += _h;
- w = widget->label->g.w;
- _h = widget->label->g.h;
- widget->label->g.x = 0;
- widget->label->g.y = h;
- }
- if (w + widget->g.w > form->p.v.window->g.w) {
- h += _h;
- w = 0;
- _h = 0;
- }
- widget->g.x = w;
- widget->g.y = h;
-
- w += widget->g.w;
- _h = MAX(_h, widget->g.h);
-
- widget = eve_widget_next(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;
diff --git a/fw/fe310/eos/eve/screen/form.h b/fw/fe310/eos/eve/screen/form.h
index 426a655..68dfdca 100644
--- a/fw/fe310/eos/eve/screen/form.h
+++ b/fw/fe310/eos/eve/screen/form.h
@@ -11,6 +11,9 @@ typedef struct EVEForm {
struct EVEWidget *widget;
uint16_t widget_size;
eve_form_action_t action;
+ int16_t win_x0;
+ int16_t win_y0;
+ uint8_t evt_lock;
} EVEForm;
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);