reduce size of the instance of struct style_text in lib/display.h (thanks to Teruaki Kawashima)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21614 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
278f1f69bb
commit
bff790d692
2 changed files with 17 additions and 11 deletions
|
@ -35,14 +35,14 @@ bool display_text(short words, char** text, struct style_text* style,
|
|||
int prev_drawmode;
|
||||
#endif
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
unsigned standard_fgcolor;
|
||||
int standard_fgcolor;
|
||||
#endif
|
||||
int space_w, width, height;
|
||||
unsigned short x , y;
|
||||
unsigned short vp_width = LCD_WIDTH;
|
||||
unsigned short vp_height = LCD_HEIGHT;
|
||||
int button;
|
||||
short i=0;
|
||||
unsigned short i = 0, style_index = 0;
|
||||
if (vp_text != NULL) {
|
||||
vp_width = vp_text->width;
|
||||
vp_height = vp_text->height;
|
||||
|
@ -85,17 +85,17 @@ bool display_text(short words, char** text, struct style_text* style,
|
|||
|| ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
|
||||
rb->screens[SCREEN_MAIN]->clear_viewport();
|
||||
}
|
||||
/* no text formations available */
|
||||
if (style==NULL) {
|
||||
/* no text formatting available */
|
||||
if (style==NULL || style[style_index].index != i) {
|
||||
rb->lcd_putsxy(x, y, text[i]);
|
||||
} else {
|
||||
/* set align */
|
||||
if (style[i].flags&TEXT_CENTER) {
|
||||
if (style[style_index].flags&TEXT_CENTER) {
|
||||
x = (vp_width-width)/2;
|
||||
}
|
||||
/* set font color */
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
switch (style[i].flags&TEXT_COLOR_MASK) {
|
||||
switch (style[style_index].flags&TEXT_COLOR_MASK) {
|
||||
case C_RED:
|
||||
rb->lcd_set_foreground(LCD_RGBPACK(255,0,0));
|
||||
break;
|
||||
|
@ -118,11 +118,16 @@ bool display_text(short words, char** text, struct style_text* style,
|
|||
}
|
||||
#endif
|
||||
rb->lcd_putsxy(x, y, text[i]);
|
||||
/* underline the word */
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
if (style[i].flags&TEXT_UNDERLINE) {
|
||||
if (style[style_index].flags&TEXT_UNDERLINE) {
|
||||
rb->lcd_hline(x, x+width, y+height-1);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_LCD_COLOR
|
||||
rb->lcd_set_foreground(standard_fgcolor);
|
||||
#endif
|
||||
style_index++;
|
||||
}
|
||||
x += width + space_w;
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@
|
|||
* basic usage:
|
||||
* #define WORDS (sizeof text / sizeof (char*))
|
||||
* char *text[] = {"normal", "centering", "red,underline"};
|
||||
* struct style_text formation[WORDS]={
|
||||
* [1] = { TEXT_CENTER },
|
||||
* [2] = { C_RED|TEXT_UNDERLINE },
|
||||
* struct style_text formation[]={
|
||||
* { 1, TEXT_CENTER },
|
||||
* { 2, C_RED|TEXT_UNDERLINE },
|
||||
* };
|
||||
* if (display_text(WORDS, text, formation, NULL))
|
||||
* return PLUGIN_USB_CONNECTED;
|
||||
|
@ -38,10 +38,11 @@ enum ecolor { STANDARD, C_YELLOW, C_RED, C_BLUE, C_GREEN , C_ORANGE };
|
|||
#define TEXT_UNDERLINE 0x0200
|
||||
|
||||
struct style_text {
|
||||
unsigned short index;
|
||||
unsigned short flags;
|
||||
};
|
||||
|
||||
/* style and vp_text is optional.
|
||||
/* style and vp_text are optional.
|
||||
* return true if usb is connected. */
|
||||
bool display_text(short words, char** text, struct style_text* style,
|
||||
struct viewport* vp_text);
|
||||
|
|
Loading…
Reference in a new issue