mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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:
parent
be25469b9b
commit
58221fc38d
3 changed files with 12 additions and 10 deletions
|
@ -44,6 +44,10 @@
|
||||||
|
|
||||||
#define ICON_PADDING 1
|
#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 */
|
/* these are static to make scrolling work */
|
||||||
static struct viewport list_text[NB_SCREENS], title_text[NB_SCREENS];
|
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))
|
if (!list_display_title(list, screen))
|
||||||
return false;
|
return false;
|
||||||
*title_text_vp = *(list->parent[screen]);
|
*title_text_vp = *(list->parent[screen]);
|
||||||
|
UPDATE_RTL(title_text_vp);
|
||||||
title_text_vp->height = font_get(title_text_vp->font)->height;
|
title_text_vp->height = font_get(title_text_vp->font)->height;
|
||||||
|
|
||||||
if (list->title_icon != Icon_NOICON && global_settings.show_icons)
|
if (list->title_icon != Icon_NOICON && global_settings.show_icons)
|
||||||
{
|
{
|
||||||
struct viewport title_icon = *title_text_vp;
|
struct viewport title_icon = *title_text_vp;
|
||||||
|
|
||||||
|
UPDATE_RTL(&title_icon);
|
||||||
title_icon.width = get_icon_width(screen) + ICON_PADDING * 2;
|
title_icon.width = get_icon_width(screen) + ICON_PADDING * 2;
|
||||||
if (lang_is_rtl())
|
if (lang_is_rtl())
|
||||||
{
|
{
|
||||||
|
@ -132,6 +138,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
|
||||||
display->clear_viewport();
|
display->clear_viewport();
|
||||||
display->scroll_stop(list_text_vp);
|
display->scroll_stop(list_text_vp);
|
||||||
*list_text_vp = *parent;
|
*list_text_vp = *parent;
|
||||||
|
UPDATE_RTL(list_text_vp);
|
||||||
if ((show_title = draw_title(display, list)))
|
if ((show_title = draw_title(display, list)))
|
||||||
{
|
{
|
||||||
list_text_vp->y += line_height;
|
list_text_vp->y += line_height;
|
||||||
|
@ -172,6 +179,7 @@ void list_draw(struct screen *display, struct gui_synclist *list)
|
||||||
|
|
||||||
/* setup icon placement */
|
/* setup icon placement */
|
||||||
list_icons = *list_text_vp;
|
list_icons = *list_text_vp;
|
||||||
|
UPDATE_RTL(&list_icons);
|
||||||
int icon_count = global_settings.show_icons &&
|
int icon_count = global_settings.show_icons &&
|
||||||
(list->callback_get_item_icon != NULL) ? 1 : 0;
|
(list->callback_get_item_icon != NULL) ? 1 : 0;
|
||||||
if (show_cursor)
|
if (show_cursor)
|
||||||
|
|
|
@ -27,15 +27,6 @@
|
||||||
* KIND, either express or implied.
|
* 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. */
|
#ifndef LCDFN /* Not compiling for remote - define macros for main LCD. */
|
||||||
#define LCDFN(fn) lcd_ ## fn
|
#define LCDFN(fn) lcd_ ## fn
|
||||||
#define FBFN(fn) fb_ ## 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);
|
chars_in_str = utf8length((char *)str);
|
||||||
LCDFN(getstringsize)(str, &w, &h);
|
LCDFN(getstringsize)(str, &w, &h);
|
||||||
xpos = x * w / chars_in_str;
|
xpos = x * w / chars_in_str;
|
||||||
if (lang_is_rtl())
|
if (current_vp->flags & VP_IS_RTL)
|
||||||
xpos = current_vp->width - w - xpos;
|
xpos = current_vp->width - w - xpos;
|
||||||
ypos = y * h;
|
ypos = y * h;
|
||||||
LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, offset);
|
LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, offset);
|
||||||
|
|
|
@ -26,12 +26,15 @@
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#define VP_IS_RTL 0x01
|
||||||
|
|
||||||
struct viewport {
|
struct viewport {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
int flags;
|
||||||
int font;
|
int font;
|
||||||
int drawmode;
|
int drawmode;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue