summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine/wps_internals.h
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2009-08-03 04:43:34 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2009-08-03 04:43:34 +0000
commit3e7444ff8770678b563af6b3f9f6b05521cac959 (patch)
tree2cc650b7726639b51eee53d75a51515a255614a2 /apps/gui/skin_engine/wps_internals.h
parent48b7e8ca2748afbf429dc691a37cb3f6f1252246 (diff)
downloadrockbox-3e7444ff8770678b563af6b3f9f6b05521cac959.tar.gz
rockbox-3e7444ff8770678b563af6b3f9f6b05521cac959.zip
part two of the grand overall wps/skinning engine cleanup work:
* rename wps_engine to skin_engine as that was agreed on * rename music_screen back to wps * clean up the skin display/update functions a bit * make skin_data_load setup the hardcoded default if a skin cant be loaded for whatever reason instead of doing it when it is first displayed ignore any gui_wps or wps_ or gwps_ nameing in skin_engine/ ... these will be renamed as this work gets finished git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22135 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/wps_internals.h')
-rw-r--r--apps/gui/skin_engine/wps_internals.h550
1 files changed, 550 insertions, 0 deletions
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
new file mode 100644
index 0000000000..2dcaa504bb
--- /dev/null
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -0,0 +1,550 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Nicolas Pennequin
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
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! */
24
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.
30*/
31#define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */
32#define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */
33
34
35
36
37/* TODO: sort this mess out */
38
39#include "screen_access.h"
40#include "statusbar.h"
41#include "metadata.h"
42
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 */
51
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)
56/* alignments */
57#define WPS_ALIGN_RIGHT 32
58#define WPS_ALIGN_CENTER 64
59#define WPS_ALIGN_LEFT 128
60
61#ifdef HAVE_ALBUMART
62
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 */
67
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 */
73
74#endif /* HAVE_ALBUMART */
75
76/* wps_data*/
77
78#ifdef HAVE_LCD_BITMAP
79struct gui_img {
80 struct bitmap bm;
81 struct viewport* vp; /* The viewport to display this image in */
82 short int x; /* x-pos */
83 short int y; /* y-pos */
84 short int num_subimages; /* number of sub-images */
85 short int subimage_height; /* height of each sub-image */
86 short int display; /* -1 for no display, 0..n to display a subimage */
87 bool loaded; /* load state */
88 bool always_display; /* not using the preload/display mechanism */
89};
90
91struct progressbar {
92 /* regular pb */
93 short x;
94 /* >=0: explicitly set in the tag -> y-coord within the viewport
95 <0 : not set in the tag -> negated 1-based line number within
96 the viewport. y-coord will be computed based on the font height */
97 short y;
98 short width;
99 short height;
100 /*progressbar image*/
101 struct bitmap bm;
102 bool have_bitmap_pb;
103};
104#endif
105
106
107
108struct align_pos {
109 char* left;
110 char* center;
111 char* right;
112};
113
114#ifdef HAVE_LCD_BITMAP
115
116#define MAX_IMAGES (26*2) /* a-z and A-Z */
117#define MAX_PROGRESSBARS 3
118
119/* The image buffer is big enough to store one full-screen native bitmap,
120 plus two full-screen mono bitmaps. */
121
122#define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
123 + (2*LCD_HEIGHT*LCD_WIDTH/8))
124
125#define WPS_MAX_VIEWPORTS 24
126#define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
127#define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
128#define WPS_MAX_TOKENS 1024
129#define WPS_MAX_STRINGS 128
130#define STRING_BUFFER_SIZE 1024
131#define WPS_MAX_COND_LEVEL 10
132
133#else
134
135#define WPS_MAX_VIEWPORTS 2
136#define WPS_MAX_LINES 2
137#define WPS_MAX_SUBLINES 12
138#define WPS_MAX_TOKENS 64
139#define WPS_MAX_STRINGS 32
140#define STRING_BUFFER_SIZE 64
141#define WPS_MAX_COND_LEVEL 5
142
143#endif
144
145#define SUBLINE_RESET -1
146
147enum wps_parse_error {
148 PARSE_OK,
149 PARSE_FAIL_UNCLOSED_COND,
150 PARSE_FAIL_INVALID_CHAR,
151 PARSE_FAIL_COND_SYNTAX_ERROR,
152 PARSE_FAIL_COND_INVALID_PARAM,
153 PARSE_FAIL_LIMITS_EXCEEDED,
154};
155
156enum wps_token_type {
157 WPS_NO_TOKEN, /* for WPS tags we don't want to save as tokens */
158 WPS_TOKEN_UNKNOWN,
159
160 /* Markers */
161 WPS_TOKEN_CHARACTER,
162 WPS_TOKEN_STRING,
163
164 /* Alignment */
165 WPS_TOKEN_ALIGN_LEFT,
166 WPS_TOKEN_ALIGN_CENTER,
167 WPS_TOKEN_ALIGN_RIGHT,
168
169 /* Sublines */
170 WPS_TOKEN_SUBLINE_TIMEOUT,
171
172 /* Battery */
173 WPS_TOKEN_BATTERY_PERCENT,
174 WPS_TOKEN_BATTERY_VOLTS,
175 WPS_TOKEN_BATTERY_TIME,
176 WPS_TOKEN_BATTERY_CHARGER_CONNECTED,
177 WPS_TOKEN_BATTERY_CHARGING,
178 WPS_TOKEN_BATTERY_SLEEPTIME,
179
180 /* Sound */
181#if (CONFIG_CODEC != MAS3507D)
182 WPS_TOKEN_SOUND_PITCH,
183#endif
184#if (CONFIG_CODEC == SWCODEC)
185 WPS_TOKEN_REPLAYGAIN,
186 WPS_TOKEN_CROSSFADE,
187#endif
188
189 /* Time */
190
191 WPS_TOKEN_RTC_PRESENT,
192
193 /* The begin/end values allow us to know if a token is an RTC one.
194 New RTC tokens should be added between the markers. */
195
196 WPS_TOKENS_RTC_BEGIN, /* just the start marker, not an actual token */
197
198 WPS_TOKEN_RTC_DAY_OF_MONTH,
199 WPS_TOKEN_RTC_DAY_OF_MONTH_BLANK_PADDED,
200 WPS_TOKEN_RTC_12HOUR_CFG,
201 WPS_TOKEN_RTC_HOUR_24_ZERO_PADDED,
202 WPS_TOKEN_RTC_HOUR_24,
203 WPS_TOKEN_RTC_HOUR_12_ZERO_PADDED,
204 WPS_TOKEN_RTC_HOUR_12,
205 WPS_TOKEN_RTC_MONTH,
206 WPS_TOKEN_RTC_MINUTE,
207 WPS_TOKEN_RTC_SECOND,
208 WPS_TOKEN_RTC_YEAR_2_DIGITS,
209 WPS_TOKEN_RTC_YEAR_4_DIGITS,
210 WPS_TOKEN_RTC_AM_PM_UPPER,
211 WPS_TOKEN_RTC_AM_PM_LOWER,
212 WPS_TOKEN_RTC_WEEKDAY_NAME,
213 WPS_TOKEN_RTC_MONTH_NAME,
214 WPS_TOKEN_RTC_DAY_OF_WEEK_START_MON,
215 WPS_TOKEN_RTC_DAY_OF_WEEK_START_SUN,
216
217 WPS_TOKENS_RTC_END, /* just the end marker, not an actual token */
218
219 /* Conditional */
220 WPS_TOKEN_CONDITIONAL,
221 WPS_TOKEN_CONDITIONAL_START,
222 WPS_TOKEN_CONDITIONAL_OPTION,
223 WPS_TOKEN_CONDITIONAL_END,
224
225 /* Database */
226#ifdef HAVE_TAGCACHE
227 WPS_TOKEN_DATABASE_PLAYCOUNT,
228 WPS_TOKEN_DATABASE_RATING,
229 WPS_TOKEN_DATABASE_AUTOSCORE,
230#endif
231
232 /* File */
233 WPS_TOKEN_FILE_BITRATE,
234 WPS_TOKEN_FILE_CODEC,
235 WPS_TOKEN_FILE_FREQUENCY,
236 WPS_TOKEN_FILE_FREQUENCY_KHZ,
237 WPS_TOKEN_FILE_NAME,
238 WPS_TOKEN_FILE_NAME_WITH_EXTENSION,
239 WPS_TOKEN_FILE_PATH,
240 WPS_TOKEN_FILE_SIZE,
241 WPS_TOKEN_FILE_VBR,
242 WPS_TOKEN_FILE_DIRECTORY,
243
244#ifdef HAVE_LCD_BITMAP
245 /* Image */
246 WPS_TOKEN_IMAGE_BACKDROP,
247 WPS_TOKEN_IMAGE_PROGRESS_BAR,
248 WPS_TOKEN_IMAGE_PRELOAD,
249 WPS_TOKEN_IMAGE_PRELOAD_DISPLAY,
250 WPS_TOKEN_IMAGE_DISPLAY,
251#endif
252
253#ifdef HAVE_ALBUMART
254 /* Albumart */
255 WPS_TOKEN_ALBUMART_DISPLAY,
256 WPS_TOKEN_ALBUMART_FOUND,
257#endif
258
259 /* Metadata */
260 WPS_TOKEN_METADATA_ARTIST,
261 WPS_TOKEN_METADATA_COMPOSER,
262 WPS_TOKEN_METADATA_ALBUM_ARTIST,
263 WPS_TOKEN_METADATA_GROUPING,
264 WPS_TOKEN_METADATA_ALBUM,
265 WPS_TOKEN_METADATA_GENRE,
266 WPS_TOKEN_METADATA_DISC_NUMBER,
267 WPS_TOKEN_METADATA_TRACK_NUMBER,
268 WPS_TOKEN_METADATA_TRACK_TITLE,
269 WPS_TOKEN_METADATA_VERSION,
270 WPS_TOKEN_METADATA_YEAR,
271 WPS_TOKEN_METADATA_COMMENT,
272
273 /* Mode */
274 WPS_TOKEN_REPEAT_MODE,
275 WPS_TOKEN_PLAYBACK_STATUS,
276
277 WPS_TOKEN_MAIN_HOLD,
278
279#ifdef HAS_REMOTE_BUTTON_HOLD
280 WPS_TOKEN_REMOTE_HOLD,
281#endif
282
283 /* Progressbar */
284 WPS_TOKEN_PROGRESSBAR,
285#ifdef HAVE_LCD_CHARCELLS
286 WPS_TOKEN_PLAYER_PROGRESSBAR,
287#endif
288
289#ifdef HAVE_LCD_BITMAP
290 /* Peakmeter */
291 WPS_TOKEN_PEAKMETER,
292#endif
293
294 /* Volume level */
295 WPS_TOKEN_VOLUME,
296
297 /* Current track */
298 WPS_TOKEN_TRACK_ELAPSED_PERCENT,
299 WPS_TOKEN_TRACK_TIME_ELAPSED,
300 WPS_TOKEN_TRACK_TIME_REMAINING,
301 WPS_TOKEN_TRACK_LENGTH,
302
303 /* Playlist */
304 WPS_TOKEN_PLAYLIST_ENTRIES,
305 WPS_TOKEN_PLAYLIST_NAME,
306 WPS_TOKEN_PLAYLIST_POSITION,
307 WPS_TOKEN_PLAYLIST_SHUFFLE,
308
309#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
310 /* Virtual LED */
311 WPS_TOKEN_VLED_HDD,
312#endif
313
314 /* Viewport display */
315 WPS_VIEWPORT_ENABLE,
316
317 /* buttons */
318 WPS_TOKEN_BUTTON_VOLUME,
319 WPS_TOKEN_LASTTOUCH,
320
321 /* Setting option */
322 WPS_TOKEN_SETTING,
323};
324
325struct wps_token {
326 unsigned char type; /* enough to store the token type */
327
328 /* Whether the tag (e.g. track name or the album) refers the
329 current or the next song (false=current, true=next) */
330 bool next;
331
332 union {
333 char c;
334 unsigned short i;
335 } value;
336};
337
338/* Description of a subline on the WPS */
339struct wps_subline {
340
341 /* Index of the first token for this subline in the token array.
342 Tokens of this subline end where tokens for the next subline
343 begin. */
344 unsigned short first_token_idx;
345
346 /* Bit or'ed WPS_REFRESH_xxx */
347 unsigned char line_type;
348
349 /* How long the subline should be displayed, in 10ths of sec */
350 unsigned char time_mult;
351};
352
353/* Description of a line on the WPS. A line is a set of sublines.
354 A subline is displayed for a certain amount of time. After that,
355 the next subline of the line is displayed. And so on. */
356struct wps_line {
357
358 /* Number of sublines in this line */
359 signed char num_sublines;
360
361 /* Number (0-based) of the subline within this line currently being displayed */
362 signed char curr_subline;
363
364 /* Index of the first subline of this line in the subline array.
365 Sublines for this line end where sublines for the next line begin. */
366 unsigned short first_subline_idx;
367
368 /* When the next subline of this line should be displayed
369 (absolute time value in ticks) */
370 long subline_expire_time;
371};
372
373#define VP_DRAW_HIDEABLE 0x1
374#define VP_DRAW_HIDDEN 0x2
375#define VP_DRAW_WASHIDDEN 0x4
376struct wps_viewport {
377 struct viewport vp; /* The LCD viewport struct */
378 struct progressbar *pb;
379 /* Indexes of the first and last lines belonging to this viewport in the
380 lines[] array */
381 int first_line, last_line;
382 char hidden_flags;
383 char label;
384};
385
386#ifdef HAVE_TOUCHSCREEN
387struct touchregion {
388 struct wps_viewport* wvp;/* The viewport this region is in */
389 short int x; /* x-pos */
390 short int y; /* y-pos */
391 short int width; /* width */
392 short int height; /* height */
393 bool repeat; /* requires the area be held for the action */
394 int action; /* action this button will return */
395};
396#define MAX_TOUCHREGIONS 15
397#endif
398/* wps_data
399 this struct holds all necessary data which describes the
400 viewable content of a wps */
401struct wps_data
402{
403#ifdef HAVE_LCD_BITMAP
404 struct gui_img img[MAX_IMAGES];
405 unsigned char img_buf[IMG_BUFSIZE];
406 unsigned char* img_buf_ptr;
407 int img_buf_free;
408 bool wps_sb_tag;
409 bool show_sb_on_wps;
410
411 struct progressbar progressbar[MAX_PROGRESSBARS];
412 short progressbar_count;
413
414 bool peak_meter_enabled;
415
416#ifdef HAVE_ALBUMART
417 /* Album art support */
418 unsigned char wps_uses_albumart; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
419 short albumart_x;
420 short albumart_y;
421 unsigned char albumart_xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
422 unsigned char albumart_yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
423 short albumart_max_width;
424 short albumart_max_height;
425
426 int albumart_cond_index;
427#endif
428
429#else /*HAVE_LCD_CHARCELLS */
430 unsigned short wps_progress_pat[8];
431 bool full_line_progressbar;
432#endif
433
434#ifdef HAVE_TOUCHSCREEN
435 struct touchregion touchregion[MAX_TOUCHREGIONS];
436 short touchregion_count;
437#endif
438
439#ifdef HAVE_REMOTE_LCD
440 bool remote_wps;
441#endif
442
443 /* Number of lines in the WPS. During WPS parsing, this is
444 the index of the line being parsed. */
445 int num_lines;
446
447 /* Number of viewports in the WPS */
448 int num_viewports;
449 struct wps_viewport viewports[WPS_MAX_VIEWPORTS];
450
451 struct wps_line lines[WPS_MAX_LINES];
452
453 /* Total number of sublines in the WPS. During WPS parsing, this is
454 the index of the subline where the parsed tokens are added to. */
455 int num_sublines;
456 struct wps_subline sublines[WPS_MAX_SUBLINES];
457
458 /* Total number of tokens in the WPS. During WPS parsing, this is
459 the index of the token being parsed. */
460 int num_tokens;
461 struct wps_token tokens[WPS_MAX_TOKENS];
462
463 char string_buffer[STRING_BUFFER_SIZE];
464 char *strings[WPS_MAX_STRINGS];
465 int num_strings;
466
467 bool wps_loaded;
468
469 /* tick the volume button was last pressed */
470 unsigned int button_time_volume;
471};
472
473/* initial setup of wps_data */
474void wps_data_init(struct wps_data *wps_data);
475
476
477/* Redraw statusbars if necessary */
478void gwps_draw_statusbars(void);
479
480/* Returns the index of the subline in the subline array
481 line - 0-based line number
482 subline - 0-based subline number within the line
483 */
484int wps_subline_index(struct wps_data *wps_data, int line, int subline);
485
486/* Returns the index of the first subline's token in the token array
487 line - 0-based line number
488 subline - 0-based subline number within the line
489 */
490int wps_first_token_index(struct wps_data *data, int line, int subline);
491
492/* Returns the index of the last subline's token in the token array.
493 line - 0-based line number
494 subline - 0-based subline number within the line
495 */
496int wps_last_token_index(struct wps_data *data, int line, int subline);
497
498/* wps_data end */
499
500/* wps_state
501 holds the data which belongs to the current played track,
502 the track which will be played afterwards, current path to the track
503 and some status infos */
504struct wps_state
505{
506 bool ff_rewind;
507 bool paused;
508 int ff_rewind_count;
509 bool wps_time_countup;
510 struct mp3entry* id3;
511 struct mp3entry* nid3;
512 bool do_full_update;
513};
514
515
516/* change the ff/rew-status
517 if ff_rew = true then we are in skipping mode
518 else we are in normal mode */
519/* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
520
521/* change the tag-information of the current played track
522 and the following track */
523/* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
524/* wps_state end*/
525
526/* gui_wps
527 defines a wps with its data, state,
528 and the screen on which the wps-content should be drawn */
529struct gui_wps
530{
531 struct screen *display;
532 struct wps_data *data;
533 struct wps_state *state;
534};
535
536/* gui_wps end */
537
538
539/* currently only on wps_state is needed */
540extern struct wps_state wps_state;
541extern struct gui_wps gui_wps[NB_SCREENS];
542
543/***** wps_tokens.c ******/
544
545const char *get_token_value(struct gui_wps *gwps,
546 struct wps_token *token,
547 char *buf, int buf_size,
548 int *intval);
549
550#endif