Update Beast installation instructions to use beastpatcher and remove instructions...
[kugel-rb.git] / apps / gui / gwps.h
blob174dff672bd99b21cb88f659fa0c38b87178ab72
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
21 #ifndef _WPS_H
22 #define _WPS_H
24 #include "screen_access.h"
25 #include "statusbar.h"
26 #include "metadata.h"
28 /* constants used in line_type and as refresh_mode for wps_refresh */
29 #define WPS_REFRESH_STATIC 1 /* line doesn't change over time */
30 #define WPS_REFRESH_DYNAMIC 2 /* line may change (e.g. time flag) */
31 #define WPS_REFRESH_SCROLL 4 /* line scrolls */
32 #define WPS_REFRESH_PLAYER_PROGRESS 8 /* line contains a progress bar */
33 #define WPS_REFRESH_PEAK_METER 16 /* line contains a peak meter */
34 #define WPS_REFRESH_ALL 0xff /* to refresh all line types */
35 /* to refresh only those lines that change over time */
36 #define WPS_REFRESH_NON_STATIC (WPS_REFRESH_ALL & ~WPS_REFRESH_STATIC & ~WPS_REFRESH_SCROLL)
38 /* alignments */
39 #define WPS_ALIGN_RIGHT 32
40 #define WPS_ALIGN_CENTER 64
41 #define WPS_ALIGN_LEFT 128
43 #ifdef HAVE_ALBUMART
45 /* albumart definitions */
46 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
47 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
48 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
50 #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
51 #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
52 #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
53 #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
54 #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
56 #endif /* HAVE_ALBUMART */
58 /* wps_data*/
60 #ifdef HAVE_LCD_BITMAP
61 struct gui_img{
62 struct bitmap bm;
63 struct viewport* vp; /* The viewport to display this image in */
64 short int x; /* x-pos */
65 short int y; /* y-pos */
66 short int num_subimages; /* number of sub-images */
67 short int subimage_height; /* height of each sub-image */
68 short int display; /* -1 for no display, 0..n to display a subimage */
69 bool loaded; /* load state */
70 bool always_display; /* not using the preload/display mechanism */
73 struct progressbar {
74 /* regular pb */
75 short x;
76 /* Negative if y is line number based (-line_num-1), positive if set explicitely */
77 short y;
78 short width;
79 short height;
80 /*progressbar image*/
81 struct bitmap bm;
82 bool have_bitmap_pb;
84 #endif
86 struct align_pos {
87 char* left;
88 char* center;
89 char* right;
92 #ifdef HAVE_LCD_BITMAP
94 #define MAX_IMAGES (26*2) /* a-z and A-Z */
95 #define MAX_PROGRESSBARS 3
97 /* The image buffer is big enough to store one full-screen native bitmap,
98 plus two full-screen mono bitmaps. */
100 #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
101 + (2*LCD_HEIGHT*LCD_WIDTH/8))
103 #define WPS_MAX_VIEWPORTS 24
104 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
105 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
106 #define WPS_MAX_TOKENS 1024
107 #define WPS_MAX_STRINGS 128
108 #define STRING_BUFFER_SIZE 1024
109 #define WPS_MAX_COND_LEVEL 10
111 #else
113 #define WPS_MAX_VIEWPORTS 2
114 #define WPS_MAX_LINES 2
115 #define WPS_MAX_SUBLINES 12
116 #define WPS_MAX_TOKENS 64
117 #define WPS_MAX_STRINGS 32
118 #define STRING_BUFFER_SIZE 64
119 #define WPS_MAX_COND_LEVEL 5
121 #endif
123 #define SUBLINE_RESET -1
125 enum wps_parse_error {
126 PARSE_OK,
127 PARSE_FAIL_UNCLOSED_COND,
128 PARSE_FAIL_INVALID_CHAR,
129 PARSE_FAIL_COND_SYNTAX_ERROR,
130 PARSE_FAIL_COND_INVALID_PARAM,
131 PARSE_FAIL_LIMITS_EXCEEDED,
134 enum wps_token_type {
135 WPS_NO_TOKEN, /* for WPS tags we don't want to save as tokens */
136 WPS_TOKEN_UNKNOWN,
138 /* Markers */
139 WPS_TOKEN_CHARACTER,
140 WPS_TOKEN_STRING,
142 /* Alignment */
143 WPS_TOKEN_ALIGN_LEFT,
144 WPS_TOKEN_ALIGN_CENTER,
145 WPS_TOKEN_ALIGN_RIGHT,
147 /* Sublines */
148 WPS_TOKEN_SUBLINE_TIMEOUT,
150 /* Battery */
151 WPS_TOKEN_BATTERY_PERCENT,
152 WPS_TOKEN_BATTERY_VOLTS,
153 WPS_TOKEN_BATTERY_TIME,
154 WPS_TOKEN_BATTERY_CHARGER_CONNECTED,
155 WPS_TOKEN_BATTERY_CHARGING,
156 WPS_TOKEN_BATTERY_SLEEPTIME,
158 /* Sound */
159 #if (CONFIG_CODEC != MAS3507D)
160 WPS_TOKEN_SOUND_PITCH,
161 #endif
162 #if (CONFIG_CODEC == SWCODEC)
163 WPS_TOKEN_REPLAYGAIN,
164 WPS_TOKEN_CROSSFADE,
165 #endif
167 /* Time */
169 /* The begin/end values allow us to know if a token is an RTC one.
170 New RTC tokens should be added between the markers. */
172 WPS_TOKENS_RTC_BEGIN, /* just the start marker, not an actual token */
174 WPS_TOKEN_RTC_DAY_OF_MONTH,
175 WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED,
176 WPS_TOKEN_RTC_12HOUR_CFG,
177 WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED,
178 WPS_TOKEN_RTC_HOUR_24,
179 WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED,
180 WPS_TOKEN_RTC_HOUR_12,
181 WPS_TOKEN_RTC_MONTH,
182 WPS_TOKEN_RTC_MINUTE,
183 WPS_TOKEN_RTC_SECOND,
184 WPS_TOKEN_RTC_YEAR_2_DIGITS,
185 WPS_TOKEN_RTC_YEAR_4_DIGITS,
186 WPS_TOKEN_RTC_AM_PM_UPPER,
187 WPS_TOKEN_RTC_AM_PM_LOWER,
188 WPS_TOKEN_RTC_WEEKDAY_NAME,
189 WPS_TOKEN_RTC_MONTH_NAME,
190 WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON,
191 WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN,
193 WPS_TOKENS_RTC_END, /* just the end marker, not an actual token */
195 /* Conditional */
196 WPS_TOKEN_CONDITIONAL,
197 WPS_TOKEN_CONDITIONAL_START,
198 WPS_TOKEN_CONDITIONAL_OPTION,
199 WPS_TOKEN_CONDITIONAL_END,
201 /* Database */
202 #ifdef HAVE_TAGCACHE
203 WPS_TOKEN_DATABASE_PLAYCOUNT,
204 WPS_TOKEN_DATABASE_RATING,
205 WPS_TOKEN_DATABASE_AUTOSCORE,
206 #endif
208 /* File */
209 WPS_TOKEN_FILE_BITRATE,
210 WPS_TOKEN_FILE_CODEC,
211 WPS_TOKEN_FILE_FREQUENCY,
212 WPS_TOKEN_FILE_FREQUENCY_KHZ,
213 WPS_TOKEN_FILE_NAME,
214 WPS_TOKEN_FILE_NAME_WITH_EXTENSION,
215 WPS_TOKEN_FILE_PATH,
216 WPS_TOKEN_FILE_SIZE,
217 WPS_TOKEN_FILE_VBR,
218 WPS_TOKEN_FILE_DIRECTORY,
220 #ifdef HAVE_LCD_BITMAP
221 /* Image */
222 WPS_TOKEN_IMAGE_BACKDROP,
223 WPS_TOKEN_IMAGE_PROGRESS_BAR,
224 WPS_TOKEN_IMAGE_PRELOAD,
225 WPS_TOKEN_IMAGE_PRELOAD_DISPLAY,
226 WPS_TOKEN_IMAGE_DISPLAY,
227 #endif
229 #ifdef HAVE_ALBUMART
230 /* Albumart */
231 WPS_TOKEN_ALBUMART_DISPLAY,
232 WPS_TOKEN_ALBUMART_FOUND,
233 #endif
235 /* Metadata */
236 WPS_TOKEN_METADATA_ARTIST,
237 WPS_TOKEN_METADATA_COMPOSER,
238 WPS_TOKEN_METADATA_ALBUM_ARTIST,
239 WPS_TOKEN_METADATA_GROUPING,
240 WPS_TOKEN_METADATA_ALBUM,
241 WPS_TOKEN_METADATA_GENRE,
242 WPS_TOKEN_METADATA_DISC_NUMBER,
243 WPS_TOKEN_METADATA_TRACK_NUMBER,
244 WPS_TOKEN_METADATA_TRACK_TITLE,
245 WPS_TOKEN_METADATA_VERSION,
246 WPS_TOKEN_METADATA_YEAR,
247 WPS_TOKEN_METADATA_COMMENT,
249 /* Mode */
250 WPS_TOKEN_REPEAT_MODE,
251 WPS_TOKEN_PLAYBACK_STATUS,
253 WPS_TOKEN_MAIN_HOLD,
255 #ifdef HAS_REMOTE_BUTTON_HOLD
256 WPS_TOKEN_REMOTE_HOLD,
257 #endif
259 /* Progressbar */
260 WPS_TOKEN_PROGRESSBAR,
261 #ifdef HAVE_LCD_CHARCELLS
262 WPS_TOKEN_PLAYER_PROGRESSBAR,
263 #endif
265 #ifdef HAVE_LCD_BITMAP
266 /* Peakmeter */
267 WPS_TOKEN_PEAKMETER,
268 #endif
270 /* Volume level */
271 WPS_TOKEN_VOLUME,
273 /* Current track */
274 WPS_TOKEN_TRACK_ELAPSED_PERCENT,
275 WPS_TOKEN_TRACK_TIME_ELAPSED,
276 WPS_TOKEN_TRACK_TIME_REMAINING,
277 WPS_TOKEN_TRACK_LENGTH,
279 /* Playlist */
280 WPS_TOKEN_PLAYLIST_ENTRIES,
281 WPS_TOKEN_PLAYLIST_NAME,
282 WPS_TOKEN_PLAYLIST_POSITION,
283 WPS_TOKEN_PLAYLIST_SHUFFLE,
285 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
286 /* Virtual LED */
287 WPS_TOKEN_VLED_HDD,
288 #endif
290 /* Viewport display */
291 WPS_VIEWPORT_ENABLE,
293 /* buttons */
294 WPS_TOKEN_BUTTON_VOLUME,
296 /* Setting option */
297 WPS_TOKEN_SETTING,
300 struct wps_token {
301 unsigned char type; /* enough to store the token type */
303 /* Whether the tag (e.g. track name or the album) refers the
304 current or the next song (false=current, true=next) */
305 bool next;
307 union {
308 char c;
309 unsigned short i;
310 } value;
313 /* Description of a subline on the WPS */
314 struct wps_subline {
316 /* Index of the first token for this subline in the token array.
317 Tokens of this subline end where tokens for the next subline
318 begin. */
319 unsigned short first_token_idx;
321 /* Bit or'ed WPS_REFRESH_xxx */
322 unsigned char line_type;
324 /* How long the subline should be displayed, in 10ths of sec */
325 unsigned char time_mult;
328 /* Description of a line on the WPS. A line is a set of sublines.
329 A subline is displayed for a certain amount of time. After that,
330 the next subline of the line is displayed. And so on. */
331 struct wps_line {
333 /* Number of sublines in this line */
334 signed char num_sublines;
336 /* Number (0-based) of the subline within this line currently being displayed */
337 signed char curr_subline;
339 /* Index of the first subline of this line in the subline array.
340 Sublines for this line end where sublines for the next line begin. */
341 unsigned short first_subline_idx;
343 /* When the next subline of this line should be displayed
344 (absolute time value in ticks) */
345 long subline_expire_time;
348 #define VP_DRAW_HIDEABLE 0x1
349 #define VP_DRAW_HIDDEN 0x2
350 #define VP_DRAW_WASHIDDEN 0x4
351 struct wps_viewport {
352 struct viewport vp; /* The LCD viewport struct */
353 struct progressbar *pb;
354 /* Indexes of the first and last lines belonging to this viewport in the
355 lines[] array */
356 int first_line, last_line;
357 char hidden_flags;
358 char label;
361 /* wps_data
362 this struct holds all necessary data which describes the
363 viewable content of a wps */
364 struct wps_data
366 #ifdef HAVE_LCD_BITMAP
367 struct gui_img img[MAX_IMAGES];
368 unsigned char img_buf[IMG_BUFSIZE];
369 unsigned char* img_buf_ptr;
370 int img_buf_free;
371 bool wps_sb_tag;
372 bool show_sb_on_wps;
374 struct progressbar progressbar[MAX_PROGRESSBARS];
375 short progressbar_count;
377 bool peak_meter_enabled;
379 #ifdef HAVE_ALBUMART
380 /* Album art support */
381 unsigned char wps_uses_albumart; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
382 short albumart_x;
383 short albumart_y;
384 unsigned char albumart_xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
385 unsigned char albumart_yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
386 short albumart_max_width;
387 short albumart_max_height;
389 int albumart_cond_index;
390 #endif
392 #else /*HAVE_LCD_CHARCELLS */
393 unsigned short wps_progress_pat[8];
394 bool full_line_progressbar;
395 #endif
397 #ifdef HAVE_REMOTE_LCD
398 bool remote_wps;
399 #endif
401 /* Number of lines in the WPS. During WPS parsing, this is
402 the index of the line being parsed. */
403 int num_lines;
405 /* Number of viewports in the WPS */
406 int num_viewports;
407 struct wps_viewport viewports[WPS_MAX_VIEWPORTS];
409 struct wps_line lines[WPS_MAX_LINES];
411 /* Total number of sublines in the WPS. During WPS parsing, this is
412 the index of the subline where the parsed tokens are added to. */
413 int num_sublines;
414 struct wps_subline sublines[WPS_MAX_SUBLINES];
416 /* Total number of tokens in the WPS. During WPS parsing, this is
417 the index of the token being parsed. */
418 int num_tokens;
419 struct wps_token tokens[WPS_MAX_TOKENS];
421 char string_buffer[STRING_BUFFER_SIZE];
422 char *strings[WPS_MAX_STRINGS];
423 int num_strings;
425 bool wps_loaded;
427 /* tick the volume button was last pressed */
428 unsigned int button_time_volume;
431 /* initial setup of wps_data */
432 void wps_data_init(struct wps_data *wps_data);
434 /* to setup up the wps-data from a format-buffer (isfile = false)
435 from a (wps-)file (isfile = true)*/
436 bool wps_data_load(struct wps_data *wps_data,
437 struct screen *display,
438 const char *buf,
439 bool isfile);
441 /* Returns the index of the subline in the subline array
442 line - 0-based line number
443 subline - 0-based subline number within the line
445 int wps_subline_index(struct wps_data *wps_data, int line, int subline);
447 /* Returns the index of the first subline's token in the token array
448 line - 0-based line number
449 subline - 0-based subline number within the line
451 int wps_first_token_index(struct wps_data *data, int line, int subline);
453 /* Returns the index of the last subline's token in the token array.
454 line - 0-based line number
455 subline - 0-based subline number within the line
457 int wps_last_token_index(struct wps_data *data, int line, int subline);
459 /* wps_data end */
461 /* wps_state
462 holds the data which belongs to the current played track,
463 the track which will be played afterwards, current path to the track
464 and some status infos */
465 struct wps_state
467 bool ff_rewind;
468 bool paused;
469 int ff_rewind_count;
470 bool wps_time_countup;
471 struct mp3entry* id3;
472 struct mp3entry* nid3;
476 /* change the ff/rew-status
477 if ff_rew = true then we are in skipping mode
478 else we are in normal mode */
479 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
481 /* change the tag-information of the current played track
482 and the following track */
483 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
484 /* wps_state end*/
486 /* gui_wps
487 defines a wps with its data, state,
488 and the screen on which the wps-content should be drawn */
489 struct gui_wps
491 struct screen *display;
492 struct wps_data *data;
493 struct wps_state *state;
496 /* gui_wps end */
498 long gui_wps_show(void);
500 /* currently only on wps_state is needed */
501 extern struct wps_state wps_state;
502 extern struct gui_wps gui_wps[NB_SCREENS];
504 void gui_sync_wps_init(void);
506 #ifdef HAVE_ALBUMART
507 /* gives back if WPS contains an albumart tag */
508 bool gui_sync_wps_uses_albumart(void);
509 #endif
511 #endif