If dircache and database "load to ram" is enabled then get the id3 info from the...
[kugel-rb.git] / apps / gui / skin_engine / wps_internals.h
blob211d9a13eeb924e18f323546ae525633001812ef
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 ****************************************************************************/
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"
41 #include "metadata.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)
56 /* alignments */
57 #define WPS_ALIGN_RIGHT 32
58 #define WPS_ALIGN_CENTER 64
59 #define WPS_ALIGN_LEFT 128
61 #ifdef HAVE_ALBUMART
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 */
76 /* wps_data*/
78 #ifdef HAVE_LCD_BITMAP
79 struct gui_img {
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 */
86 struct bitmap bm;
87 char label;
88 bool loaded; /* load state */
89 bool always_display; /* not using the preload/display mechanism */
93 struct progressbar {
94 enum wps_token_type type;
95 struct viewport *vp;
96 /* regular pb */
97 short x;
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 */
101 short y;
102 short width;
103 short height;
104 bool follow_lang_direction;
105 /*progressbar image*/
106 struct bitmap bm;
107 bool have_bitmap_pb;
109 bool draw;
111 #endif
115 struct align_pos {
116 char* left;
117 char* center;
118 char* right;
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
137 #else
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
147 #endif
149 #define SUBLINE_RESET -1
151 enum wps_parse_error {
152 PARSE_OK,
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
166 begin. */
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. */
183 struct skin_line {
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;
210 char hidden_flags;
211 char label;
214 #ifdef HAVE_TOUCHSCREEN
215 struct touchregion {
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 */
221 enum {
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. */
231 #endif
233 #define MAX_PLAYLISTLINE_TOKENS 16
234 #define MAX_PLAYLISTLINE_STRINGS 8
235 #define MAX_PLAYLISTLINE_STRLEN 8
236 enum info_line_type {
237 TRACK_HAS_INFO = 0,
238 TRACK_HAS_NO_INFO
240 struct playlistviewer {
241 struct viewport *vp;
242 bool show_icons;
243 int start_offset;
244 #ifdef HAVE_TC_RAMCACHE
245 struct mp3entry tempid3;
246 #endif
247 struct {
248 enum wps_token_type tokens[MAX_PLAYLISTLINE_TOKENS];
249 char strings[MAX_PLAYLISTLINE_STRINGS][MAX_PLAYLISTLINE_STRLEN];
250 int count;
251 bool scroll;
252 } lines[2];
256 #ifdef HAVE_ALBUMART
257 struct skin_albumart {
258 /* Album art support */
259 struct viewport *vp;/* The viewport this is in */
260 int x;
261 int y;
262 int width;
263 int height;
265 bool draw;
266 unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
267 unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
268 unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
270 #endif
272 /* wps_data
273 this struct holds all necessary data which describes the
274 viewable content of a wps */
275 struct wps_data
277 #ifdef HAVE_LCD_BITMAP
278 struct skin_token_list *images;
279 struct skin_token_list *progressbars;
280 #endif
281 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
282 char *backdrop;
283 #endif
285 #ifdef HAVE_TOUCHSCREEN
286 struct skin_token_list *touchregions;
287 #endif
288 struct skin_token_list *viewports;
289 struct skin_token_list *strings;
290 #ifdef HAVE_ALBUMART
291 struct skin_albumart *albumart;
292 int playback_aa_slot;
293 #endif
294 struct wps_token *tokens;
295 /* Total number of tokens in the WPS. During WPS parsing, this is
296 the index of the token being parsed. */
297 int num_tokens;
299 #ifdef HAVE_LCD_BITMAP
300 bool peak_meter_enabled;
301 bool wps_sb_tag;
302 bool show_sb_on_wps;
303 #else /*HAVE_LCD_CHARCELLS */
304 unsigned short wps_progress_pat[8];
305 bool full_line_progressbar;
306 #endif
307 bool wps_loaded;
310 /* wps_data end */
312 /* wps_state
313 holds the data which belongs to the current played track,
314 the track which will be played afterwards, current path to the track
315 and some status infos */
316 struct wps_state
318 struct mp3entry* id3;
319 struct mp3entry* nid3;
320 int ff_rewind_count;
321 bool ff_rewind;
322 bool paused;
323 bool wps_time_countup;
324 bool is_fading;
327 /* Holds data for all screens in a skin. */
328 struct wps_sync_data
330 /* suitable for the viewportmanager, possibly only temporary here
331 * needs to be same for all screens! can't be split up for screens
332 * due to what viewportmanager_set_statusbar() accepts
333 * (FIXME?) */
334 int statusbars;
335 /* indicates whether the skin needs a full update for all screens */
336 bool do_full_update;
339 /* change the ff/rew-status
340 if ff_rew = true then we are in skipping mode
341 else we are in normal mode */
342 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
344 /* change the tag-information of the current played track
345 and the following track */
346 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
347 /* wps_state end*/
349 /* gui_wps
350 defines a wps with its data, state,
351 and the screen on which the wps-content should be drawn */
352 struct gui_wps
354 struct screen *display;
355 struct wps_data *data;
356 struct wps_state *state;
357 /* must point to the same struct for all screens */
358 struct wps_sync_data *sync_data;
361 /* gui_wps end */
363 char *get_image_filename(const char *start, const char* bmpdir,
364 char *buf, int buf_size);
365 /***** wps_tokens.c ******/
367 const char *get_token_value(struct gui_wps *gwps,
368 struct wps_token *token,
369 char *buf, int buf_size,
370 int *intval);
372 const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
373 char *buf, int buf_size, int limit, int *intval);
376 struct gui_img* find_image(char label, struct wps_data *data);
377 struct skin_viewport* find_viewport(char label, struct wps_data *data);
380 #if defined(DEBUG) || defined(SIMULATOR)
381 #define DEBUG_SKIN_ENGINE
382 extern bool debug_wps;
383 #endif
385 #endif