summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--apps/abrepeat.c65
-rw-r--r--apps/abrepeat.h9
-rwxr-xr-xapps/gui/skin_engine/skin_display.c67
3 files changed, 79 insertions, 62 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 @@
unsigned int ab_A_marker IDATA_ATTR = AB_MARKER_NONE;
unsigned int ab_B_marker IDATA_ATTR = AB_MARKER_NONE;
+
static inline bool ab_A_marker_set(void)
{
return ab_A_marker != AB_MARKER_NONE;
@@ -37,6 +38,7 @@ static inline bool ab_B_marker_set(void)
return ab_B_marker != AB_MARKER_NONE;
}
+
#if (CONFIG_CODEC == SWCODEC)
void ab_end_of_track_report(void)
{
@@ -158,67 +160,16 @@ void ab_set_B_marker(unsigned int song_position)
ab_A_marker = AB_MARKER_NONE;
}
-#ifdef HAVE_LCD_BITMAP
-
-static int ab_calc_mark_x_pos(int mark, int capacity,
- int offset, int size)
-{
- return offset + ( (size * mark) / capacity );
-}
-
-static void ab_draw_vertical_line_mark(struct screen * screen,
- int x, int y, int h)
+bool ab_get_A_marker(unsigned *song_position)
{
- screen->set_drawmode(DRMODE_COMPLEMENT);
- screen->vline(x, y, y+h-1);
-}
-
-#define DIRECTION_RIGHT 1
-#define DIRECTION_LEFT -1
-
-static void ab_draw_arrow_mark(struct screen * screen,
- int x, int y, int h, int direction)
-{
- /* draw lines in decreasing size until a height of zero is reached */
- screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
- while( h > 0 )
- {
- screen->vline(x, y, y+h-1);
- h -= 2;
- y++;
- x += direction;
- screen->set_drawmode(DRMODE_COMPLEMENT);
- }
+ *song_position = ab_A_marker;
+ return ab_A_marker_set();
}
-void ab_draw_markers(struct screen * screen, int capacity,
- int x, int y, int w, int h)
+bool ab_get_B_marker(unsigned *song_position)
{
- int xa = ab_calc_mark_x_pos(ab_A_marker, capacity, x, w);
- int xb = ab_calc_mark_x_pos(ab_B_marker, capacity, x, w);
- /* if both markers are set, determine if they're far enough apart
- to draw arrows */
- if ( ab_A_marker_set() && ab_B_marker_set() )
- {
- int arrow_width = (h+1) / 2;
- if ( (xb-xa) < (arrow_width*2) )
- {
- ab_draw_vertical_line_mark(screen, xa, y, h);
- ab_draw_vertical_line_mark(screen, xb, y, h);
- return;
- }
- }
-
- if (ab_A_marker_set())
- {
- ab_draw_arrow_mark(screen, xa, y, h, DIRECTION_RIGHT);
- }
- if (ab_B_marker_set())
- {
- ab_draw_arrow_mark(screen, xb, y, h, DIRECTION_LEFT);
- }
+ *song_position = ab_B_marker;
+ return ab_B_marker_set();
}
-#endif /* HAVE_LCD_BITMAP */
-
#endif /* AB_REPEAT_ENABLE */
diff --git a/apps/abrepeat.h b/apps/abrepeat.h
index 49557a34b7..ec0a07c827 100644
--- a/apps/abrepeat.h
+++ b/apps/abrepeat.h
@@ -37,14 +37,13 @@ void ab_jump_to_A_marker(void);
void ab_reset_markers(void);
void ab_set_A_marker(unsigned int song_position);
void ab_set_B_marker(unsigned int song_position);
+/* These return whether the marker are actually set.
+ * The actual positions are returned via output parameter */
+bool ab_get_A_marker(unsigned int *song_position);
+bool ab_get_B_marker(unsigned int *song_position);
#if (CONFIG_CODEC == SWCODEC)
void ab_end_of_track_report(void);
#endif
-#ifdef HAVE_LCD_BITMAP
-#include "screen_access.h"
-void ab_draw_markers(struct screen * screen, int capacity,
- int x, int y, int w, int h);
-#endif
/* These functions really need to be inlined for speed */
extern unsigned int ab_A_marker;
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 137bced19b..60557bba0d 100755
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -97,6 +97,73 @@ void skin_update(enum skinnable_screens skin, enum screen_type screen,
#ifdef HAVE_LCD_BITMAP
+
+#ifdef AB_REPEAT_ENABLE
+
+#define DIRECTION_RIGHT 1
+#define DIRECTION_LEFT -1
+
+static int ab_calc_mark_x_pos(int mark, int capacity,
+ int offset, int size)
+{
+ return offset + ( (size * mark) / capacity );
+}
+
+static void ab_draw_vertical_line_mark(struct screen * screen,
+ int x, int y, int h)
+{
+ screen->set_drawmode(DRMODE_COMPLEMENT);
+ screen->vline(x, y, y+h-1);
+}
+
+static void ab_draw_arrow_mark(struct screen * screen,
+ int x, int y, int h, int direction)
+{
+ /* draw lines in decreasing size until a height of zero is reached */
+ screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
+ while( h > 0 )
+ {
+ screen->vline(x, y, y+h-1);
+ h -= 2;
+ y++;
+ x += direction;
+ screen->set_drawmode(DRMODE_COMPLEMENT);
+ }
+}
+
+void ab_draw_markers(struct screen * screen, int capacity,
+ int x, int y, int w, int h)
+{
+ bool a_set, b_set;
+ unsigned int a, b;
+ int xa, xb;
+
+ a_set = ab_get_A_marker(&a);
+ b_set = ab_get_B_marker(&b);
+ xa = ab_calc_mark_x_pos(a, capacity, x, w);
+ xb = ab_calc_mark_x_pos(b, capacity, x, w);
+ /* if both markers are set, determine if they're far enough apart
+ to draw arrows */
+ if ( a_set && b_set )
+ {
+ int arrow_width = (h+1) / 2;
+ if ( (xb-xa) < (arrow_width*2) )
+ {
+ ab_draw_vertical_line_mark(screen, xa, y, h);
+ ab_draw_vertical_line_mark(screen, xb, y, h);
+ return;
+ }
+ }
+
+ if (a_set)
+ ab_draw_arrow_mark(screen, xa, y, h, DIRECTION_RIGHT);
+
+ if (b_set)
+ ab_draw_arrow_mark(screen, xb, y, h, DIRECTION_LEFT);
+}
+
+#endif
+
void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
{
struct screen *display = gwps->display;