Allow the progressbar and volume touch regions to be reverse by prepending them with...
[kugel-rb.git] / apps / gui / skin_engine / wps_internals.h
blob4ef860a8b7d04195c192563edc7092d27e7522c0
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;
212 unsigned start_fgcolour;
213 unsigned start_bgcolour;
215 struct viewport_colour {
216 struct viewport *vp;
217 unsigned colour;
219 #ifdef HAVE_TOUCHSCREEN
220 struct touchregion {
221 struct skin_viewport* wvp;/* The viewport this region is in */
222 short int x; /* x-pos */
223 short int y; /* y-pos */
224 short int width; /* width */
225 short int height; /* height */
226 enum {
227 WPS_TOUCHREGION_ACTION,
228 WPS_TOUCHREGION_SCROLLBAR,
229 WPS_TOUCHREGION_VOLUME
230 } type; /* type of touch region */
231 bool reverse_bar; /* if true 0% is the left or top */
232 bool repeat; /* requires the area be held for the action */
233 int action; /* action this button will return */
234 bool armed; /* A region is armed on press. Only armed regions are triggered
235 on repeat or release. */
237 #endif
239 #define MAX_PLAYLISTLINE_TOKENS 16
240 #define MAX_PLAYLISTLINE_STRINGS 8
241 #define MAX_PLAYLISTLINE_STRLEN 8
242 enum info_line_type {
243 TRACK_HAS_INFO = 0,
244 TRACK_HAS_NO_INFO
246 struct playlistviewer {
247 struct viewport *vp;
248 bool show_icons;
249 int start_offset;
250 #ifdef HAVE_TC_RAMCACHE
251 struct mp3entry tempid3;
252 #endif
253 struct {
254 enum wps_token_type tokens[MAX_PLAYLISTLINE_TOKENS];
255 char strings[MAX_PLAYLISTLINE_STRINGS][MAX_PLAYLISTLINE_STRLEN];
256 int count;
257 bool scroll;
258 } lines[2];
262 #ifdef HAVE_ALBUMART
263 struct skin_albumart {
264 /* Album art support */
265 struct viewport *vp;/* The viewport this is in */
266 int x;
267 int y;
268 int width;
269 int height;
271 bool draw;
272 unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
273 unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
274 unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
276 #endif
278 /* wps_data
279 this struct holds all necessary data which describes the
280 viewable content of a wps */
281 struct wps_data
283 #ifdef HAVE_LCD_BITMAP
284 struct skin_token_list *images;
285 struct skin_token_list *progressbars;
286 #endif
287 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
288 char *backdrop;
289 #endif
291 #ifdef HAVE_TOUCHSCREEN
292 struct skin_token_list *touchregions;
293 #endif
294 struct skin_token_list *viewports;
295 struct skin_token_list *strings;
296 #ifdef HAVE_ALBUMART
297 struct skin_albumart *albumart;
298 int playback_aa_slot;
299 #endif
300 struct wps_token *tokens;
301 /* Total number of tokens in the WPS. During WPS parsing, this is
302 the index of the token being parsed. */
303 int num_tokens;
305 #ifdef HAVE_LCD_BITMAP
306 bool peak_meter_enabled;
307 bool wps_sb_tag;
308 bool show_sb_on_wps;
309 #else /*HAVE_LCD_CHARCELLS */
310 unsigned short wps_progress_pat[8];
311 bool full_line_progressbar;
312 #endif
313 bool wps_loaded;
316 /* wps_data end */
318 /* wps_state
319 holds the data which belongs to the current played track,
320 the track which will be played afterwards, current path to the track
321 and some status infos */
322 struct wps_state
324 struct mp3entry* id3;
325 struct mp3entry* nid3;
326 int ff_rewind_count;
327 bool ff_rewind;
328 bool paused;
329 bool wps_time_countup;
330 bool is_fading;
333 /* Holds data for all screens in a skin. */
334 struct wps_sync_data
336 /* suitable for the viewportmanager, possibly only temporary here
337 * needs to be same for all screens! can't be split up for screens
338 * due to what viewportmanager_set_statusbar() accepts
339 * (FIXME?) */
340 int statusbars;
341 /* indicates whether the skin needs a full update for all screens */
342 bool do_full_update;
345 /* change the ff/rew-status
346 if ff_rew = true then we are in skipping mode
347 else we are in normal mode */
348 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
350 /* change the tag-information of the current played track
351 and the following track */
352 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
353 /* wps_state end*/
355 /* gui_wps
356 defines a wps with its data, state,
357 and the screen on which the wps-content should be drawn */
358 struct gui_wps
360 struct screen *display;
361 struct wps_data *data;
362 struct wps_state *state;
363 /* must point to the same struct for all screens */
364 struct wps_sync_data *sync_data;
367 /* gui_wps end */
369 char *get_image_filename(const char *start, const char* bmpdir,
370 char *buf, int buf_size);
371 /***** wps_tokens.c ******/
373 const char *get_token_value(struct gui_wps *gwps,
374 struct wps_token *token,
375 char *buf, int buf_size,
376 int *intval);
378 const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
379 char *buf, int buf_size, int limit, int *intval);
380 #if CONFIG_TUNER
381 const char *get_radio_token(struct wps_token *token, int preset_offset,
382 char *buf, int buf_size, int limit, int *intval);
383 #endif
385 struct gui_img* find_image(char label, struct wps_data *data);
386 struct skin_viewport* find_viewport(char label, struct wps_data *data);
389 #if defined(DEBUG) || defined(SIMULATOR)
390 #define DEBUG_SKIN_ENGINE
391 extern bool debug_wps;
392 #endif
394 #endif