diff options
| author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-02-18 01:52:13 +0000 |
|---|---|---|
| committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-02-18 01:52:13 +0000 |
| commit | 3cb735ef39325accc7f3b37419f963dba8260752 (patch) | |
| tree | d301c4f29e320d3096f6abc79af24212975e0a9a /apps | |
| parent | 3a9852be1c2fa1fc6da47fedef978476c82ec951 (diff) | |
| download | rockbox-3cb735ef39325accc7f3b37419f963dba8260752.zip rockbox-3cb735ef39325accc7f3b37419f963dba8260752.tar.gz rockbox-3cb735ef39325accc7f3b37419f963dba8260752.tar.bz2 rockbox-3cb735ef39325accc7f3b37419f963dba8260752.tar.xz | |
basic alignment support (%a|l|c|r|L|R) in the playlist viewer. no sublines so the whole line will either be left, right or centered.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24740 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/gui/skin_engine/skin_display.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 8637190..62eacb5 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -176,6 +176,7 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, int start_item = MAX(0, cur_playlist_pos + viewer->start_offset); int i; struct wps_token token; + int x, length, alignment = WPS_TOKEN_ALIGN_LEFT; struct mp3entry *pid3; #if CONFIG_CODEC == SWCODEC @@ -228,6 +229,14 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, } switch (viewer->lines[line].tokens[j]) { + case WPS_TOKEN_ALIGN_CENTER: + case WPS_TOKEN_ALIGN_LEFT: + case WPS_TOKEN_ALIGN_LEFT_RTL: + case WPS_TOKEN_ALIGN_RIGHT: + case WPS_TOKEN_ALIGN_RIGHT_RTL: + alignment = viewer->lines[line].tokens[j]; + tempbuf[0] = '\0'; + break; case WPS_TOKEN_STRING: case WPS_TOKEN_CHARACTER: snprintf(tempbuf, sizeof(tempbuf), "%s", @@ -255,13 +264,44 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, j++; } - if (viewer->lines[line].scroll) + int vpwidth = viewer->vp->width; + length = gwps->display->getstringsize(buf, NULL, NULL); + if (viewer->lines[line].scroll && length >= vpwidth) { gwps->display->puts_scroll(0, (i-start_item), buf ); } else - { - gwps->display->putsxy(0, (i-start_item)*line_height, buf ); + { + if (length >= vpwidth) + x = 0; + else + { + switch (alignment) + { + case WPS_TOKEN_ALIGN_CENTER: + x = (vpwidth-length)/2; + break; + case WPS_TOKEN_ALIGN_LEFT_RTL: + if (lang_is_rtl() && VP_IS_RTL(viewer->vp)) + { + x = vpwidth - length; + break; + } + case WPS_TOKEN_ALIGN_LEFT: + x = 0; + break; + case WPS_TOKEN_ALIGN_RIGHT_RTL: + if (lang_is_rtl() && VP_IS_RTL(viewer->vp)) + { + x = 0; + break; + } + case WPS_TOKEN_ALIGN_RIGHT: + x = vpwidth - length; + break; + } + } + gwps->display->putsxy(x, (i-start_item)*line_height, buf ); } } } |