diff options
Diffstat (limited to 'apps/gui/skin_engine/skin_parser.c')
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 136 |
1 files changed, 67 insertions, 69 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 59499d7c98..e2f7f5363c 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -156,7 +156,7 @@ static int parse_image_special(const char *wps_bufptr, | |||
156 | #ifdef HAVE_ALBUMART | 156 | #ifdef HAVE_ALBUMART |
157 | static int parse_albumart_load(const char *wps_bufptr, | 157 | static int parse_albumart_load(const char *wps_bufptr, |
158 | struct wps_token *token, struct wps_data *wps_data); | 158 | struct wps_token *token, struct wps_data *wps_data); |
159 | static int parse_albumart_conditional(const char *wps_bufptr, | 159 | static int parse_albumart_display(const char *wps_bufptr, |
160 | struct wps_token *token, struct wps_data *wps_data); | 160 | struct wps_token *token, struct wps_data *wps_data); |
161 | #endif /* HAVE_ALBUMART */ | 161 | #endif /* HAVE_ALBUMART */ |
162 | #ifdef HAVE_TOUCHSCREEN | 162 | #ifdef HAVE_TOUCHSCREEN |
@@ -337,8 +337,7 @@ static const struct wps_tag all_tags[] = { | |||
337 | { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, | 337 | { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, |
338 | #ifdef HAVE_ALBUMART | 338 | #ifdef HAVE_ALBUMART |
339 | { WPS_NO_TOKEN, "Cl", 0, parse_albumart_load }, | 339 | { WPS_NO_TOKEN, "Cl", 0, parse_albumart_load }, |
340 | { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC, | 340 | { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC, parse_albumart_display }, |
341 | parse_albumart_conditional }, | ||
342 | #endif | 341 | #endif |
343 | 342 | ||
344 | { WPS_VIEWPORT_ENABLE, "Vd", WPS_REFRESH_DYNAMIC, | 343 | { WPS_VIEWPORT_ENABLE, "Vd", WPS_REFRESH_DYNAMIC, |
@@ -960,13 +959,17 @@ static int parse_albumart_load(const char *wps_bufptr, | |||
960 | { | 959 | { |
961 | const char *_pos, *newline; | 960 | const char *_pos, *newline; |
962 | bool parsing; | 961 | bool parsing; |
962 | struct skin_albumart *aa = skin_buffer_alloc(sizeof(struct skin_albumart)); | ||
963 | (void)token; /* silence warning */ | 963 | (void)token; /* silence warning */ |
964 | if (!aa) | ||
965 | return skip_end_of_line(wps_bufptr); | ||
964 | 966 | ||
965 | /* reset albumart info in wps */ | 967 | /* reset albumart info in wps */ |
966 | wps_data->albumart_max_width = -1; | 968 | aa->albumart_max_width = -1; |
967 | wps_data->albumart_max_height = -1; | 969 | aa->albumart_max_height = -1; |
968 | wps_data->albumart_xalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ | 970 | aa->albumart_xalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ |
969 | wps_data->albumart_yalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ | 971 | aa->albumart_yalign = WPS_ALBUMART_ALIGN_CENTER; /* default */ |
972 | aa->vp = &curr_vp->vp; | ||
970 | 973 | ||
971 | /* format: %Cl|x|y|[[l|c|r]mwidth]|[[t|c|b]mheight]| */ | 974 | /* format: %Cl|x|y|[[l|c|r]mwidth]|[[t|c|b]mheight]| */ |
972 | 975 | ||
@@ -979,13 +982,13 @@ static int parse_albumart_load(const char *wps_bufptr, | |||
979 | _pos = wps_bufptr + 1; | 982 | _pos = wps_bufptr + 1; |
980 | if (!isdigit(*_pos)) | 983 | if (!isdigit(*_pos)) |
981 | return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl|@ */ | 984 | return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl|@ */ |
982 | wps_data->albumart_x = atoi(_pos); | 985 | aa->albumart_x = atoi(_pos); |
983 | 986 | ||
984 | _pos = strchr(_pos, '|'); | 987 | _pos = strchr(_pos, '|'); |
985 | if (!_pos || _pos > newline || !isdigit(*(++_pos))) | 988 | if (!_pos || _pos > newline || !isdigit(*(++_pos))) |
986 | return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl|7\n or %Cl|7|@ */ | 989 | return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl|7\n or %Cl|7|@ */ |
987 | 990 | ||
988 | wps_data->albumart_y = atoi(_pos); | 991 | aa->albumart_y = atoi(_pos); |
989 | 992 | ||
990 | _pos = strchr(_pos, '|'); | 993 | _pos = strchr(_pos, '|'); |
991 | if (!_pos || _pos > newline) | 994 | if (!_pos || _pos > newline) |
@@ -1003,16 +1006,16 @@ static int parse_albumart_load(const char *wps_bufptr, | |||
1003 | case 'l': | 1006 | case 'l': |
1004 | case 'L': | 1007 | case 'L': |
1005 | case '+': | 1008 | case '+': |
1006 | wps_data->albumart_xalign = WPS_ALBUMART_ALIGN_LEFT; | 1009 | aa->albumart_xalign = WPS_ALBUMART_ALIGN_LEFT; |
1007 | break; | 1010 | break; |
1008 | case 'c': | 1011 | case 'c': |
1009 | case 'C': | 1012 | case 'C': |
1010 | wps_data->albumart_xalign = WPS_ALBUMART_ALIGN_CENTER; | 1013 | aa->albumart_xalign = WPS_ALBUMART_ALIGN_CENTER; |
1011 | break; | 1014 | break; |
1012 | case 'r': | 1015 | case 'r': |
1013 | case 'R': | 1016 | case 'R': |
1014 | case '-': | 1017 | case '-': |
1015 | wps_data->albumart_xalign = WPS_ALBUMART_ALIGN_RIGHT; | 1018 | aa->albumart_xalign = WPS_ALBUMART_ALIGN_RIGHT; |
1016 | break; | 1019 | break; |
1017 | case 'd': | 1020 | case 'd': |
1018 | case 'D': | 1021 | case 'D': |
@@ -1033,7 +1036,7 @@ static int parse_albumart_load(const char *wps_bufptr, | |||
1033 | if (!isdigit(*_pos)) /* malformed token: e.g. %Cl|7|59|# */ | 1036 | if (!isdigit(*_pos)) /* malformed token: e.g. %Cl|7|59|# */ |
1034 | return WPS_ERROR_INVALID_PARAM; | 1037 | return WPS_ERROR_INVALID_PARAM; |
1035 | 1038 | ||
1036 | wps_data->albumart_max_width = atoi(_pos); | 1039 | aa->albumart_max_width = atoi(_pos); |
1037 | 1040 | ||
1038 | _pos = strchr(_pos, '|'); | 1041 | _pos = strchr(_pos, '|'); |
1039 | if (!_pos || _pos > newline) | 1042 | if (!_pos || _pos > newline) |
@@ -1052,16 +1055,16 @@ static int parse_albumart_load(const char *wps_bufptr, | |||
1052 | case 't': | 1055 | case 't': |
1053 | case 'T': | 1056 | case 'T': |
1054 | case '-': | 1057 | case '-': |
1055 | wps_data->albumart_yalign = WPS_ALBUMART_ALIGN_TOP; | 1058 | aa->albumart_yalign = WPS_ALBUMART_ALIGN_TOP; |
1056 | break; | 1059 | break; |
1057 | case 'c': | 1060 | case 'c': |
1058 | case 'C': | 1061 | case 'C': |
1059 | wps_data->albumart_yalign = WPS_ALBUMART_ALIGN_CENTER; | 1062 | aa->albumart_yalign = WPS_ALBUMART_ALIGN_CENTER; |
1060 | break; | 1063 | break; |
1061 | case 'b': | 1064 | case 'b': |
1062 | case 'B': | 1065 | case 'B': |
1063 | case '+': | 1066 | case '+': |
1064 | wps_data->albumart_yalign = WPS_ALBUMART_ALIGN_BOTTOM; | 1067 | aa->albumart_yalign = WPS_ALBUMART_ALIGN_BOTTOM; |
1065 | break; | 1068 | break; |
1066 | case 'd': | 1069 | case 'd': |
1067 | case 'D': | 1070 | case 'D': |
@@ -1082,7 +1085,7 @@ static int parse_albumart_load(const char *wps_bufptr, | |||
1082 | if (!isdigit(*_pos)) | 1085 | if (!isdigit(*_pos)) |
1083 | return WPS_ERROR_INVALID_PARAM; /* malformed token e.g. %Cl|7|59|200|@ */ | 1086 | return WPS_ERROR_INVALID_PARAM; /* malformed token e.g. %Cl|7|59|200|@ */ |
1084 | 1087 | ||
1085 | wps_data->albumart_max_height = atoi(_pos); | 1088 | aa->albumart_max_height = atoi(_pos); |
1086 | 1089 | ||
1087 | _pos = strchr(_pos, '|'); | 1090 | _pos = strchr(_pos, '|'); |
1088 | if (!_pos || _pos > newline) | 1091 | if (!_pos || _pos > newline) |
@@ -1091,54 +1094,41 @@ static int parse_albumart_load(const char *wps_bufptr, | |||
1091 | } | 1094 | } |
1092 | 1095 | ||
1093 | /* if we got here, we parsed everything ok .. ! */ | 1096 | /* if we got here, we parsed everything ok .. ! */ |
1094 | if (wps_data->albumart_max_width < 0) | 1097 | if (aa->albumart_max_width < 0) |
1095 | wps_data->albumart_max_width = 0; | 1098 | aa->albumart_max_width = 0; |
1096 | else if (wps_data->albumart_max_width > LCD_WIDTH) | 1099 | else if (aa->albumart_max_width > LCD_WIDTH) |
1097 | wps_data->albumart_max_width = LCD_WIDTH; | 1100 | aa->albumart_max_width = LCD_WIDTH; |
1098 | 1101 | ||
1099 | if (wps_data->albumart_max_height < 0) | 1102 | if (aa->albumart_max_height < 0) |
1100 | wps_data->albumart_max_height = 0; | 1103 | aa->albumart_max_height = 0; |
1101 | else if (wps_data->albumart_max_height > LCD_HEIGHT) | 1104 | else if (aa->albumart_max_height > LCD_HEIGHT) |
1102 | wps_data->albumart_max_height = LCD_HEIGHT; | 1105 | aa->albumart_max_height = LCD_HEIGHT; |
1103 | 1106 | ||
1104 | wps_data->wps_uses_albumart = WPS_ALBUMART_LOAD; | 1107 | aa->wps_uses_albumart = WPS_ALBUMART_LOAD; |
1108 | aa->draw = false; | ||
1109 | wps_data->albumart = aa; | ||
1105 | 1110 | ||
1106 | /* Skip the rest of the line */ | 1111 | /* Skip the rest of the line */ |
1107 | return skip_end_of_line(wps_bufptr); | 1112 | return skip_end_of_line(wps_bufptr); |
1108 | } | 1113 | } |
1109 | 1114 | ||
1110 | static int parse_albumart_conditional(const char *wps_bufptr, | 1115 | static int parse_albumart_display(const char *wps_bufptr, |
1111 | struct wps_token *token, | 1116 | struct wps_token *token, |
1112 | struct wps_data *wps_data) | 1117 | struct wps_data *wps_data) |
1113 | { | 1118 | { |
1114 | struct wps_token *prevtoken = token; | 1119 | (void)wps_bufptr; |
1115 | --prevtoken; | 1120 | (void)token; |
1116 | if (wps_data->num_tokens >= 1 && prevtoken->type == WPS_TOKEN_CONDITIONAL) | 1121 | if (wps_data->albumart) |
1117 | { | ||
1118 | /* This %C is part of a %?C construct. | ||
1119 | It's either %?C<blah> or %?Cn<blah> */ | ||
1120 | token->type = WPS_TOKEN_ALBUMART_FOUND; | ||
1121 | if (*wps_bufptr == 'n' && *(wps_bufptr + 1) == '<') | ||
1122 | { | ||
1123 | token->next = true; | ||
1124 | return 1; | ||
1125 | } | ||
1126 | else if (*wps_bufptr == '<') | ||
1127 | { | ||
1128 | return 0; | ||
1129 | } | ||
1130 | else | ||
1131 | { | ||
1132 | token->type = WPS_NO_TOKEN; | ||
1133 | return 0; | ||
1134 | } | ||
1135 | } | ||
1136 | else | ||
1137 | { | 1122 | { |
1138 | /* This %C tag is in a conditional construct. */ | 1123 | wps_data->albumart->vp = &curr_vp->vp; |
1139 | wps_data->albumart_cond_index = condindex[level]; | ||
1140 | return 0; | ||
1141 | } | 1124 | } |
1125 | #if 0 | ||
1126 | /* the old code did this so keep it here for now... | ||
1127 | * this is to allow the posibility to showing the next tracks AA! */ | ||
1128 | if (wps_bufptr+1 == 'n') | ||
1129 | return 1; | ||
1130 | #endif | ||
1131 | return 0; | ||
1142 | }; | 1132 | }; |
1143 | #endif /* HAVE_ALBUMART */ | 1133 | #endif /* HAVE_ALBUMART */ |
1144 | 1134 | ||
@@ -1675,16 +1665,21 @@ bool skin_data_load(struct wps_data *wps_data, | |||
1675 | const char *buf, | 1665 | const char *buf, |
1676 | bool isfile) | 1666 | bool isfile) |
1677 | { | 1667 | { |
1668 | |||
1669 | if (!wps_data || !buf) | ||
1670 | return false; | ||
1678 | #ifdef HAVE_ALBUMART | 1671 | #ifdef HAVE_ALBUMART |
1672 | int status; | ||
1679 | struct mp3entry *curtrack; | 1673 | struct mp3entry *curtrack; |
1680 | long offset; | 1674 | long offset; |
1681 | int status; | 1675 | struct skin_albumart old_aa = {.wps_uses_albumart = WPS_ALBUMART_NONE}; |
1682 | int wps_uses_albumart = wps_data->wps_uses_albumart; | 1676 | if (wps_data->albumart) |
1683 | int albumart_max_height = wps_data->albumart_max_height; | 1677 | { |
1684 | int albumart_max_width = wps_data->albumart_max_width; | 1678 | old_aa.wps_uses_albumart = wps_data->albumart->wps_uses_albumart; |
1679 | old_aa.albumart_max_height = wps_data->albumart->albumart_max_height; | ||
1680 | old_aa.albumart_max_width = wps_data->albumart->albumart_max_width; | ||
1681 | } | ||
1685 | #endif | 1682 | #endif |
1686 | if (!wps_data || !buf) | ||
1687 | return false; | ||
1688 | 1683 | ||
1689 | wps_reset(wps_data); | 1684 | wps_reset(wps_data); |
1690 | 1685 | ||
@@ -1799,17 +1794,20 @@ bool skin_data_load(struct wps_data *wps_data, | |||
1799 | #endif | 1794 | #endif |
1800 | #ifdef HAVE_ALBUMART | 1795 | #ifdef HAVE_ALBUMART |
1801 | status = audio_status(); | 1796 | status = audio_status(); |
1802 | if (((!wps_uses_albumart && wps_data->wps_uses_albumart) || | 1797 | if (status & AUDIO_STATUS_PLAY) |
1803 | (wps_data->wps_uses_albumart && | ||
1804 | (albumart_max_height != wps_data->albumart_max_height || | ||
1805 | albumart_max_width != wps_data->albumart_max_width))) && | ||
1806 | status & AUDIO_STATUS_PLAY) | ||
1807 | { | 1798 | { |
1808 | curtrack = audio_current_track(); | 1799 | struct skin_albumart *aa = wps_data->albumart; |
1809 | offset = curtrack->offset; | 1800 | if (aa && ((aa->wps_uses_albumart && !old_aa.wps_uses_albumart) || |
1810 | audio_stop(); | 1801 | (aa->wps_uses_albumart && |
1811 | if (!(status & AUDIO_STATUS_PAUSE)) | 1802 | (((old_aa.albumart_max_height != aa->albumart_max_height) || |
1812 | audio_play(offset); | 1803 | (old_aa.albumart_max_width != aa->albumart_max_width)))))) |
1804 | { | ||
1805 | curtrack = audio_current_track(); | ||
1806 | offset = curtrack->offset; | ||
1807 | audio_stop(); | ||
1808 | if (!(status & AUDIO_STATUS_PAUSE)) | ||
1809 | audio_play(offset); | ||
1810 | } | ||
1813 | } | 1811 | } |
1814 | #endif | 1812 | #endif |
1815 | #if defined(DEBUG) || defined(SIMULATOR) | 1813 | #if defined(DEBUG) || defined(SIMULATOR) |