summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2009-07-27 13:27:38 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2009-07-27 13:27:38 +0000
commit95c25d6d274e932d01fe6b610f95744ea0882ede (patch)
treeec173c220033319dee69791650e01ff8fe4bb87c
parentc08a2c7c53fcfc652bf2463986a447120f946b53 (diff)
downloadrockbox-95c25d6d274e932d01fe6b610f95744ea0882ede.tar.gz
rockbox-95c25d6d274e932d01fe6b610f95744ea0882ede.tar.bz2
rockbox-95c25d6d274e932d01fe6b610f95744ea0882ede.zip
Touchscreen targets: add basic progress bar & volume handling
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22068 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/music_screen.c47
-rw-r--r--apps/gui/wps_engine/wps_internals.h5
-rw-r--r--apps/gui/wps_engine/wps_parser.c55
-rw-r--r--wps/cabbiev2.240x400x16.wps2
4 files changed, 84 insertions, 25 deletions
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;
+ }
+ }
}
}
}
diff --git a/apps/gui/wps_engine/wps_internals.h b/apps/gui/wps_engine/wps_internals.h
index 581763fb9a..ce9b4d3d46 100644
--- a/apps/gui/wps_engine/wps_internals.h
+++ b/apps/gui/wps_engine/wps_internals.h
@@ -390,6 +390,11 @@ struct touchregion {
short int y; /* y-pos */
short int width; /* width */
short int height; /* height */
+ enum {
+ WPS_TOUCHREGION_ACTION,
+ WPS_TOUCHREGION_SCROLLBAR,
+ WPS_TOUCHREGION_VOLUME
+ } type; /* type of touch region */
bool repeat; /* requires the area be held for the action */
int action; /* action this button will return */
};
diff --git a/apps/gui/wps_engine/wps_parser.c b/apps/gui/wps_engine/wps_parser.c
index 15acc1401d..91c63059b0 100644
--- a/apps/gui/wps_engine/wps_parser.c
+++ b/apps/gui/wps_engine/wps_parser.c
@@ -1173,6 +1173,8 @@ static int parse_touchregion(const char *wps_bufptr,
struct touchregion *region;
const char *ptr = wps_bufptr;
const char *action;
+ const char pb_string[] = "progressbar";
+ const char vol_string[] = "volume";
int x,y,w,h;
/* format: %T|x|y|width|height|action|
@@ -1203,7 +1205,7 @@ static int parse_touchregion(const char *wps_bufptr,
/* Check there is a terminating | */
if (*ptr != '|')
return WPS_ERROR_INVALID_PARAM;
-
+
/* should probably do some bounds checking here with the viewport... but later */
region = &wps_data->touchregion[wps_data->touchregion_count];
region->action = ACTION_NONE;
@@ -1212,28 +1214,41 @@ static int parse_touchregion(const char *wps_bufptr,
region->width = w;
region->height = h;
region->wvp = &wps_data->viewports[wps_data->num_viewports];
- i = 0;
- if (*action == '&')
- {
- action++;
- region->repeat = true;
- }
- else
- region->repeat = false;
- imax = ARRAYLEN(touchactions);
- while ((region->action == ACTION_NONE) &&
- (i < imax))
+ if(!strncmp(pb_string, action, sizeof(pb_string)-1)
+ && *(action + sizeof(pb_string)-1) == '|')
+ region->type = WPS_TOUCHREGION_SCROLLBAR;
+ else if(!strncmp(vol_string, action, sizeof(vol_string)-1)
+ && *(action + sizeof(vol_string)-1) == '|')
+ region->type = WPS_TOUCHREGION_VOLUME;
+ else
{
- /* try to match with one of our touchregion screens */
- int len = strlen(touchactions[i].s);
- if (!strncmp(touchactions[i].s, action, len)
- && *(action+len) == '|')
- region->action = touchactions[i].action;
- i++;
+ region->type = WPS_TOUCHREGION_ACTION;
+
+ if (*action == '&')
+ {
+ action++;
+ region->repeat = true;
+ }
+ else
+ region->repeat = false;
+
+ i = 0;
+ imax = ARRAYLEN(touchactions);
+ while ((region->action == ACTION_NONE) &&
+ (i < imax))
+ {
+ /* try to match with one of our touchregion screens */
+ int len = strlen(touchactions[i].s);
+ if (!strncmp(touchactions[i].s, action, len)
+ && *(action+len) == '|')
+ region->action = touchactions[i].action;
+ i++;
+ }
+ if (region->action == ACTION_NONE)
+ return WPS_ERROR_INVALID_PARAM;
}
- if (region->action == ACTION_NONE)
- return WPS_ERROR_INVALID_PARAM;
+
wps_data->touchregion_count++;
return skip_end_of_line(wps_bufptr);
}
diff --git a/wps/cabbiev2.240x400x16.wps b/wps/cabbiev2.240x400x16.wps
index 9d45643074..2ef33d5bcf 100644
--- a/wps/cabbiev2.240x400x16.wps
+++ b/wps/cabbiev2.240x400x16.wps
@@ -9,6 +9,8 @@
%T|182|372|18|92|repmode|
%T|139|372|37|23|shuffle|
%T|90|238|60|20|playlist|
+%T|22|284|199|13|progressbar|
+%T|98|372|33|23|volume|
%X|wpsbackdrop-240x400x16.bmp|
%xl|A|lock-240x320x16.bmp|11|372|2|