diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-01-28 20:14:01 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-01-28 20:14:01 +0000 |
commit | 76ba8ec8903f0ee3f9c7a3548e35acf8f209f8ab (patch) | |
tree | 79e6c7991d317ce1cf3fcbb7c428f3ffda4906c5 | |
parent | 0dd66418720374a262c63a2b20496a68c14f1423 (diff) | |
download | rockbox-76ba8ec8903f0ee3f9c7a3548e35acf8f209f8ab.tar.gz rockbox-76ba8ec8903f0ee3f9c7a3548e35acf8f209f8ab.zip |
Some cleanup (such as #include cleanup, clearer variable names) in pitchscreen. Also, don't update the full display all the time, but only the necessary parts.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19871 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/pitchscreen.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/apps/gui/pitchscreen.c b/apps/gui/pitchscreen.c index 568bbf4aee..746af0d7de 100644 --- a/apps/gui/pitchscreen.c +++ b/apps/gui/pitchscreen.c | |||
@@ -24,17 +24,12 @@ | |||
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include "config.h" | 25 | #include "config.h" |
26 | #include "sprintf.h" | 26 | #include "sprintf.h" |
27 | #include "settings.h" | ||
28 | #include "action.h" | 27 | #include "action.h" |
29 | #include "system.h" | ||
30 | #include "font.h" | ||
31 | #include "misc.h" | ||
32 | #include "dsp.h" | 28 | #include "dsp.h" |
33 | #include "sound.h" | 29 | #include "sound.h" |
34 | #include "pcmbuf.h" | 30 | #include "pcmbuf.h" |
35 | #include "lang.h" | 31 | #include "lang.h" |
36 | #include "icons.h" | 32 | #include "icons.h" |
37 | #include "screen_access.h" | ||
38 | #include "screens.h" | 33 | #include "screens.h" |
39 | #include "statusbar.h" | 34 | #include "statusbar.h" |
40 | #include "viewport.h" | 35 | #include "viewport.h" |
@@ -66,13 +61,14 @@ enum | |||
66 | static void pitchscreen_fix_viewports(struct viewport *parent, | 61 | static void pitchscreen_fix_viewports(struct viewport *parent, |
67 | struct viewport pitch_viewports[PITCH_ITEM_COUNT]) | 62 | struct viewport pitch_viewports[PITCH_ITEM_COUNT]) |
68 | { | 63 | { |
69 | short n, height; | 64 | int i, height; |
70 | height = font_get(parent->font)->height; | 65 | height = font_get(parent->font)->height; |
71 | for (n = 0; n < PITCH_ITEM_COUNT; n++) | 66 | for (i = 0; i < PITCH_ITEM_COUNT; i++) |
72 | { | 67 | { |
73 | pitch_viewports[n] = *parent; | 68 | pitch_viewports[i] = *parent; |
74 | pitch_viewports[n].height = height; | 69 | pitch_viewports[i].height = height; |
75 | } | 70 | } |
71 | |||
76 | pitch_viewports[PITCH_TOP].y += ICON_BORDER; | 72 | pitch_viewports[PITCH_TOP].y += ICON_BORDER; |
77 | 73 | ||
78 | pitch_viewports[PITCH_MID].x += ICON_BORDER; | 74 | pitch_viewports[PITCH_MID].x += ICON_BORDER; |
@@ -80,6 +76,7 @@ static void pitchscreen_fix_viewports(struct viewport *parent, | |||
80 | pitch_viewports[PITCH_MID].height = height * 2; | 76 | pitch_viewports[PITCH_MID].height = height * 2; |
81 | pitch_viewports[PITCH_MID].y += parent->height / 2 - | 77 | pitch_viewports[PITCH_MID].y += parent->height / 2 - |
82 | pitch_viewports[PITCH_MID].height / 2; | 78 | pitch_viewports[PITCH_MID].height / 2; |
79 | |||
83 | pitch_viewports[PITCH_BOTTOM].y += parent->height - height - ICON_BORDER; | 80 | pitch_viewports[PITCH_BOTTOM].y += parent->height - height - ICON_BORDER; |
84 | } | 81 | } |
85 | 82 | ||
@@ -108,7 +105,7 @@ static void pitchscreen_draw (struct screen *display, int max_lines, | |||
108 | { | 105 | { |
109 | unsigned char* ptr; | 106 | unsigned char* ptr; |
110 | unsigned char buf[32]; | 107 | unsigned char buf[32]; |
111 | int w, h; | 108 | int width_val, w, h; |
112 | bool show_lang_pitch; | 109 | bool show_lang_pitch; |
113 | 110 | ||
114 | /* Hide "Pitch up/Pitch down" for a small screen */ | 111 | /* Hide "Pitch up/Pitch down" for a small screen */ |
@@ -126,6 +123,7 @@ static void pitchscreen_draw (struct screen *display, int max_lines, | |||
126 | /* draw text */ | 123 | /* draw text */ |
127 | display->putsxy((pitch_viewports[PITCH_TOP].width / 2) - | 124 | display->putsxy((pitch_viewports[PITCH_TOP].width / 2) - |
128 | (w / 2), 0, ptr); | 125 | (w / 2), 0, ptr); |
126 | display->update_viewport(); | ||
129 | 127 | ||
130 | /* DOWN: Pitch Down */ | 128 | /* DOWN: Pitch Down */ |
131 | display->set_viewport(&pitch_viewports[PITCH_BOTTOM]); | 129 | display->set_viewport(&pitch_viewports[PITCH_BOTTOM]); |
@@ -139,6 +137,7 @@ static void pitchscreen_draw (struct screen *display, int max_lines, | |||
139 | /* draw text */ | 137 | /* draw text */ |
140 | display->putsxy((pitch_viewports[PITCH_BOTTOM].width / 2) - | 138 | display->putsxy((pitch_viewports[PITCH_BOTTOM].width / 2) - |
141 | (w / 2), 0, ptr); | 139 | (w / 2), 0, ptr); |
140 | display->update_viewport(); | ||
142 | } | 141 | } |
143 | display->set_viewport(&pitch_viewports[PITCH_MID]); | 142 | display->set_viewport(&pitch_viewports[PITCH_MID]); |
144 | 143 | ||
@@ -150,35 +149,33 @@ static void pitchscreen_draw (struct screen *display, int max_lines, | |||
150 | display->putsxy((pitch_viewports[PITCH_MID].width / 2) - (w / 2), | 149 | display->putsxy((pitch_viewports[PITCH_MID].width / 2) - (w / 2), |
151 | 0, buf); | 150 | 0, buf); |
152 | 151 | ||
153 | /* we don't need max_lines any more, reuse it*/ | ||
154 | max_lines = w; | ||
155 | /* "XXX.X%" */ | 152 | /* "XXX.X%" */ |
156 | snprintf((char *)buf, sizeof(buf), "%d.%d%%", | 153 | snprintf((char *)buf, sizeof(buf), "%d.%d%%", |
157 | pitch / 10, pitch % 10 ); | 154 | pitch / 10, pitch % 10 ); |
158 | display->getstringsize(buf,&w,&h); | 155 | display->getstringsize(buf,&width_val,&h); |
159 | display->putsxy((pitch_viewports[PITCH_MID].width / 2) - (w / 2), | 156 | display->putsxy((pitch_viewports[PITCH_MID].width / 2) - (w / 2), |
160 | (show_lang_pitch? h : h/2), buf); | 157 | (show_lang_pitch? h : h/2), buf); |
161 | 158 | ||
162 | /* What's wider? LANG_PITCH or the value? | 159 | /* What's wider? LANG_PITCH or the value? |
163 | * Only interesting if LANG_PITCH is actually drawn */ | 160 | * Only interesting if LANG_PITCH is actually drawn */ |
164 | max_lines = (show_lang_pitch ? ((max_lines > w) ? max_lines : w) : w); | 161 | if (show_lang_pitch && width_val > w) |
162 | w = width_val; | ||
165 | 163 | ||
166 | /* Let's treat '+' and '-' as equally wide | 164 | /* Let's treat '+' and '-' as equally wide |
167 | * This saves a getstringsize call | 165 | * This saves a getstringsize call |
168 | * Also, it wouldn't look nice if -2% shows up, but +2% not */ | 166 | * Also, it wouldn't look nice if -2% shows up, but +2% not */ |
169 | display->getstringsize("+2%",&w,&h); | 167 | display->getstringsize("+2%",&width_val,&h); |
170 | max_lines += 2*w; | 168 | w += width_val*2; |
171 | /* hide +2%/-2% for a narrow screens */ | 169 | /* hide +2%/-2% for a narrow screens */ |
172 | if (max_lines < pitch_viewports[PITCH_MID].width) | 170 | if (w <= pitch_viewports[PITCH_MID].width) |
173 | { | 171 | { |
174 | /* RIGHT: +2% */ | 172 | /* RIGHT: +2% */ |
175 | display->putsxy(pitch_viewports[PITCH_MID].width - w, h /2, "+2%"); | 173 | display->putsxy(pitch_viewports[PITCH_MID].width - width_val, h /2, "+2%"); |
176 | /* LEFT: -2% */ | 174 | /* LEFT: -2% */ |
177 | display->putsxy(0, h / 2, "-2%"); | 175 | display->putsxy(0, h / 2, "-2%"); |
178 | } | 176 | } |
179 | /* Lastly, a fullscreen update */ | 177 | display->update_viewport(); |
180 | display->set_viewport(NULL); | 178 | display->set_viewport(NULL); |
181 | display->update(); | ||
182 | } | 179 | } |
183 | 180 | ||
184 | static int pitch_increase(int pitch, int delta, bool allow_cutoff) | 181 | static int pitch_increase(int pitch, int delta, bool allow_cutoff) |
@@ -255,16 +252,15 @@ static int pitch_increase_semitone(int pitch, bool up) | |||
255 | 252 | ||
256 | int gui_syncpitchscreen_run(void) | 253 | int gui_syncpitchscreen_run(void) |
257 | { | 254 | { |
258 | int button; | 255 | int button, i; |
259 | int pitch = sound_get_pitch(); | 256 | int pitch = sound_get_pitch(); |
260 | int new_pitch, delta = 0; | 257 | int new_pitch, delta = 0; |
261 | bool nudged = false; | 258 | bool nudged = false; |
262 | bool exit = false; | 259 | bool exit = false; |
263 | short i; | 260 | /* should maybe be passed per parameter later, not needed for now */ |
264 | struct viewport parent[NB_SCREENS]; /* should maybe | 261 | struct viewport parent[NB_SCREENS]; |
265 | be a parameter of this function */ | ||
266 | short max_lines[NB_SCREENS]; | ||
267 | struct viewport pitch_viewports[NB_SCREENS][PITCH_ITEM_COUNT]; | 262 | struct viewport pitch_viewports[NB_SCREENS][PITCH_ITEM_COUNT]; |
263 | int max_lines[NB_SCREENS]; | ||
268 | 264 | ||
269 | /* initialize pitchscreen vps */ | 265 | /* initialize pitchscreen vps */ |
270 | FOR_NB_SCREENS(i) | 266 | FOR_NB_SCREENS(i) |
@@ -276,11 +272,12 @@ int gui_syncpitchscreen_run(void) | |||
276 | 272 | ||
277 | /* also, draw the icons now, it's only needed once */ | 273 | /* also, draw the icons now, it's only needed once */ |
278 | pitchscreen_draw_icons(&screens[i], &parent[i]); | 274 | pitchscreen_draw_icons(&screens[i], &parent[i]); |
275 | screens[i].update(); | ||
279 | } | 276 | } |
280 | #if CONFIG_CODEC == SWCODEC | 277 | #if CONFIG_CODEC == SWCODEC |
281 | pcmbuf_set_low_latency(true); | 278 | pcmbuf_set_low_latency(true); |
282 | #endif | 279 | #endif |
283 | i = 0; | 280 | |
284 | while (!exit) | 281 | while (!exit) |
285 | { | 282 | { |
286 | FOR_NB_SCREENS(i) | 283 | FOR_NB_SCREENS(i) |