diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-06-16 13:55:35 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-06-22 21:37:02 +0100 |
commit | 02860d67c3c2807e3c9fd7d272ce9cc098c052ae (patch) | |
tree | 381e1c33279cc09215f585fdad0ac32748f7aca8 /apps/gui/skin_engine | |
parent | 8a6b2f3abc4ec3d6417cb3dc3a6040c977a6036a (diff) | |
download | rockbox-02860d67c3c2807e3c9fd7d272ce9cc098c052ae.tar.gz rockbox-02860d67c3c2807e3c9fd7d272ce9cc098c052ae.zip |
Touchscreen: adjust calculation of bar touch position
Increased the precision of the bar from 100 steps to 1000 steps so
it is possible to make finer adjustments, and made it possible to
pick the maximum value in a bar rather than just the maximum - 1.
Change-Id: I2e694d3e86e4a151e014da1bd15ab3ade4c4b95e
Diffstat (limited to 'apps/gui/skin_engine')
-rw-r--r-- | apps/gui/skin_engine/skin_touchsupport.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/apps/gui/skin_engine/skin_touchsupport.c b/apps/gui/skin_engine/skin_touchsupport.c index 7a03e83c36..b92fd1e83e 100644 --- a/apps/gui/skin_engine/skin_touchsupport.c +++ b/apps/gui/skin_engine/skin_touchsupport.c | |||
@@ -109,12 +109,21 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, | |||
109 | { | 109 | { |
110 | struct progressbar *bar = | 110 | struct progressbar *bar = |
111 | SKINOFFSETTOPTR(skin_buffer, r->bar); | 111 | SKINOFFSETTOPTR(skin_buffer, r->bar); |
112 | if(r->width > r->height) | 112 | if(r->width > r->height) { |
113 | *edge_offset = vx*100/r->width; | 113 | if(r->width > 1) |
114 | else /* vertical bars are bottom-up by default */ | 114 | *edge_offset = vx*1000/(r->width - 1); |
115 | *edge_offset = 100 - vy*100/r->height; | 115 | else |
116 | *edge_offset = 0; | ||
117 | } else { | ||
118 | /* vertical bars are bottom-up by default */ | ||
119 | if(r->height > 1) | ||
120 | *edge_offset = 1000 - vy*1000/(r->height - 1); | ||
121 | else | ||
122 | *edge_offset = 0; | ||
123 | } | ||
124 | |||
116 | if (r->reverse_bar || (bar && bar->invert_fill_direction)) | 125 | if (r->reverse_bar || (bar && bar->invert_fill_direction)) |
117 | *edge_offset = 100 - *edge_offset; | 126 | *edge_offset = 1000 - *edge_offset; |
118 | } | 127 | } |
119 | temp = r; | 128 | temp = r; |
120 | returncode = r->action; | 129 | returncode = r->action; |
@@ -294,7 +303,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, | |||
294 | { | 303 | { |
295 | int val, count; | 304 | int val, count; |
296 | get_setting_info_for_bar(bar->setting_id, &count, &val); | 305 | get_setting_info_for_bar(bar->setting_id, &count, &val); |
297 | val = *edge_offset * count / 100; | 306 | val = *edge_offset * count / 1000; |
298 | update_setting_value_from_touch(bar->setting_id, val); | 307 | update_setting_value_from_touch(bar->setting_id, val); |
299 | } | 308 | } |
300 | } | 309 | } |