summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/skin_parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r--apps/gui/skin_engine/skin_parser.c96
1 files changed, 56 insertions, 40 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index d2b8fdc259..82083e8922 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -77,6 +77,9 @@ static int numoptions[WPS_MAX_COND_LEVEL];
77/* the current line in the file */ 77/* the current line in the file */
78static int line; 78static int line;
79 79
80/* the current viewport */
81static struct skin_viewport *curr_vp;
82
80#ifdef HAVE_LCD_BITMAP 83#ifdef HAVE_LCD_BITMAP
81 84
82#if LCD_DEPTH > 1 85#if LCD_DEPTH > 1
@@ -419,10 +422,11 @@ static int parse_statusbar_enable(const char *wps_bufptr,
419 (void)token; /* Kill warnings */ 422 (void)token; /* Kill warnings */
420 wps_data->wps_sb_tag = true; 423 wps_data->wps_sb_tag = true;
421 wps_data->show_sb_on_wps = true; 424 wps_data->show_sb_on_wps = true;
422 if (wps_data->viewports[0].vp.y == 0) 425 struct skin_viewport *default_vp = find_viewport(VP_DEFAULT_LABEL, wps_data);
426 if (default_vp->vp.y == 0)
423 { 427 {
424 wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT; 428 default_vp->vp.y = STATUSBAR_HEIGHT;
425 wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT; 429 default_vp->vp.height -= STATUSBAR_HEIGHT;
426 } 430 }
427 return skip_end_of_line(wps_bufptr); 431 return skip_end_of_line(wps_bufptr);
428} 432}
@@ -434,10 +438,11 @@ static int parse_statusbar_disable(const char *wps_bufptr,
434 (void)token; /* Kill warnings */ 438 (void)token; /* Kill warnings */
435 wps_data->wps_sb_tag = true; 439 wps_data->wps_sb_tag = true;
436 wps_data->show_sb_on_wps = false; 440 wps_data->show_sb_on_wps = false;
437 if (wps_data->viewports[0].vp.y == STATUSBAR_HEIGHT) 441 struct skin_viewport *default_vp = find_viewport(VP_DEFAULT_LABEL, wps_data);
442 if (default_vp->vp.y == STATUSBAR_HEIGHT)
438 { 443 {
439 wps_data->viewports[0].vp.y = 0; 444 default_vp->vp.y = 0;
440 wps_data->viewports[0].vp.height += STATUSBAR_HEIGHT; 445 default_vp->vp.height += STATUSBAR_HEIGHT;
441 } 446 }
442 return skip_end_of_line(wps_bufptr); 447 return skip_end_of_line(wps_bufptr);
443} 448}
@@ -556,7 +561,7 @@ static int parse_image_load(const char *wps_bufptr,
556 img->always_display = false; 561 img->always_display = false;
557 562
558 /* save current viewport */ 563 /* save current viewport */
559 img->vp = &wps_data->viewports[wps_data->num_viewports].vp; 564 img->vp = &curr_vp->vp;
560 565
561 if (token->type == WPS_TOKEN_IMAGE_DISPLAY) 566 if (token->type == WPS_TOKEN_IMAGE_DISPLAY)
562 { 567 {
@@ -612,13 +617,13 @@ static int parse_viewport(const char *wps_bufptr,
612#endif 617#endif
613 SCREEN_MAIN; 618 SCREEN_MAIN;
614 619
615 if (wps_data->num_viewports >= WPS_MAX_VIEWPORTS) 620 struct skin_viewport *skin_vp = skin_buffer_alloc(sizeof(struct skin_viewport));
616 return WPS_ERROR_INVALID_PARAM;
617 621
618 wps_data->num_viewports++;
619 /* check for the optional letter to signify its a hideable viewport */ 622 /* check for the optional letter to signify its a hideable viewport */
620 /* %Vl|<label>|<rest of tags>| */ 623 /* %Vl|<label>|<rest of tags>| */
621 wps_data->viewports[wps_data->num_viewports].hidden_flags = 0; 624 skin_vp->hidden_flags = 0;
625 skin_vp->label = VP_NO_LABEL;
626 skin_vp->pb = NULL;
622 627
623 if (*ptr == 'l') 628 if (*ptr == 'l')
624 { 629 {
@@ -627,8 +632,8 @@ static int parse_viewport(const char *wps_bufptr,
627 char label = *(ptr+2); 632 char label = *(ptr+2);
628 if (label >= 'a' && label <= 'z') 633 if (label >= 'a' && label <= 'z')
629 { 634 {
630 wps_data->viewports[wps_data->num_viewports].hidden_flags = VP_DRAW_HIDEABLE; 635 skin_vp->hidden_flags = VP_DRAW_HIDEABLE;
631 wps_data->viewports[wps_data->num_viewports].label = label; 636 skin_vp->label = label;
632 } 637 }
633 else 638 else
634 return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */ 639 return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7 */
@@ -639,7 +644,7 @@ static int parse_viewport(const char *wps_bufptr,
639 return WPS_ERROR_INVALID_PARAM; 644 return WPS_ERROR_INVALID_PARAM;
640 645
641 ptr++; 646 ptr++;
642 struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp; 647 struct viewport *vp = &skin_vp->vp;
643 /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ 648 /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */
644 649
645 if (!(ptr = viewport_parse_viewport(vp, screen, ptr, '|'))) 650 if (!(ptr = viewport_parse_viewport(vp, screen, ptr, '|')))
@@ -649,10 +654,9 @@ static int parse_viewport(const char *wps_bufptr,
649 if (*ptr != '|') 654 if (*ptr != '|')
650 return WPS_ERROR_INVALID_PARAM; 655 return WPS_ERROR_INVALID_PARAM;
651 656
657 curr_vp->last_line = wps_data->num_lines - 1;
652 658
653 wps_data->viewports[wps_data->num_viewports-1].last_line = wps_data->num_lines - 1; 659 skin_vp->first_line = wps_data->num_lines;
654
655 wps_data->viewports[wps_data->num_viewports].first_line = wps_data->num_lines;
656 660
657 if (wps_data->num_sublines < WPS_MAX_SUBLINES) 661 if (wps_data->num_sublines < WPS_MAX_SUBLINES)
658 { 662 {
@@ -663,6 +667,11 @@ static int parse_viewport(const char *wps_bufptr,
663 wps_data->num_tokens; 667 wps_data->num_tokens;
664 } 668 }
665 669
670 struct skin_token_list *list = new_skin_token_list_item(NULL, skin_vp);
671 if (!list)
672 return WPS_ERROR_INVALID_PARAM;
673 add_to_ll_chain(&wps_data->viewports, list);
674 curr_vp = skin_vp;
666 /* Skip the rest of the line */ 675 /* Skip the rest of the line */
667 return skip_end_of_line(wps_bufptr); 676 return skip_end_of_line(wps_bufptr);
668} 677}
@@ -818,14 +827,13 @@ static int parse_progressbar(const char *wps_bufptr,
818 if (!pb || !item) 827 if (!pb || !item)
819 return WPS_ERROR_INVALID_PARAM; 828 return WPS_ERROR_INVALID_PARAM;
820 829
821 struct viewport *vp = &wps_data->viewports[wps_data->num_viewports].vp; 830 struct viewport *vp = &curr_vp->vp;
822#ifndef __PCTOOL__ 831#ifndef __PCTOOL__
823 int font_height = font_get(vp->font)->height; 832 int font_height = font_get(vp->font)->height;
824#else 833#else
825 int font_height = 8; 834 int font_height = 8;
826#endif 835#endif
827 int line_num = wps_data->num_lines - 836 int line_num = wps_data->num_lines - curr_vp->first_line;
828 wps_data->viewports[wps_data->num_viewports].first_line;
829 837
830 pb->have_bitmap_pb = false; 838 pb->have_bitmap_pb = false;
831 pb->bm.data = NULL; /* no bitmap specified */ 839 pb->bm.data = NULL; /* no bitmap specified */
@@ -837,7 +845,7 @@ static int parse_progressbar(const char *wps_bufptr,
837 pb->height = SYSFONT_HEIGHT-2; 845 pb->height = SYSFONT_HEIGHT-2;
838 pb->y = -line_num - 1; /* Will be computed during the rendering */ 846 pb->y = -line_num - 1; /* Will be computed during the rendering */
839 847
840 wps_data->viewports[wps_data->num_viewports].pb = pb; 848 curr_vp->pb = pb;
841 add_to_ll_chain(&wps_data->progressbars, item); 849 add_to_ll_chain(&wps_data->progressbars, item);
842 return 0; 850 return 0;
843 } 851 }
@@ -882,7 +890,7 @@ static int parse_progressbar(const char *wps_bufptr,
882 else 890 else
883 pb->y = -line_num - 1; /* Will be computed during the rendering */ 891 pb->y = -line_num - 1; /* Will be computed during the rendering */
884 892
885 wps_data->viewports[wps_data->num_viewports].pb = pb; 893 curr_vp->pb = pb;
886 add_to_ll_chain(&wps_data->progressbars, item); 894 add_to_ll_chain(&wps_data->progressbars, item);
887 895
888 /* Skip the rest of the line */ 896 /* Skip the rest of the line */
@@ -1154,7 +1162,7 @@ static int parse_touchregion(const char *wps_bufptr,
1154 region->y = y; 1162 region->y = y;
1155 region->width = w; 1163 region->width = w;
1156 region->height = h; 1164 region->height = h;
1157 region->wvp = &wps_data->viewports[wps_data->num_viewports]; 1165 region->wvp = curr_vp;
1158 1166
1159 if(!strncmp(pb_string, action, sizeof(pb_string)-1) 1167 if(!strncmp(pb_string, action, sizeof(pb_string)-1)
1160 && *(action + sizeof(pb_string)-1) == '|') 1168 && *(action + sizeof(pb_string)-1) == '|')
@@ -1282,7 +1290,6 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
1282 level = -1; 1290 level = -1;
1283 1291
1284 while(*wps_bufptr && !fail && data->num_tokens < WPS_MAX_TOKENS - 1 1292 while(*wps_bufptr && !fail && data->num_tokens < WPS_MAX_TOKENS - 1
1285 && data->num_viewports < WPS_MAX_VIEWPORTS
1286 && data->num_lines < WPS_MAX_LINES) 1293 && data->num_lines < WPS_MAX_LINES)
1287 { 1294 {
1288 switch(*wps_bufptr++) 1295 switch(*wps_bufptr++)
@@ -1481,10 +1488,7 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr)
1481 /* one of the limits of the while loop was exceeded */ 1488 /* one of the limits of the while loop was exceeded */
1482 fail = PARSE_FAIL_LIMITS_EXCEEDED; 1489 fail = PARSE_FAIL_LIMITS_EXCEEDED;
1483 1490
1484 data->viewports[data->num_viewports].last_line = data->num_lines - 1; 1491 curr_vp->last_line = data->num_lines - 1;
1485
1486 /* We have finished with the last viewport, so increment count */
1487 data->num_viewports++;
1488 1492
1489#if defined(DEBUG) || defined(SIMULATOR) 1493#if defined(DEBUG) || defined(SIMULATOR)
1490 print_debug_info(data, fail, line); 1494 print_debug_info(data, fail, line);
@@ -1611,34 +1615,46 @@ bool skin_data_load(struct wps_data *wps_data,
1611 return false; 1615 return false;
1612 1616
1613 wps_reset(wps_data); 1617 wps_reset(wps_data);
1618
1619 curr_vp = skin_buffer_alloc(sizeof(struct skin_viewport));
1620 if (!curr_vp)
1621 return false;
1622 struct skin_token_list *list = new_skin_token_list_item(NULL, curr_vp);
1623 if (!list)
1624 return false;
1625 add_to_ll_chain(&wps_data->viewports, list);
1626
1614 1627
1615 /* Initialise the first (default) viewport */ 1628 /* Initialise the first (default) viewport */
1616 wps_data->viewports[0].vp.x = 0; 1629 curr_vp->label = VP_DEFAULT_LABEL;
1617 wps_data->viewports[0].vp.width = display->getwidth(); 1630 curr_vp->vp.x = 0;
1618 wps_data->viewports[0].vp.height = display->getheight(); 1631 curr_vp->vp.width = display->getwidth();
1632 curr_vp->vp.height = display->getheight();
1633 curr_vp->pb = NULL;
1634 curr_vp->hidden_flags = 0;
1619 switch (statusbar_position(display->screen_type)) 1635 switch (statusbar_position(display->screen_type))
1620 { 1636 {
1621 case STATUSBAR_OFF: 1637 case STATUSBAR_OFF:
1622 wps_data->viewports[0].vp.y = 0; 1638 curr_vp->vp.y = 0;
1623 break; 1639 break;
1624 case STATUSBAR_TOP: 1640 case STATUSBAR_TOP:
1625 wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT; 1641 curr_vp->vp.y = STATUSBAR_HEIGHT;
1626 wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT; 1642 curr_vp->vp.height -= STATUSBAR_HEIGHT;
1627 break; 1643 break;
1628 case STATUSBAR_BOTTOM: 1644 case STATUSBAR_BOTTOM:
1629 wps_data->viewports[0].vp.y = 0; 1645 curr_vp->vp.y = 0;
1630 wps_data->viewports[0].vp.height -= STATUSBAR_HEIGHT; 1646 curr_vp->vp.height -= STATUSBAR_HEIGHT;
1631 break; 1647 break;
1632 } 1648 }
1633#ifdef HAVE_LCD_BITMAP 1649#ifdef HAVE_LCD_BITMAP
1634 wps_data->viewports[0].vp.font = FONT_UI; 1650 curr_vp->vp.font = FONT_UI;
1635 wps_data->viewports[0].vp.drawmode = DRMODE_SOLID; 1651 curr_vp->vp.drawmode = DRMODE_SOLID;
1636#endif 1652#endif
1637#if LCD_DEPTH > 1 1653#if LCD_DEPTH > 1
1638 if (display->depth > 1) 1654 if (display->depth > 1)
1639 { 1655 {
1640 wps_data->viewports[0].vp.fg_pattern = display->get_foreground(); 1656 curr_vp->vp.fg_pattern = display->get_foreground();
1641 wps_data->viewports[0].vp.bg_pattern = display->get_background(); 1657 curr_vp->vp.bg_pattern = display->get_background();
1642 } 1658 }
1643#endif 1659#endif
1644 if (!isfile) 1660 if (!isfile)