summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-02-28 08:36:13 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-02-28 08:36:13 +0000
commit8717c1eaa12ce23501d1c6e6103eaed310204243 (patch)
tree904e2ac64e5bf4388bad7307ff10cd9affd08358 /apps/gui
parent8c5eaa35ecd8b5239e2cb4848e29310daa6f4a88 (diff)
downloadrockbox-8717c1eaa12ce23501d1c6e6103eaed310204243.tar.gz
rockbox-8717c1eaa12ce23501d1c6e6103eaed310204243.zip
redo r24943. the font mappings are not needed once the skin is finished parsing so using the skin buffer there is a waste and overcomplicates things.
Also that commit breaks plain %pb so make sure you dont use %pb inside a viewport with a font number > 1 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24957 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/skin_engine/skin_parser.c66
-rw-r--r--apps/gui/skin_engine/wps_internals.h7
2 files changed, 25 insertions, 48 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 8f802a12a4..01913e48b7 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -431,18 +431,6 @@ struct gui_img* find_image(char label, struct wps_data *data)
431 return NULL; 431 return NULL;
432} 432}
433 433
434struct skin_font* find_font(int id, struct wps_data *data)
435{
436 struct skin_token_list *list = data->fonts;
437 while (list)
438 {
439 struct skin_font *f = (struct skin_font*)list->token->value.data;
440 if (f->id == id)
441 return f;
442 list = list->next;
443 }
444 return NULL;
445}
446#endif 434#endif
447 435
448/* traverse the viewport linked list for a viewport */ 436/* traverse the viewport linked list for a viewport */
@@ -705,10 +693,11 @@ static int parse_image_load(const char *wps_bufptr,
705 /* Skip the rest of the line */ 693 /* Skip the rest of the line */
706 return skip_end_of_line(wps_bufptr); 694 return skip_end_of_line(wps_bufptr);
707} 695}
708 696struct skin_font {
709/* this array acts as a simple mapping between the id the user uses for a font 697 int id; /* the id from font_load */
710 * and the id the font actually gets from the font loader. 698 char *name; /* filename without path and extension */
711 * font id 2 is always the first skin font (regardless of how many screens */ 699};
700static struct skin_font skinfonts[MAXUSERFONTS];
712static int parse_font_load(const char *wps_bufptr, 701static int parse_font_load(const char *wps_bufptr,
713 struct wps_token *token, struct wps_data *wps_data) 702 struct wps_token *token, struct wps_data *wps_data)
714{ 703{
@@ -716,7 +705,6 @@ static int parse_font_load(const char *wps_bufptr,
716 const char *ptr = wps_bufptr; 705 const char *ptr = wps_bufptr;
717 int id; 706 int id;
718 char *filename; 707 char *filename;
719 struct skin_font *font;
720 708
721 if (*ptr != '|') 709 if (*ptr != '|')
722 return WPS_ERROR_INVALID_PARAM; 710 return WPS_ERROR_INVALID_PARAM;
@@ -732,24 +720,15 @@ static int parse_font_load(const char *wps_bufptr,
732 720
733 if (id <= FONT_UI || id >= MAXFONTS-1) 721 if (id <= FONT_UI || id >= MAXFONTS-1)
734 return WPS_ERROR_INVALID_PARAM; 722 return WPS_ERROR_INVALID_PARAM;
735 723#if defined(DEBUG) || defined(SIMULATOR)
736 font = skin_buffer_alloc(sizeof(struct skin_font)); 724 if (skinfonts[id-FONT_FIRSTUSERFONT].name != NULL)
737 int len = ptr-filename+1; 725 {
738 char* name = skin_buffer_alloc(len); 726 DEBUGF("font id %d already being used\n", id);
739 if (!font || !name) 727 }
740 return WPS_ERROR_INVALID_PARAM; 728#endif
741 729 skinfonts[id-FONT_FIRSTUSERFONT].id = -1;
742 strlcpy(name, filename, len); 730 skinfonts[id-FONT_FIRSTUSERFONT].name = filename;
743 font->id = id; 731
744 font->font_id = -1;
745 font->name = name;
746
747 struct skin_token_list *item = new_skin_token_list_item(NULL, font);
748
749 if (!item)
750 return WPS_ERROR_INVALID_PARAM;
751 add_to_ll_chain(&wps_data->fonts, item);
752
753 return skip_end_of_line(wps_bufptr); 732 return skip_end_of_line(wps_bufptr);
754} 733}
755 734
@@ -1974,7 +1953,8 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
1974static void skin_data_reset(struct wps_data *wps_data) 1953static void skin_data_reset(struct wps_data *wps_data)
1975{ 1954{
1976#ifdef HAVE_LCD_BITMAP 1955#ifdef HAVE_LCD_BITMAP
1977 wps_data->images = wps_data->progressbars = wps_data->fonts = NULL; 1956 wps_data->images = NULL;
1957 wps_data->progressbars = NULL;
1978#endif 1958#endif
1979#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 1959#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
1980 wps_data->backdrop = NULL; 1960 wps_data->backdrop = NULL;
@@ -2121,7 +2101,7 @@ static bool skin_load_fonts(struct wps_data *data)
2121 int skin_font_id = vp->font-1; 2101 int skin_font_id = vp->font-1;
2122 2102
2123 /* now find the corresponding skin_font */ 2103 /* now find the corresponding skin_font */
2124 struct skin_font *font = find_font(skin_font_id, data); 2104 struct skin_font *font = &skinfonts[skin_font_id-FONT_FIRSTUSERFONT];
2125 if (!font) 2105 if (!font)
2126 { 2106 {
2127 DEBUGF("Could not find font %d\n", skin_font_id); 2107 DEBUGF("Could not find font %d\n", skin_font_id);
@@ -2131,10 +2111,14 @@ static bool skin_load_fonts(struct wps_data *data)
2131 2111
2132 /* load the font - will handle loading the same font again if 2112 /* load the font - will handle loading the same font again if
2133 * multiple viewports use the same */ 2113 * multiple viewports use the same */
2134 if (font->font_id < 0) 2114 if (font->id < 0)
2135 font->font_id = skin_font_load(font->name); 2115 {
2116 char *bar = strchr(font->name, '|');
2117 *bar = '\0';
2118 font->id = skin_font_load(font->name);
2119 }
2136 2120
2137 if (font->font_id < 0) 2121 if (font->id < 0)
2138 { 2122 {
2139 DEBUGF("Unable to load font %d: '%s.fnt'\n", 2123 DEBUGF("Unable to load font %d: '%s.fnt'\n",
2140 skin_font_id, font->name); 2124 skin_font_id, font->name);
@@ -2143,7 +2127,7 @@ static bool skin_load_fonts(struct wps_data *data)
2143 } 2127 }
2144 2128
2145 /* finally, assign the font_id to the viewport */ 2129 /* finally, assign the font_id to the viewport */
2146 vp->font = font->font_id; 2130 vp->font = font->id;
2147 } 2131 }
2148 return success; 2132 return success;
2149} 2133}
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index aa99804fd4..f6c7463804 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -264,12 +264,6 @@ struct skin_albumart {
264}; 264};
265#endif 265#endif
266 266
267struct skin_font {
268 int id; /* the id used in the %V tags */
269 int font_id; /* the id returned by font_load */
270 char *name; /* filename without path and extension */
271};
272
273/* wps_data 267/* wps_data
274 this struct holds all necessary data which describes the 268 this struct holds all necessary data which describes the
275 viewable content of a wps */ 269 viewable content of a wps */
@@ -278,7 +272,6 @@ struct wps_data
278#ifdef HAVE_LCD_BITMAP 272#ifdef HAVE_LCD_BITMAP
279 struct skin_token_list *images; 273 struct skin_token_list *images;
280 struct skin_token_list *progressbars; 274 struct skin_token_list *progressbars;
281 struct skin_token_list *fonts;
282#endif 275#endif
283#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 276#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
284 char *backdrop; 277 char *backdrop;