summaryrefslogtreecommitdiff
path: root/apps/abrepeat.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2013-12-13 10:24:15 +0100
committerThomas Martitz <kugel@rockbox.org>2014-03-10 22:55:26 +0100
commit50f0dd80d660b332a1739e07a630c2cef1b678c6 (patch)
treed06ff8c644092167028e0582911ab3550b29ca66 /apps/abrepeat.c
parent4262e648eb3adbd502ea57319d3fd27103a4f267 (diff)
downloadrockbox-50f0dd80d660b332a1739e07a630c2cef1b678c6.tar.gz
rockbox-50f0dd80d660b332a1739e07a630c2cef1b678c6.zip
ab_repeat: Move GUI bits to the skin engine. This allows ab_repeat to be compiled headless.
Change-Id: I4fa3b8ef7139313891ca70df11f7f17c5df38cb7
Diffstat (limited to 'apps/abrepeat.c')
-rw-r--r--apps/abrepeat.c65
1 files changed, 8 insertions, 57 deletions
diff --git a/apps/abrepeat.c b/apps/abrepeat.c
index a149069709..999d9dcf38 100644
--- a/apps/abrepeat.c
+++ b/apps/abrepeat.c
@@ -27,6 +27,7 @@
27unsigned int ab_A_marker IDATA_ATTR = AB_MARKER_NONE; 27unsigned int ab_A_marker IDATA_ATTR = AB_MARKER_NONE;
28unsigned int ab_B_marker IDATA_ATTR = AB_MARKER_NONE; 28unsigned int ab_B_marker IDATA_ATTR = AB_MARKER_NONE;
29 29
30
30static inline bool ab_A_marker_set(void) 31static inline bool ab_A_marker_set(void)
31{ 32{
32 return ab_A_marker != AB_MARKER_NONE; 33 return ab_A_marker != AB_MARKER_NONE;
@@ -37,6 +38,7 @@ static inline bool ab_B_marker_set(void)
37 return ab_B_marker != AB_MARKER_NONE; 38 return ab_B_marker != AB_MARKER_NONE;
38} 39}
39 40
41
40#if (CONFIG_CODEC == SWCODEC) 42#if (CONFIG_CODEC == SWCODEC)
41void ab_end_of_track_report(void) 43void ab_end_of_track_report(void)
42{ 44{
@@ -158,67 +160,16 @@ void ab_set_B_marker(unsigned int song_position)
158 ab_A_marker = AB_MARKER_NONE; 160 ab_A_marker = AB_MARKER_NONE;
159} 161}
160 162
161#ifdef HAVE_LCD_BITMAP 163bool ab_get_A_marker(unsigned *song_position)
162
163static int ab_calc_mark_x_pos(int mark, int capacity,
164 int offset, int size)
165{
166 return offset + ( (size * mark) / capacity );
167}
168
169static void ab_draw_vertical_line_mark(struct screen * screen,
170 int x, int y, int h)
171{ 164{
172 screen->set_drawmode(DRMODE_COMPLEMENT); 165 *song_position = ab_A_marker;
173 screen->vline(x, y, y+h-1); 166 return ab_A_marker_set();
174}
175
176#define DIRECTION_RIGHT 1
177#define DIRECTION_LEFT -1
178
179static void ab_draw_arrow_mark(struct screen * screen,
180 int x, int y, int h, int direction)
181{
182 /* draw lines in decreasing size until a height of zero is reached */
183 screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
184 while( h > 0 )
185 {
186 screen->vline(x, y, y+h-1);
187 h -= 2;
188 y++;
189 x += direction;
190 screen->set_drawmode(DRMODE_COMPLEMENT);
191 }
192} 167}
193 168
194void ab_draw_markers(struct screen * screen, int capacity, 169bool ab_get_B_marker(unsigned *song_position)
195 int x, int y, int w, int h)
196{ 170{
197 int xa = ab_calc_mark_x_pos(ab_A_marker, capacity, x, w); 171 *song_position = ab_B_marker;
198 int xb = ab_calc_mark_x_pos(ab_B_marker, capacity, x, w); 172 return ab_B_marker_set();
199 /* if both markers are set, determine if they're far enough apart
200 to draw arrows */
201 if ( ab_A_marker_set() && ab_B_marker_set() )
202 {
203 int arrow_width = (h+1) / 2;
204 if ( (xb-xa) < (arrow_width*2) )
205 {
206 ab_draw_vertical_line_mark(screen, xa, y, h);
207 ab_draw_vertical_line_mark(screen, xb, y, h);
208 return;
209 }
210 }
211
212 if (ab_A_marker_set())
213 {
214 ab_draw_arrow_mark(screen, xa, y, h, DIRECTION_RIGHT);
215 }
216 if (ab_B_marker_set())
217 {
218 ab_draw_arrow_mark(screen, xb, y, h, DIRECTION_LEFT);
219 }
220} 173}
221 174
222#endif /* HAVE_LCD_BITMAP */
223
224#endif /* AB_REPEAT_ENABLE */ 175#endif /* AB_REPEAT_ENABLE */