From 76e07a7fd201391b67988681ef3cf6a53d4f22d2 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Wed, 16 Jun 2021 13:57:49 +0100 Subject: 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 --- apps/gui/skin_engine/skin_parser.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'apps/gui/skin_engine/skin_parser.c') diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 7f3f4d62e1..7bcd25d258 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -1148,7 +1148,6 @@ static int parse_progressbar_tag(struct skin_element* element, { struct touchregion *region = skin_buffer_alloc(sizeof(*region)); struct skin_token_list *item; - int wpad, hpad; if (!region) return 0; @@ -1163,24 +1162,24 @@ static int parse_progressbar_tag(struct skin_element* element, /* try to add some extra space on either end to make pressing the * full bar easier. ~5% on either side */ - wpad = pb->width * 5 / 100; - if (wpad > 10) - wpad = 10; - hpad = pb->height * 5 / 100; - if (hpad > 10) - hpad = 10; - - region->x = pb->x - wpad; + region->wpad = pb->width * 5 / 100; + if (region->wpad > 10) + region->wpad = 10; + region->hpad = pb->height * 5 / 100; + if (region->hpad > 10) + region->hpad = 10; + + region->x = pb->x; if (region->x < 0) region->x = 0; - region->width = pb->width + 2 * wpad; + region->width = pb->width; if (region->x + region->width > curr_vp->vp.x + curr_vp->vp.width) region->width = curr_vp->vp.x + curr_vp->vp.width - region->x; - region->y = pb->y - hpad; + region->y = pb->y; if (region->y < 0) region->y = 0; - region->height = pb->height + 2 * hpad; + region->height = pb->height; if (region->y + region->height > curr_vp->vp.y + curr_vp->vp.height) region->height = curr_vp->vp.y + curr_vp->vp.height - region->y; @@ -1541,6 +1540,10 @@ static int parse_touchregion(struct skin_element *element, /* should probably do some bounds checking here with the viewport... but later */ region->action = ACTION_NONE; + /* padding is only for bars, user defined regions have no need of it */ + region->wpad = 0; + region->hpad = 0; + if (get_param(element, 0)->type == STRING) { region->label = PTRTOSKINOFFSET(skin_buffer, get_param_text(element, 0)); -- cgit v1.2.3