summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/gui/skin_engine/skin_display.c20
-rw-r--r--apps/gui/skin_engine/skin_parser.c136
-rw-r--r--apps/gui/skin_engine/skin_tokens.c8
-rw-r--r--apps/gui/skin_engine/skin_tokens.h1
-rw-r--r--apps/gui/skin_engine/wps_debug.c6
-rw-r--r--apps/gui/skin_engine/wps_internals.h30
-rw-r--r--apps/gui/wps.c9
-rw-r--r--apps/recorder/albumart.c32
8 files changed, 136 insertions, 106 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 01f8b13acb..4a87b69ce4 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -77,6 +77,9 @@ void skin_data_init(struct wps_data *wps_data)
wps_data->peak_meter_enabled = false;
wps_data->images = NULL;
wps_data->progressbars = NULL;
+#ifdef HAVE_ALBUMART
+ wps_data->albumart = NULL;
+#endif
/* progress bars */
#else /* HAVE_LCD_CHARCELLS */
int i;
@@ -265,6 +268,14 @@ static void wps_display_images(struct gui_wps *gwps, struct viewport* vp)
}
list = list->next;
}
+#ifdef HAVE_ALBUMART
+ /* now draw the AA */
+ if (data->albumart && data->albumart->vp == vp && data->albumart->draw)
+ {
+ draw_album_art(gwps, audio_current_aa_hid(), false);
+ }
+#endif
+
display->set_drawmode(DRMODE_SOLID);
}
@@ -465,8 +476,11 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index)
clear_image_pos(gwps, find_image(data->tokens[i].value.i&0xFF, gwps->data));
#endif
#ifdef HAVE_ALBUMART
- if (data->tokens[i].type == WPS_TOKEN_ALBUMART_DISPLAY)
+ if (data->albumart && data->tokens[i].type == WPS_TOKEN_ALBUMART_DISPLAY)
+ {
draw_album_art(gwps, audio_current_aa_hid(), true);
+ data->albumart->draw = false;
+ }
#endif
}
@@ -961,9 +975,9 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
skin_viewport->hidden_flags |= VP_DRAW_HIDDEN;
}
}
-
+ int viewport_count = 0;
for (viewport_list = data->viewports;
- viewport_list; viewport_list = viewport_list->next)
+ viewport_list; viewport_list = viewport_list->next, viewport_count++)
{
struct skin_viewport *skin_viewport =
(struct skin_viewport *)viewport_list->token->value.data;
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 59499d7c98..e2f7f5363c 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -156,7 +156,7 @@ static int parse_image_special(const char *wps_bufptr,
#ifdef HAVE_ALBUMART
static int parse_albumart_load(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
-static int parse_albumart_conditional(const char *wps_bufptr,
+static int parse_albumart_display(const char *wps_bufptr,
struct wps_token *token, struct wps_data *wps_data);
#endif /* HAVE_ALBUMART */
#ifdef HAVE_TOUCHSCREEN
@@ -337,8 +337,7 @@ static const struct wps_tag all_tags[] = {
{ WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load },
#ifdef HAVE_ALBUMART
{ WPS_NO_TOKEN, "Cl", 0, parse_albumart_load },
- { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC,
- parse_albumart_conditional },
+ { WPS_TOKEN_ALBUMART_DISPLAY, "C", WPS_REFRESH_STATIC, parse_albumart_display },
#endif
{ WPS_VIEWPORT_ENABLE, "Vd", WPS_REFRESH_DYNAMIC,
@@ -960,13 +959,17 @@ static int parse_albumart_load(const char *wps_bufptr,
{
const char *_pos, *newline;
bool parsing;
+ struct skin_albumart *aa = skin_buffer_alloc(sizeof(struct skin_albumart));
(void)token; /* silence warning */
+ if (!aa)
+ return skip_end_of_line(wps_bufptr);
/* reset albumart info in wps */
- wps_data->albumart_max_width = -1;
- wps_data->albumart_max_height = -1;
- wps_data->albumart_xalign = WPS_ALBUMART_ALIGN_CENTER; /* default */
- wps_data->albumart_yalign = WPS_ALBUMART_ALIGN_CENTER; /* default */
+ aa->albumart_max_width = -1;
+ aa->albumart_max_height = -1;
+ aa->albumart_xalign = WPS_ALBUMART_ALIGN_CENTER; /* default */
+ aa->albumart_yalign = WPS_ALBUMART_ALIGN_CENTER; /* default */
+ aa->vp = &curr_vp->vp;
/* format: %Cl|x|y|[[l|c|r]mwidth]|[[t|c|b]mheight]| */
@@ -979,13 +982,13 @@ static int parse_albumart_load(const char *wps_bufptr,
_pos = wps_bufptr + 1;
if (!isdigit(*_pos))
return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl|@ */
- wps_data->albumart_x = atoi(_pos);
+ aa->albumart_x = atoi(_pos);
_pos = strchr(_pos, '|');
if (!_pos || _pos > newline || !isdigit(*(++_pos)))
return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl|7\n or %Cl|7|@ */
- wps_data->albumart_y = atoi(_pos);
+ aa->albumart_y = atoi(_pos);
_pos = strchr(_pos, '|');
if (!_pos || _pos > newline)
@@ -1003,16 +1006,16 @@ static int parse_albumart_load(const char *wps_bufptr,
case 'l':
case 'L':
case '+':
- wps_data->albumart_xalign = WPS_ALBUMART_ALIGN_LEFT;
+ aa->albumart_xalign = WPS_ALBUMART_ALIGN_LEFT;
break;
case 'c':
case 'C':
- wps_data->albumart_xalign = WPS_ALBUMART_ALIGN_CENTER;
+ aa->albumart_xalign = WPS_ALBUMART_ALIGN_CENTER;
break;
case 'r':
case 'R':
case '-':
- wps_data->albumart_xalign = WPS_ALBUMART_ALIGN_RIGHT;
+ aa->albumart_xalign = WPS_ALBUMART_ALIGN_RIGHT;
break;
case 'd':
case 'D':
@@ -1033,7 +1036,7 @@ static int parse_albumart_load(const char *wps_bufptr,
if (!isdigit(*_pos)) /* malformed token: e.g. %Cl|7|59|# */
return WPS_ERROR_INVALID_PARAM;
- wps_data->albumart_max_width = atoi(_pos);
+ aa->albumart_max_width = atoi(_pos);
_pos = strchr(_pos, '|');
if (!_pos || _pos > newline)
@@ -1052,16 +1055,16 @@ static int parse_albumart_load(const char *wps_bufptr,
case 't':
case 'T':
case '-':
- wps_data->albumart_yalign = WPS_ALBUMART_ALIGN_TOP;
+ aa->albumart_yalign = WPS_ALBUMART_ALIGN_TOP;
break;
case 'c':
case 'C':
- wps_data->albumart_yalign = WPS_ALBUMART_ALIGN_CENTER;
+ aa->albumart_yalign = WPS_ALBUMART_ALIGN_CENTER;
break;
case 'b':
case 'B':
case '+':
- wps_data->albumart_yalign = WPS_ALBUMART_ALIGN_BOTTOM;
+ aa->albumart_yalign = WPS_ALBUMART_ALIGN_BOTTOM;
break;
case 'd':
case 'D':
@@ -1082,7 +1085,7 @@ static int parse_albumart_load(const char *wps_bufptr,
if (!isdigit(*_pos))
return WPS_ERROR_INVALID_PARAM; /* malformed token e.g. %Cl|7|59|200|@ */
- wps_data->albumart_max_height = atoi(_pos);
+ aa->albumart_max_height = atoi(_pos);
_pos = strchr(_pos, '|');
if (!_pos || _pos > newline)
@@ -1091,54 +1094,41 @@ static int parse_albumart_load(const char *wps_bufptr,
}
/* if we got here, we parsed everything ok .. ! */
- if (wps_data->albumart_max_width < 0)
- wps_data->albumart_max_width = 0;
- else if (wps_data->albumart_max_width > LCD_WIDTH)
- wps_data->albumart_max_width = LCD_WIDTH;
+ if (aa->albumart_max_width < 0)
+ aa->albumart_max_width = 0;
+ else if (aa->albumart_max_width > LCD_WIDTH)
+ aa->albumart_max_width = LCD_WIDTH;
- if (wps_data->albumart_max_height < 0)
- wps_data->albumart_max_height = 0;
- else if (wps_data->albumart_max_height > LCD_HEIGHT)
- wps_data->albumart_max_height = LCD_HEIGHT;
+ if (aa->albumart_max_height < 0)
+ aa->albumart_max_height = 0;
+ else if (aa->albumart_max_height > LCD_HEIGHT)
+ aa->albumart_max_height = LCD_HEIGHT;
- wps_data->wps_uses_albumart = WPS_ALBUMART_LOAD;
+ aa->wps_uses_albumart = WPS_ALBUMART_LOAD;
+ aa->draw = false;
+ wps_data->albumart = aa;
/* Skip the rest of the line */
return skip_end_of_line(wps_bufptr);
}
-static int parse_albumart_conditional(const char *wps_bufptr,
+static int parse_albumart_display(const char *wps_bufptr,
struct wps_token *token,
struct wps_data *wps_data)
{
- struct wps_token *prevtoken = token;
- --prevtoken;
- if (wps_data->num_tokens >= 1 && prevtoken->type == WPS_TOKEN_CONDITIONAL)
- {
- /* This %C is part of a %?C construct.
- It's either %?C<blah> or %?Cn<blah> */
- token->type = WPS_TOKEN_ALBUMART_FOUND;
- if (*wps_bufptr == 'n' && *(wps_bufptr + 1) == '<')
- {
- token->next = true;
- return 1;
- }
- else if (*wps_bufptr == '<')
- {
- return 0;
- }
- else
- {
- token->type = WPS_NO_TOKEN;
- return 0;
- }
- }
- else
+ (void)wps_bufptr;
+ (void)token;
+ if (wps_data->albumart)
{
- /* This %C tag is in a conditional construct. */
- wps_data->albumart_cond_index = condindex[level];
- return 0;
+ wps_data->albumart->vp = &curr_vp->vp;
}
+#if 0
+ /* the old code did this so keep it here for now...
+ * this is to allow the posibility to showing the next tracks AA! */
+ if (wps_bufptr+1 == 'n')
+ return 1;
+#endif
+ return 0;
};
#endif /* HAVE_ALBUMART */
@@ -1675,16 +1665,21 @@ bool skin_data_load(struct wps_data *wps_data,
const char *buf,
bool isfile)
{
+
+ if (!wps_data || !buf)
+ return false;
#ifdef HAVE_ALBUMART
+ int status;
struct mp3entry *curtrack;
long offset;
- int status;
- int wps_uses_albumart = wps_data->wps_uses_albumart;
- int albumart_max_height = wps_data->albumart_max_height;
- int albumart_max_width = wps_data->albumart_max_width;
+ struct skin_albumart old_aa = {.wps_uses_albumart = WPS_ALBUMART_NONE};
+ if (wps_data->albumart)
+ {
+ old_aa.wps_uses_albumart = wps_data->albumart->wps_uses_albumart;
+ old_aa.albumart_max_height = wps_data->albumart->albumart_max_height;
+ old_aa.albumart_max_width = wps_data->albumart->albumart_max_width;
+ }
#endif
- if (!wps_data || !buf)
- return false;
wps_reset(wps_data);
@@ -1799,17 +1794,20 @@ bool skin_data_load(struct wps_data *wps_data,
#endif
#ifdef HAVE_ALBUMART
status = audio_status();
- if (((!wps_uses_albumart && wps_data->wps_uses_albumart) ||
- (wps_data->wps_uses_albumart &&
- (albumart_max_height != wps_data->albumart_max_height ||
- albumart_max_width != wps_data->albumart_max_width))) &&
- status & AUDIO_STATUS_PLAY)
+ if (status & AUDIO_STATUS_PLAY)
{
- curtrack = audio_current_track();
- offset = curtrack->offset;
- audio_stop();
- if (!(status & AUDIO_STATUS_PAUSE))
- audio_play(offset);
+ struct skin_albumart *aa = wps_data->albumart;
+ if (aa && ((aa->wps_uses_albumart && !old_aa.wps_uses_albumart) ||
+ (aa->wps_uses_albumart &&
+ (((old_aa.albumart_max_height != aa->albumart_max_height) ||
+ (old_aa.albumart_max_width != aa->albumart_max_width))))))
+ {
+ curtrack = audio_current_track();
+ offset = curtrack->offset;
+ audio_stop();
+ if (!(status & AUDIO_STATUS_PAUSE))
+ audio_play(offset);
+ }
}
#endif
#if defined(DEBUG) || defined(SIMULATOR)
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 1254900844..deab0eaf60 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -319,13 +319,13 @@ const char *get_token_value(struct gui_wps *gwps,
#ifdef HAVE_ALBUMART
case WPS_TOKEN_ALBUMART_DISPLAY:
- draw_album_art(gwps, audio_current_aa_hid(), false);
- return NULL;
-
- case WPS_TOKEN_ALBUMART_FOUND:
+ if (!data->albumart)
+ return NULL;
if (audio_current_aa_hid() >= 0) {
+ data->albumart->draw = true;
return "C";
}
+ data->albumart->draw = false;
return NULL;
#endif
diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h
index ea59053c7a..ad016047ba 100644
--- a/apps/gui/skin_engine/skin_tokens.h
+++ b/apps/gui/skin_engine/skin_tokens.h
@@ -177,7 +177,6 @@ enum wps_token_type {
WPS_TOKEN_PLAYLIST_NAME,
WPS_TOKEN_PLAYLIST_POSITION,
WPS_TOKEN_PLAYLIST_SHUFFLE,
-
#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
/* Virtual LED */
WPS_TOKEN_VLED_HDD,
diff --git a/apps/gui/skin_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c
index 523e2d62ce..db8aa7759e 100644
--- a/apps/gui/skin_engine/wps_debug.c
+++ b/apps/gui/skin_engine/wps_debug.c
@@ -431,6 +431,12 @@ static char *get_token_desc(struct wps_token *token, char *buf, int bufsize)
snprintf(buf, bufsize, "pitch value");
break;
#endif
+
+#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
+ case WPS_TOKEN_VLED_HDD:
+ snprintf(buf, bufsize, "display virtual HDD LED");
+ break;
+#endif
case WPS_VIEWPORT_ENABLE:
snprintf(buf, bufsize, "enable VP:%d",
token->value.i);
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index d1674ac88e..e2330a777e 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -220,6 +220,24 @@ struct touchregion {
int action; /* action this button will return */
};
#endif
+
+
+#ifdef HAVE_ALBUMART
+struct skin_albumart {
+ /* Album art support */
+ struct viewport *vp;/* The viewport this is in */
+ unsigned char wps_uses_albumart; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
+ short albumart_x;
+ short albumart_y;
+ unsigned char albumart_xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
+ unsigned char albumart_yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
+ short albumart_max_width;
+ short albumart_max_height;
+
+ bool draw;
+};
+#endif
+
/* wps_data
this struct holds all necessary data which describes the
viewable content of a wps */
@@ -233,18 +251,8 @@ struct wps_data
struct skin_token_list *progressbars;
bool peak_meter_enabled;
-
#ifdef HAVE_ALBUMART
- /* Album art support */
- unsigned char wps_uses_albumart; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
- short albumart_x;
- short albumart_y;
- unsigned char albumart_xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
- unsigned char albumart_yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
- short albumart_max_width;
- short albumart_max_height;
-
- int albumart_cond_index;
+ struct skin_albumart *albumart;
#endif
#else /*HAVE_LCD_CHARCELLS */
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index f336f77503..dcd3e2480d 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -1280,7 +1280,7 @@ void gui_sync_wps_init(void)
{
skin_data_init(&wps_datas[i]);
#ifdef HAVE_ALBUMART
- wps_datas[i].wps_uses_albumart = 0;
+ wps_datas[i].albumart = NULL;
#endif
#ifdef HAVE_REMOTE_LCD
wps_datas[i].remote_wps = (i == SCREEN_REMOTE);
@@ -1306,12 +1306,13 @@ bool wps_uses_albumart(int *width, int *height)
int i;
FOR_NB_SCREENS(i) {
struct gui_wps *gwps = &gui_wps[i];
- if (gwps->data && (gwps->data->wps_uses_albumart != WPS_ALBUMART_NONE))
+ struct skin_albumart *aa = gwps->data->albumart;
+ if (aa && (aa->wps_uses_albumart != WPS_ALBUMART_NONE))
{
if (width)
- *width = gui_wps[0].data->albumart_max_width;
+ *width = aa->albumart_max_width;
if (height)
- *height = gui_wps[0].data->albumart_max_height;
+ *height = aa->albumart_max_height;
return true;
}
}
diff --git a/apps/recorder/albumart.c b/apps/recorder/albumart.c
index 438c173211..7715287d46 100644
--- a/apps/recorder/albumart.c
+++ b/apps/recorder/albumart.c
@@ -308,6 +308,7 @@ void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear)
return;
struct wps_data *data = gwps->data;
+ struct skin_albumart *aa = data->albumart;
#ifdef HAVE_REMOTE_LCD
/* No album art on RWPS */
@@ -315,37 +316,40 @@ void draw_album_art(struct gui_wps *gwps, int handle_id, bool clear)
return;
#endif
+ if (!aa)
+ return;
+
struct bitmap *bmp;
if (bufgetdata(handle_id, 0, (void *)&bmp) <= 0)
return;
- short x = data->albumart_x;
- short y = data->albumart_y;
+ short x = aa->albumart_x;
+ short y = aa->albumart_y;
short width = bmp->width;
short height = bmp->height;
- if (data->albumart_max_width > 0)
+ if (aa->albumart_max_width > 0)
{
/* Crop if the bitmap is too wide */
- width = MIN(bmp->width, data->albumart_max_width);
+ width = MIN(bmp->width, aa->albumart_max_width);
/* Align */
- if (data->albumart_xalign & WPS_ALBUMART_ALIGN_RIGHT)
- x += data->albumart_max_width - width;
- else if (data->albumart_xalign & WPS_ALBUMART_ALIGN_CENTER)
- x += (data->albumart_max_width - width) / 2;
+ if (aa->albumart_xalign & WPS_ALBUMART_ALIGN_RIGHT)
+ x += aa->albumart_max_width - width;
+ else if (aa->albumart_xalign & WPS_ALBUMART_ALIGN_CENTER)
+ x += (aa->albumart_max_width - width) / 2;
}
- if (data->albumart_max_height > 0)
+ if (aa->albumart_max_height > 0)
{
/* Crop if the bitmap is too high */
- height = MIN(bmp->height, data->albumart_max_height);
+ height = MIN(bmp->height, aa->albumart_max_height);
/* Align */
- if (data->albumart_yalign & WPS_ALBUMART_ALIGN_BOTTOM)
- y += data->albumart_max_height - height;
- else if (data->albumart_yalign & WPS_ALBUMART_ALIGN_CENTER)
- y += (data->albumart_max_height - height) / 2;
+ if (aa->albumart_yalign & WPS_ALBUMART_ALIGN_BOTTOM)
+ y += aa->albumart_max_height - height;
+ else if (aa->albumart_yalign & WPS_ALBUMART_ALIGN_CENTER)
+ y += (aa->albumart_max_height - height) / 2;
}
if (!clear)