diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/quickscreen.c | 18 | ||||
-rw-r--r-- | apps/gui/viewport.c | 9 | ||||
-rw-r--r-- | apps/gui/viewport.h | 4 | ||||
-rw-r--r-- | apps/gui/wps.c | 11 |
4 files changed, 24 insertions, 18 deletions
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 402b1e2585..863bd54be4 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c | |||
@@ -285,15 +285,8 @@ static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button) | |||
285 | talk_qs_option((struct settings_list *)qs->items[item], false); | 285 | talk_qs_option((struct settings_list *)qs->items[item], false); |
286 | return true; | 286 | return true; |
287 | } | 287 | } |
288 | #ifdef HAVE_TOUCHSCREEN | ||
289 | /* figure out which button was pressed... */ | ||
290 | static bool xy_is_within_viewport(int x, int y, const struct viewport *vp) | ||
291 | { | ||
292 | bool is_x = (x > vp->x && x < (vp->x + vp->width)); | ||
293 | bool is_y = (y > vp->y && y < (vp->y + vp->height)); | ||
294 | return (is_x && is_y); | ||
295 | } | ||
296 | 288 | ||
289 | #ifdef HAVE_TOUCHSCREEN | ||
297 | static int quickscreen_touchscreen_button(const struct viewport | 290 | static int quickscreen_touchscreen_button(const struct viewport |
298 | vps[QUICKSCREEN_ITEM_COUNT]) | 291 | vps[QUICKSCREEN_ITEM_COUNT]) |
299 | { | 292 | { |
@@ -301,17 +294,18 @@ static int quickscreen_touchscreen_button(const struct viewport | |||
301 | /* only hitting the text counts, everything else is exit */ | 294 | /* only hitting the text counts, everything else is exit */ |
302 | if (action_get_touchscreen_press(&x, &y) != BUTTON_REL) | 295 | if (action_get_touchscreen_press(&x, &y) != BUTTON_REL) |
303 | return ACTION_NONE; | 296 | return ACTION_NONE; |
304 | else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_TOP])) | 297 | else if (viewport_point_within_vp(&vps[QUICKSCREEN_TOP], x, y)) |
305 | return ACTION_QS_TOP; | 298 | return ACTION_QS_TOP; |
306 | else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_BOTTOM])) | 299 | else if (viewport_point_within_vp(&vps[QUICKSCREEN_BOTTOM], x, y)) |
307 | return ACTION_QS_DOWN; | 300 | return ACTION_QS_DOWN; |
308 | else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_LEFT])) | 301 | else if (viewport_point_within_vp(&vps[QUICKSCREEN_LEFT], x, y)) |
309 | return ACTION_QS_LEFT; | 302 | return ACTION_QS_LEFT; |
310 | else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_RIGHT])) | 303 | else if (viewport_point_within_vp(&vps[QUICKSCREEN_RIGHT], x, y)) |
311 | return ACTION_QS_RIGHT; | 304 | return ACTION_QS_RIGHT; |
312 | return ACTION_STD_CANCEL; | 305 | return ACTION_STD_CANCEL; |
313 | } | 306 | } |
314 | #endif | 307 | #endif |
308 | |||
315 | static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) | 309 | static bool gui_syncquickscreen_run(struct gui_quickscreen * qs, int button_enter) |
316 | { | 310 | { |
317 | int button, i, j; | 311 | int button, i, j; |
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index e05cd78970..63f0b8fc20 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c | |||
@@ -401,4 +401,13 @@ static unsigned viewport_init_ui_vp(void) | |||
401 | return ret; | 401 | return ret; |
402 | } | 402 | } |
403 | 403 | ||
404 | #ifdef HAVE_TOUCHSCREEN | ||
405 | /* check if a point (x and y coordinates) are within a viewport */ | ||
406 | bool viewport_point_within_vp(const struct viewport *vp, int x, int y) | ||
407 | { | ||
408 | bool is_x = (x >= vp->x && x < (vp->x + vp->width)); | ||
409 | bool is_y = (y >= vp->y && y < (vp->y + vp->height)); | ||
410 | return (is_x && is_y); | ||
411 | } | ||
412 | #endif /* HAVE_TOUCHSCREEN */ | ||
404 | #endif /* HAVE_LCD_BITMAP */ | 413 | #endif /* HAVE_LCD_BITMAP */ |
diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h index 2ed138b365..93b5c70fc3 100644 --- a/apps/gui/viewport.h +++ b/apps/gui/viewport.h | |||
@@ -116,6 +116,10 @@ struct viewport* viewport_get_current_vp(void); | |||
116 | */ | 116 | */ |
117 | void viewport_set_current_vp(struct viewport* vp); | 117 | void viewport_set_current_vp(struct viewport* vp); |
118 | 118 | ||
119 | #ifdef HAVE_TOUCHSCREEN | ||
120 | bool viewport_point_within_vp(const struct viewport *vp, int x, int y); | ||
121 | #endif | ||
122 | |||
119 | #else /* HAVE_LCD_CHARCELL */ | 123 | #else /* HAVE_LCD_CHARCELL */ |
120 | #define viewport_set_current_vp(a) | 124 | #define viewport_set_current_vp(a) |
121 | #define viewport_get_current_vp() NULL | 125 | #define viewport_get_current_vp() NULL |
diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 99bc731c7d..f336f77503 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c | |||
@@ -601,13 +601,12 @@ int wps_get_touchaction(struct wps_data *data) | |||
601 | regions = regions->next; | 601 | regions = regions->next; |
602 | continue; | 602 | continue; |
603 | } | 603 | } |
604 | /* reposition the touch inside the viewport */ | ||
605 | vx = x - r->wvp->vp.x; | ||
606 | vy = y - r->wvp->vp.y; | ||
607 | /* check if it's inside this viewport */ | 604 | /* check if it's inside this viewport */ |
608 | if (vx >= 0 && vx < r->wvp->vp.x + r->wvp->vp.width && | 605 | if (viewport_point_within_vp(&(r->wvp->vp), x, y)) |
609 | vy >= 0 && vy < r->wvp->vp.y + r->wvp->vp.height) | 606 | { /* reposition the touch inside the viewport since touchregions |
610 | { | 607 | * are relative to a preceding viewport */ |
608 | vx = x - r->wvp->vp.x; | ||
609 | vy = y - r->wvp->vp.y; | ||
611 | /* now see if the point is inside this region */ | 610 | /* now see if the point is inside this region */ |
612 | if (vx >= r->x && vx < r->x+r->width && | 611 | if (vx >= r->x && vx < r->x+r->width && |
613 | vy >= r->y && vy < r->y+r->height) | 612 | vy >= r->y && vy < r->y+r->height) |