1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Nicolas Pennequin
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 /* This stuff is for the wps engine only.. anyone caught using this outside
23 * of apps/gui/wps_engine will be shot on site! */
25 #ifndef _WPS_ENGINE_INTERNALS_
26 #define _WPS_ENGINE_INTERNALS_
27 /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds
28 (possibly with a decimal fraction) but stored as integer values.
29 E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units.
31 #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */
32 #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */
34 #include "skin_tokens.h"
37 /* TODO: sort this mess out */
39 #include "screen_access.h"
40 #include "statusbar.h"
43 /* constants used in line_type and as refresh_mode for wps_refresh */
44 #define WPS_REFRESH_STATIC (1u<<0) /* line doesn't change over time */
45 #define WPS_REFRESH_DYNAMIC (1u<<1) /* line may change (e.g. time flag) */
46 #define WPS_REFRESH_SCROLL (1u<<2) /* line scrolls */
47 #define WPS_REFRESH_PLAYER_PROGRESS (1u<<3) /* line contains a progress bar */
48 #define WPS_REFRESH_PEAK_METER (1u<<4) /* line contains a peak meter */
49 #define WPS_REFRESH_STATUSBAR (1u<<5) /* refresh statusbar */
50 #define WPS_REFRESH_ALL (0xffffffffu) /* to refresh all line types */
52 /* to refresh only those lines that change over time */
53 #define WPS_REFRESH_NON_STATIC (WPS_REFRESH_DYNAMIC| \
54 WPS_REFRESH_PLAYER_PROGRESS| \
55 WPS_REFRESH_PEAK_METER)
57 #define WPS_ALIGN_RIGHT 32
58 #define WPS_ALIGN_CENTER 64
59 #define WPS_ALIGN_LEFT 128
63 /* albumart definitions */
64 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
65 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
66 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
68 #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
69 #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
70 #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
71 #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
72 #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
74 #endif /* HAVE_ALBUMART */
78 #ifdef HAVE_LCD_BITMAP
80 struct viewport
* vp
; /* The viewport to display this image in */
81 short int x
; /* x-pos */
82 short int y
; /* y-pos */
83 short int num_subimages
; /* number of sub-images */
84 short int subimage_height
; /* height of each sub-image */
85 short int display
; /* -1 for no display, 0..n to display a subimage */
88 bool loaded
; /* load state */
89 bool always_display
; /* not using the preload/display mechanism */
94 enum wps_token_type type
;
98 /* >=0: explicitly set in the tag -> y-coord within the viewport
99 <0 : not set in the tag -> negated 1-based line number within
100 the viewport. y-coord will be computed based on the font height */
104 bool follow_lang_direction
;
105 /*progressbar image*/
121 #ifdef HAVE_LCD_BITMAP
123 #define MAX_IMAGES (26*2) /* a-z and A-Z */
124 #define MAX_PROGRESSBARS 3
126 /* The image buffer is big enough to store one full-screen native bitmap,
127 plus two full-screen mono bitmaps. */
129 #define WPS_MAX_VIEWPORTS 24
130 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
131 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
132 #define WPS_MAX_TOKENS 1024
133 #define WPS_MAX_STRINGS 128
134 #define STRING_BUFFER_SIZE 1024
135 #define WPS_MAX_COND_LEVEL 10
139 #define WPS_MAX_VIEWPORTS 2
140 #define WPS_MAX_LINES 2
141 #define WPS_MAX_SUBLINES 12
142 #define WPS_MAX_TOKENS 64
143 #define WPS_MAX_STRINGS 32
144 #define STRING_BUFFER_SIZE 64
145 #define WPS_MAX_COND_LEVEL 5
149 #define SUBLINE_RESET -1
151 enum wps_parse_error
{
153 PARSE_FAIL_UNCLOSED_COND
,
154 PARSE_FAIL_INVALID_CHAR
,
155 PARSE_FAIL_COND_SYNTAX_ERROR
,
156 PARSE_FAIL_COND_INVALID_PARAM
,
157 PARSE_FAIL_LIMITS_EXCEEDED
,
161 /* Description of a subline on the WPS */
162 struct skin_subline
{
164 /* Index of the first token for this subline in the token array.
165 Tokens of this subline end where tokens for the next subline
167 unsigned short first_token_idx
;
168 unsigned short last_token_idx
;
170 /* Bit or'ed WPS_REFRESH_xxx */
171 unsigned char line_type
;
173 /* How long the subline should be displayed, in 10ths of sec */
174 unsigned char time_mult
;
176 /* pointer to the next subline in this line */
177 struct skin_subline
*next
;
180 /* Description of a line on the WPS. A line is a set of sublines.
181 A subline is displayed for a certain amount of time. After that,
182 the next subline of the line is displayed. And so on. */
185 /* Linked list of all the sublines on this line,
186 * a line *must* have at least one subline so no need to add an extra pointer */
187 struct skin_subline sublines
;
188 /* pointer to the current subline */
189 struct skin_subline
*curr_subline
;
191 /* When the next subline of this line should be displayed
192 (absolute time value in ticks) */
193 long subline_expire_time
;
195 /* pointer to the next line */
196 struct skin_line
*next
;
199 #define VP_DRAW_HIDEABLE 0x1
200 #define VP_DRAW_HIDDEN 0x2
201 #define VP_DRAW_WASHIDDEN 0x4
202 /* these are never drawn, nor cleared, i.e. just ignored */
203 #define VP_NEVER_VISIBLE 0x8
204 #define VP_DEFAULT_LABEL '|'
205 #define VP_NO_LABEL '-'
206 #define VP_INFO_LABEL 0x80
207 struct skin_viewport
{
208 struct viewport vp
; /* The LCD viewport struct */
209 struct skin_line
*lines
;
214 #ifdef HAVE_TOUCHSCREEN
216 struct skin_viewport
* wvp
;/* The viewport this region is in */
217 short int x
; /* x-pos */
218 short int y
; /* y-pos */
219 short int width
; /* width */
220 short int height
; /* height */
222 WPS_TOUCHREGION_ACTION
,
223 WPS_TOUCHREGION_SCROLLBAR
,
224 WPS_TOUCHREGION_VOLUME
225 } type
; /* type of touch region */
226 bool repeat
; /* requires the area be held for the action */
227 int action
; /* action this button will return */
228 bool armed
; /* A region is armed on press. Only armed regions are triggered
229 on repeat or release. */
233 #define MAX_PLAYLISTLINE_TOKENS 16
234 #define MAX_PLAYLISTLINE_STRINGS 8
235 #define MAX_PLAYLISTLINE_STRLEN 8
236 enum info_line_type
{
240 struct playlistviewer
{
245 enum wps_token_type tokens
[MAX_PLAYLISTLINE_TOKENS
];
246 char strings
[MAX_PLAYLISTLINE_STRINGS
][MAX_PLAYLISTLINE_STRLEN
];
254 struct skin_albumart
{
255 /* Album art support */
256 struct viewport
*vp
;/* The viewport this is in */
263 unsigned char xalign
; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
264 unsigned char yalign
; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
265 unsigned char state
; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
270 this struct holds all necessary data which describes the
271 viewable content of a wps */
274 #ifdef HAVE_LCD_BITMAP
275 struct skin_token_list
*images
;
276 struct skin_token_list
*progressbars
;
278 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
282 #ifdef HAVE_TOUCHSCREEN
283 struct skin_token_list
*touchregions
;
285 struct skin_token_list
*viewports
;
286 struct skin_token_list
*strings
;
288 struct skin_albumart
*albumart
;
289 int playback_aa_slot
;
291 struct wps_token
*tokens
;
292 /* Total number of tokens in the WPS. During WPS parsing, this is
293 the index of the token being parsed. */
296 #ifdef HAVE_LCD_BITMAP
297 bool peak_meter_enabled
;
300 #else /*HAVE_LCD_CHARCELLS */
301 unsigned short wps_progress_pat
[8];
302 bool full_line_progressbar
;
310 holds the data which belongs to the current played track,
311 the track which will be played afterwards, current path to the track
312 and some status infos */
315 struct mp3entry
* id3
;
316 struct mp3entry
* nid3
;
320 bool wps_time_countup
;
324 /* Holds data for all screens in a skin. */
327 /* suitable for the viewportmanager, possibly only temporary here
328 * needs to be same for all screens! can't be split up for screens
329 * due to what viewportmanager_set_statusbar() accepts
332 /* indicates whether the skin needs a full update for all screens */
336 /* change the ff/rew-status
337 if ff_rew = true then we are in skipping mode
338 else we are in normal mode */
339 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
341 /* change the tag-information of the current played track
342 and the following track */
343 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
347 defines a wps with its data, state,
348 and the screen on which the wps-content should be drawn */
351 struct screen
*display
;
352 struct wps_data
*data
;
353 struct wps_state
*state
;
354 /* must point to the same struct for all screens */
355 struct wps_sync_data
*sync_data
;
360 char *get_image_filename(const char *start
, const char* bmpdir
,
361 char *buf
, int buf_size
);
362 /***** wps_tokens.c ******/
364 const char *get_token_value(struct gui_wps
*gwps
,
365 struct wps_token
*token
,
366 char *buf
, int buf_size
,
369 const char *get_id3_token(struct wps_token
*token
, struct mp3entry
*id3
,
370 char *buf
, int buf_size
, int limit
, int *intval
);
373 struct gui_img
* find_image(char label
, struct wps_data
*data
);
374 struct skin_viewport
* find_viewport(char label
, struct wps_data
*data
);
377 #if defined(DEBUG) || defined(SIMULATOR)
378 #define DEBUG_SKIN_ENGINE
379 extern bool debug_wps
;