summaryrefslogtreecommitdiff
path: root/fw
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-03-28 16:51:56 +0200
committerUros Majstorovic <majstor@majstor.org>2021-03-28 16:51:56 +0200
commitcd7d67b9a801f6446c2546ec89f71a6019432b68 (patch)
tree44f849f68584060cbdea9ac3d103ab814c6c1929 /fw
parentdaa87d92b3df433578e53284a8c88083e24f8623 (diff)
fixed cursor handling in strw and textw
Diffstat (limited to 'fw')
-rw-r--r--fw/fe310/eos/eve/widget/strw.c67
-rw-r--r--fw/fe310/eos/eve/widget/textw.c37
2 files changed, 56 insertions, 48 deletions
diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c
index 4e1e2c0..b169adb 100644
--- a/fw/fe310/eos/eve/widget/strw.c
+++ b/fw/fe310/eos/eve/widget/strw.c
@@ -227,44 +227,49 @@ int eve_strw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
}
}
- if ((evt & EVE_TOUCH_ETYPE_TRACK) && widget->track.mode) {
+ if (widget->track.mode) {
int x, w1;
- switch (widget->track.mode) {
- case STRW_TMODE_TXT:
- if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
- widget->str_g.x0 = widget->str_g.x;
- }
- x = widget->str_g.x0 + touch->x0 - touch->x;
- w1 = _widget->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_CRSR:
- eve_strw_cursor_set(widget, widget->track.cursor, eve_page_x(page, touch->x) + widget->track.dx);
- break;
+ if (evt & EVE_TOUCH_ETYPE_TRACK) {
+ switch (widget->track.mode) {
+ case STRW_TMODE_TXT:
+ if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
+ widget->str_g.x0 = widget->str_g.x;
+ }
+ x = widget->str_g.x0 + touch->x0 - touch->x;
+ w1 = _widget->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_CRSR:
+ eve_strw_cursor_set(widget, widget->track.cursor, eve_page_x(page, touch->x) + widget->track.dx);
+ break;
+ }
}
ret = 1;
- } else if (evt & EVE_TOUCH_ETYPE_LPRESS) {
- if (widget->cursor2.on) {
- // copy
- } else if (widget->cursor1.on) {
- if (t_cursor) {
- // paste
+ } 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, touch->x));
+ }
} else {
- eve_strw_cursor_set(widget, &widget->cursor2, eve_page_x(page, touch->x));
+ // select
}
- } else {
- // select
+ ret = 1;
+ }
+ if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(touch->eevt & (EVE_TOUCH_EETYPE_TRACK_XY | EVE_TOUCH_EETYPE_ABORT | EVE_TOUCH_EETYPE_LPRESS))) {
+ eve_strw_cursor_set(widget, &widget->cursor1, eve_page_x(page, touch->x0));
+ if (widget->cursor2.on) eve_strw_cursor_clear(widget, &widget->cursor2);
+ set_focus(widget);
+ ret = 1;
}
- ret = 1;
- } else if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(touch->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
- eve_strw_cursor_set(widget, &widget->cursor1, eve_page_x(page, touch->x0));
- if (widget->cursor2.on) eve_strw_cursor_clear(widget, &widget->cursor2);
- set_focus(widget);
- ret = 1;
}
if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c
index e17351c..abf2a68 100644
--- a/fw/fe310/eos/eve/widget/textw.c
+++ b/fw/fe310/eos/eve/widget/textw.c
@@ -257,27 +257,30 @@ int eve_textw_touch(EVEWidget *_widget, EVETouch *touch, uint16_t evt) {
}
}
- if ((evt & EVE_TOUCH_ETYPE_TRACK) && widget->track.cursor) {
- eve_textw_cursor_set(widget, widget->track.cursor, touch->tag + widget->track.dl, eve_page_x(page, touch->x) + widget->track.dx);
+ if (widget->track.cursor) {
+ if (evt & EVE_TOUCH_ETYPE_TRACK) eve_textw_cursor_set(widget, widget->track.cursor, touch->tag + widget->track.dl, eve_page_x(page, touch->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 {
+ 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, touch->tag, eve_page_x(page, touch->x));
+ }
} else {
- eve_textw_cursor_set(widget, &widget->cursor2, touch->tag, eve_page_x(page, touch->x));
+ // select
}
- } else {
- // select
+ ret = 1;
+ }
+ if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(touch->eevt & (EVE_TOUCH_EETYPE_TRACK_XY | EVE_TOUCH_EETYPE_ABORT | EVE_TOUCH_EETYPE_LPRESS))) {
+ eve_textw_cursor_set(widget, &widget->cursor1, touch->tag_up, eve_page_x(page, touch->x0));
+ if (widget->cursor2.on) eve_textw_cursor_clear(widget, &widget->cursor2);
+ set_focus(widget, &widget->cursor1);
+ ret = 1;
}
- ret = 1;
- } else if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(touch->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
- eve_textw_cursor_set(widget, &widget->cursor1, touch->tag_up, eve_page_x(page, touch->x0));
- if (widget->cursor2.on) eve_textw_cursor_clear(widget, &widget->cursor2);
- set_focus(widget, &widget->cursor1);
- ret = 1;
}
if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {