fiddle with the skin debug output so the load lines arnt shown unless debugwps is...
[kugel-rb.git] / apps / gui / skin_engine / wps_internals.h
blobb0f5f36eb5dc6cd67758dc8c409634bdb547837f
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 /* regular pb */
95 short x;
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 */
99 short y;
100 short width;
101 short height;
102 bool follow_lang_direction;
103 /*progressbar image*/
104 struct bitmap bm;
105 bool have_bitmap_pb;
107 #endif
111 struct align_pos {
112 char* left;
113 char* center;
114 char* right;
117 #ifdef HAVE_LCD_BITMAP
119 #define MAX_IMAGES (26*2) /* a-z and A-Z */
120 #define MAX_PROGRESSBARS 3
122 /* The image buffer is big enough to store one full-screen native bitmap,
123 plus two full-screen mono bitmaps. */
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
133 #else
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
143 #endif
145 #define SUBLINE_RESET -1
147 enum 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,
157 /* Description of a subline on the WPS */
158 struct skin_subline {
160 /* Index of the first token for this subline in the token array.
161 Tokens of this subline end where tokens for the next subline
162 begin. */
163 unsigned short first_token_idx;
164 unsigned short last_token_idx;
166 /* Bit or'ed WPS_REFRESH_xxx */
167 unsigned char line_type;
169 /* How long the subline should be displayed, in 10ths of sec */
170 unsigned char time_mult;
172 /* pointer to the next subline in this line */
173 struct skin_subline *next;
176 /* Description of a line on the WPS. A line is a set of sublines.
177 A subline is displayed for a certain amount of time. After that,
178 the next subline of the line is displayed. And so on. */
179 struct skin_line {
181 /* Linked list of all the sublines on this line,
182 * a line *must* have at least one subline so no need to add an extra pointer */
183 struct skin_subline sublines;
184 /* pointer to the current subline */
185 struct skin_subline *curr_subline;
187 /* When the next subline of this line should be displayed
188 (absolute time value in ticks) */
189 long subline_expire_time;
191 /* pointer to the next line */
192 struct skin_line *next;
195 #define VP_DRAW_HIDEABLE 0x1
196 #define VP_DRAW_HIDDEN 0x2
197 #define VP_DRAW_WASHIDDEN 0x4
198 /* these are never drawn, nor cleared, i.e. just ignored */
199 #define VP_NEVER_VISIBLE 0x8
200 #define VP_DEFAULT_LABEL '|'
201 #define VP_NO_LABEL '-'
202 #define VP_INFO_LABEL '_'
203 struct skin_viewport {
204 struct viewport vp; /* The LCD viewport struct */
205 struct progressbar *pb;
206 struct skin_line *lines;
207 char hidden_flags;
208 char label;
211 #ifdef HAVE_TOUCHSCREEN
212 struct touchregion {
213 struct skin_viewport* wvp;/* The viewport this region is in */
214 short int x; /* x-pos */
215 short int y; /* y-pos */
216 short int width; /* width */
217 short int height; /* height */
218 enum {
219 WPS_TOUCHREGION_ACTION,
220 WPS_TOUCHREGION_SCROLLBAR,
221 WPS_TOUCHREGION_VOLUME
222 } type; /* type of touch region */
223 bool repeat; /* requires the area be held for the action */
224 int action; /* action this button will return */
225 bool armed; /* A region is armed on press. Only armed regions are triggered
226 on repeat or release. */
228 #endif
230 #define MAX_PLAYLISTLINE_TOKENS 16
231 #define MAX_PLAYLISTLINE_STRINGS 8
232 #define MAX_PLAYLISTLINE_STRLEN 8
233 enum info_line_type {
234 TRACK_HAS_INFO = 0,
235 TRACK_HAS_NO_INFO
237 struct playlistviewer {
238 struct viewport *vp;
239 bool show_icons;
240 int start_offset;
241 struct {
242 enum wps_token_type tokens[MAX_PLAYLISTLINE_TOKENS];
243 char strings[MAX_PLAYLISTLINE_STRINGS][MAX_PLAYLISTLINE_STRLEN];
244 int count;
245 bool scroll;
246 } lines[2];
250 #ifdef HAVE_ALBUMART
251 struct skin_albumart {
252 /* Album art support */
253 struct viewport *vp;/* The viewport this is in */
254 int x;
255 int y;
256 int width;
257 int height;
259 bool draw;
260 unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
261 unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
262 unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
264 #endif
266 /* wps_data
267 this struct holds all necessary data which describes the
268 viewable content of a wps */
269 struct wps_data
271 #ifdef HAVE_LCD_BITMAP
272 struct skin_token_list *images;
273 struct skin_token_list *progressbars;
274 #endif
275 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
276 char *backdrop;
277 #endif
279 #ifdef HAVE_TOUCHSCREEN
280 struct skin_token_list *touchregions;
281 #endif
282 struct skin_token_list *viewports;
283 struct skin_token_list *strings;
284 #ifdef HAVE_ALBUMART
285 struct skin_albumart *albumart;
286 int playback_aa_slot;
287 #endif
288 struct wps_token *tokens;
289 /* Total number of tokens in the WPS. During WPS parsing, this is
290 the index of the token being parsed. */
291 int num_tokens;
293 #ifdef HAVE_LCD_BITMAP
294 bool peak_meter_enabled;
295 bool wps_sb_tag;
296 bool show_sb_on_wps;
297 #else /*HAVE_LCD_CHARCELLS */
298 unsigned short wps_progress_pat[8];
299 bool full_line_progressbar;
300 #endif
301 bool wps_loaded;
304 /* wps_data end */
306 /* wps_state
307 holds the data which belongs to the current played track,
308 the track which will be played afterwards, current path to the track
309 and some status infos */
310 struct wps_state
312 struct mp3entry* id3;
313 struct mp3entry* nid3;
314 int ff_rewind_count;
315 bool ff_rewind;
316 bool paused;
317 bool wps_time_countup;
318 bool is_fading;
321 /* Holds data for all screens in a skin. */
322 struct wps_sync_data
324 /* suitable for the viewportmanager, possibly only temporary here
325 * needs to be same for all screens! can't be split up for screens
326 * due to what viewportmanager_set_statusbar() accepts
327 * (FIXME?) */
328 int statusbars;
329 /* indicates whether the skin needs a full update for all screens */
330 bool do_full_update;
333 /* change the ff/rew-status
334 if ff_rew = true then we are in skipping mode
335 else we are in normal mode */
336 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
338 /* change the tag-information of the current played track
339 and the following track */
340 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
341 /* wps_state end*/
343 /* gui_wps
344 defines a wps with its data, state,
345 and the screen on which the wps-content should be drawn */
346 struct gui_wps
348 struct screen *display;
349 struct wps_data *data;
350 struct wps_state *state;
351 /* must point to the same struct for all screens */
352 struct wps_sync_data *sync_data;
355 /* gui_wps end */
357 char *get_image_filename(const char *start, const char* bmpdir,
358 char *buf, int buf_size);
359 /***** wps_tokens.c ******/
361 const char *get_token_value(struct gui_wps *gwps,
362 struct wps_token *token,
363 char *buf, int buf_size,
364 int *intval);
366 const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
367 char *buf, int buf_size, int limit, int *intval);
370 struct gui_img* find_image(char label, struct wps_data *data);
371 struct skin_viewport* find_viewport(char label, struct wps_data *data);
374 #if defined(DEBUG) || defined(SIMULATOR)
375 #define DEBUG_SKIN_ENGINE
376 extern bool debug_wps;
377 #endif
379 #endif