ab_repeat: Move GUI bits to the skin engine. This allows ab_repeat to be compiled headless.

Change-Id: I4fa3b8ef7139313891ca70df11f7f17c5df38cb7
This commit is contained in:
Thomas Martitz 2013-12-13 10:24:15 +01:00
parent 4262e648eb
commit 50f0dd80d6
3 changed files with 79 additions and 62 deletions

View file

@ -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)
bool ab_get_A_marker(unsigned *song_position)
{
return offset + ( (size * mark) / capacity );
*song_position = ab_A_marker;
return ab_A_marker_set();
}
static void ab_draw_vertical_line_mark(struct screen * screen,
int x, int y, int h)
bool ab_get_B_marker(unsigned *song_position)
{
screen->set_drawmode(DRMODE_COMPLEMENT);
screen->vline(x, y, y+h-1);
*song_position = ab_B_marker;
return ab_B_marker_set();
}
#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);
}
}
void ab_draw_markers(struct screen * screen, int capacity,
int x, int y, int w, int h)
{
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);
}
}
#endif /* HAVE_LCD_BITMAP */
#endif /* AB_REPEAT_ENABLE */

View file

@ -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;

View file

@ -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;