diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-06-16 13:57:49 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-06-22 21:37:02 +0100 |
commit | 76e07a7fd201391b67988681ef3cf6a53d4f22d2 (patch) | |
tree | 5ee68637f7192461f65191617b6413a2c310d52e /apps/gui/skin_engine/skin_parser.c | |
parent | 02860d67c3c2807e3c9fd7d272ce9cc098c052ae (diff) | |
download | rockbox-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_parser.c')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 27 |
1 files changed, 15 insertions, 12 deletions
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, | |||
1148 | { | 1148 | { |
1149 | struct touchregion *region = skin_buffer_alloc(sizeof(*region)); | 1149 | struct touchregion *region = skin_buffer_alloc(sizeof(*region)); |
1150 | struct skin_token_list *item; | 1150 | struct skin_token_list *item; |
1151 | int wpad, hpad; | ||
1152 | 1151 | ||
1153 | if (!region) | 1152 | if (!region) |
1154 | return 0; | 1153 | return 0; |
@@ -1163,24 +1162,24 @@ static int parse_progressbar_tag(struct skin_element* element, | |||
1163 | /* try to add some extra space on either end to make pressing the | 1162 | /* try to add some extra space on either end to make pressing the |
1164 | * full bar easier. ~5% on either side | 1163 | * full bar easier. ~5% on either side |
1165 | */ | 1164 | */ |
1166 | wpad = pb->width * 5 / 100; | 1165 | region->wpad = pb->width * 5 / 100; |
1167 | if (wpad > 10) | 1166 | if (region->wpad > 10) |
1168 | wpad = 10; | 1167 | region->wpad = 10; |
1169 | hpad = pb->height * 5 / 100; | 1168 | region->hpad = pb->height * 5 / 100; |
1170 | if (hpad > 10) | 1169 | if (region->hpad > 10) |
1171 | hpad = 10; | 1170 | region->hpad = 10; |
1172 | 1171 | ||
1173 | region->x = pb->x - wpad; | 1172 | region->x = pb->x; |
1174 | if (region->x < 0) | 1173 | if (region->x < 0) |
1175 | region->x = 0; | 1174 | region->x = 0; |
1176 | region->width = pb->width + 2 * wpad; | 1175 | region->width = pb->width; |
1177 | if (region->x + region->width > curr_vp->vp.x + curr_vp->vp.width) | 1176 | if (region->x + region->width > curr_vp->vp.x + curr_vp->vp.width) |
1178 | region->width = curr_vp->vp.x + curr_vp->vp.width - region->x; | 1177 | region->width = curr_vp->vp.x + curr_vp->vp.width - region->x; |
1179 | 1178 | ||
1180 | region->y = pb->y - hpad; | 1179 | region->y = pb->y; |
1181 | if (region->y < 0) | 1180 | if (region->y < 0) |
1182 | region->y = 0; | 1181 | region->y = 0; |
1183 | region->height = pb->height + 2 * hpad; | 1182 | region->height = pb->height; |
1184 | if (region->y + region->height > curr_vp->vp.y + curr_vp->vp.height) | 1183 | if (region->y + region->height > curr_vp->vp.y + curr_vp->vp.height) |
1185 | region->height = curr_vp->vp.y + curr_vp->vp.height - region->y; | 1184 | region->height = curr_vp->vp.y + curr_vp->vp.height - region->y; |
1186 | 1185 | ||
@@ -1541,6 +1540,10 @@ static int parse_touchregion(struct skin_element *element, | |||
1541 | /* should probably do some bounds checking here with the viewport... but later */ | 1540 | /* should probably do some bounds checking here with the viewport... but later */ |
1542 | region->action = ACTION_NONE; | 1541 | region->action = ACTION_NONE; |
1543 | 1542 | ||
1543 | /* padding is only for bars, user defined regions have no need of it */ | ||
1544 | region->wpad = 0; | ||
1545 | region->hpad = 0; | ||
1546 | |||
1544 | if (get_param(element, 0)->type == STRING) | 1547 | if (get_param(element, 0)->type == STRING) |
1545 | { | 1548 | { |
1546 | region->label = PTRTOSKINOFFSET(skin_buffer, get_param_text(element, 0)); | 1549 | region->label = PTRTOSKINOFFSET(skin_buffer, get_param_text(element, 0)); |