2005-11-17 20:20:01 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2007-04-04 14:41:40 +00:00
|
|
|
* Copyright (C) 2007 Nicolas Pennequin
|
2005-11-17 20:20:01 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-11-17 20:20:01 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2009-07-27 07:21:05 +00:00
|
|
|
|
|
|
|
/* This stuff is for the wps engine only.. anyone caught using this outside
|
|
|
|
* of apps/gui/wps_engine will be shot on site! */
|
|
|
|
|
|
|
|
#ifndef _WPS_ENGINE_INTERNALS_
|
|
|
|
#define _WPS_ENGINE_INTERNALS_
|
|
|
|
/* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds
|
|
|
|
(possibly with a decimal fraction) but stored as integer values.
|
|
|
|
E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units.
|
|
|
|
*/
|
|
|
|
#define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */
|
|
|
|
#define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */
|
|
|
|
|
2009-08-16 18:23:00 +00:00
|
|
|
#include "skin_tokens.h"
|
2009-07-27 07:21:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* TODO: sort this mess out */
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
#include "screen_access.h"
|
2005-11-20 22:13:52 +00:00
|
|
|
#include "statusbar.h"
|
2008-10-15 06:38:51 +00:00
|
|
|
#include "metadata.h"
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
/* constants used in line_type and as refresh_mode for wps_refresh */
|
2009-03-23 03:08:56 +00:00
|
|
|
#define WPS_REFRESH_STATIC (1u<<0) /* line doesn't change over time */
|
|
|
|
#define WPS_REFRESH_DYNAMIC (1u<<1) /* line may change (e.g. time flag) */
|
|
|
|
#define WPS_REFRESH_SCROLL (1u<<2) /* line scrolls */
|
|
|
|
#define WPS_REFRESH_PLAYER_PROGRESS (1u<<3) /* line contains a progress bar */
|
|
|
|
#define WPS_REFRESH_PEAK_METER (1u<<4) /* line contains a peak meter */
|
|
|
|
#define WPS_REFRESH_STATUSBAR (1u<<5) /* refresh statusbar */
|
|
|
|
#define WPS_REFRESH_ALL (0xffffffffu) /* to refresh all line types */
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2009-03-20 16:12:09 +00:00
|
|
|
/* to refresh only those lines that change over time */
|
|
|
|
#define WPS_REFRESH_NON_STATIC (WPS_REFRESH_DYNAMIC| \
|
|
|
|
WPS_REFRESH_PLAYER_PROGRESS| \
|
|
|
|
WPS_REFRESH_PEAK_METER)
|
2005-11-17 20:20:01 +00:00
|
|
|
/* alignments */
|
|
|
|
#define WPS_ALIGN_RIGHT 32
|
|
|
|
#define WPS_ALIGN_CENTER 64
|
|
|
|
#define WPS_ALIGN_LEFT 128
|
|
|
|
|
2007-11-11 12:29:37 +00:00
|
|
|
#ifdef HAVE_ALBUMART
|
|
|
|
|
|
|
|
/* albumart definitions */
|
|
|
|
#define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
|
|
|
|
#define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
|
|
|
|
#define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
|
|
|
|
|
2008-12-09 23:07:59 +00:00
|
|
|
#define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
|
|
|
|
#define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
|
|
|
|
#define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
|
|
|
|
#define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
|
|
|
|
#define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
|
2007-11-11 12:29:37 +00:00
|
|
|
|
|
|
|
#endif /* HAVE_ALBUMART */
|
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
/* wps_data*/
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2009-03-08 11:32:02 +00:00
|
|
|
struct gui_img {
|
2008-03-21 19:38:00 +00:00
|
|
|
struct viewport* vp; /* The viewport to display this image in */
|
2008-04-27 12:54:36 +00:00
|
|
|
short int x; /* x-pos */
|
|
|
|
short int y; /* y-pos */
|
|
|
|
short int num_subimages; /* number of sub-images */
|
|
|
|
short int subimage_height; /* height of each sub-image */
|
|
|
|
short int display; /* -1 for no display, 0..n to display a subimage */
|
2009-10-19 00:26:46 +00:00
|
|
|
struct bitmap bm;
|
|
|
|
char label;
|
2005-11-17 20:20:01 +00:00
|
|
|
bool loaded; /* load state */
|
|
|
|
bool always_display; /* not using the preload/display mechanism */
|
|
|
|
};
|
2006-02-10 13:57:11 +00:00
|
|
|
|
2009-08-16 18:23:00 +00:00
|
|
|
|
2008-06-23 06:04:17 +00:00
|
|
|
struct progressbar {
|
|
|
|
/* regular pb */
|
|
|
|
short x;
|
2009-03-08 11:32:02 +00:00
|
|
|
/* >=0: explicitly set in the tag -> y-coord within the viewport
|
|
|
|
<0 : not set in the tag -> negated 1-based line number within
|
|
|
|
the viewport. y-coord will be computed based on the font height */
|
2008-06-23 06:04:17 +00:00
|
|
|
short y;
|
|
|
|
short width;
|
|
|
|
short height;
|
2010-01-07 07:34:15 +00:00
|
|
|
bool follow_lang_direction;
|
2008-06-23 06:04:17 +00:00
|
|
|
/*progressbar image*/
|
2006-02-10 13:57:11 +00:00
|
|
|
struct bitmap bm;
|
|
|
|
bool have_bitmap_pb;
|
|
|
|
};
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
|
|
|
|
2009-04-20 01:41:56 +00:00
|
|
|
|
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
struct align_pos {
|
|
|
|
char* left;
|
|
|
|
char* center;
|
|
|
|
char* right;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
#define MAX_IMAGES (26*2) /* a-z and A-Z */
|
2008-06-23 06:04:17 +00:00
|
|
|
#define MAX_PROGRESSBARS 3
|
2008-04-04 12:32:37 +00:00
|
|
|
|
|
|
|
/* The image buffer is big enough to store one full-screen native bitmap,
|
|
|
|
plus two full-screen mono bitmaps. */
|
|
|
|
|
2008-06-23 06:04:17 +00:00
|
|
|
#define WPS_MAX_VIEWPORTS 24
|
2008-03-22 00:31:22 +00:00
|
|
|
#define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
|
2007-04-08 04:01:06 +00:00
|
|
|
#define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
|
|
|
|
#define WPS_MAX_TOKENS 1024
|
|
|
|
#define WPS_MAX_STRINGS 128
|
2007-04-15 02:59:34 +00:00
|
|
|
#define STRING_BUFFER_SIZE 1024
|
2007-04-08 04:01:06 +00:00
|
|
|
#define WPS_MAX_COND_LEVEL 10
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
#else
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2008-03-21 19:38:00 +00:00
|
|
|
#define WPS_MAX_VIEWPORTS 2
|
2007-04-08 04:01:06 +00:00
|
|
|
#define WPS_MAX_LINES 2
|
|
|
|
#define WPS_MAX_SUBLINES 12
|
|
|
|
#define WPS_MAX_TOKENS 64
|
|
|
|
#define WPS_MAX_STRINGS 32
|
|
|
|
#define STRING_BUFFER_SIZE 64
|
|
|
|
#define WPS_MAX_COND_LEVEL 5
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
#define SUBLINE_RESET -1
|
|
|
|
|
2008-07-12 15:12:09 +00:00
|
|
|
enum wps_parse_error {
|
|
|
|
PARSE_OK,
|
|
|
|
PARSE_FAIL_UNCLOSED_COND,
|
|
|
|
PARSE_FAIL_INVALID_CHAR,
|
|
|
|
PARSE_FAIL_COND_SYNTAX_ERROR,
|
|
|
|
PARSE_FAIL_COND_INVALID_PARAM,
|
|
|
|
PARSE_FAIL_LIMITS_EXCEEDED,
|
|
|
|
};
|
|
|
|
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2007-04-08 04:01:06 +00:00
|
|
|
/* Description of a subline on the WPS */
|
2009-09-02 06:23:01 +00:00
|
|
|
struct skin_subline {
|
2007-04-08 04:01:06 +00:00
|
|
|
|
|
|
|
/* Index of the first token for this subline in the token array.
|
|
|
|
Tokens of this subline end where tokens for the next subline
|
|
|
|
begin. */
|
|
|
|
unsigned short first_token_idx;
|
2009-09-02 02:55:33 +00:00
|
|
|
unsigned short last_token_idx;
|
2007-04-08 04:01:06 +00:00
|
|
|
|
|
|
|
/* Bit or'ed WPS_REFRESH_xxx */
|
|
|
|
unsigned char line_type;
|
|
|
|
|
|
|
|
/* How long the subline should be displayed, in 10ths of sec */
|
|
|
|
unsigned char time_mult;
|
2009-09-02 02:55:33 +00:00
|
|
|
|
|
|
|
/* pointer to the next subline in this line */
|
2009-09-02 06:23:01 +00:00
|
|
|
struct skin_subline *next;
|
2007-04-08 04:01:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Description of a line on the WPS. A line is a set of sublines.
|
|
|
|
A subline is displayed for a certain amount of time. After that,
|
|
|
|
the next subline of the line is displayed. And so on. */
|
2009-09-02 06:23:01 +00:00
|
|
|
struct skin_line {
|
2007-04-08 04:01:06 +00:00
|
|
|
|
2009-09-02 02:55:33 +00:00
|
|
|
/* Linked list of all the sublines on this line,
|
|
|
|
* a line *must* have at least one subline so no need to add an extra pointer */
|
2009-09-02 06:23:01 +00:00
|
|
|
struct skin_subline sublines;
|
2009-09-02 02:55:33 +00:00
|
|
|
/* pointer to the current subline */
|
2009-09-02 06:23:01 +00:00
|
|
|
struct skin_subline *curr_subline;
|
2007-04-08 04:01:06 +00:00
|
|
|
|
|
|
|
/* When the next subline of this line should be displayed
|
|
|
|
(absolute time value in ticks) */
|
|
|
|
long subline_expire_time;
|
2009-09-02 02:55:33 +00:00
|
|
|
|
|
|
|
/* pointer to the next line */
|
2009-09-02 06:23:01 +00:00
|
|
|
struct skin_line *next;
|
2007-04-08 04:01:06 +00:00
|
|
|
};
|
|
|
|
|
2009-10-19 15:28:15 +00:00
|
|
|
#define VP_DRAW_HIDEABLE 0x1
|
|
|
|
#define VP_DRAW_HIDDEN 0x2
|
|
|
|
#define VP_DRAW_WASHIDDEN 0x4
|
|
|
|
/* these are never drawn, nor cleared, i.e. just ignored */
|
|
|
|
#define VP_NEVER_VISIBLE 0x8
|
|
|
|
#define VP_DEFAULT_LABEL '|'
|
|
|
|
#define VP_NO_LABEL '-'
|
|
|
|
#define VP_INFO_LABEL '_'
|
2009-08-18 05:30:59 +00:00
|
|
|
struct skin_viewport {
|
2008-03-21 19:38:00 +00:00
|
|
|
struct viewport vp; /* The LCD viewport struct */
|
2008-06-23 06:04:17 +00:00
|
|
|
struct progressbar *pb;
|
2009-09-02 06:23:01 +00:00
|
|
|
struct skin_line *lines;
|
2008-06-23 06:04:17 +00:00
|
|
|
char hidden_flags;
|
|
|
|
char label;
|
2008-03-21 19:38:00 +00:00
|
|
|
};
|
2007-04-04 14:41:40 +00:00
|
|
|
|
2009-04-20 01:41:56 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
struct touchregion {
|
2009-08-18 05:30:59 +00:00
|
|
|
struct skin_viewport* wvp;/* The viewport this region is in */
|
2009-04-20 01:41:56 +00:00
|
|
|
short int x; /* x-pos */
|
|
|
|
short int y; /* y-pos */
|
|
|
|
short int width; /* width */
|
|
|
|
short int height; /* height */
|
2009-08-09 17:30:05 +00:00
|
|
|
enum {
|
|
|
|
WPS_TOUCHREGION_ACTION,
|
|
|
|
WPS_TOUCHREGION_SCROLLBAR,
|
|
|
|
WPS_TOUCHREGION_VOLUME
|
|
|
|
} type; /* type of touch region */
|
2009-05-17 06:25:18 +00:00
|
|
|
bool repeat; /* requires the area be held for the action */
|
2009-04-20 01:41:56 +00:00
|
|
|
int action; /* action this button will return */
|
|
|
|
};
|
|
|
|
#endif
|
2009-09-07 02:36:56 +00:00
|
|
|
|
2010-01-13 06:02:38 +00:00
|
|
|
#define MAX_PLAYLISTLINE_TOKENS 16
|
|
|
|
#define MAX_PLAYLISTLINE_STRINGS 8
|
|
|
|
#define MAX_PLAYLISTLINE_STRLEN 8
|
|
|
|
enum info_line_type {
|
|
|
|
TRACK_HAS_INFO = 0,
|
|
|
|
TRACK_HAS_NO_INFO
|
|
|
|
};
|
|
|
|
struct playlistviewer {
|
|
|
|
struct viewport *vp;
|
|
|
|
bool show_icons;
|
|
|
|
int start_offset;
|
|
|
|
struct {
|
|
|
|
enum wps_token_type tokens[MAX_PLAYLISTLINE_TOKENS];
|
|
|
|
char strings[MAX_PLAYLISTLINE_STRINGS][MAX_PLAYLISTLINE_STRLEN];
|
|
|
|
int count;
|
|
|
|
bool scroll;
|
|
|
|
} lines[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-09-07 02:36:56 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_ALBUMART
|
|
|
|
struct skin_albumart {
|
|
|
|
/* Album art support */
|
|
|
|
struct viewport *vp;/* The viewport this is in */
|
2009-09-25 18:36:28 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int width;
|
|
|
|
int height;
|
2009-09-07 02:36:56 +00:00
|
|
|
|
|
|
|
bool draw;
|
2009-09-25 18:36:28 +00:00
|
|
|
unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
|
|
|
|
unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
|
|
|
|
unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
|
2009-09-07 02:36:56 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
/* wps_data
|
2007-04-04 14:41:40 +00:00
|
|
|
this struct holds all necessary data which describes the
|
2005-11-17 20:20:01 +00:00
|
|
|
viewable content of a wps */
|
|
|
|
struct wps_data
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2009-08-16 18:23:00 +00:00
|
|
|
struct skin_token_list *images;
|
|
|
|
struct skin_token_list *progressbars;
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|
2007-04-25 13:09:56 +00:00
|
|
|
|
2009-04-20 01:41:56 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2009-08-16 21:22:57 +00:00
|
|
|
struct skin_token_list *touchregions;
|
2009-04-20 01:41:56 +00:00
|
|
|
#endif
|
2009-08-18 05:30:59 +00:00
|
|
|
struct skin_token_list *viewports;
|
2009-10-14 15:49:11 +00:00
|
|
|
struct skin_token_list *strings;
|
|
|
|
#ifdef HAVE_ALBUMART
|
|
|
|
struct skin_albumart *albumart;
|
2009-10-16 19:14:41 +00:00
|
|
|
int playback_aa_slot;
|
2009-10-14 15:49:11 +00:00
|
|
|
#endif
|
|
|
|
struct wps_token *tokens;
|
2007-04-08 04:01:06 +00:00
|
|
|
/* Total number of tokens in the WPS. During WPS parsing, this is
|
|
|
|
the index of the token being parsed. */
|
|
|
|
int num_tokens;
|
2009-10-16 20:34:04 +00:00
|
|
|
|
2009-10-14 15:49:11 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
bool peak_meter_enabled;
|
|
|
|
bool wps_sb_tag;
|
|
|
|
bool show_sb_on_wps;
|
|
|
|
#else /*HAVE_LCD_CHARCELLS */
|
|
|
|
unsigned short wps_progress_pat[8];
|
|
|
|
bool full_line_progressbar;
|
|
|
|
#endif
|
|
|
|
bool wps_loaded;
|
2005-11-17 20:20:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* wps_data end */
|
|
|
|
|
|
|
|
/* wps_state
|
|
|
|
holds the data which belongs to the current played track,
|
|
|
|
the track which will be played afterwards, current path to the track
|
|
|
|
and some status infos */
|
|
|
|
struct wps_state
|
|
|
|
{
|
2009-11-01 13:36:52 +00:00
|
|
|
struct mp3entry* id3;
|
|
|
|
struct mp3entry* nid3;
|
|
|
|
int ff_rewind_count;
|
2005-11-17 20:20:01 +00:00
|
|
|
bool ff_rewind;
|
|
|
|
bool paused;
|
|
|
|
bool wps_time_countup;
|
2009-11-01 13:36:52 +00:00
|
|
|
bool is_fading;
|
2005-11-17 20:20:01 +00:00
|
|
|
};
|
|
|
|
|
2009-10-20 23:12:20 +00:00
|
|
|
/* Holds data for all screens in a skin. */
|
|
|
|
struct wps_sync_data
|
|
|
|
{
|
|
|
|
/* suitable for the viewportmanager, possibly only temporary here
|
|
|
|
* needs to be same for all screens! can't be split up for screens
|
|
|
|
* due to what viewportmanager_set_statusbar() accepts
|
|
|
|
* (FIXME?) */
|
|
|
|
int statusbars;
|
|
|
|
/* indicates whether the skin needs a full update for all screens */
|
|
|
|
bool do_full_update;
|
|
|
|
};
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
/* change the ff/rew-status
|
2006-04-02 10:41:16 +00:00
|
|
|
if ff_rew = true then we are in skipping mode
|
2005-11-17 20:20:01 +00:00
|
|
|
else we are in normal mode */
|
2006-12-13 11:52:21 +00:00
|
|
|
/* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
|
2005-11-17 20:20:01 +00:00
|
|
|
|
|
|
|
/* change the tag-information of the current played track
|
|
|
|
and the following track */
|
2006-12-13 11:52:21 +00:00
|
|
|
/* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
|
2005-11-17 20:20:01 +00:00
|
|
|
/* wps_state end*/
|
|
|
|
|
|
|
|
/* gui_wps
|
2007-04-08 04:01:06 +00:00
|
|
|
defines a wps with its data, state,
|
2005-11-17 20:20:01 +00:00
|
|
|
and the screen on which the wps-content should be drawn */
|
|
|
|
struct gui_wps
|
|
|
|
{
|
2007-04-08 04:01:06 +00:00
|
|
|
struct screen *display;
|
2005-11-17 20:20:01 +00:00
|
|
|
struct wps_data *data;
|
|
|
|
struct wps_state *state;
|
2009-10-20 23:12:20 +00:00
|
|
|
/* must point to the same struct for all screens */
|
|
|
|
struct wps_sync_data *sync_data;
|
2005-11-17 20:20:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* gui_wps end */
|
|
|
|
|
|
|
|
|
2009-07-27 07:21:05 +00:00
|
|
|
/***** wps_tokens.c ******/
|
2005-11-17 20:20:01 +00:00
|
|
|
|
2009-07-27 07:21:05 +00:00
|
|
|
const char *get_token_value(struct gui_wps *gwps,
|
|
|
|
struct wps_token *token,
|
|
|
|
char *buf, int buf_size,
|
|
|
|
int *intval);
|
2007-11-11 12:29:37 +00:00
|
|
|
|
2009-08-16 18:23:00 +00:00
|
|
|
|
|
|
|
|
2009-08-18 07:17:51 +00:00
|
|
|
struct gui_img* find_image(char label, struct wps_data *data);
|
2009-08-18 05:30:59 +00:00
|
|
|
struct skin_viewport* find_viewport(char label, struct wps_data *data);
|
2009-08-16 18:23:00 +00:00
|
|
|
|
2005-11-17 20:20:01 +00:00
|
|
|
#endif
|