diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-10-11 12:21:27 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-10-11 12:21:27 +0000 |
commit | a79dc877615c2af571bf0416dd2867c000701e7e (patch) | |
tree | 20be2176756c12d56d4e1947a05c2331fe1666ca /apps/menus/time_menu.c | |
parent | e171294c1d50dc4e4ba30339940a854c2b82d1ea (diff) | |
download | rockbox-a79dc877615c2af571bf0416dd2867c000701e7e.tar.gz rockbox-a79dc877615c2af571bf0416dd2867c000701e7e.zip |
Add a center flag, next to the rtl flag, for viewports. That results in any text being drawn centered. It overrides the RTL flag if set.
Simplify splashes and time menu by using it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23105 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/menus/time_menu.c')
-rw-r--r-- | apps/menus/time_menu.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/apps/menus/time_menu.c b/apps/menus/time_menu.c index cb0e4aac5b..bc08374ba0 100644 --- a/apps/menus/time_menu.c +++ b/apps/menus/time_menu.c | |||
@@ -46,11 +46,9 @@ | |||
46 | 46 | ||
47 | static int timedate_set(void) | 47 | static int timedate_set(void) |
48 | { | 48 | { |
49 | struct tm tm; | ||
50 | int result; | ||
51 | |||
52 | /* Make a local copy of the time struct */ | 49 | /* Make a local copy of the time struct */ |
53 | memcpy(&tm, get_time(), sizeof(struct tm)); | 50 | struct tm tm = *get_time(); |
51 | int result; | ||
54 | 52 | ||
55 | /* do some range checks */ | 53 | /* do some range checks */ |
56 | /* This prevents problems with time/date setting after a power loss */ | 54 | /* This prevents problems with time/date setting after a power loss */ |
@@ -160,21 +158,6 @@ static void talk_timedate(void) | |||
160 | } | 158 | } |
161 | } | 159 | } |
162 | 160 | ||
163 | static void vp_puts_center(struct viewport *vp, struct screen *display, | ||
164 | int line, const char *str) | ||
165 | { | ||
166 | int w, offset; | ||
167 | |||
168 | display->getstringsize(str, &w, NULL); | ||
169 | if (w > vp->width) | ||
170 | display->puts_scroll(0, line, str); | ||
171 | else | ||
172 | { | ||
173 | offset = (vp->width - w)/2; | ||
174 | display->putsxy(offset, line * font_get(vp->font)->height, str); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | static void draw_timedate(struct viewport *vp, struct screen *display) | 161 | static void draw_timedate(struct viewport *vp, struct screen *display) |
179 | { | 162 | { |
180 | struct tm *tm = get_time(); | 163 | struct tm *tm = get_time(); |
@@ -210,13 +193,14 @@ static void draw_timedate(struct viewport *vp, struct screen *display) | |||
210 | d = str(LANG_UNKNOWN); | 193 | d = str(LANG_UNKNOWN); |
211 | } | 194 | } |
212 | 195 | ||
213 | vp_puts_center(vp, display, line, t); | 196 | display->puts_scroll(0, line++, time); |
214 | line++; | 197 | display->puts_scroll(0, line, date); |
215 | vp_puts_center(vp, display, line, d); | ||
216 | 198 | ||
217 | display->update_viewport(); | 199 | display->update_viewport(); |
200 | display->set_viewport(NULL); | ||
218 | } | 201 | } |
219 | 202 | ||
203 | |||
220 | static struct viewport clock[NB_SCREENS], menu[NB_SCREENS]; | 204 | static struct viewport clock[NB_SCREENS], menu[NB_SCREENS]; |
221 | static bool menu_was_pressed; | 205 | static bool menu_was_pressed; |
222 | static int time_menu_callback(int action, | 206 | static int time_menu_callback(int action, |
@@ -281,7 +265,11 @@ int time_screen(void* ignored) | |||
281 | } | 265 | } |
282 | #endif | 266 | #endif |
283 | nb_lines = viewport_get_nb_lines(&clock[i]); | 267 | nb_lines = viewport_get_nb_lines(&clock[i]); |
268 | |||
284 | menu[i] = clock[i]; | 269 | menu[i] = clock[i]; |
270 | /* force time to be drawn centered */ | ||
271 | clock[i].flags |= VP_FLAG_CENTER_ALIGN; | ||
272 | |||
285 | font_h = font_get(clock[i].font)->height; | 273 | font_h = font_get(clock[i].font)->height; |
286 | if (nb_lines > 3) | 274 | if (nb_lines > 3) |
287 | { | 275 | { |
@@ -302,6 +290,7 @@ int time_screen(void* ignored) | |||
302 | menu[i].height -= clock[i].height; | 290 | menu[i].height -= clock[i].height; |
303 | draw_timedate(&clock[i], &screens[i]); | 291 | draw_timedate(&clock[i], &screens[i]); |
304 | } | 292 | } |
293 | |||
305 | ret = do_menu(&time_menu, NULL, menu, false); | 294 | ret = do_menu(&time_menu, NULL, menu, false); |
306 | /* see comments above in the button callback */ | 295 | /* see comments above in the button callback */ |
307 | if (!menu_was_pressed && ret == GO_TO_PREVIOUS) | 296 | if (!menu_was_pressed && ret == GO_TO_PREVIOUS) |