From fbb008331d45b45224a03b68627e420f0bcb3849 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 16 Sep 2010 12:56:51 +0000 Subject: skin engine: completly rework the sbs title handing code This hopefully fixes the remaining data aborts and freezes when loading skins caused by the somewhat nasty list/sbs title handling code. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28093 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_parser.c | 3 ++ apps/gui/skin_engine/skin_tokens.c | 7 ++-- apps/gui/statusbar-skinned.c | 82 +++++++++++--------------------------- apps/gui/statusbar-skinned.h | 3 ++ 4 files changed, 34 insertions(+), 61 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 2534bf9104..117a926fa3 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -1372,6 +1372,9 @@ static int skin_element_callback(struct skin_element* element, void* data) case SKIN_TOKEN_DRAW_INBUILTBAR: function = parse_statusbar_tags; break; + case SKIN_TOKEN_LIST_TITLE_TEXT: + sb_skin_has_title(curr_screen); + break; #endif case SKIN_TOKEN_FILE_DIRECTORY: token->value.i = element->params[0].data.number; diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index c3f803e4a3..b5c32584b1 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -57,6 +57,7 @@ #include "wps_internals.h" #include "skin_engine.h" +#include "statusbar-skinned.h" #include "root_menu.h" #ifdef HAVE_RECORDING #include "recording.h" @@ -706,11 +707,11 @@ const char *get_token_value(struct gui_wps *gwps, return buf; case SKIN_TOKEN_LIST_TITLE_TEXT: - return (char*)token->value.data; + return sb_get_title(gwps->display->screen_type); case SKIN_TOKEN_LIST_TITLE_ICON: if (intval) - *intval = token->value.i; - snprintf(buf, buf_size, "%d", token->value.i); + *intval = sb_get_icon(gwps->display->screen_type); + snprintf(buf, buf_size, "%d",sb_get_icon(gwps->display->screen_type)); return buf; case SKIN_TOKEN_PLAYLIST_NAME: diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c index 2139bd698a..a5c751b804 100644 --- a/apps/gui/statusbar-skinned.c +++ b/apps/gui/statusbar-skinned.c @@ -42,73 +42,39 @@ /* initial setup of wps_data */ static int update_delay = DEFAULT_UPDATE_DELAY; -static int set_title_worker(char* title, enum themable_icons icon, - struct wps_data *data, struct skin_element *root) + +static bool sbs_has_title[NB_SCREENS]; +static char* sbs_title[NB_SCREENS]; +static enum themable_icons sbs_icon[NB_SCREENS]; + +bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen) { - int retval = 0; - struct skin_element *element = root; - while (element) - { - struct wps_token *token = NULL; - if (element->type == CONDITIONAL) - { - struct conditional *cond = (struct conditional *)element->data; - token = cond->token; - } - else if (element->type == TAG) - { - token = (struct wps_token *)element->data; - } - if (token) - { - if (token->type == SKIN_TOKEN_LIST_TITLE_TEXT) - { - token->value.data = title; - retval = 1; - } - else if (token->type == SKIN_TOKEN_LIST_TITLE_ICON) - { - /* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */ - token->value.i = icon+2; - } - else if (element->params_count) - { - int i; - for (i=0; iparams_count; i++) - { - if (element->params[i].type == CODE) - retval |= set_title_worker(title, icon, data, - element->params[i].data.code); - } - } - } - if (element->children_count) - { - int i; - for (i=0; ichildren_count; i++) - retval |= set_title_worker(title, icon, data, element->children[i]); - } - element = element->next; - } - return retval; + sbs_title[screen] = title; + /* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */ + sbs_icon[screen] = icon + 2; + return sbs_has_title[screen]; } -bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen) +void sb_skin_has_title(enum screen_type screen) { - struct wps_data *data = skin_get_gwps(CUSTOM_STATUSBAR, screen)->data; - bool retval = data->wps_loaded && - set_title_worker(title, icon, data, data->tree) > 0; - return retval; + sbs_has_title[screen] = true; +} + +const char* sb_get_title(enum screen_type screen) +{ + return sbs_has_title[screen] ? sbs_title[screen] : NULL; +} +enum themable_icons sb_get_icon(enum screen_type screen) +{ + return sbs_has_title[screen] ? sbs_icon[screen] : Icon_NOICON + 2; } int sb_preproccess(enum screen_type screen, struct wps_data *data) { (void)data; - /* We need to disable the theme here or else viewport_set_defaults() - * (which is called in the viewport tag parser) will crash because - * the theme is enabled but sb_set_info_vp() isnt set untill after the sbs - * is parsed. This only affects the default viewport which is ignored - * int he sbs anyway */ + int i; + FOR_NB_SCREENS(i) + sbs_has_title[i] = false; viewportmanager_theme_enable(screen, false, NULL); return 1; } diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h index a6e79a2246..bfd8193110 100644 --- a/apps/gui/statusbar-skinned.h +++ b/apps/gui/statusbar-skinned.h @@ -42,6 +42,9 @@ void sb_skin_update(enum screen_type screen, bool force); void sb_skin_set_update_delay(int delay); bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen); +void sb_skin_has_title(enum screen_type screen); +const char* sb_get_title(enum screen_type screen); +enum themable_icons sb_get_icon(enum screen_type screen); #ifdef HAVE_TOUCHSCREEN void sb_bypass_touchregions(bool enable); -- cgit v1.2.3