Manual: The c200v2 also needs to be set to MSC mode for installation.
[maemo-rb.git] / apps / gui / skin_engine / wps_internals.h
blobc9d5429484a0231c668466e0d1e77e57e4acae70
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_
28 #include "tag_table.h"
29 #include "skin_parser.h"
30 #ifndef __PCTOOL__
31 #include "core_alloc.h"
32 #endif
34 struct skin_stats {
35 size_t buflib_handles;
36 size_t tree_size;
37 size_t images_size;
40 int skin_get_num_skins(void);
41 struct skin_stats *skin_get_stats(int number, int screen);
42 #define skin_clear_stats(stats) memset(stats, 0, sizeof(struct skin_stats))
43 bool skin_backdrop_get_debug(int index, char **path, int *ref_count, size_t *size);
45 /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds
46 (possibly with a decimal fraction) but stored as integer values.
47 E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units.
49 #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */
50 #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */
52 /* TODO: sort this mess out */
54 #include "screen_access.h"
55 #include "statusbar.h"
56 #include "metadata.h"
58 #define TOKEN_VALUE_ONLY 0x0DEADC0D
60 /* wps_data*/
61 struct wps_token {
62 union {
63 char c;
64 unsigned short i;
65 long l;
66 OFFSETTYPE(void*) data;
67 } value;
69 enum skin_token_type type; /* enough to store the token type */
70 /* Whether the tag (e.g. track name or the album) refers the
71 current or the next song (false=current, true=next) */
72 bool next;
75 char* get_dir(char* buf, int buf_size, const char* path, int level);
78 struct skin_token_list {
79 OFFSETTYPE(struct wps_token *) token;
80 OFFSETTYPE(struct skin_token_list *) next;
83 #ifdef HAVE_LCD_BITMAP
84 struct gui_img {
85 OFFSETTYPE(struct viewport*) vp; /* The viewport to display this image in */
86 short int x; /* x-pos */
87 short int y; /* y-pos */
88 short int num_subimages; /* number of sub-images */
89 short int subimage_height; /* height of each sub-image */
90 struct bitmap bm;
91 int buflib_handle;
92 OFFSETTYPE(char*) label;
93 bool loaded; /* load state */
94 int display;
95 bool using_preloaded_icons; /* using the icon system instead of a bmp */
96 bool is_9_segment;
99 struct image_display {
100 OFFSETTYPE(char*) label;
101 int subimage;
102 OFFSETTYPE(struct wps_token*) token; /* the token to get the subimage number from */
103 int offset; /* offset into the bitmap strip to start */
106 struct progressbar {
107 enum skin_token_type type;
108 OFFSETTYPE(struct viewport *) vp;
109 /* regular pb */
110 short x;
111 /* >=0: explicitly set in the tag -> y-coord within the viewport
112 <0 : not set in the tag -> negated 1-based line number within
113 the viewport. y-coord will be computed based on the font height */
114 short y;
115 short width;
116 short height;
117 bool follow_lang_direction;
119 OFFSETTYPE(struct gui_img *) image;
121 bool invert_fill_direction;
122 bool nofill;
123 bool nobar;
124 OFFSETTYPE(struct gui_img *) slider;
125 bool horizontal;
126 OFFSETTYPE(struct gui_img *) backdrop;
127 int setting_id; /* for the setting bar type */
131 struct draw_rectangle {
132 int x;
133 int y;
134 int width;
135 int height;
136 unsigned start_colour;
137 unsigned end_colour;
139 #endif
143 struct align_pos {
144 char* left;
145 char* center;
146 char* right;
149 #ifdef HAVE_LCD_BITMAP
150 #define WPS_MAX_TOKENS 1150
151 #else
152 #define WPS_MAX_TOKENS 64
153 #endif
155 enum wps_parse_error {
156 PARSE_OK,
157 PARSE_FAIL_UNCLOSED_COND,
158 PARSE_FAIL_INVALID_CHAR,
159 PARSE_FAIL_COND_SYNTAX_ERROR,
160 PARSE_FAIL_COND_INVALID_PARAM,
161 PARSE_FAIL_LIMITS_EXCEEDED,
163 #ifdef HAVE_LCD_COLOR
164 struct gradient_config {
165 unsigned start;
166 unsigned end;
167 unsigned text;
168 int lines_count;
170 #endif
172 #define VP_DRAW_HIDEABLE 0x1
173 #define VP_DRAW_HIDDEN 0x2
174 #define VP_DRAW_WASHIDDEN 0x4
175 /* these are never drawn, nor cleared, i.e. just ignored */
176 #define VP_NEVER_VISIBLE 0x8
177 #ifndef __PCTOOL__
178 #define VP_DEFAULT_LABEL -200
179 #else
180 #define VP_DEFAULT_LABEL NULL
181 #endif
182 #define VP_DEFAULT_LABEL_STRING "|"
183 struct skin_viewport {
184 struct viewport vp; /* The LCD viewport struct */
185 char hidden_flags;
186 bool is_infovp;
187 OFFSETTYPE(char*) label;
188 int parsed_fontid;
189 #if LCD_DEPTH > 1
190 bool output_to_backdrop_buffer;
191 unsigned start_fgcolour;
192 unsigned start_bgcolour;
193 #ifdef HAVE_LCD_COLOR
194 struct gradient_config start_gradient;
195 #endif
196 #endif
198 struct viewport_colour {
199 OFFSETTYPE(struct viewport *) vp;
200 unsigned colour;
203 #ifdef HAVE_TOUCHSCREEN
204 struct touchregion {
205 OFFSETTYPE(char*) label; /* label to identify this region */
206 OFFSETTYPE(struct skin_viewport*) wvp;/* The viewport this region is in */
207 short int x; /* x-pos */
208 short int y; /* y-pos */
209 short int width; /* width */
210 short int height; /* height */
211 bool reverse_bar; /* if true 0% is the left or top */
212 bool allow_while_locked;
213 enum {
214 PRESS, /* quick press only */
215 LONG_PRESS, /* Long press without repeat */
216 REPEAT, /* long press allowing repeats */
217 } press_length;
218 int action; /* action this button will return */
219 bool armed; /* A region is armed on press. Only armed regions are triggered
220 on repeat or release. */
221 union { /* Extra data, action dependant */
222 struct touchsetting {
223 const struct settings_list *setting; /* setting being controlled */
224 union { /* Value to set the setting to for ACTION_SETTING_SET */
225 int number;
226 OFFSETTYPE(char*) text;
227 } value;
228 } setting_data;
229 int value;
231 long last_press; /* last tick this was pressed */
232 OFFSETTYPE(struct progressbar*) bar;
237 struct touchregion_lastpress {
238 OFFSETTYPE(struct touchregion *) region;
239 long timeout;
241 #endif
243 struct playlistviewer {
244 OFFSETTYPE(struct viewport *) vp;
245 bool show_icons;
246 int start_offset;
247 OFFSETTYPE(struct skin_element *) line;
251 #ifdef HAVE_ALBUMART
253 /* albumart definitions */
254 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
255 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
256 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
258 #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
259 #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
260 #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
261 #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
262 #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
264 struct skin_albumart {
265 /* Album art support */
266 int x;
267 int y;
268 int width;
269 int height;
271 unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
272 unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
273 unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
275 OFFSETTYPE(struct viewport *) vp;
276 int draw_handle;
278 #endif
281 struct line {
282 unsigned update_mode;
285 struct line_alternator {
286 int current_line;
287 unsigned long next_change_tick;
290 struct conditional {
291 int last_value;
292 OFFSETTYPE(struct wps_token *) token;
295 struct logical_if {
296 OFFSETTYPE(struct wps_token *) token;
297 enum {
298 IF_EQUALS, /* == */
299 IF_NOTEQUALS, /* != */
300 IF_LESSTHAN, /* < */
301 IF_LESSTHAN_EQ, /* <= */
302 IF_GREATERTHAN, /* > */
303 IF_GREATERTHAN_EQ /* >= */
304 } op;
305 struct skin_tag_parameter operand;
306 int num_options;
309 struct substring {
310 int start;
311 int length;
312 bool expect_number;
313 OFFSETTYPE(struct wps_token *) token;
316 struct listitem {
317 bool wrap;
318 short offset;
321 #ifdef HAVE_SKIN_VARIABLES
322 struct skin_var {
323 OFFSETTYPE(const char *) label;
324 int value;
325 long last_changed;
327 struct skin_var_lastchange {
328 OFFSETTYPE(struct skin_var *) var;
329 long timeout;
331 struct skin_var_changer {
332 OFFSETTYPE(struct skin_var *) var;
333 int newval;
334 bool direct; /* true to make val=newval, false for val += newval */
335 int max;
337 #endif
339 /* wps_data
340 this struct holds all necessary data which describes the
341 viewable content of a wps */
342 struct wps_data
344 int buflib_handle;
346 OFFSETTYPE(struct skin_element *) tree;
347 #ifdef HAVE_LCD_BITMAP
348 OFFSETTYPE(struct skin_token_list *) images;
349 OFFSETTYPE(int *) font_ids;
350 int font_count;
351 #endif
352 #ifdef HAVE_BACKDROP_IMAGE
353 int backdrop_id;
354 bool use_extra_framebuffer;
355 #endif
357 #ifdef HAVE_TOUCHSCREEN
358 OFFSETTYPE(struct skin_token_list *) touchregions;
359 bool touchscreen_locked;
360 #endif
361 #ifdef HAVE_ALBUMART
362 OFFSETTYPE(struct skin_albumart *) albumart;
363 int playback_aa_slot;
364 #endif
366 #ifdef HAVE_SKIN_VARIABLES
367 OFFSETTYPE(struct skin_token_list *) skinvars;
368 #endif
370 #ifdef HAVE_LCD_BITMAP
371 bool peak_meter_enabled;
372 bool wps_sb_tag;
373 bool show_sb_on_wps;
374 #else /*HAVE_LCD_CHARCELLS */
375 unsigned short wps_progress_pat[8];
376 bool full_line_progressbar;
377 #endif
378 bool wps_loaded;
381 #ifndef __PCTOOL__
382 static inline char* get_skin_buffer(struct wps_data* data)
384 if (data->buflib_handle >= 0)
385 return core_get_data(data->buflib_handle);
386 return NULL;
388 #else
389 #define get_skin_buffer(d) skin_buffer
390 #endif
392 /* wps_data end */
394 /* wps_state
395 holds the data which belongs to the current played track,
396 the track which will be played afterwards, current path to the track
397 and some status infos */
398 struct wps_state
400 struct mp3entry* id3;
401 struct mp3entry* nid3;
402 int ff_rewind_count;
403 bool ff_rewind;
404 bool paused;
405 bool is_fading;
408 /* change the ff/rew-status
409 if ff_rew = true then we are in skipping mode
410 else we are in normal mode */
411 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
413 /* change the tag-information of the current played track
414 and the following track */
415 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
416 /* wps_state end*/
418 /* gui_wps
419 defines a wps with its data, state,
420 and the screen on which the wps-content should be drawn */
421 struct gui_wps
423 struct screen *display;
424 struct wps_data *data;
427 /* gui_wps end */
429 void get_image_filename(const char *start, const char* bmpdir,
430 char *buf, int buf_size);
431 /***** wps_tokens.c ******/
433 const char *get_token_value(struct gui_wps *gwps,
434 struct wps_token *token, int offset,
435 char *buf, int buf_size,
436 int *intval);
438 /* Get the id3 fields from the cuesheet */
439 const char *get_cuesheetid3_token(struct wps_token *token, struct mp3entry *id3,
440 int offset_tracks, char *buf, int buf_size);
441 const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
442 char *filename, char *buf, int buf_size, int limit, int *intval);
443 #if CONFIG_TUNER
444 const char *get_radio_token(struct wps_token *token, int preset_offset,
445 char *buf, int buf_size, int limit, int *intval);
446 #endif
448 enum skin_find_what {
449 SKIN_FIND_VP = 0,
450 SKIN_FIND_UIVP,
451 #ifdef HAVE_LCD_BITMAP
452 SKIN_FIND_IMAGE,
453 #endif
454 #ifdef HAVE_TOUCHSCREEN
455 SKIN_FIND_TOUCHREGION,
456 #endif
457 #ifdef HAVE_SKIN_VARIABLES
458 SKIN_VARIABLE,
459 #endif
461 void *skin_find_item(const char *label, enum skin_find_what what,
462 struct wps_data *data);
463 #ifdef SIMULATOR
464 #define DEBUG_SKIN_ENGINE
465 extern bool debug_wps;
466 #endif
468 #endif