summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2009-10-05 11:43:38 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2009-10-05 11:43:38 +0000
commit6d80565b1b5277820593de80bf036304be93c8ef (patch)
tree230b2d57d96190430c757cd98534db290c95bd3e /apps
parentf06c98fec82e8c800e09603f3022676dbbfdd84b (diff)
downloadrockbox-6d80565b1b5277820593de80bf036304be93c8ef.tar.gz
rockbox-6d80565b1b5277820593de80bf036304be93c8ef.tar.bz2
rockbox-6d80565b1b5277820593de80bf036304be93c8ef.zip
RTL support in menus
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22945 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/bitmap/list.c31
-rw-r--r--apps/gui/icon.c3
-rw-r--r--apps/lang/arabic.lang3
-rw-r--r--apps/lang/english.lang51
-rw-r--r--apps/lang/hebrew.lang4
-rw-r--r--apps/language.c13
-rw-r--r--apps/language.h2
-rw-r--r--apps/settings.h2
-rw-r--r--apps/settings_list.c5
9 files changed, 100 insertions, 14 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 94870538d6..ff29397532 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -40,6 +40,7 @@
#include "sound.h"
#include "misc.h"
#include "viewport.h"
+#include "language.h"
#define ICON_PADDING 1
@@ -61,6 +62,9 @@ bool list_display_title(struct gui_synclist *list, enum screen_type screen);
| | | items | I - icons
| | | |
------------------
+
+ Note: This image is flipped horizontally when the language is a
+ right-to-left one (Hebrew, Arabic)
*/
static bool draw_title(struct screen *display, struct gui_synclist *list)
{
@@ -77,10 +81,17 @@ static bool draw_title(struct screen *display, struct gui_synclist *list)
struct viewport title_icon = title_text[screen];
title_icon.width = get_icon_width(screen)
+ ICON_PADDING*2;
- title_icon.x += ICON_PADDING;
-
+ if (lang_is_rtl())
+ {
+ title_icon.x = title_text[screen].width - ICON_PADDING -
+ get_icon_width(screen);
+ }
+ else
+ {
+ title_icon.x = ICON_PADDING;
+ title_text[screen].x += title_icon.width;
+ }
title_text[screen].width -= title_icon.width;
- title_text[screen].x += title_icon.width;
display->set_viewport(&title_icon);
screen_put_icon(display, 0, 0, list->title_icon);
@@ -108,7 +119,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
#ifdef HAVE_LCD_COLOR
unsigned char cur_line = 0;
#endif
- int item_offset;
+ int item_offset, is_rtl = lang_is_rtl();
bool show_title;
line_height = font_get(parent->font)->height;
display->set_viewport(parent);
@@ -132,12 +143,12 @@ void list_draw(struct screen *display, struct gui_synclist *list)
vp = list_text[screen];
vp.width = SCROLLBAR_WIDTH;
list_text[screen].width -= SCROLLBAR_WIDTH;
- if(global_settings.scrollbar == SCROLLBAR_LEFT)
+ if (global_settings.scrollbar == SCROLLBAR_SHOW)
list_text[screen].x += SCROLLBAR_WIDTH;
vp.height = line_height *
viewport_get_nb_lines(&list_text[screen]);
vp.x = parent->x;
- if(global_settings.scrollbar == SCROLLBAR_RIGHT)
+ if (global_settings.scrollbar == SCROLLBAR_SHOW_OPPOSITE)
vp.x += list_text[screen].width;
display->set_viewport(&vp);
gui_scrollbar_draw(display, 0, 0, SCROLLBAR_WIDTH-1,
@@ -149,7 +160,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
else if (show_title)
{
/* shift everything right a bit... */
- if(global_settings.scrollbar == SCROLLBAR_LEFT)
+ if (global_settings.scrollbar == SCROLLBAR_SHOW)
{
list_text[screen].width -= SCROLLBAR_WIDTH;
list_text[screen].x += SCROLLBAR_WIDTH;
@@ -167,8 +178,10 @@ void list_draw(struct screen *display, struct gui_synclist *list)
list_icons.width = icon_width * icon_count;
list_text[screen].width -=
list_icons.width + ICON_PADDING;
- list_text[screen].x +=
- list_icons.width + ICON_PADDING;
+ if (is_rtl)
+ list_icons.x += list_text[screen].width;
+ else
+ list_text[screen].x += list_icons.width + ICON_PADDING;
}
for (i=start; i<end && i<list->nb_items; i++)
diff --git a/apps/gui/icon.c b/apps/gui/icon.c
index 53cfd87774..a473c82872 100644
--- a/apps/gui/icon.c
+++ b/apps/gui/icon.c
@@ -29,6 +29,7 @@
#include "settings.h"
#include "bmp.h"
#include "filetypes.h"
+#include "language.h"
#include "bitmaps/default_icons.h"
#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
@@ -170,6 +171,8 @@ void screen_put_iconxy(struct screen * display,
#endif
draw_func = display->bitmap_part;
+ if (lang_is_rtl())
+ xpos = display->getwidth() - xpos - width;
draw_func(data, 0, height * icon, stride, xpos, ypos, width, height);
}
diff --git a/apps/lang/arabic.lang b/apps/lang/arabic.lang
index c06af35560..73a98fe906 100644
--- a/apps/lang/arabic.lang
+++ b/apps/lang/arabic.lang
@@ -17,6 +17,9 @@
# Arabic language file, translated by:
# - Mohamed Tarek
# - Raafat Akkad
+<options>
+ rtl: 1
+</options>
<phrase>
id: LANG_EQUALIZER_HARDWARE_BANDWIDTH_NARROW
desc: deprecated
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 8be7380225..d34b2e9b32 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -13075,3 +13075,54 @@
swcodec: "Release Time"
</voice>
</phrase>
+<phrase>
+ id: LANG_HIDE
+ desc: in Settings -> General -> Display -> Status-/Scrollbar -> Scrollbar
+ user: core
+ <source>
+ *: none
+ lcd_bitmap: "Hide"
+ </source>
+ <dest>
+ *: none
+ lcd_bitmap: "Hide"
+ </dest>
+ <voice>
+ *: none
+ lcd_bitmap: "Hide"
+ </voice>
+</phrase>
+<phrase>
+ id: LANG_SHOW
+ desc: in Settings -> General -> Display -> Status-/Scrollbar -> Scrollbar
+ user: core
+ <source>
+ *: none
+ lcd_bitmap: "Show"
+ </source>
+ <dest>
+ *: none
+ lcd_bitmap: "Show"
+ </dest>
+ <voice>
+ *: none
+ lcd_bitmap: "Show"
+ </voice>
+</phrase>
+<phrase>
+ id: LANG_SHOW_OPPOSITE
+ desc: in Settings -> General -> Display -> Status-/Scrollbar -> Scrollbar
+ user: core
+ <source>
+ *: none
+ lcd_bitmap: "Show Opposite"
+ </source>
+ <dest>
+ *: none
+ lcd_bitmap: "Show Opposite"
+ </dest>
+ <voice>
+ *: none
+ lcd_bitmap: "Show Opposite"
+ </voice>
+</phrase>
diff --git a/apps/lang/hebrew.lang b/apps/lang/hebrew.lang
index 76deb4d007..449bbfe0a0 100644
--- a/apps/lang/hebrew.lang
+++ b/apps/lang/hebrew.lang
@@ -20,6 +20,10 @@
# - Rani Hod
# - Tomer Shalev
# - Sasha Khamkov
+
+<options>
+ rtl: 1
+</options>
<phrase>
id: LANG_SET_BOOL_YES
desc: bool true representation
diff --git a/apps/language.c b/apps/language.c
index bba1359616..0c6245f08c 100644
--- a/apps/language.c
+++ b/apps/language.c
@@ -34,9 +34,10 @@
/* These defines must match the initial bytes in the binary lang file */
/* See tools/genlang (TODO: Use common include for both) */
#define LANGUAGE_COOKIE 0x1a
-#define LANGUAGE_VERSION 0x04
+#define LANGUAGE_VERSION 0x05
+#define LANGUAGE_FLAG_RTL 0x01
-#define HEADER_SIZE 3
+#define HEADER_SIZE 4
static unsigned char language_buffer[MAX_LANGUAGE_SIZE];
@@ -51,6 +52,13 @@ void lang_init(void)
}
}
+static unsigned char lang_options = 0;
+
+int lang_is_rtl(void)
+{
+ return (lang_options & LANGUAGE_FLAG_RTL) != 0;
+}
+
int lang_load(const char *filename)
{
int fsize;
@@ -98,6 +106,7 @@ int lang_load(const char *filename)
retcode = 3;
}
close(fd);
+ lang_options = (retcode ? 0 : lang_header[3]);
return retcode;
}
diff --git a/apps/language.h b/apps/language.h
index 06769a3dd9..c2a1b70e18 100644
--- a/apps/language.h
+++ b/apps/language.h
@@ -30,4 +30,6 @@ int lang_load(const char *filename);
/* get the ID of an english string so it can be localised */
int lang_english_to_id(const char* english);
+/* returns whether the loaded language is a right-to-left language */
+int lang_is_rtl(void);
#endif
diff --git a/apps/settings.h b/apps/settings.h
index b208ee5872..b64fe37c74 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -158,7 +158,7 @@ enum { REPLAYGAIN_TRACK = 0, REPLAYGAIN_ALBUM, REPLAYGAIN_SHUFFLE, REPLAYGAIN_OF
enum { SHOW_PATH_OFF = 0, SHOW_PATH_CURRENT, SHOW_PATH_FULL };
/* scrollbar visibility/position */
-enum { SCROLLBAR_OFF = 0, SCROLLBAR_LEFT, SCROLLBAR_RIGHT };
+enum { SCROLLBAR_HIDE = 0, SCROLLBAR_SHOW, SCROLLBAR_SHOW_OPPOSITE };
/* Alarm settings */
#ifdef HAVE_RTC_ALARM
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 62a9351782..d76c2deb69 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -641,8 +641,9 @@ const struct settings_list settings[] = {
ID2P(LANG_STATUSBAR_BOTTOM)),
#endif
CHOICE_SETTING(F_THEMESETTING|F_TEMPVAR, scrollbar,
- LANG_SCROLL_BAR, SCROLLBAR_LEFT, "scrollbar","off,left,right",
- NULL, 3, ID2P(LANG_OFF), ID2P(LANG_LEFT), ID2P(LANG_RIGHT)),
+ LANG_SCROLL_BAR, SCROLLBAR_SHOW,
+ "scrollbar","hide,show,show_opposite", NULL, 3,
+ ID2P(LANG_HIDE), ID2P(LANG_SHOW), ID2P(LANG_SHOW_OPPOSITE)),
INT_SETTING(F_THEMESETTING, scrollbar_width, LANG_SCROLLBAR_WIDTH, 6,
"scrollbar width",UNIT_INT, 3, MAX(LCD_WIDTH/10,25), 1,
NULL, NULL, NULL),