last of the errors... hopefully
[maemo-rb.git] / apps / gui / skin_engine / wps_internals.h
blob47453ed34b1fdf0a3f0dc0fda40063b2aed463cb
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_
29 /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds
30 (possibly with a decimal fraction) but stored as integer values.
31 E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units.
33 #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */
34 #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */
36 #include "skin_tokens.h"
37 #include "tag_table.h"
38 #include "skin_parser.h"
41 /* TODO: sort this mess out */
43 #include "screen_access.h"
44 #include "statusbar.h"
45 #include "metadata.h"
47 /* alignments */
48 #define WPS_ALIGN_RIGHT 32
49 #define WPS_ALIGN_CENTER 64
50 #define WPS_ALIGN_LEFT 128
53 #define TOKEN_VALUE_ONLY 0x0DEADC0D
55 #ifdef HAVE_ALBUMART
57 /* albumart definitions */
58 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
59 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
60 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
62 #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
63 #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
64 #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
65 #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
66 #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
68 #endif /* HAVE_ALBUMART */
70 /* wps_data*/
72 #ifdef HAVE_LCD_BITMAP
73 struct gui_img {
74 struct viewport* vp; /* The viewport to display this image in */
75 short int x; /* x-pos */
76 short int y; /* y-pos */
77 short int num_subimages; /* number of sub-images */
78 short int subimage_height; /* height of each sub-image */
79 struct bitmap bm;
80 const char *label;
81 bool loaded; /* load state */
82 bool always_display; /* not using the preload/display mechanism */
83 int display;
84 bool using_preloaded_icons; /* using the icon system instead of a bmp */
87 struct image_display {
88 const char *label;
89 int subimage;
90 struct wps_token *token; /* the token to get the subimage number from */
91 int offset; /* offset into the bitmap strip to start */
94 struct progressbar {
95 enum skin_token_type type;
96 struct viewport *vp;
97 /* regular pb */
98 short x;
99 /* >=0: explicitly set in the tag -> y-coord within the viewport
100 <0 : not set in the tag -> negated 1-based line number within
101 the viewport. y-coord will be computed based on the font height */
102 short y;
103 short width;
104 short height;
105 bool follow_lang_direction;
107 struct gui_img *image;
109 bool invert_fill_direction;
110 bool nofill;
111 bool nobar;
112 struct gui_img *slider;
113 bool horizontal;
114 struct gui_img *backdrop;
116 #endif
120 struct align_pos {
121 char* left;
122 char* center;
123 char* right;
126 #ifdef HAVE_LCD_BITMAP
128 #define MAX_IMAGES (26*2) /* a-z and A-Z */
129 #define MAX_PROGRESSBARS 3
131 /* The image buffer is big enough to store one full-screen native bitmap,
132 plus two full-screen mono bitmaps. */
134 #define WPS_MAX_VIEWPORTS 24
135 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
136 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
137 #define WPS_MAX_TOKENS 1024
138 #define WPS_MAX_STRINGS 128
139 #define STRING_BUFFER_SIZE 1024
140 #define WPS_MAX_COND_LEVEL 10
142 #else
144 #define WPS_MAX_VIEWPORTS 2
145 #define WPS_MAX_LINES 2
146 #define WPS_MAX_SUBLINES 12
147 #define WPS_MAX_TOKENS 64
148 #define WPS_MAX_STRINGS 32
149 #define STRING_BUFFER_SIZE 64
150 #define WPS_MAX_COND_LEVEL 5
152 #endif
154 #define SUBLINE_RESET -1
156 enum wps_parse_error {
157 PARSE_OK,
158 PARSE_FAIL_UNCLOSED_COND,
159 PARSE_FAIL_INVALID_CHAR,
160 PARSE_FAIL_COND_SYNTAX_ERROR,
161 PARSE_FAIL_COND_INVALID_PARAM,
162 PARSE_FAIL_LIMITS_EXCEEDED,
165 #define VP_DRAW_HIDEABLE 0x1
166 #define VP_DRAW_HIDDEN 0x2
167 #define VP_DRAW_WASHIDDEN 0x4
168 /* these are never drawn, nor cleared, i.e. just ignored */
169 #define VP_NEVER_VISIBLE 0x8
170 #define VP_DEFAULT_LABEL "|"
171 struct skin_viewport {
172 struct viewport vp; /* The LCD viewport struct */
173 char hidden_flags;
174 bool is_infovp;
175 char* label;
176 unsigned start_fgcolour;
177 unsigned start_bgcolour;
179 struct viewport_colour {
180 struct viewport *vp;
181 unsigned colour;
183 #ifdef HAVE_TOUCHSCREEN
184 struct touchregion {
185 char* label; /* label to identify this region */
186 struct skin_viewport* wvp;/* The viewport this region is in */
187 short int x; /* x-pos */
188 short int y; /* y-pos */
189 short int width; /* width */
190 short int height; /* height */
191 enum {
192 WPS_TOUCHREGION_ACTION,
193 WPS_TOUCHREGION_SCROLLBAR,
194 WPS_TOUCHREGION_VOLUME
195 } type; /* type of touch region */
196 bool reverse_bar; /* if true 0% is the left or top */
197 bool repeat; /* requires the area be held for the action */
198 int action; /* action this button will return */
199 bool armed; /* A region is armed on press. Only armed regions are triggered
200 on repeat or release. */
201 union { /* Extra data, action dependant */
202 struct touchsetting {
203 const struct settings_list *setting; /* setting being controlled */
204 union { /* Value to set the setting to for ACTION_SETTING_SET */
205 int number;
206 char* text;
207 } value;
208 } setting_data;
209 int value;
211 long last_press; /* last tick this was pressed */
216 struct touchregion_lastpress {
217 struct touchregion *region;
218 long timeout;
220 #endif
222 struct playlistviewer {
223 struct viewport *vp;
224 bool show_icons;
225 int start_offset;
226 struct skin_element *line;
230 #ifdef HAVE_ALBUMART
231 struct skin_albumart {
232 /* Album art support */
233 int x;
234 int y;
235 int width;
236 int height;
238 unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
239 unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
240 unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
242 struct viewport *vp;
243 int draw_handle;
245 #endif
248 struct line {
249 unsigned update_mode;
252 struct line_alternator {
253 int current_line;
254 unsigned long next_change_tick;
257 struct conditional {
258 int last_value;
259 struct wps_token *token;
262 struct logical_if {
263 struct wps_token *token;
264 enum {
265 IF_EQUALS, /* == */
266 IF_NOTEQUALS, /* != */
267 IF_LESSTHAN, /* < */
268 IF_LESSTHAN_EQ, /* <= */
269 IF_GREATERTHAN, /* > */
270 IF_GREATERTHAN_EQ /* >= */
271 } op;
272 struct skin_tag_parameter operand;
273 int num_options;
276 /* wps_data
277 this struct holds all necessary data which describes the
278 viewable content of a wps */
279 struct wps_data
281 struct skin_element *tree;
282 #ifdef HAVE_LCD_BITMAP
283 struct skin_token_list *images;
284 #endif
285 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
286 struct {
287 char *backdrop;
288 int backdrop_id;
290 #endif
292 #ifdef HAVE_TOUCHSCREEN
293 struct skin_token_list *touchregions;
294 #endif
295 #ifdef HAVE_ALBUMART
296 struct skin_albumart *albumart;
297 int playback_aa_slot;
298 #endif
300 #ifdef HAVE_LCD_BITMAP
301 bool peak_meter_enabled;
302 bool wps_sb_tag;
303 bool show_sb_on_wps;
304 #else /*HAVE_LCD_CHARCELLS */
305 unsigned short wps_progress_pat[8];
306 bool full_line_progressbar;
307 #endif
308 bool wps_loaded;
311 /* wps_data end */
313 /* wps_state
314 holds the data which belongs to the current played track,
315 the track which will be played afterwards, current path to the track
316 and some status infos */
317 struct wps_state
319 struct mp3entry* id3;
320 struct mp3entry* nid3;
321 int ff_rewind_count;
322 bool ff_rewind;
323 bool paused;
324 bool is_fading;
327 /* change the ff/rew-status
328 if ff_rew = true then we are in skipping mode
329 else we are in normal mode */
330 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
332 /* change the tag-information of the current played track
333 and the following track */
334 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
335 /* wps_state end*/
337 /* gui_wps
338 defines a wps with its data, state,
339 and the screen on which the wps-content should be drawn */
340 struct gui_wps
342 struct screen *display;
343 struct wps_data *data;
346 /* gui_wps end */
348 char *get_image_filename(const char *start, const char* bmpdir,
349 char *buf, int buf_size);
350 /***** wps_tokens.c ******/
352 const char *get_token_value(struct gui_wps *gwps,
353 struct wps_token *token, int offset,
354 char *buf, int buf_size,
355 int *intval);
357 /* Get the id3 fields from the cuesheet */
358 const char *get_cuesheetid3_token(struct wps_token *token, struct mp3entry *id3,
359 int offset_tracks, char *buf, int buf_size);
360 const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
361 char *filename, char *buf, int buf_size, int limit, int *intval);
362 #if CONFIG_TUNER
363 const char *get_radio_token(struct wps_token *token, int preset_offset,
364 char *buf, int buf_size, int limit, int *intval);
365 #endif
367 enum skin_find_what {
368 SKIN_FIND_VP = 0,
369 SKIN_FIND_UIVP,
370 #ifdef HAVE_LCD_BITMAP
371 SKIN_FIND_IMAGE,
372 #endif
373 #ifdef HAVE_TOUCHSCREEN
374 SKIN_FIND_TOUCHREGION,
375 #endif
377 void *skin_find_item(const char *label, enum skin_find_what what,
378 struct wps_data *data);
379 #ifdef SIMULATOR
380 #define DEBUG_SKIN_ENGINE
381 extern bool debug_wps;
382 #endif
384 #endif