From a092b9ce923b3355868f0f7e99bf1d7cf2f83181 Mon Sep 17 00:00:00 2001 From: Tomer Shalev Date: Tue, 6 Oct 2009 08:07:30 +0000 Subject: Use macro to test viewport's RTL flag git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22978 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/bitmap/list.c | 11 +++++------ apps/gui/viewport.c | 4 ++-- firmware/drivers/lcd-bitmap-common.c | 2 +- firmware/export/lcd.h | 4 +++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index f0eb2ec160..986fcaea69 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -42,7 +42,6 @@ #include "viewport.h" #define ICON_PADDING 1 -#define IS_RTL(vp) (((vp)->flags & VP_IS_RTL) != 0) /* these are static to make scrolling work */ static struct viewport list_text[NB_SCREENS], title_text[NB_SCREENS]; @@ -83,7 +82,7 @@ static bool draw_title(struct screen *display, struct gui_synclist *list) struct viewport title_icon = *title_text_vp; title_icon.width = get_icon_width(screen) + ICON_PADDING * 2; - if (IS_RTL(&title_icon)) + if (VP_IS_RTL(&title_icon)) { title_icon.x = title_text_vp->width - title_icon.width; } @@ -155,19 +154,19 @@ void list_draw(struct screen *display, struct gui_synclist *list) else vp.x += list_text_vp->width; display->set_viewport(&vp); - gui_scrollbar_draw(display, IS_RTL(&vp) ? 1 : 0, 0, SCROLLBAR_WIDTH-1, vp.height, + gui_scrollbar_draw(display, VP_IS_RTL(&vp) ? 1 : 0, 0, SCROLLBAR_WIDTH-1, vp.height, list->nb_items, list_start_item, list_start_item + end-start, VERTICAL); } else if (show_title) { /* shift everything a bit in relation to the title... */ - if (!IS_RTL(list_text_vp) && scrollbar_in_left) + if (!VP_IS_RTL(list_text_vp) && scrollbar_in_left) { list_text_vp->width -= SCROLLBAR_WIDTH; list_text_vp->x += SCROLLBAR_WIDTH; } - else if (IS_RTL(list_text_vp) && !scrollbar_in_left) + else if (VP_IS_RTL(list_text_vp) && !scrollbar_in_left) { list_text_vp->width -= SCROLLBAR_WIDTH; } @@ -183,7 +182,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) { list_icons.width = icon_width * icon_count; list_text_vp->width -= list_icons.width + ICON_PADDING; - if (IS_RTL(&list_icons)) + if (VP_IS_RTL(&list_icons)) list_icons.x += list_text_vp->width + ICON_PADDING; else list_text_vp->x += list_icons.width + ICON_PADDING; diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index 1db1a810da..6e1541021d 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -151,8 +151,8 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen) viewport_set_fullscreen(vp, screen); #ifdef HAVE_LCD_BITMAP - vp->flags &= ~VP_IS_RTL; - vp->flags |= lang_is_rtl() ? VP_IS_RTL : 0; + vp->flags &= ~VP_FLAG_IS_RTL; + vp->flags |= lang_is_rtl() ? VP_FLAG_IS_RTL : 0; #endif } diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index 0dafe092fc..9d88eba3b2 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c @@ -177,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 (current_vp->flags & VP_IS_RTL) + if (VP_IS_RTL(current_vp)) 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 ddfba2a8ac..2c66b5f8b3 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -26,7 +26,9 @@ #include "cpu.h" #include "config.h" -#define VP_IS_RTL 0x01 +#define VP_FLAG_IS_RTL 0x01 + +#define VP_IS_RTL(vp) (((vp)->flags & VP_FLAG_IS_RTL) != 0) struct viewport { int x; -- cgit v1.2.3