Implement RTL as a viewport's bit-field

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22968 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tomer Shalev 2009-10-05 20:22:02 +00:00
parent be25469b9b
commit 58221fc38d
3 changed files with 12 additions and 10 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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