summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/skin_engine')
-rw-r--r--apps/gui/skin_engine/skin_display.c11
-rw-r--r--apps/gui/skin_engine/skin_parser.c48
-rw-r--r--apps/gui/skin_engine/skin_tokens.h2
-rw-r--r--apps/gui/skin_engine/wps_internals.h1
4 files changed, 57 insertions, 5 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index ea2c794272..b8cc75e10a 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -31,6 +31,7 @@
31#endif 31#endif
32#include "abrepeat.h" 32#include "abrepeat.h"
33#include "lang.h" 33#include "lang.h"
34#include "language.h"
34#include "statusbar.h" 35#include "statusbar.h"
35#include "scrollbar.h" 36#include "scrollbar.h"
36#include "screen_access.h" 37#include "screen_access.h"
@@ -528,8 +529,10 @@ static bool get_line(struct gui_wps *gwps,
528#endif 529#endif
529 530
530 case WPS_TOKEN_ALIGN_LEFT: 531 case WPS_TOKEN_ALIGN_LEFT:
532 case WPS_TOKEN_ALIGN_LEFT_RTL:
531 case WPS_TOKEN_ALIGN_CENTER: 533 case WPS_TOKEN_ALIGN_CENTER:
532 case WPS_TOKEN_ALIGN_RIGHT: 534 case WPS_TOKEN_ALIGN_RIGHT:
535 case WPS_TOKEN_ALIGN_RIGHT_RTL:
533 /* remember where the current aligned text started */ 536 /* remember where the current aligned text started */
534 switch (cur_align) 537 switch (cur_align)
535 { 538 {
@@ -551,12 +554,20 @@ static bool get_line(struct gui_wps *gwps,
551 case WPS_TOKEN_ALIGN_LEFT: 554 case WPS_TOKEN_ALIGN_LEFT:
552 cur_align = WPS_ALIGN_LEFT; 555 cur_align = WPS_ALIGN_LEFT;
553 break; 556 break;
557 case WPS_TOKEN_ALIGN_LEFT_RTL:
558 cur_align = lang_is_rtl() ? WPS_ALIGN_RIGHT :
559 WPS_ALIGN_LEFT;
560 break;
554 case WPS_TOKEN_ALIGN_CENTER: 561 case WPS_TOKEN_ALIGN_CENTER:
555 cur_align = WPS_ALIGN_CENTER; 562 cur_align = WPS_ALIGN_CENTER;
556 break; 563 break;
557 case WPS_TOKEN_ALIGN_RIGHT: 564 case WPS_TOKEN_ALIGN_RIGHT:
558 cur_align = WPS_ALIGN_RIGHT; 565 cur_align = WPS_ALIGN_RIGHT;
559 break; 566 break;
567 case WPS_TOKEN_ALIGN_RIGHT_RTL:
568 cur_align = lang_is_rtl() ? WPS_ALIGN_LEFT :
569 WPS_ALIGN_RIGHT;
570 break;
560 default: 571 default:
561 break; 572 break;
562 } 573 }
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 {
diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h
index 547bc858f9..25acfdacef 100644
--- a/apps/gui/skin_engine/skin_tokens.h
+++ b/apps/gui/skin_engine/skin_tokens.h
@@ -38,8 +38,10 @@ enum wps_token_type {
38 38
39 /* Alignment */ 39 /* Alignment */
40 WPS_TOKEN_ALIGN_LEFT, 40 WPS_TOKEN_ALIGN_LEFT,
41 WPS_TOKEN_ALIGN_LEFT_RTL,
41 WPS_TOKEN_ALIGN_CENTER, 42 WPS_TOKEN_ALIGN_CENTER,
42 WPS_TOKEN_ALIGN_RIGHT, 43 WPS_TOKEN_ALIGN_RIGHT,
44 WPS_TOKEN_ALIGN_RIGHT_RTL,
43 45
44 /* Sublines */ 46 /* Sublines */
45 WPS_TOKEN_SUBLINE_TIMEOUT, 47 WPS_TOKEN_SUBLINE_TIMEOUT,
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index e975616f91..bd0c1c01c7 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -99,6 +99,7 @@ struct progressbar {
99 short y; 99 short y;
100 short width; 100 short width;
101 short height; 101 short height;
102 bool follow_lang_direction;
102 /*progressbar image*/ 103 /*progressbar image*/
103 struct bitmap bm; 104 struct bitmap bm;
104 bool have_bitmap_pb; 105 bool have_bitmap_pb;