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.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 568f9cb578..1e24762fee 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -89,6 +89,8 @@ static struct skin_viewport *curr_vp;
89/* the current line, linked to the above viewport */ 89/* the current line, linked to the above viewport */
90static struct skin_line *curr_line; 90static struct skin_line *curr_line;
91 91
92static int follow_lang_direction = 0;
93
92#ifdef HAVE_LCD_BITMAP 94#ifdef HAVE_LCD_BITMAP
93 95
94#if LCD_DEPTH > 1 96#if LCD_DEPTH > 1
@@ -140,6 +142,19 @@ static int parse_dir_level(const char *wps_bufptr,
140 struct wps_token *token, struct wps_data *wps_data); 142 struct wps_token *token, struct wps_data *wps_data);
141static int parse_setting_and_lang(const char *wps_bufptr, 143static int parse_setting_and_lang(const char *wps_bufptr,
142 struct wps_token *token, struct wps_data *wps_data); 144 struct wps_token *token, struct wps_data *wps_data);
145
146
147int parse_languagedirection(const char *wps_bufptr,
148 struct wps_token *token, struct wps_data *wps_data)
149{
150 (void)wps_bufptr;
151 (void)token;
152 (void)wps_data;
153 follow_lang_direction = 2; /* 2 because it is decremented immediatly after
154 this token is parsed, after the next token it
155 will be 0 again. */
156 return 0;
157}
143 158
144#ifdef HAVE_LCD_BITMAP 159#ifdef HAVE_LCD_BITMAP
145static int parse_viewport_display(const char *wps_bufptr, 160static int parse_viewport_display(const char *wps_bufptr,
@@ -189,7 +204,10 @@ static const struct wps_tag all_tags[] = {
189 204
190 { WPS_TOKEN_ALIGN_CENTER, "ac", 0, NULL }, 205 { WPS_TOKEN_ALIGN_CENTER, "ac", 0, NULL },
191 { WPS_TOKEN_ALIGN_LEFT, "al", 0, NULL }, 206 { WPS_TOKEN_ALIGN_LEFT, "al", 0, NULL },
207 { WPS_TOKEN_ALIGN_LEFT_RTL, "aL", 0, NULL },
192 { WPS_TOKEN_ALIGN_RIGHT, "ar", 0, NULL }, 208 { WPS_TOKEN_ALIGN_RIGHT, "ar", 0, NULL },
209 { WPS_TOKEN_ALIGN_RIGHT_RTL, "aR", 0, NULL },
210 { WPS_NO_TOKEN, "ax", 0, parse_languagedirection },
193 211
194 { WPS_TOKEN_BATTERY_PERCENT, "bl", WPS_REFRESH_DYNAMIC, NULL }, 212 { WPS_TOKEN_BATTERY_PERCENT, "bl", WPS_REFRESH_DYNAMIC, NULL },
195 { WPS_TOKEN_BATTERY_VOLTS, "bv", WPS_REFRESH_DYNAMIC, NULL }, 213 { WPS_TOKEN_BATTERY_VOLTS, "bv", WPS_REFRESH_DYNAMIC, NULL },
@@ -748,15 +766,22 @@ static int parse_viewport(const char *wps_bufptr,
748 ptr++; 766 ptr++;
749 struct viewport *vp = &skin_vp->vp; 767 struct viewport *vp = &skin_vp->vp;
750 /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */ 768 /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */
751
752 if (!(ptr = viewport_parse_viewport(vp, curr_screen, ptr, '|'))) 769 if (!(ptr = viewport_parse_viewport(vp, curr_screen, ptr, '|')))
753 return WPS_ERROR_INVALID_PARAM; 770 return WPS_ERROR_INVALID_PARAM;
754 771
755 vp->flags &= ~VP_FLAG_ALIGN_RIGHT; /* ignore right-to-left languages */
756 /* Check for trailing | */ 772 /* Check for trailing | */
757 if (*ptr != '|') 773 if (*ptr != '|')
758 return WPS_ERROR_INVALID_PARAM; 774 return WPS_ERROR_INVALID_PARAM;
759 775
776 if (follow_lang_direction && lang_is_rtl())
777 {
778 vp->flags |= VP_FLAG_ALIGN_RIGHT;
779 vp->x = screens[curr_screen].lcdwidth - vp->width - vp->x;
780 }
781 else
782 vp->flags &= ~VP_FLAG_ALIGN_RIGHT; /* ignore right-to-left languages */
783
784
760 785
761 struct skin_token_list *list = new_skin_token_list_item(NULL, skin_vp); 786 struct skin_token_list *list = new_skin_token_list_item(NULL, skin_vp);
762 if (!list) 787 if (!list)
@@ -954,6 +979,7 @@ static int parse_progressbar(const char *wps_bufptr,
954 } 979 }
955 pb->have_bitmap_pb = false; 980 pb->have_bitmap_pb = false;
956 pb->bm.data = NULL; /* no bitmap specified */ 981 pb->bm.data = NULL; /* no bitmap specified */
982 pb->follow_lang_direction = follow_lang_direction > 0;
957 983
958 if (*wps_bufptr != '|') /* regular old style */ 984 if (*wps_bufptr != '|') /* regular old style */
959 { 985 {
@@ -1041,6 +1067,7 @@ static int parse_albumart_load(const char *wps_bufptr,
1041 bool parsing; 1067 bool parsing;
1042 struct dim dimensions; 1068 struct dim dimensions;
1043 int albumart_slot; 1069 int albumart_slot;
1070 bool swap_for_rtl = lang_is_rtl() && follow_lang_direction;
1044 struct skin_albumart *aa = skin_buffer_alloc(sizeof(struct skin_albumart)); 1071 struct skin_albumart *aa = skin_buffer_alloc(sizeof(struct skin_albumart));
1045 (void)token; /* silence warning */ 1072 (void)token; /* silence warning */
1046 if (!aa) 1073 if (!aa)
@@ -1085,7 +1112,10 @@ static int parse_albumart_load(const char *wps_bufptr,
1085 case 'l': 1112 case 'l':
1086 case 'L': 1113 case 'L':
1087 case '+': 1114 case '+':
1088 aa->xalign = WPS_ALBUMART_ALIGN_LEFT; 1115 if (swap_for_rtl)
1116 aa->xalign = WPS_ALBUMART_ALIGN_RIGHT;
1117 else
1118 aa->xalign = WPS_ALBUMART_ALIGN_LEFT;
1089 break; 1119 break;
1090 case 'c': 1120 case 'c':
1091 case 'C': 1121 case 'C':
@@ -1094,7 +1124,10 @@ static int parse_albumart_load(const char *wps_bufptr,
1094 case 'r': 1124 case 'r':
1095 case 'R': 1125 case 'R':
1096 case '-': 1126 case '-':
1097 aa->xalign = WPS_ALBUMART_ALIGN_RIGHT; 1127 if (swap_for_rtl)
1128 aa->xalign = WPS_ALBUMART_ALIGN_LEFT;
1129 else
1130 aa->xalign = WPS_ALBUMART_ALIGN_RIGHT;
1098 break; 1131 break;
1099 case 'd': 1132 case 'd':
1100 case 'D': 1133 case 'D':
@@ -1168,6 +1201,9 @@ static int parse_albumart_load(const char *wps_bufptr,
1168 aa->height = 0; 1201 aa->height = 0;
1169 else if (aa->height > LCD_HEIGHT) 1202 else if (aa->height > LCD_HEIGHT)
1170 aa->height = LCD_HEIGHT; 1203 aa->height = LCD_HEIGHT;
1204
1205 if (swap_for_rtl)
1206 aa->x = LCD_WIDTH - (aa->x + aa->width);
1171 1207
1172 aa->state = WPS_ALBUMART_LOAD; 1208 aa->state = WPS_ALBUMART_LOAD;
1173 aa->draw = false; 1209 aa->draw = false;
@@ -1500,6 +1536,8 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
1500 1536
1501 while (*wps_bufptr && !fail) 1537 while (*wps_bufptr && !fail)
1502 { 1538 {
1539 if (follow_lang_direction)
1540 follow_lang_direction--;
1503 /* first make sure there is enough room for tokens */ 1541 /* first make sure there is enough room for tokens */
1504 if (max_tokens <= data->num_tokens + 5) 1542 if (max_tokens <= data->num_tokens + 5)
1505 { 1543 {