From 02860d67c3c2807e3c9fd7d272ce9cc098c052ae Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Wed, 16 Jun 2021 13:55:35 +0100 Subject: 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 --- apps/gui/skin_engine/skin_touchsupport.c | 21 +++++++++++++++------ apps/gui/wps.c | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'apps') 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, { struct progressbar *bar = SKINOFFSETTOPTR(skin_buffer, r->bar); - if(r->width > r->height) - *edge_offset = vx*100/r->width; - else /* vertical bars are bottom-up by default */ - *edge_offset = 100 - vy*100/r->height; + if(r->width > r->height) { + if(r->width > 1) + *edge_offset = vx*1000/(r->width - 1); + else + *edge_offset = 0; + } else { + /* vertical bars are bottom-up by default */ + if(r->height > 1) + *edge_offset = 1000 - vy*1000/(r->height - 1); + else + *edge_offset = 0; + } + if (r->reverse_bar || (bar && bar->invert_fill_direction)) - *edge_offset = 100 - *edge_offset; + *edge_offset = 1000 - *edge_offset; } temp = r; returncode = r->action; @@ -294,7 +303,7 @@ int skin_get_touchaction(struct wps_data *data, int* edge_offset, { int val, count; get_setting_info_for_bar(bar->setting_id, &count, &val); - val = *edge_offset * count / 100; + val = *edge_offset * count / 1000; update_setting_value_from_touch(bar->setting_id, val); } } diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 2c668998f0..35716087c2 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -182,7 +182,7 @@ static int skintouch_to_wps(struct wps_data *data) return ACTION_WPS_HOTKEY; #endif case ACTION_TOUCH_SCROLLBAR: - skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/100; + skin_get_global_state()->id3->elapsed = skin_get_global_state()->id3->length*offset/1000; audio_pre_ff_rewind(); audio_ff_rewind(skin_get_global_state()->id3->elapsed); return ACTION_TOUCHSCREEN; @@ -191,7 +191,7 @@ static int skintouch_to_wps(struct wps_data *data) const int min_vol = sound_min(SOUND_VOLUME); const int max_vol = sound_max(SOUND_VOLUME); const int step_vol = sound_steps(SOUND_VOLUME); - global_settings.volume = (offset * (max_vol - min_vol)) / 100; + global_settings.volume = (offset * (max_vol - min_vol)) / 1000; global_settings.volume += min_vol; global_settings.volume -= (global_settings.volume % step_vol); setvol(); -- cgit v1.2.3