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
82 struct viewport
* vp
; /* The viewport to display this image in */
83 short int x
; /* x-pos */
84 short int y
; /* y-pos */
85 short int num_subimages
; /* number of sub-images */
86 short int subimage_height
; /* height of each sub-image */
87 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 */
96 /* >=0: explicitly set in the tag -> y-coord within the viewport
97 <0 : not set in the tag -> negated 1-based line number within
98 the viewport. y-coord will be computed based on the font height */
102 /*progressbar image*/
116 #ifdef HAVE_LCD_BITMAP
118 #define MAX_IMAGES (26*2) /* a-z and A-Z */
119 #define MAX_PROGRESSBARS 3
121 /* The image buffer is big enough to store one full-screen native bitmap,
122 plus two full-screen mono bitmaps. */
124 #define WPS_MAX_VIEWPORTS 24
125 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
126 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
127 #define WPS_MAX_TOKENS 1024
128 #define WPS_MAX_STRINGS 128
129 #define STRING_BUFFER_SIZE 1024
130 #define WPS_MAX_COND_LEVEL 10
134 #define WPS_MAX_VIEWPORTS 2
135 #define WPS_MAX_LINES 2
136 #define WPS_MAX_SUBLINES 12
137 #define WPS_MAX_TOKENS 64
138 #define WPS_MAX_STRINGS 32
139 #define STRING_BUFFER_SIZE 64
140 #define WPS_MAX_COND_LEVEL 5
144 #define SUBLINE_RESET -1
146 enum wps_parse_error
{
148 PARSE_FAIL_UNCLOSED_COND
,
149 PARSE_FAIL_INVALID_CHAR
,
150 PARSE_FAIL_COND_SYNTAX_ERROR
,
151 PARSE_FAIL_COND_INVALID_PARAM
,
152 PARSE_FAIL_LIMITS_EXCEEDED
,
156 /* Description of a subline on the WPS */
159 /* Index of the first token for this subline in the token array.
160 Tokens of this subline end where tokens for the next subline
162 unsigned short first_token_idx
;
164 /* Bit or'ed WPS_REFRESH_xxx */
165 unsigned char line_type
;
167 /* How long the subline should be displayed, in 10ths of sec */
168 unsigned char time_mult
;
171 /* Description of a line on the WPS. A line is a set of sublines.
172 A subline is displayed for a certain amount of time. After that,
173 the next subline of the line is displayed. And so on. */
176 /* Number of sublines in this line */
177 signed char num_sublines
;
179 /* Number (0-based) of the subline within this line currently being displayed */
180 signed char curr_subline
;
182 /* Index of the first subline of this line in the subline array.
183 Sublines for this line end where sublines for the next line begin. */
184 unsigned short first_subline_idx
;
186 /* When the next subline of this line should be displayed
187 (absolute time value in ticks) */
188 long subline_expire_time
;
191 #define VP_DRAW_HIDEABLE 0x1
192 #define VP_DRAW_HIDDEN 0x2
193 #define VP_DRAW_WASHIDDEN 0x4
194 #define VP_DEFAULT_LABEL '|'
195 #define VP_NO_LABEL '-'
196 struct skin_viewport
{
197 struct viewport vp
; /* The LCD viewport struct */
198 struct progressbar
*pb
;
199 /* Indexes of the first and last lines belonging to this viewport in the
201 int first_line
, last_line
;
206 #ifdef HAVE_TOUCHSCREEN
208 struct skin_viewport
* wvp
;/* The viewport this region is in */
209 short int x
; /* x-pos */
210 short int y
; /* y-pos */
211 short int width
; /* width */
212 short int height
; /* height */
214 WPS_TOUCHREGION_ACTION
,
215 WPS_TOUCHREGION_SCROLLBAR
,
216 WPS_TOUCHREGION_VOLUME
217 } type
; /* type of touch region */
218 bool repeat
; /* requires the area be held for the action */
219 int action
; /* action this button will return */
223 this struct holds all necessary data which describes the
224 viewable content of a wps */
227 #ifdef HAVE_LCD_BITMAP
231 struct skin_token_list
*images
;
232 struct skin_token_list
*progressbars
;
234 bool peak_meter_enabled
;
237 /* Album art support */
238 unsigned char wps_uses_albumart
; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
241 unsigned char albumart_xalign
; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
242 unsigned char albumart_yalign
; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
243 short albumart_max_width
;
244 short albumart_max_height
;
246 int albumart_cond_index
;
249 #else /*HAVE_LCD_CHARCELLS */
250 unsigned short wps_progress_pat
[8];
251 bool full_line_progressbar
;
254 #ifdef HAVE_TOUCHSCREEN
255 struct skin_token_list
*touchregions
;
258 #ifdef HAVE_REMOTE_LCD
262 /* Number of lines in the WPS. During WPS parsing, this is
263 the index of the line being parsed. */
266 /* Number of viewports in the WPS */
267 struct skin_token_list
*viewports
;
269 struct wps_line lines
[WPS_MAX_LINES
];
271 /* Total number of sublines in the WPS. During WPS parsing, this is
272 the index of the subline where the parsed tokens are added to. */
274 struct wps_subline sublines
[WPS_MAX_SUBLINES
];
276 /* Total number of tokens in the WPS. During WPS parsing, this is
277 the index of the token being parsed. */
279 struct wps_token
*tokens
;
281 struct skin_token_list
*strings
;
285 /* tick the volume button was last pressed */
286 unsigned int button_time_volume
;
289 /* Returns the index of the last subline's token in the token array.
290 line - 0-based line number
291 subline - 0-based subline number within the line
293 int skin_last_token_index(struct wps_data
*data
, int line
, int subline
);
298 holds the data which belongs to the current played track,
299 the track which will be played afterwards, current path to the track
300 and some status infos */
306 bool wps_time_countup
;
307 struct mp3entry
* id3
;
308 struct mp3entry
* nid3
;
313 /* change the ff/rew-status
314 if ff_rew = true then we are in skipping mode
315 else we are in normal mode */
316 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
318 /* change the tag-information of the current played track
319 and the following track */
320 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
324 defines a wps with its data, state,
325 and the screen on which the wps-content should be drawn */
328 struct screen
*display
;
329 struct wps_data
*data
;
330 struct wps_state
*state
;
332 /* suitable for the viewportmanager, possibly only temporary here
333 * needs to be same for all screens! can't be split up for screens
334 * due to what viewportmanager_set_statusbar() accepts
342 /***** wps_tokens.c ******/
344 const char *get_token_value(struct gui_wps
*gwps
,
345 struct wps_token
*token
,
346 char *buf
, int buf_size
,
351 struct gui_img
* find_image(char label
, struct wps_data
*data
);
352 struct skin_viewport
* find_viewport(char label
, struct wps_data
*data
);