summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-09-05 23:32:16 +0000
committerThomas Martitz <kugel@rockbox.org>2009-09-05 23:32:16 +0000
commita17d06ccc3b589cfc5eb92edbea3c09494b1ed48 (patch)
treec21e62003915ab6ce65c9e9df0595fe59baac150
parent9c938a23b93902c3d38204df68677d7455a313c3 (diff)
downloadrockbox-a17d06ccc3b589cfc5eb92edbea3c09494b1ed48.tar.gz
rockbox-a17d06ccc3b589cfc5eb92edbea3c09494b1ed48.zip
Improve and simplify touchscreen handling of the quickscreen in absolut mode - and implement handling for the top item.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22637 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/quickscreen.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c
index 639233b3b1..402b1e2585 100644
--- a/apps/gui/quickscreen.c
+++ b/apps/gui/quickscreen.c
@@ -286,24 +286,28 @@ static bool gui_quickscreen_do_button(struct gui_quickscreen * qs, int button)
return true;
}
#ifdef HAVE_TOUCHSCREEN
-/* figure out which button was pressed...
- * top is exit, left/right/botton are the respective actions
- */
+/* figure out which button was pressed... */
+static bool xy_is_within_viewport(int x, int y, const struct viewport *vp)
+{
+ bool is_x = (x > vp->x && x < (vp->x + vp->width));
+ bool is_y = (y > vp->y && y < (vp->y + vp->height));
+ return (is_x && is_y);
+}
+
static int quickscreen_touchscreen_button(const struct viewport
vps[QUICKSCREEN_ITEM_COUNT])
{
short x,y;
+ /* only hitting the text counts, everything else is exit */
if (action_get_touchscreen_press(&x, &y) != BUTTON_REL)
return ACTION_NONE;
- if (y < vps[QUICKSCREEN_LEFT].y)
- return ACTION_STD_CANCEL;
- else if (y > vps[QUICKSCREEN_LEFT].y +
- vps[QUICKSCREEN_LEFT].height)
+ else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_TOP]))
+ return ACTION_QS_TOP;
+ else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_BOTTOM]))
return ACTION_QS_DOWN;
- else if (x < vps[QUICKSCREEN_LEFT].x +
- vps[QUICKSCREEN_LEFT].width)
+ else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_LEFT]))
return ACTION_QS_LEFT;
- else if (x >= vps[QUICKSCREEN_RIGHT].x)
+ else if (xy_is_within_viewport(x,y,&vps[QUICKSCREEN_RIGHT]))
return ACTION_QS_RIGHT;
return ACTION_STD_CANCEL;
}