diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-05-05 13:48:50 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-05-05 13:48:50 +0000 |
commit | efd1f4e49facbcdcbb11dbf6a8ead3843df586d3 (patch) | |
tree | 1247db65aa3b5eb15814b01d3becd8dbe98d2eb0 | |
parent | 268f7c42f0d7128a4c88cb1c9b64b663dd266bf6 (diff) | |
download | rockbox-efd1f4e49facbcdcbb11dbf6a8ead3843df586d3.tar.gz rockbox-efd1f4e49facbcdcbb11dbf6a8ead3843df586d3.zip |
Make it possible to move the UI viewport using conditional viewports.
%Vi|<label>|<Usual %Vi params>| <- specify the possible viewports to use
%VI<label> <- make the UI viewport use the %Vi definition with the <label> label.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25826 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 4 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 24 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_tokens.h | 1 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_debug.c | 4 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 2 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.c | 18 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.h | 1 |
7 files changed, 47 insertions, 7 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index a0b3497683..475f3a102c 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -775,6 +775,10 @@ static bool get_line(struct gui_wps *gwps, | |||
775 | } | 775 | } |
776 | } | 776 | } |
777 | break; | 777 | break; |
778 | case WPS_TOKEN_UIVIEWPORT_ENABLE: | ||
779 | sb_set_info_vp(gwps->display->screen_type, | ||
780 | data->tokens[i].value.i|VP_INFO_LABEL); | ||
781 | break; | ||
778 | #ifdef HAVE_LCD_BITMAP | 782 | #ifdef HAVE_LCD_BITMAP |
779 | case WPS_VIEWPORT_CUSTOMLIST: | 783 | case WPS_VIEWPORT_CUSTOMLIST: |
780 | draw_playlist_viewer_list(gwps, data->tokens[i].value.data); | 784 | draw_playlist_viewer_list(gwps, data->tokens[i].value.data); |
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 6ea0180534..78ec26eaf9 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -370,6 +370,8 @@ static const struct wps_tag all_tags[] = { | |||
370 | 370 | ||
371 | { WPS_VIEWPORT_ENABLE, "Vd", WPS_REFRESH_DYNAMIC, | 371 | { WPS_VIEWPORT_ENABLE, "Vd", WPS_REFRESH_DYNAMIC, |
372 | parse_viewport_display }, | 372 | parse_viewport_display }, |
373 | { WPS_TOKEN_UIVIEWPORT_ENABLE, "VI", WPS_REFRESH_STATIC, | ||
374 | parse_viewport_display }, | ||
373 | #ifdef HAVE_LCD_BITMAP | 375 | #ifdef HAVE_LCD_BITMAP |
374 | { WPS_VIEWPORT_CUSTOMLIST, "Vp", WPS_REFRESH_STATIC, parse_playlistview }, | 376 | { WPS_VIEWPORT_CUSTOMLIST, "Vp", WPS_REFRESH_STATIC, parse_playlistview }, |
375 | { WPS_TOKEN_LIST_TITLE_TEXT, "Lt", WPS_REFRESH_DYNAMIC, NULL }, | 377 | { WPS_TOKEN_LIST_TITLE_TEXT, "Lt", WPS_REFRESH_DYNAMIC, NULL }, |
@@ -915,9 +917,25 @@ static int parse_viewport(const char *wps_bufptr, | |||
915 | 917 | ||
916 | if (*ptr == 'i') | 918 | if (*ptr == 'i') |
917 | { | 919 | { |
918 | skin_vp->label = VP_INFO_LABEL; | 920 | if (*(ptr+1) == '|') |
919 | skin_vp->hidden_flags = VP_NEVER_VISIBLE; | 921 | { |
920 | ++ptr; | 922 | char label = *(ptr+2); |
923 | if (label >= 'a' && label <= 'z') | ||
924 | { | ||
925 | skin_vp->hidden_flags = VP_NEVER_VISIBLE; | ||
926 | skin_vp->label = VP_INFO_LABEL|label; | ||
927 | ptr += 3; | ||
928 | } | ||
929 | else | ||
930 | { | ||
931 | skin_vp->label = VP_INFO_LABEL|VP_DEFAULT_LABEL; | ||
932 | skin_vp->hidden_flags = VP_NEVER_VISIBLE; | ||
933 | ++ptr; | ||
934 | } | ||
935 | } | ||
936 | else | ||
937 | return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */ | ||
938 | |||
921 | } | 939 | } |
922 | else if (*ptr == 'l') | 940 | else if (*ptr == 'l') |
923 | { | 941 | { |
diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h index 3b155509f9..aefae40af9 100644 --- a/apps/gui/skin_engine/skin_tokens.h +++ b/apps/gui/skin_engine/skin_tokens.h | |||
@@ -55,6 +55,7 @@ enum wps_token_type { | |||
55 | /* Viewport display */ | 55 | /* Viewport display */ |
56 | WPS_VIEWPORT_ENABLE, | 56 | WPS_VIEWPORT_ENABLE, |
57 | WPS_VIEWPORT_CUSTOMLIST, | 57 | WPS_VIEWPORT_CUSTOMLIST, |
58 | WPS_TOKEN_UIVIEWPORT_ENABLE, | ||
58 | 59 | ||
59 | /* Battery */ | 60 | /* Battery */ |
60 | TOKEN_MARKER_BATTERY, | 61 | TOKEN_MARKER_BATTERY, |
diff --git a/apps/gui/skin_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c index 26554b1db6..4186e306e3 100644 --- a/apps/gui/skin_engine/wps_debug.c +++ b/apps/gui/skin_engine/wps_debug.c | |||
@@ -490,7 +490,9 @@ static char *get_token_desc(struct wps_token *token, char *buf, | |||
490 | break; | 490 | break; |
491 | #endif | 491 | #endif |
492 | case WPS_VIEWPORT_ENABLE: | 492 | case WPS_VIEWPORT_ENABLE: |
493 | snprintf(buf, bufsize, "enable VP: %c", | 493 | case WPS_TOKEN_UIVIEWPORT_ENABLE: |
494 | snprintf(buf, bufsize, "enable %sVP: %c", | ||
495 | token->type == WPS_TOKEN_UIVIEWPORT_ENABLE ? "UI " : "", | ||
494 | (char)token->value.i); | 496 | (char)token->value.i); |
495 | break; | 497 | break; |
496 | case WPS_TOKEN_BUTTON_VOLUME: | 498 | case WPS_TOKEN_BUTTON_VOLUME: |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index a014770017..edfae68e84 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -203,7 +203,7 @@ struct skin_line { | |||
203 | #define VP_NEVER_VISIBLE 0x8 | 203 | #define VP_NEVER_VISIBLE 0x8 |
204 | #define VP_DEFAULT_LABEL '|' | 204 | #define VP_DEFAULT_LABEL '|' |
205 | #define VP_NO_LABEL '-' | 205 | #define VP_NO_LABEL '-' |
206 | #define VP_INFO_LABEL '_' | 206 | #define VP_INFO_LABEL 0x80 |
207 | struct skin_viewport { | 207 | struct skin_viewport { |
208 | struct viewport vp; /* The LCD viewport struct */ | 208 | struct viewport vp; /* The LCD viewport struct */ |
209 | struct skin_line *lines; | 209 | struct skin_line *lines; |
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c index 0902950599..af02b9b54d 100644 --- a/apps/gui/statusbar-skinned.c +++ b/apps/gui/statusbar-skinned.c | |||
@@ -86,15 +86,29 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile) | |||
86 | } | 86 | } |
87 | /* hide this viewport, forever */ | 87 | /* hide this viewport, forever */ |
88 | vp->hidden_flags = VP_NEVER_VISIBLE; | 88 | vp->hidden_flags = VP_NEVER_VISIBLE; |
89 | sb_set_info_vp(screen, VP_INFO_LABEL|VP_DEFAULT_LABEL); | ||
89 | } | 90 | } |
90 | 91 | ||
91 | if (!success && isfile) | 92 | if (!success && isfile) |
92 | sb_create_from_settings(screen); | 93 | sb_create_from_settings(screen); |
93 | } | 94 | } |
94 | 95 | static char infovp_label[NB_SCREENS]; | |
96 | static char oldinfovp_label[NB_SCREENS]; | ||
97 | void sb_set_info_vp(enum screen_type screen, char label) | ||
98 | { | ||
99 | infovp_label[screen] = label; | ||
100 | } | ||
101 | |||
95 | struct viewport *sb_skin_get_info_vp(enum screen_type screen) | 102 | struct viewport *sb_skin_get_info_vp(enum screen_type screen) |
96 | { | 103 | { |
97 | return &find_viewport(VP_INFO_LABEL, sb_skin[screen].data)->vp; | 104 | if (oldinfovp_label[screen] != infovp_label[screen]) |
105 | { | ||
106 | /* UI viewport changed, so force a redraw */ | ||
107 | oldinfovp_label[screen] = infovp_label[screen]; | ||
108 | viewportmanager_theme_enable(screen, false, NULL); | ||
109 | viewportmanager_theme_undo(screen, true); | ||
110 | } | ||
111 | return &find_viewport(infovp_label[screen], sb_skin[screen].data)->vp; | ||
98 | } | 112 | } |
99 | 113 | ||
100 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) | 114 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) |
diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h index 7558d5a6f8..eb27b06196 100644 --- a/apps/gui/statusbar-skinned.h +++ b/apps/gui/statusbar-skinned.h | |||
@@ -36,6 +36,7 @@ void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile); | |||
36 | 36 | ||
37 | void sb_create_from_settings(enum screen_type screen); | 37 | void sb_create_from_settings(enum screen_type screen); |
38 | void sb_skin_init(void) INIT_ATTR; | 38 | void sb_skin_init(void) INIT_ATTR; |
39 | void sb_set_info_vp(enum screen_type screen, char label); | ||
39 | struct viewport *sb_skin_get_info_vp(enum screen_type screen); | 40 | struct viewport *sb_skin_get_info_vp(enum screen_type screen); |
40 | void sb_skin_update(enum screen_type screen, bool force); | 41 | void sb_skin_update(enum screen_type screen, bool force); |
41 | 42 | ||