diff options
author | Johannes Schwarz <ubuntuxer@rockbox.org> | 2009-07-02 17:02:47 +0000 |
---|---|---|
committer | Johannes Schwarz <ubuntuxer@rockbox.org> | 2009-07-02 17:02:47 +0000 |
commit | bff790d692333fe8e43605682c4a980821e82b53 (patch) | |
tree | 1a8e45107901fcf215d92815f8cc528e54e4295f | |
parent | 278f1f69bb132ee4600f7706ff5783a625f9039c (diff) | |
download | rockbox-bff790d692333fe8e43605682c4a980821e82b53.tar.gz rockbox-bff790d692333fe8e43605682c4a980821e82b53.zip |
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
-rw-r--r-- | apps/plugins/lib/display_text.c | 19 | ||||
-rw-r--r-- | apps/plugins/lib/display_text.h | 9 |
2 files changed, 17 insertions, 11 deletions
diff --git a/apps/plugins/lib/display_text.c b/apps/plugins/lib/display_text.c index 8ba31e2ff3..67c78ec242 100644 --- a/apps/plugins/lib/display_text.c +++ b/apps/plugins/lib/display_text.c | |||
@@ -35,14 +35,14 @@ bool display_text(short words, char** text, struct style_text* style, | |||
35 | int prev_drawmode; | 35 | int prev_drawmode; |
36 | #endif | 36 | #endif |
37 | #ifdef HAVE_LCD_COLOR | 37 | #ifdef HAVE_LCD_COLOR |
38 | unsigned standard_fgcolor; | 38 | int standard_fgcolor; |
39 | #endif | 39 | #endif |
40 | int space_w, width, height; | 40 | int space_w, width, height; |
41 | unsigned short x , y; | 41 | unsigned short x , y; |
42 | unsigned short vp_width = LCD_WIDTH; | 42 | unsigned short vp_width = LCD_WIDTH; |
43 | unsigned short vp_height = LCD_HEIGHT; | 43 | unsigned short vp_height = LCD_HEIGHT; |
44 | int button; | 44 | int button; |
45 | short i=0; | 45 | unsigned short i = 0, style_index = 0; |
46 | if (vp_text != NULL) { | 46 | if (vp_text != NULL) { |
47 | vp_width = vp_text->width; | 47 | vp_width = vp_text->width; |
48 | vp_height = vp_text->height; | 48 | vp_height = vp_text->height; |
@@ -85,17 +85,17 @@ bool display_text(short words, char** text, struct style_text* style, | |||
85 | || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); | 85 | || ( button & (BUTTON_REL|BUTTON_REPEAT) ) ); |
86 | rb->screens[SCREEN_MAIN]->clear_viewport(); | 86 | rb->screens[SCREEN_MAIN]->clear_viewport(); |
87 | } | 87 | } |
88 | /* no text formations available */ | 88 | /* no text formatting available */ |
89 | if (style==NULL) { | 89 | if (style==NULL || style[style_index].index != i) { |
90 | rb->lcd_putsxy(x, y, text[i]); | 90 | rb->lcd_putsxy(x, y, text[i]); |
91 | } else { | 91 | } else { |
92 | /* set align */ | 92 | /* set align */ |
93 | if (style[i].flags&TEXT_CENTER) { | 93 | if (style[style_index].flags&TEXT_CENTER) { |
94 | x = (vp_width-width)/2; | 94 | x = (vp_width-width)/2; |
95 | } | 95 | } |
96 | /* set font color */ | 96 | /* set font color */ |
97 | #ifdef HAVE_LCD_COLOR | 97 | #ifdef HAVE_LCD_COLOR |
98 | switch (style[i].flags&TEXT_COLOR_MASK) { | 98 | switch (style[style_index].flags&TEXT_COLOR_MASK) { |
99 | case C_RED: | 99 | case C_RED: |
100 | rb->lcd_set_foreground(LCD_RGBPACK(255,0,0)); | 100 | rb->lcd_set_foreground(LCD_RGBPACK(255,0,0)); |
101 | break; | 101 | break; |
@@ -118,11 +118,16 @@ bool display_text(short words, char** text, struct style_text* style, | |||
118 | } | 118 | } |
119 | #endif | 119 | #endif |
120 | rb->lcd_putsxy(x, y, text[i]); | 120 | rb->lcd_putsxy(x, y, text[i]); |
121 | /* underline the word */ | ||
121 | #ifdef HAVE_LCD_BITMAP | 122 | #ifdef HAVE_LCD_BITMAP |
122 | if (style[i].flags&TEXT_UNDERLINE) { | 123 | if (style[style_index].flags&TEXT_UNDERLINE) { |
123 | rb->lcd_hline(x, x+width, y+height-1); | 124 | rb->lcd_hline(x, x+width, y+height-1); |
124 | } | 125 | } |
125 | #endif | 126 | #endif |
127 | #ifdef HAVE_LCD_COLOR | ||
128 | rb->lcd_set_foreground(standard_fgcolor); | ||
129 | #endif | ||
130 | style_index++; | ||
126 | } | 131 | } |
127 | x += width + space_w; | 132 | x += width + space_w; |
128 | } | 133 | } |
diff --git a/apps/plugins/lib/display_text.h b/apps/plugins/lib/display_text.h index 9f21d236ea..39b5f76a14 100644 --- a/apps/plugins/lib/display_text.h +++ b/apps/plugins/lib/display_text.h | |||
@@ -24,9 +24,9 @@ | |||
24 | * basic usage: | 24 | * basic usage: |
25 | * #define WORDS (sizeof text / sizeof (char*)) | 25 | * #define WORDS (sizeof text / sizeof (char*)) |
26 | * char *text[] = {"normal", "centering", "red,underline"}; | 26 | * char *text[] = {"normal", "centering", "red,underline"}; |
27 | * struct style_text formation[WORDS]={ | 27 | * struct style_text formation[]={ |
28 | * [1] = { TEXT_CENTER }, | 28 | * { 1, TEXT_CENTER }, |
29 | * [2] = { C_RED|TEXT_UNDERLINE }, | 29 | * { 2, C_RED|TEXT_UNDERLINE }, |
30 | * }; | 30 | * }; |
31 | * if (display_text(WORDS, text, formation, NULL)) | 31 | * if (display_text(WORDS, text, formation, NULL)) |
32 | * return PLUGIN_USB_CONNECTED; | 32 | * return PLUGIN_USB_CONNECTED; |
@@ -38,10 +38,11 @@ enum ecolor { STANDARD, C_YELLOW, C_RED, C_BLUE, C_GREEN , C_ORANGE }; | |||
38 | #define TEXT_UNDERLINE 0x0200 | 38 | #define TEXT_UNDERLINE 0x0200 |
39 | 39 | ||
40 | struct style_text { | 40 | struct style_text { |
41 | unsigned short index; | ||
41 | unsigned short flags; | 42 | unsigned short flags; |
42 | }; | 43 | }; |
43 | 44 | ||
44 | /* style and vp_text is optional. | 45 | /* style and vp_text are optional. |
45 | * return true if usb is connected. */ | 46 | * return true if usb is connected. */ |
46 | bool display_text(short words, char** text, struct style_text* style, | 47 | bool display_text(short words, char** text, struct style_text* style, |
47 | struct viewport* vp_text); | 48 | struct viewport* vp_text); |