1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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"
31 #include "core_alloc.h"
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"
47 #define TOKEN_VALUE_ONLY 0x0DEADC0D
55 OFFSETTYPE(void*) data
;
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) */
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
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 */
81 OFFSETTYPE(char*) label
;
82 bool loaded
; /* load state */
84 bool using_preloaded_icons
; /* using the icon system instead of a bmp */
88 struct image_display
{
89 OFFSETTYPE(char*) label
;
91 OFFSETTYPE(struct wps_token
*) token
; /* the token to get the subimage number from */
92 int offset
; /* offset into the bitmap strip to start */
96 enum skin_token_type type
;
97 OFFSETTYPE(struct viewport
*) vp
;
100 /* >=0: explicitly set in the tag -> y-coord within the viewport
101 <0 : not set in the tag -> negated 1-based line number within
102 the viewport. y-coord will be computed based on the font height */
106 bool follow_lang_direction
;
108 OFFSETTYPE(struct gui_img
*) image
;
110 bool invert_fill_direction
;
113 OFFSETTYPE(struct gui_img
*) slider
;
115 OFFSETTYPE(struct gui_img
*) backdrop
;
116 int setting_id
; /* for the setting bar type */
120 struct draw_rectangle
{
125 unsigned start_colour
;
138 #ifdef HAVE_LCD_BITMAP
139 #define WPS_MAX_TOKENS 1150
141 #define WPS_MAX_TOKENS 64
144 enum wps_parse_error
{
146 PARSE_FAIL_UNCLOSED_COND
,
147 PARSE_FAIL_INVALID_CHAR
,
148 PARSE_FAIL_COND_SYNTAX_ERROR
,
149 PARSE_FAIL_COND_INVALID_PARAM
,
150 PARSE_FAIL_LIMITS_EXCEEDED
,
152 #ifdef HAVE_LCD_COLOR
153 struct gradient_config
{
161 #define VP_DRAW_HIDEABLE 0x1
162 #define VP_DRAW_HIDDEN 0x2
163 #define VP_DRAW_WASHIDDEN 0x4
164 /* these are never drawn, nor cleared, i.e. just ignored */
165 #define VP_NEVER_VISIBLE 0x8
167 #define VP_DEFAULT_LABEL -200
169 #define VP_DEFAULT_LABEL NULL
171 #define VP_DEFAULT_LABEL_STRING "|"
172 struct skin_viewport
{
173 struct viewport vp
; /* The LCD viewport struct */
176 OFFSETTYPE(char*) label
;
179 bool output_to_backdrop_buffer
;
180 unsigned start_fgcolour
;
181 unsigned start_bgcolour
;
182 #ifdef HAVE_LCD_COLOR
183 struct gradient_config start_gradient
;
187 struct viewport_colour
{
188 OFFSETTYPE(struct viewport
*) vp
;
192 #ifdef HAVE_TOUCHSCREEN
194 OFFSETTYPE(char*) label
; /* label to identify this region */
195 OFFSETTYPE(struct skin_viewport
*) wvp
;/* The viewport this region is in */
196 short int x
; /* x-pos */
197 short int y
; /* y-pos */
198 short int width
; /* width */
199 short int height
; /* height */
200 bool reverse_bar
; /* if true 0% is the left or top */
201 bool allow_while_locked
;
203 PRESS
, /* quick press only */
204 LONG_PRESS
, /* Long press without repeat */
205 REPEAT
, /* long press allowing repeats */
207 int action
; /* action this button will return */
208 bool armed
; /* A region is armed on press. Only armed regions are triggered
209 on repeat or release. */
210 union { /* Extra data, action dependant */
211 struct touchsetting
{
212 const struct settings_list
*setting
; /* setting being controlled */
213 union { /* Value to set the setting to for ACTION_SETTING_SET */
215 OFFSETTYPE(char*) text
;
220 long last_press
; /* last tick this was pressed */
221 OFFSETTYPE(struct progressbar
*) bar
;
226 struct touchregion_lastpress
{
227 OFFSETTYPE(struct touchregion
*) region
;
232 struct playlistviewer
{
233 OFFSETTYPE(struct viewport
*) vp
;
236 OFFSETTYPE(struct skin_element
*) line
;
242 /* albumart definitions */
243 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
244 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
245 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
247 #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
248 #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
249 #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
250 #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
251 #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
253 struct skin_albumart
{
254 /* Album art support */
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 OFFSETTYPE(struct viewport
*) vp
;
271 unsigned update_mode
;
274 struct line_alternator
{
276 unsigned long next_change_tick
;
281 OFFSETTYPE(struct wps_token
*) token
;
285 OFFSETTYPE(struct wps_token
*) token
;
288 IF_NOTEQUALS
, /* != */
290 IF_LESSTHAN_EQ
, /* <= */
291 IF_GREATERTHAN
, /* > */
292 IF_GREATERTHAN_EQ
/* >= */
294 struct skin_tag_parameter operand
;
302 OFFSETTYPE(struct wps_token
*) token
;
310 #ifdef HAVE_SKIN_VARIABLES
312 OFFSETTYPE(const char *) label
;
316 struct skin_var_lastchange
{
317 OFFSETTYPE(struct skin_var
*) var
;
320 struct skin_var_changer
{
321 OFFSETTYPE(struct skin_var
*) var
;
323 bool direct
; /* true to make val=newval, false for val += newval */
329 this struct holds all necessary data which describes the
330 viewable content of a wps */
335 OFFSETTYPE(struct skin_element
*) tree
;
336 #ifdef HAVE_LCD_BITMAP
337 OFFSETTYPE(struct skin_token_list
*) images
;
338 OFFSETTYPE(int *) font_ids
;
341 #ifdef HAVE_BACKDROP_IMAGE
343 bool use_extra_framebuffer
;
346 #ifdef HAVE_TOUCHSCREEN
347 OFFSETTYPE(struct skin_token_list
*) touchregions
;
348 bool touchscreen_locked
;
351 OFFSETTYPE(struct skin_albumart
*) albumart
;
352 int playback_aa_slot
;
355 #ifdef HAVE_SKIN_VARIABLES
356 OFFSETTYPE(struct skin_token_list
*) skinvars
;
359 #ifdef HAVE_LCD_BITMAP
360 bool peak_meter_enabled
;
363 #else /*HAVE_LCD_CHARCELLS */
364 unsigned short wps_progress_pat
[8];
365 bool full_line_progressbar
;
371 static inline char* get_skin_buffer(struct wps_data
* data
)
373 if (data
->buflib_handle
>= 0)
374 return core_get_data(data
->buflib_handle
);
378 #define get_skin_buffer(d) skin_buffer
384 holds the data which belongs to the current played track,
385 the track which will be played afterwards, current path to the track
386 and some status infos */
389 struct mp3entry
* id3
;
390 struct mp3entry
* nid3
;
397 /* change the ff/rew-status
398 if ff_rew = true then we are in skipping mode
399 else we are in normal mode */
400 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
402 /* change the tag-information of the current played track
403 and the following track */
404 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
408 defines a wps with its data, state,
409 and the screen on which the wps-content should be drawn */
412 struct screen
*display
;
413 struct wps_data
*data
;
418 void get_image_filename(const char *start
, const char* bmpdir
,
419 char *buf
, int buf_size
);
420 /***** wps_tokens.c ******/
422 const char *get_token_value(struct gui_wps
*gwps
,
423 struct wps_token
*token
, int offset
,
424 char *buf
, int buf_size
,
427 /* Get the id3 fields from the cuesheet */
428 const char *get_cuesheetid3_token(struct wps_token
*token
, struct mp3entry
*id3
,
429 int offset_tracks
, char *buf
, int buf_size
);
430 const char *get_id3_token(struct wps_token
*token
, struct mp3entry
*id3
,
431 char *filename
, char *buf
, int buf_size
, int limit
, int *intval
);
433 const char *get_radio_token(struct wps_token
*token
, int preset_offset
,
434 char *buf
, int buf_size
, int limit
, int *intval
);
437 enum skin_find_what
{
440 #ifdef HAVE_LCD_BITMAP
443 #ifdef HAVE_TOUCHSCREEN
444 SKIN_FIND_TOUCHREGION
,
446 #ifdef HAVE_SKIN_VARIABLES
450 void *skin_find_item(const char *label
, enum skin_find_what what
,
451 struct wps_data
*data
);
453 #define DEBUG_SKIN_ENGINE
454 extern bool debug_wps
;