summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_touchsupport.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-06-16 13:57:49 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-06-22 21:37:02 +0100
commit76e07a7fd201391b67988681ef3cf6a53d4f22d2 (patch)
tree5ee68637f7192461f65191617b6413a2c310d52e /apps/gui/skin_engine/skin_touchsupport.c
parent02860d67c3c2807e3c9fd7d272ce9cc098c052ae (diff)
downloadrockbox-76e07a7fd201391b67988681ef3cf6a53d4f22d2.tar.gz
rockbox-76e07a7fd201391b67988681ef3cf6a53d4f22d2.zip
Touchscreen: adjust how bar padding is handled
The old way of padding out bars was to just create a bigger touch region, the intent being to make it easier to touch the end of a bar. Unfortunately, this didn't even accomplish that, and caused an annoying offset between the bar graphics and the touch point. New method is to account for padding explicitly and clamp touches in the padding region so they are within the proper touch region. Change-Id: Id39e571fc1b033a4da94f0eb1143a2fc276bab03
Diffstat (limited to 'apps/gui/skin_engine/skin_touchsupport.c')
-rw-r--r--apps/gui/skin_engine/skin_touchsupport.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c
index b92fd1e83e..045bc809c8 100644
--- a/apps/gui/skin_engine/skin_touchsupport.c
+++ b/apps/gui/skin_engine/skin_touchsupport.c
@@ -92,6 +92,18 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset,
92 * are relative to a preceding viewport */ 92 * are relative to a preceding viewport */
93 vx = x - wvp->vp.x; 93 vx = x - wvp->vp.x;
94 vy = y - wvp->vp.y; 94 vy = y - wvp->vp.y;
95
96 /* project touches in the padding region so they clamp to the
97 * edge of the region instead */
98 if(r->x - r->wpad <= vx && vx < r->x)
99 vx = r->x;
100 else if(r->x + r->width <= vx && vx < r->x + r->width + r->wpad)
101 vx = r->x + r->width - 1;
102 if(r->y - r->hpad <= vy && vy < r->y)
103 vy = r->y;
104 else if(r->y + r->height <= vy && vy < r->y + r->height + r->hpad)
105 vy = r->y + r->height - 1;
106
95 /* now see if the point is inside this region */ 107 /* now see if the point is inside this region */
96 if (vx >= r->x && vx < r->x+r->width && 108 if (vx >= r->x && vx < r->x+r->width &&
97 vy >= r->y && vy < r->y+r->height) 109 vy >= r->y && vy < r->y+r->height)