touchscreen: Allow progress bars to be used in the .sbs

Progress bars (for seeking in the current track) can now be
used on the .sbs skin.

Change-Id: I42377b16036ca4ca8017ecfa2bdab08bd0fa1e64
This commit is contained in:
Aidan MacDonald 2021-08-21 18:03:10 +01:00
parent 9b5b9d6a6d
commit 9d7af45122
3 changed files with 25 additions and 17 deletions

View file

@ -33,6 +33,7 @@
#include "splash.h" #include "splash.h"
#include "playlist.h" #include "playlist.h"
#include "dsp_misc.h" #include "dsp_misc.h"
#include "playback.h"
/** Disarms all touchregions. */ /** Disarms all touchregions. */
void skin_disarm_touchregions(struct gui_wps *gwps) void skin_disarm_touchregions(struct gui_wps *gwps)
@ -195,13 +196,32 @@ int skin_get_touchaction(struct gui_wps *gwps, int* edge_offset)
switch (action) switch (action)
{ {
case ACTION_TOUCH_SCROLLBAR: case ACTION_TOUCH_SCROLLBAR:
{
action = ACTION_TOUCHSCREEN;
struct wps_state* gwps = get_wps_state();
if (!gwps->id3)
break;
if (gevent.id == GESTURE_HOLD || if (gevent.id == GESTURE_HOLD ||
gevent.id == GESTURE_DRAGSTART || gevent.id == GESTURE_DRAGSTART ||
gevent.id == GESTURE_DRAG) gevent.id == GESTURE_DRAG)
action = ACTION_TOUCH_SCROLLBAR_SET; {
audio_pre_ff_rewind();
gwps->id3->elapsed = gwps->id3->length * (*edge_offset) / 1000;
}
else if (gevent.id == GESTURE_RELEASE) else if (gevent.id == GESTURE_RELEASE)
action = ACTION_TOUCH_SCROLLBAR_END; {
break; audio_ff_rewind(gwps->id3->elapsed);
}
else
{
gwps->id3->elapsed = gwps->id3->length * (*edge_offset) / 1000;
audio_pre_ff_rewind();
audio_ff_rewind(gwps->id3->elapsed);
}
} break;
case ACTION_TOUCH_VOLUME: case ACTION_TOUCH_VOLUME:
{ {

View file

@ -170,7 +170,6 @@ void wps_do_action(enum wps_do_action_type action, bool updatewps)
static int skintouch_to_wps(void) static int skintouch_to_wps(void)
{ {
int offset = 0; int offset = 0;
struct wps_state *gstate = get_wps_state();
struct gui_wps *gwps = skin_get_gwps(WPS, SCREEN_MAIN); struct gui_wps *gwps = skin_get_gwps(WPS, SCREEN_MAIN);
int button = skin_get_touchaction(gwps, &offset); int button = skin_get_touchaction(gwps, &offset);
switch (button) switch (button)
@ -193,18 +192,6 @@ static int skintouch_to_wps(void)
case ACTION_STD_HOTKEY: case ACTION_STD_HOTKEY:
return ACTION_WPS_HOTKEY; return ACTION_WPS_HOTKEY;
#endif #endif
case ACTION_TOUCH_SCROLLBAR_SET:
audio_pre_ff_rewind();
gstate->id3->elapsed = gstate->id3->length*offset/1000;
return ACTION_TOUCHSCREEN;
case ACTION_TOUCH_SCROLLBAR_END:
audio_ff_rewind(gstate->id3->elapsed);
return ACTION_TOUCHSCREEN;
case ACTION_TOUCH_SCROLLBAR:
gstate->id3->elapsed = gstate->id3->length*offset/1000;
audio_pre_ff_rewind();
audio_ff_rewind(gstate->id3->elapsed);
return ACTION_TOUCHSCREEN;
} }
return button; return button;
} }

View file

@ -115,7 +115,8 @@ int fms_do_button_loop(bool update_screen)
case ACTION_STD_MENU: case ACTION_STD_MENU:
return ACTION_FM_MENU; return ACTION_FM_MENU;
case ACTION_TOUCH_SCROLLBAR: case ACTION_TOUCH_SCROLLBAR:
/* TODO */ /* TODO - skin_get_touchaction has this hardcoded to seek in
* current track, refactor it if this is ever implemented. */
break; break;
} }
#endif #endif