diff options
author | Nils Wallménius <nils@rockbox.org> | 2007-09-20 10:06:33 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2007-09-20 10:06:33 +0000 |
commit | 7b71787bd8dc1f570d2270a312438f86b66e3456 (patch) | |
tree | 8b550370c78411dc49ed5d43d8ce7fe62f1832ba /apps/gui | |
parent | 39ff1878bc35b2ce69180d734cc1b58b69419e8e (diff) | |
download | rockbox-7b71787bd8dc1f570d2270a312438f86b66e3456.tar.gz rockbox-7b71787bd8dc1f570d2270a312438f86b66e3456.zip |
Get rid of macros and do these calculations only once instead
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14770 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/quickscreen.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 008c6fa721..c2da5879fe 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c | |||
@@ -50,11 +50,6 @@ void gui_quickscreen_init(struct gui_quickscreen * qs, | |||
50 | */ | 50 | */ |
51 | static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * display) | 51 | static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * display) |
52 | { | 52 | { |
53 | #define PUTS_CENTER (display->height/2/font_h) | ||
54 | #define PUTS_BOTTOM (display->height/font_h) | ||
55 | #define PUTSXY_CENTER (display->height/2) | ||
56 | #define PUTSXY_BOTTOM (display->height) | ||
57 | |||
58 | const unsigned char *option; | 53 | const unsigned char *option; |
59 | const unsigned char *title; | 54 | const unsigned char *title; |
60 | int w, font_h; | 55 | int w, font_h; |
@@ -69,13 +64,19 @@ static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * di | |||
69 | } | 64 | } |
70 | display->getstringsize("A", NULL, &font_h); | 65 | display->getstringsize("A", NULL, &font_h); |
71 | 66 | ||
67 | /* do these calculations once */ | ||
68 | const unsigned int puts_center = display->height/2/font_h; | ||
69 | const unsigned int puts_bottom = display->height/font_h; | ||
70 | const unsigned int putsxy_center = display->height/2; | ||
71 | const unsigned int putsxy_bottom = display->height; | ||
72 | |||
72 | /* Displays the first line of text */ | 73 | /* Displays the first line of text */ |
73 | option=(unsigned char *)option_select_get_text(qs->left_option); | 74 | option=(unsigned char *)option_select_get_text(qs->left_option); |
74 | title=(unsigned char *)qs->left_option->title; | 75 | title=(unsigned char *)qs->left_option->title; |
75 | display->puts_scroll(2, PUTS_CENTER-4+!statusbar, title); | 76 | display->puts_scroll(2, puts_center-4+!statusbar, title); |
76 | display->puts_scroll(2, PUTS_CENTER-3+!statusbar, option); | 77 | display->puts_scroll(2, puts_center-3+!statusbar, option); |
77 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 1, | 78 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 1, |
78 | PUTSXY_CENTER-(font_h*3), 7, 8); | 79 | putsxy_center-(font_h*3), 7, 8); |
79 | 80 | ||
80 | /* Displays the second line of text */ | 81 | /* Displays the second line of text */ |
81 | option=(unsigned char *)option_select_get_text(qs->right_option); | 82 | option=(unsigned char *)option_select_get_text(qs->right_option); |
@@ -83,21 +84,21 @@ static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * di | |||
83 | display->getstringsize(title, &w, NULL); | 84 | display->getstringsize(title, &w, NULL); |
84 | if(w > display->width - 8) | 85 | if(w > display->width - 8) |
85 | { | 86 | { |
86 | display->puts_scroll(2, PUTS_CENTER-2+!statusbar, title); | 87 | display->puts_scroll(2, puts_center-2+!statusbar, title); |
87 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], 1, | 88 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], 1, |
88 | PUTSXY_CENTER-font_h, 7, 8); | 89 | putsxy_center-font_h, 7, 8); |
89 | } | 90 | } |
90 | else | 91 | else |
91 | { | 92 | { |
92 | display->putsxy(display->width - w - 12, PUTSXY_CENTER-font_h, title); | 93 | display->putsxy(display->width - w - 12, putsxy_center-font_h, title); |
93 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], | 94 | display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], |
94 | display->width - 8, PUTSXY_CENTER-font_h, 7, 8); | 95 | display->width - 8, putsxy_center-font_h, 7, 8); |
95 | } | 96 | } |
96 | display->getstringsize(option, &w, NULL); | 97 | display->getstringsize(option, &w, NULL); |
97 | if(w > display->width) | 98 | if(w > display->width) |
98 | display->puts_scroll(0, PUTS_CENTER-1+!statusbar, option); | 99 | display->puts_scroll(0, puts_center-1+!statusbar, option); |
99 | else | 100 | else |
100 | display->putsxy(display->width -w-12, PUTSXY_CENTER, option); | 101 | display->putsxy(display->width -w-12, putsxy_center, option); |
101 | 102 | ||
102 | /* Displays the third line of text */ | 103 | /* Displays the third line of text */ |
103 | option=(unsigned char *)option_select_get_text(qs->bottom_option); | 104 | option=(unsigned char *)option_select_get_text(qs->bottom_option); |
@@ -105,17 +106,17 @@ static void gui_quickscreen_draw(struct gui_quickscreen * qs, struct screen * di | |||
105 | 106 | ||
106 | display->getstringsize(title, &w, NULL); | 107 | display->getstringsize(title, &w, NULL); |
107 | if(w > display->width) | 108 | if(w > display->width) |
108 | display->puts_scroll(0, PUTS_BOTTOM-4+!statusbar, title); | 109 | display->puts_scroll(0, puts_bottom-4+!statusbar, title); |
109 | else | 110 | else |
110 | display->putsxy(display->width/2-w/2, PUTSXY_BOTTOM-(font_h*3), title); | 111 | display->putsxy(display->width/2-w/2, putsxy_bottom-(font_h*3), title); |
111 | 112 | ||
112 | display->getstringsize(option, &w, NULL); | 113 | display->getstringsize(option, &w, NULL); |
113 | if(w > display->width) | 114 | if(w > display->width) |
114 | display->puts_scroll(0, PUTS_BOTTOM-3+!statusbar, option); | 115 | display->puts_scroll(0, puts_bottom-3+!statusbar, option); |
115 | else | 116 | else |
116 | display->putsxy(display->width/2-w/2, PUTSXY_BOTTOM-(font_h*2), option); | 117 | display->putsxy(display->width/2-w/2, putsxy_bottom-(font_h*2), option); |
117 | display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], display->width/2-4, | 118 | display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], display->width/2-4, |
118 | PUTSXY_BOTTOM-font_h, 7, 8); | 119 | putsxy_bottom-font_h, 7, 8); |
119 | 120 | ||
120 | gui_textarea_update(display); | 121 | gui_textarea_update(display); |
121 | display->setfont(FONT_UI); | 122 | display->setfont(FONT_UI); |