summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2009-10-06 08:07:30 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2009-10-06 08:07:30 +0000
commita092b9ce923b3355868f0f7e99bf1d7cf2f83181 (patch)
tree930c0ad1b518107538a3f2edbdcebf913a342465
parent8b6161b24b642ce6ac7e74218de1f64728f747f9 (diff)
downloadrockbox-a092b9ce923b3355868f0f7e99bf1d7cf2f83181.tar.gz
rockbox-a092b9ce923b3355868f0f7e99bf1d7cf2f83181.zip
Use macro to test viewport's RTL flag
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22978 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/bitmap/list.c11
-rw-r--r--apps/gui/viewport.c4
-rw-r--r--firmware/drivers/lcd-bitmap-common.c2
-rw-r--r--firmware/export/lcd.h4
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 @@
42#include "viewport.h" 42#include "viewport.h"
43 43
44#define ICON_PADDING 1 44#define ICON_PADDING 1
45#define IS_RTL(vp) (((vp)->flags & VP_IS_RTL) != 0)
46 45
47/* these are static to make scrolling work */ 46/* these are static to make scrolling work */
48static struct viewport list_text[NB_SCREENS], title_text[NB_SCREENS]; 47static 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)
83 struct viewport title_icon = *title_text_vp; 82 struct viewport title_icon = *title_text_vp;
84 83
85 title_icon.width = get_icon_width(screen) + ICON_PADDING * 2; 84 title_icon.width = get_icon_width(screen) + ICON_PADDING * 2;
86 if (IS_RTL(&title_icon)) 85 if (VP_IS_RTL(&title_icon))
87 { 86 {
88 title_icon.x = title_text_vp->width - title_icon.width; 87 title_icon.x = title_text_vp->width - title_icon.width;
89 } 88 }
@@ -155,19 +154,19 @@ void list_draw(struct screen *display, struct gui_synclist *list)
155 else 154 else
156 vp.x += list_text_vp->width; 155 vp.x += list_text_vp->width;
157 display->set_viewport(&vp); 156 display->set_viewport(&vp);
158 gui_scrollbar_draw(display, IS_RTL(&vp) ? 1 : 0, 0, SCROLLBAR_WIDTH-1, vp.height, 157 gui_scrollbar_draw(display, VP_IS_RTL(&vp) ? 1 : 0, 0, SCROLLBAR_WIDTH-1, vp.height,
159 list->nb_items, list_start_item, list_start_item + end-start, 158 list->nb_items, list_start_item, list_start_item + end-start,
160 VERTICAL); 159 VERTICAL);
161 } 160 }
162 else if (show_title) 161 else if (show_title)
163 { 162 {
164 /* shift everything a bit in relation to the title... */ 163 /* shift everything a bit in relation to the title... */
165 if (!IS_RTL(list_text_vp) && scrollbar_in_left) 164 if (!VP_IS_RTL(list_text_vp) && scrollbar_in_left)
166 { 165 {
167 list_text_vp->width -= SCROLLBAR_WIDTH; 166 list_text_vp->width -= SCROLLBAR_WIDTH;
168 list_text_vp->x += SCROLLBAR_WIDTH; 167 list_text_vp->x += SCROLLBAR_WIDTH;
169 } 168 }
170 else if (IS_RTL(list_text_vp) && !scrollbar_in_left) 169 else if (VP_IS_RTL(list_text_vp) && !scrollbar_in_left)
171 { 170 {
172 list_text_vp->width -= SCROLLBAR_WIDTH; 171 list_text_vp->width -= SCROLLBAR_WIDTH;
173 } 172 }
@@ -183,7 +182,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
183 { 182 {
184 list_icons.width = icon_width * icon_count; 183 list_icons.width = icon_width * icon_count;
185 list_text_vp->width -= list_icons.width + ICON_PADDING; 184 list_text_vp->width -= list_icons.width + ICON_PADDING;
186 if (IS_RTL(&list_icons)) 185 if (VP_IS_RTL(&list_icons))
187 list_icons.x += list_text_vp->width + ICON_PADDING; 186 list_icons.x += list_text_vp->width + ICON_PADDING;
188 else 187 else
189 list_text_vp->x += list_icons.width + ICON_PADDING; 188 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)
151 viewport_set_fullscreen(vp, screen); 151 viewport_set_fullscreen(vp, screen);
152 152
153#ifdef HAVE_LCD_BITMAP 153#ifdef HAVE_LCD_BITMAP
154 vp->flags &= ~VP_IS_RTL; 154 vp->flags &= ~VP_FLAG_IS_RTL;
155 vp->flags |= lang_is_rtl() ? VP_IS_RTL : 0; 155 vp->flags |= lang_is_rtl() ? VP_FLAG_IS_RTL : 0;
156#endif 156#endif
157} 157}
158 158
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,
177 chars_in_str = utf8length((char *)str); 177 chars_in_str = utf8length((char *)str);
178 LCDFN(getstringsize)(str, &w, &h); 178 LCDFN(getstringsize)(str, &w, &h);
179 xpos = x * w / chars_in_str; 179 xpos = x * w / chars_in_str;
180 if (current_vp->flags & VP_IS_RTL) 180 if (VP_IS_RTL(current_vp))
181 xpos = current_vp->width - w - xpos; 181 xpos = current_vp->width - w - xpos;
182 ypos = y * h; 182 ypos = y * h;
183 LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, offset); 183 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 @@
26#include "cpu.h" 26#include "cpu.h"
27#include "config.h" 27#include "config.h"
28 28
29#define VP_IS_RTL 0x01 29#define VP_FLAG_IS_RTL 0x01
30
31#define VP_IS_RTL(vp) (((vp)->flags & VP_FLAG_IS_RTL) != 0)
30 32
31struct viewport { 33struct viewport {
32 int x; 34 int x;