From 58221fc38d6cc64d14ed6ac60642562baccb29c6 Mon Sep 17 00:00:00 2001 From: Tomer Shalev Date: Mon, 5 Oct 2009 20:22:02 +0000 Subject: Implement RTL as a viewport's bit-field git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22968 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/bitmap/list.c | 8 ++++++++ firmware/drivers/lcd-bitmap-common.c | 11 +---------- firmware/export/lcd.h | 3 +++ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index 44587cd378..953ce1b1d7 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -44,6 +44,10 @@ #define ICON_PADDING 1 +#define UPDATE_RTL(vp) \ + (vp)->flags &= ~VP_IS_RTL; \ + (vp)->flags |= lang_is_rtl() ? VP_IS_RTL : 0; + /* these are static to make scrolling work */ static struct viewport list_text[NB_SCREENS], title_text[NB_SCREENS]; @@ -76,12 +80,14 @@ static bool draw_title(struct screen *display, struct gui_synclist *list) if (!list_display_title(list, screen)) return false; *title_text_vp = *(list->parent[screen]); + UPDATE_RTL(title_text_vp); title_text_vp->height = font_get(title_text_vp->font)->height; if (list->title_icon != Icon_NOICON && global_settings.show_icons) { struct viewport title_icon = *title_text_vp; + UPDATE_RTL(&title_icon); title_icon.width = get_icon_width(screen) + ICON_PADDING * 2; if (lang_is_rtl()) { @@ -132,6 +138,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) display->clear_viewport(); display->scroll_stop(list_text_vp); *list_text_vp = *parent; + UPDATE_RTL(list_text_vp); if ((show_title = draw_title(display, list))) { list_text_vp->y += line_height; @@ -172,6 +179,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) /* setup icon placement */ list_icons = *list_text_vp; + UPDATE_RTL(&list_icons); int icon_count = global_settings.show_icons && (list->callback_get_item_icon != NULL) ? 1 : 0; if (show_cursor) diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 1e2765f34f..0dafe092fc 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c @@ -27,15 +27,6 @@ * KIND, either express or implied. * ****************************************************************************/ -#ifdef BOOTLOADER -static int lang_is_rtl(void) -{ - return 0; -} -#else -#include "language.h" -#endif - #ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */ #define LCDFN(fn) lcd_ ## fn #define FBFN(fn) fb_ ## fn @@ -186,7 +177,7 @@ void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, chars_in_str = utf8length((char *)str); LCDFN(getstringsize)(str, &w, &h); xpos = x * w / chars_in_str; - if (lang_is_rtl()) + if (current_vp->flags & VP_IS_RTL) xpos = current_vp->width - w - xpos; ypos = y * h; LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, offset); diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index a8253db656..ddfba2a8ac 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -26,12 +26,15 @@ #include "cpu.h" #include "config.h" +#define VP_IS_RTL 0x01 + struct viewport { int x; int y; int width; int height; #ifdef HAVE_LCD_BITMAP + int flags; int font; int drawmode; #endif -- cgit v1.2.3