From 95c25d6d274e932d01fe6b610f95744ea0882ede Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Mon, 27 Jul 2009 13:27:38 +0000 Subject: Touchscreen targets: add basic progress bar & volume handling git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22068 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/music_screen.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) (limited to 'apps/gui/music_screen.c') diff --git a/apps/gui/music_screen.c b/apps/gui/music_screen.c index 39d5e0e85b..d5eccd5868 100644 --- a/apps/gui/music_screen.c +++ b/apps/gui/music_screen.c @@ -553,12 +553,49 @@ int wps_get_touchaction(struct wps_data *data) if (vx >= r->x && vx < r->x+r->width && vy >= r->y && vy < r->y+r->height) { - if ((repeated && r->repeat) || - (released && !r->repeat)) + /* reposition the touch within the area */ + vx -= r->x; + vy -= r->y; + + switch(r->type) { - last_action = r->action; - return r->action; - } + case WPS_TOUCHREGION_ACTION: + if ((repeated && r->repeat) || (released && !r->repeat)) + { + last_action = r->action; + return r->action; + } + break; + case WPS_TOUCHREGION_SCROLLBAR: + if(r->width > r->height) + /* landscape */ + wps_state.id3->elapsed = (vx * + wps_state.id3->length) / r->width; + else + /* portrait */ + wps_state.id3->elapsed = (vy * + wps_state.id3->length) / r->height; + + audio_ff_rewind(wps_state.id3->elapsed); + break; + case WPS_TOUCHREGION_VOLUME: + { + const int min_vol = sound_min(SOUND_VOLUME); + const int max_vol = sound_max(SOUND_VOLUME); + if(r->width > r->height) + /* landscape */ + global_settings.volume = (vx * + (max_vol - min_vol)) / r->width; + else + /* portrait */ + global_settings.volume = (vy * + (max_vol-min_vol)) / r->height; + + global_settings.volume += min_vol; + setvol(); + break; + } + } } } } -- cgit v1.2.3