From cd7d67b9a801f6446c2546ec89f71a6019432b68 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 28 Mar 2021 16:51:56 +0200 Subject: fixed cursor handling in strw and textw --- fw/fe310/eos/eve/widget/strw.c | 67 ++++++++++++++++++++++------------------- fw/fe310/eos/eve/widget/textw.c | 37 ++++++++++++----------- 2 files changed, 56 insertions(+), 48 deletions(-) (limited to 'fw/fe310') 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) { -- cgit v1.2.3