1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Jonathan Gordon 2010-09-16 12:56:51 +00:00
parent 520baf0b6a
commit fbb008331d
4 changed files with 35 additions and 62 deletions

View file

@ -1372,6 +1372,9 @@ static int skin_element_callback(struct skin_element* element, void* data)
case SKIN_TOKEN_DRAW_INBUILTBAR: case SKIN_TOKEN_DRAW_INBUILTBAR:
function = parse_statusbar_tags; function = parse_statusbar_tags;
break; break;
case SKIN_TOKEN_LIST_TITLE_TEXT:
sb_skin_has_title(curr_screen);
break;
#endif #endif
case SKIN_TOKEN_FILE_DIRECTORY: case SKIN_TOKEN_FILE_DIRECTORY:
token->value.i = element->params[0].data.number; token->value.i = element->params[0].data.number;

View file

@ -57,6 +57,7 @@
#include "wps_internals.h" #include "wps_internals.h"
#include "skin_engine.h" #include "skin_engine.h"
#include "statusbar-skinned.h"
#include "root_menu.h" #include "root_menu.h"
#ifdef HAVE_RECORDING #ifdef HAVE_RECORDING
#include "recording.h" #include "recording.h"
@ -706,11 +707,11 @@ const char *get_token_value(struct gui_wps *gwps,
return buf; return buf;
case SKIN_TOKEN_LIST_TITLE_TEXT: 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: case SKIN_TOKEN_LIST_TITLE_ICON:
if (intval) if (intval)
*intval = token->value.i; *intval = sb_get_icon(gwps->display->screen_type);
snprintf(buf, buf_size, "%d", token->value.i); snprintf(buf, buf_size, "%d",sb_get_icon(gwps->display->screen_type));
return buf; return buf;
case SKIN_TOKEN_PLAYLIST_NAME: case SKIN_TOKEN_PLAYLIST_NAME:

View file

@ -42,73 +42,39 @@
/* initial setup of wps_data */ /* initial setup of wps_data */
static int update_delay = DEFAULT_UPDATE_DELAY; 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];
int retval = 0; static enum themable_icons sbs_icon[NB_SCREENS];
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; i<element->params_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; i<element->children_count; i++)
retval |= set_title_worker(title, icon, data, element->children[i]);
}
element = element->next;
}
return retval;
}
bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen) bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type screen)
{ {
struct wps_data *data = skin_get_gwps(CUSTOM_STATUSBAR, screen)->data; sbs_title[screen] = title;
bool retval = data->wps_loaded && /* Icon_NOICON == -1 which the skin engine wants at position 1, so + 2 */
set_title_worker(title, icon, data, data->tree) > 0; sbs_icon[screen] = icon + 2;
return retval; return sbs_has_title[screen];
}
void sb_skin_has_title(enum screen_type screen)
{
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) int sb_preproccess(enum screen_type screen, struct wps_data *data)
{ {
(void)data; (void)data;
/* We need to disable the theme here or else viewport_set_defaults() int i;
* (which is called in the viewport tag parser) will crash because FOR_NB_SCREENS(i)
* the theme is enabled but sb_set_info_vp() isnt set untill after the sbs sbs_has_title[i] = false;
* is parsed. This only affects the default viewport which is ignored
* int he sbs anyway */
viewportmanager_theme_enable(screen, false, NULL); viewportmanager_theme_enable(screen, false, NULL);
return 1; return 1;
} }

View file

@ -42,6 +42,9 @@ void sb_skin_update(enum screen_type screen, bool force);
void sb_skin_set_update_delay(int delay); void sb_skin_set_update_delay(int delay);
bool sb_set_title_text(char* title, enum themable_icons icon, enum screen_type 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);
const char* sb_get_title(enum screen_type screen);
enum themable_icons sb_get_icon(enum screen_type screen);
#ifdef HAVE_TOUCHSCREEN #ifdef HAVE_TOUCHSCREEN
void sb_bypass_touchregions(bool enable); void sb_bypass_touchregions(bool enable);