diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/splash.c | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/apps/gui/splash.c b/apps/gui/splash.c index 034e4a5912..69691793a8 100644 --- a/apps/gui/splash.c +++ b/apps/gui/splash.c | |||
@@ -28,10 +28,7 @@ | |||
28 | #include "settings.h" | 28 | #include "settings.h" |
29 | #include "talk.h" | 29 | #include "talk.h" |
30 | #include "splash.h" | 30 | #include "splash.h" |
31 | 31 | #include "viewport.h" | |
32 | #ifndef MAX | ||
33 | #define MAX(a, b) (((a)>(b))?(a):(b)) | ||
34 | #endif | ||
35 | 32 | ||
36 | #ifdef HAVE_LCD_BITMAP | 33 | #ifdef HAVE_LCD_BITMAP |
37 | 34 | ||
@@ -45,6 +42,8 @@ | |||
45 | 42 | ||
46 | #endif | 43 | #endif |
47 | 44 | ||
45 | #define RECT_SPACING 2 | ||
46 | |||
48 | static void splash_internal(struct screen * screen, const char *fmt, va_list ap) | 47 | static void splash_internal(struct screen * screen, const char *fmt, va_list ap) |
49 | { | 48 | { |
50 | char splash_buf[MAXBUFFER]; | 49 | char splash_buf[MAXBUFFER]; |
@@ -59,10 +58,8 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap) | |||
59 | int y, i; | 58 | int y, i; |
60 | int space_w, w, h; | 59 | int space_w, w, h; |
61 | #ifdef HAVE_LCD_BITMAP | 60 | #ifdef HAVE_LCD_BITMAP |
61 | struct viewport vp; | ||
62 | int maxw = 0; | 62 | int maxw = 0; |
63 | #if LCD_DEPTH > 1 | ||
64 | unsigned prevfg = 0; | ||
65 | #endif | ||
66 | 63 | ||
67 | screen->getstringsize(" ", &space_w, &h); | 64 | screen->getstringsize(" ", &space_w, &h); |
68 | #else /* HAVE_LCD_CHARCELLS */ | 65 | #else /* HAVE_LCD_CHARCELLS */ |
@@ -91,7 +88,8 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap) | |||
91 | #endif | 88 | #endif |
92 | if (lastbreak) | 89 | if (lastbreak) |
93 | { | 90 | { |
94 | if (x + (next - lastbreak) * space_w + w > screen->lcdwidth) | 91 | if (x + (next - lastbreak) * space_w + w |
92 | > screen->lcdwidth - RECT_SPACING*2) | ||
95 | { /* too wide, wrap */ | 93 | { /* too wide, wrap */ |
96 | widths[line] = x; | 94 | widths[line] = x; |
97 | #ifdef HAVE_LCD_BITMAP | 95 | #ifdef HAVE_LCD_BITMAP |
@@ -125,38 +123,54 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap) | |||
125 | } | 123 | } |
126 | } | 124 | } |
127 | 125 | ||
128 | /* prepare screen */ | 126 | /* prepare viewport |
127 | * First boundaries, then the grey filling, then the black border and finally | ||
128 | * the text*/ | ||
129 | 129 | ||
130 | screen->stop_scroll(); | 130 | screen->stop_scroll(); |
131 | 131 | ||
132 | #ifdef HAVE_LCD_BITMAP | 132 | #ifdef HAVE_LCD_BITMAP |
133 | viewport_set_defaults(&vp, screen->screen_type); | ||
133 | /* If we center the display, then just clear the box we need and put | 134 | /* If we center the display, then just clear the box we need and put |
134 | a nice little frame and put the text in there! */ | 135 | a nice little frame and put the text in there! */ |
135 | y = (screen->lcdheight - y) / 2; /* height => y start position */ | 136 | vp.y = (screen->lcdheight - y) / 2 - RECT_SPACING; /* height => y start position */ |
136 | x = (screen->lcdwidth - maxw) / 2 - 2; | 137 | vp.x = (screen->lcdwidth - maxw) / 2 - RECT_SPACING; |
137 | 138 | vp.width = maxw + 2*RECT_SPACING; | |
139 | vp.height = screen->lcdheight - (vp.y*2) + RECT_SPACING; | ||
140 | |||
141 | if (vp.y < 0) | ||
142 | vp.y = 0; | ||
143 | if (vp.x < 0) | ||
144 | vp.x = 0; | ||
145 | if (vp.width > screen->lcdwidth) | ||
146 | vp.width = screen->lcdwidth; | ||
147 | if (vp.height > screen->lcdheight) | ||
148 | vp.height = screen->lcdheight; | ||
149 | |||
138 | #if LCD_DEPTH > 1 | 150 | #if LCD_DEPTH > 1 |
139 | if (screen->depth > 1) | 151 | if (screen->depth > 1) |
140 | { | 152 | { |
141 | prevfg = screen->get_foreground(); | 153 | vp.drawmode = DRMODE_FG; |
142 | screen->set_drawmode(DRMODE_FG); | 154 | vp.fg_pattern = SCREEN_COLOR_TO_NATIVE(screen, LCD_LIGHTGRAY); |
143 | screen->set_foreground( | ||
144 | SCREEN_COLOR_TO_NATIVE(screen, LCD_LIGHTGRAY)); | ||
145 | } | 155 | } |
146 | else | 156 | else |
147 | #endif | 157 | #endif |
148 | screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 158 | vp.drawmode = (DRMODE_SOLID|DRMODE_INVERSEVID); |
149 | 159 | ||
150 | screen->fillrect(x, y-2, maxw+4, screen->lcdheight-y*2+4); | 160 | screen->set_viewport(&vp); |
161 | screen->fillrect(0, 0, vp.width, vp.height); | ||
151 | 162 | ||
152 | #if LCD_DEPTH > 1 | 163 | #if LCD_DEPTH > 1 |
153 | if (screen->depth > 1) | 164 | if (screen->depth > 1) |
154 | screen->set_foreground(SCREEN_COLOR_TO_NATIVE(screen, LCD_BLACK)); | 165 | vp.fg_pattern = SCREEN_COLOR_TO_NATIVE(screen, LCD_BLACK); |
155 | else | 166 | else |
156 | #endif | 167 | #endif |
157 | screen->set_drawmode(DRMODE_SOLID); | 168 | vp.drawmode = DRMODE_SOLID; |
169 | |||
170 | screen->drawrect(0, 0, vp.width, vp.height); | ||
158 | 171 | ||
159 | screen->drawrect(x, y-2, maxw+4, screen->lcdheight-y*2+4); | 172 | /* prepare putting the text */ |
173 | y = RECT_SPACING; | ||
160 | #else /* HAVE_LCD_CHARCELLS */ | 174 | #else /* HAVE_LCD_CHARCELLS */ |
161 | y = 0; /* vertical centering on 2 lines would be silly */ | 175 | y = 0; /* vertical centering on 2 lines would be silly */ |
162 | x = 0; | 176 | x = 0; |
@@ -164,27 +178,25 @@ static void splash_internal(struct screen * screen, const char *fmt, va_list ap) | |||
164 | #endif | 178 | #endif |
165 | 179 | ||
166 | /* print the message to screen */ | 180 | /* print the message to screen */ |
167 | 181 | for (i = 0; i <= line; i++, y+=h) | |
168 | for (i = 0; i <= line; i++) | ||
169 | { | 182 | { |
170 | x = MAX((screen->lcdwidth - widths[i]) / 2, 0); | ||
171 | |||
172 | #ifdef HAVE_LCD_BITMAP | 183 | #ifdef HAVE_LCD_BITMAP |
173 | screen->putsxy(x, y, lines[i]); | 184 | #define W (vp.width - RECT_SPACING*2) |
185 | #else | ||
186 | #define W (screens->lcdwidth) | ||
187 | #endif | ||
188 | x = (W - widths[i])/2; | ||
189 | if (x < 0) | ||
190 | x = 0; | ||
191 | #ifdef HAVE_LCD_BITMAP | ||
192 | screen->putsxy(x+RECT_SPACING, y, lines[i]); | ||
174 | #else | 193 | #else |
175 | screen->puts(x, y, lines[i]); | 194 | screen->puts(x, y, lines[i]); |
176 | #endif | 195 | #endif |
177 | y += h; | 196 | #undef W |
178 | } | 197 | } |
179 | 198 | screen->update_viewport(); | |
180 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH > 1) | 199 | screen->set_viewport(NULL); |
181 | if (screen->depth > 1) | ||
182 | { | ||
183 | screen->set_foreground(prevfg); | ||
184 | screen->set_drawmode(DRMODE_SOLID); | ||
185 | } | ||
186 | #endif | ||
187 | screen->update(); | ||
188 | } | 200 | } |
189 | 201 | ||
190 | void splashf(int ticks, const char *fmt, ...) | 202 | void splashf(int ticks, const char *fmt, ...) |
@@ -198,12 +210,10 @@ void splashf(int ticks, const char *fmt, ...) | |||
198 | FOR_NB_SCREENS(i) | 210 | FOR_NB_SCREENS(i) |
199 | { | 211 | { |
200 | va_start(ap, fmt); | 212 | va_start(ap, fmt); |
201 | screens[i].set_viewport(NULL); | ||
202 | splash_internal(&(screens[i]), fmt, ap); | 213 | splash_internal(&(screens[i]), fmt, ap); |
203 | va_end(ap); | 214 | va_end(ap); |
204 | } | 215 | } |
205 | 216 | if (ticks) | |
206 | if(ticks) | ||
207 | sleep(ticks); | 217 | sleep(ticks); |
208 | } | 218 | } |
209 | 219 | ||