FS#12756 by Marek Salaba - update Czech translation
[maemo-rb.git] / apps / gui / skin_engine / wps_internals.h
blob8cd5d9cb60a7d4ba4dff5d9e59e08a406b9620ca
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 /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds
35 (possibly with a decimal fraction) but stored as integer values.
36 E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units.
38 #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */
39 #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */
41 /* TODO: sort this mess out */
43 #include "screen_access.h"
44 #include "statusbar.h"
45 #include "metadata.h"
47 #define TOKEN_VALUE_ONLY 0x0DEADC0D
49 /* wps_data*/
50 struct wps_token {
51 union {
52 char c;
53 unsigned short i;
54 long l;
55 OFFSETTYPE(void*) data;
56 } value;
58 enum skin_token_type type; /* enough to store the token type */
59 /* Whether the tag (e.g. track name or the album) refers the
60 current or the next song (false=current, true=next) */
61 bool next;
64 char* get_dir(char* buf, int buf_size, const char* path, int level);
67 struct skin_token_list {
68 OFFSETTYPE(struct wps_token *) token;
69 OFFSETTYPE(struct skin_token_list *) next;
72 #ifdef HAVE_LCD_BITMAP
73 struct gui_img {
74 OFFSETTYPE(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 int buflib_handle;
81 OFFSETTYPE(char*) label;
82 bool loaded; /* load state */
83 int display;
84 bool using_preloaded_icons; /* using the icon system instead of a bmp */
87 struct image_display {
88 OFFSETTYPE(char*) label;
89 int subimage;
90 OFFSETTYPE(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 OFFSETTYPE(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 OFFSETTYPE(struct gui_img *) image;
109 bool invert_fill_direction;
110 bool nofill;
111 bool nobar;
112 OFFSETTYPE(struct gui_img *) slider;
113 bool horizontal;
114 OFFSETTYPE(struct gui_img *) backdrop;
115 int setting_id; /* for the setting bar type */
119 struct draw_rectangle {
120 int x;
121 int y;
122 int width;
123 int height;
124 unsigned start_colour;
125 unsigned end_colour;
127 #endif
131 struct align_pos {
132 char* left;
133 char* center;
134 char* right;
137 #ifdef HAVE_LCD_BITMAP
138 #define WPS_MAX_TOKENS 1150
139 #else
140 #define WPS_MAX_TOKENS 64
141 #endif
143 enum wps_parse_error {
144 PARSE_OK,
145 PARSE_FAIL_UNCLOSED_COND,
146 PARSE_FAIL_INVALID_CHAR,
147 PARSE_FAIL_COND_SYNTAX_ERROR,
148 PARSE_FAIL_COND_INVALID_PARAM,
149 PARSE_FAIL_LIMITS_EXCEEDED,
151 #ifdef HAVE_LCD_COLOR
152 struct gradient_config {
153 unsigned start;
154 unsigned end;
155 unsigned text;
156 int lines_count;
158 #endif
160 #define VP_DRAW_HIDEABLE 0x1
161 #define VP_DRAW_HIDDEN 0x2
162 #define VP_DRAW_WASHIDDEN 0x4
163 /* these are never drawn, nor cleared, i.e. just ignored */
164 #define VP_NEVER_VISIBLE 0x8
165 #ifndef __PCTOOL__
166 #define VP_DEFAULT_LABEL -200
167 #else
168 #define VP_DEFAULT_LABEL NULL
169 #endif
170 #define VP_DEFAULT_LABEL_STRING "|"
171 struct skin_viewport {
172 struct viewport vp; /* The LCD viewport struct */
173 char hidden_flags;
174 bool is_infovp;
175 OFFSETTYPE(char*) label;
176 int parsed_fontid;
177 #if LCD_DEPTH > 1
178 bool output_to_backdrop_buffer;
179 unsigned start_fgcolour;
180 unsigned start_bgcolour;
181 #ifdef HAVE_LCD_COLOR
182 struct gradient_config start_gradient;
183 #endif
184 #endif
186 struct viewport_colour {
187 OFFSETTYPE(struct viewport *) vp;
188 unsigned colour;
191 #ifdef HAVE_TOUCHSCREEN
192 struct touchregion {
193 OFFSETTYPE(char*) label; /* label to identify this region */
194 OFFSETTYPE(struct skin_viewport*) wvp;/* The viewport this region is in */
195 short int x; /* x-pos */
196 short int y; /* y-pos */
197 short int width; /* width */
198 short int height; /* height */
199 bool reverse_bar; /* if true 0% is the left or top */
200 bool allow_while_locked;
201 enum {
202 PRESS, /* quick press only */
203 LONG_PRESS, /* Long press without repeat */
204 REPEAT, /* long press allowing repeats */
205 } press_length;
206 int action; /* action this button will return */
207 bool armed; /* A region is armed on press. Only armed regions are triggered
208 on repeat or release. */
209 union { /* Extra data, action dependant */
210 struct touchsetting {
211 const struct settings_list *setting; /* setting being controlled */
212 union { /* Value to set the setting to for ACTION_SETTING_SET */
213 int number;
214 OFFSETTYPE(char*) text;
215 } value;
216 } setting_data;
217 int value;
219 long last_press; /* last tick this was pressed */
220 OFFSETTYPE(struct progressbar*) bar;
225 struct touchregion_lastpress {
226 OFFSETTYPE(struct touchregion *) region;
227 long timeout;
229 #endif
231 struct playlistviewer {
232 OFFSETTYPE(struct viewport *) vp;
233 bool show_icons;
234 int start_offset;
235 OFFSETTYPE(struct skin_element *) line;
239 #ifdef HAVE_ALBUMART
241 /* albumart definitions */
242 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
243 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
244 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
246 #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
247 #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
248 #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
249 #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
250 #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
252 struct skin_albumart {
253 /* Album art support */
254 int x;
255 int y;
256 int width;
257 int height;
259 unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
260 unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
261 unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
263 OFFSETTYPE(struct viewport *) vp;
264 int draw_handle;
266 #endif
269 struct line {
270 unsigned update_mode;
273 struct line_alternator {
274 int current_line;
275 unsigned long next_change_tick;
278 struct conditional {
279 int last_value;
280 OFFSETTYPE(struct wps_token *) token;
283 struct logical_if {
284 OFFSETTYPE(struct wps_token *) token;
285 enum {
286 IF_EQUALS, /* == */
287 IF_NOTEQUALS, /* != */
288 IF_LESSTHAN, /* < */
289 IF_LESSTHAN_EQ, /* <= */
290 IF_GREATERTHAN, /* > */
291 IF_GREATERTHAN_EQ /* >= */
292 } op;
293 struct skin_tag_parameter operand;
294 int num_options;
297 struct substring {
298 int start;
299 int length;
300 bool expect_number;
301 OFFSETTYPE(struct wps_token *) token;
304 struct listitem {
305 bool wrap;
306 short offset;
309 #ifdef HAVE_SKIN_VARIABLES
310 struct skin_var {
311 OFFSETTYPE(const char *) label;
312 int value;
313 long last_changed;
315 struct skin_var_lastchange {
316 OFFSETTYPE(struct skin_var *) var;
317 long timeout;
319 struct skin_var_changer {
320 OFFSETTYPE(struct skin_var *) var;
321 int newval;
322 bool direct; /* true to make val=newval, false for val += newval */
323 int max;
325 #endif
327 /* wps_data
328 this struct holds all necessary data which describes the
329 viewable content of a wps */
330 struct wps_data
332 int buflib_handle;
334 OFFSETTYPE(struct skin_element *) tree;
335 #ifdef HAVE_LCD_BITMAP
336 OFFSETTYPE(struct skin_token_list *) images;
337 OFFSETTYPE(int *) font_ids;
338 int font_count;
339 #endif
340 #ifdef HAVE_BACKDROP_IMAGE
341 int backdrop_id;
342 bool use_extra_framebuffer;
343 #endif
345 #ifdef HAVE_TOUCHSCREEN
346 OFFSETTYPE(struct skin_token_list *) touchregions;
347 bool touchscreen_locked;
348 #endif
349 #ifdef HAVE_ALBUMART
350 OFFSETTYPE(struct skin_albumart *) albumart;
351 int playback_aa_slot;
352 #endif
354 #ifdef HAVE_SKIN_VARIABLES
355 OFFSETTYPE(struct skin_token_list *) skinvars;
356 #endif
358 #ifdef HAVE_LCD_BITMAP
359 bool peak_meter_enabled;
360 bool wps_sb_tag;
361 bool show_sb_on_wps;
362 #else /*HAVE_LCD_CHARCELLS */
363 unsigned short wps_progress_pat[8];
364 bool full_line_progressbar;
365 #endif
366 bool wps_loaded;
369 #ifndef __PCTOOL__
370 static inline char* get_skin_buffer(struct wps_data* data)
372 if (data->buflib_handle >= 0)
373 return core_get_data(data->buflib_handle);
374 return NULL;
376 #else
377 #define get_skin_buffer(d) skin_buffer
378 #endif
380 /* wps_data end */
382 /* wps_state
383 holds the data which belongs to the current played track,
384 the track which will be played afterwards, current path to the track
385 and some status infos */
386 struct wps_state
388 struct mp3entry* id3;
389 struct mp3entry* nid3;
390 int ff_rewind_count;
391 bool ff_rewind;
392 bool paused;
393 bool is_fading;
396 /* change the ff/rew-status
397 if ff_rew = true then we are in skipping mode
398 else we are in normal mode */
399 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
401 /* change the tag-information of the current played track
402 and the following track */
403 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
404 /* wps_state end*/
406 /* gui_wps
407 defines a wps with its data, state,
408 and the screen on which the wps-content should be drawn */
409 struct gui_wps
411 struct screen *display;
412 struct wps_data *data;
415 /* gui_wps end */
417 void get_image_filename(const char *start, const char* bmpdir,
418 char *buf, int buf_size);
419 /***** wps_tokens.c ******/
421 const char *get_token_value(struct gui_wps *gwps,
422 struct wps_token *token, int offset,
423 char *buf, int buf_size,
424 int *intval);
426 /* Get the id3 fields from the cuesheet */
427 const char *get_cuesheetid3_token(struct wps_token *token, struct mp3entry *id3,
428 int offset_tracks, char *buf, int buf_size);
429 const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
430 char *filename, char *buf, int buf_size, int limit, int *intval);
431 #if CONFIG_TUNER
432 const char *get_radio_token(struct wps_token *token, int preset_offset,
433 char *buf, int buf_size, int limit, int *intval);
434 #endif
436 enum skin_find_what {
437 SKIN_FIND_VP = 0,
438 SKIN_FIND_UIVP,
439 #ifdef HAVE_LCD_BITMAP
440 SKIN_FIND_IMAGE,
441 #endif
442 #ifdef HAVE_TOUCHSCREEN
443 SKIN_FIND_TOUCHREGION,
444 #endif
445 #ifdef HAVE_SKIN_VARIABLES
446 SKIN_VARIABLE,
447 #endif
449 void *skin_find_item(const char *label, enum skin_find_what what,
450 struct wps_data *data);
451 #ifdef SIMULATOR
452 #define DEBUG_SKIN_ENGINE
453 extern bool debug_wps;
454 #endif
456 #endif