remove an unused #define
[kugel-rb.git] / apps / gui / skin_engine / wps_internals.h
blob55fa87ae254e4fe59f0bf34aec37d770a77c300c
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 short int id;
81 struct bitmap bm;
82 struct viewport* vp; /* The viewport to display this image in */
83 short int x; /* x-pos */
84 short int y; /* y-pos */
85 short int num_subimages; /* number of sub-images */
86 short int subimage_height; /* height of each sub-image */
87 short int display; /* -1 for no display, 0..n to display a subimage */
88 bool loaded; /* load state */
89 bool always_display; /* not using the preload/display mechanism */
93 struct progressbar {
94 /* regular pb */
95 short x;
96 /* >=0: explicitly set in the tag -> y-coord within the viewport
97 <0 : not set in the tag -> negated 1-based line number within
98 the viewport. y-coord will be computed based on the font height */
99 short y;
100 short width;
101 short height;
102 /*progressbar image*/
103 struct bitmap bm;
104 bool have_bitmap_pb;
106 #endif
110 struct align_pos {
111 char* left;
112 char* center;
113 char* right;
116 #ifdef HAVE_LCD_BITMAP
118 #define MAX_IMAGES (26*2) /* a-z and A-Z */
119 #define MAX_PROGRESSBARS 3
121 /* The image buffer is big enough to store one full-screen native bitmap,
122 plus two full-screen mono bitmaps. */
124 #define IMG_BUFSIZE ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
125 + (2*LCD_HEIGHT*LCD_WIDTH/8))
127 #define WPS_MAX_VIEWPORTS 24
128 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
129 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
130 #define WPS_MAX_TOKENS 1024
131 #define WPS_MAX_STRINGS 128
132 #define STRING_BUFFER_SIZE 1024
133 #define WPS_MAX_COND_LEVEL 10
135 #else
137 #define WPS_MAX_VIEWPORTS 2
138 #define WPS_MAX_LINES 2
139 #define WPS_MAX_SUBLINES 12
140 #define WPS_MAX_TOKENS 64
141 #define WPS_MAX_STRINGS 32
142 #define STRING_BUFFER_SIZE 64
143 #define WPS_MAX_COND_LEVEL 5
145 #endif
147 #define SUBLINE_RESET -1
149 enum wps_parse_error {
150 PARSE_OK,
151 PARSE_FAIL_UNCLOSED_COND,
152 PARSE_FAIL_INVALID_CHAR,
153 PARSE_FAIL_COND_SYNTAX_ERROR,
154 PARSE_FAIL_COND_INVALID_PARAM,
155 PARSE_FAIL_LIMITS_EXCEEDED,
159 /* Description of a subline on the WPS */
160 struct wps_subline {
162 /* Index of the first token for this subline in the token array.
163 Tokens of this subline end where tokens for the next subline
164 begin. */
165 unsigned short first_token_idx;
167 /* Bit or'ed WPS_REFRESH_xxx */
168 unsigned char line_type;
170 /* How long the subline should be displayed, in 10ths of sec */
171 unsigned char time_mult;
174 /* Description of a line on the WPS. A line is a set of sublines.
175 A subline is displayed for a certain amount of time. After that,
176 the next subline of the line is displayed. And so on. */
177 struct wps_line {
179 /* Number of sublines in this line */
180 signed char num_sublines;
182 /* Number (0-based) of the subline within this line currently being displayed */
183 signed char curr_subline;
185 /* Index of the first subline of this line in the subline array.
186 Sublines for this line end where sublines for the next line begin. */
187 unsigned short first_subline_idx;
189 /* When the next subline of this line should be displayed
190 (absolute time value in ticks) */
191 long subline_expire_time;
194 #define VP_DRAW_HIDEABLE 0x1
195 #define VP_DRAW_HIDDEN 0x2
196 #define VP_DRAW_WASHIDDEN 0x4
197 struct wps_viewport {
198 struct viewport vp; /* The LCD viewport struct */
199 struct progressbar *pb;
200 /* Indexes of the first and last lines belonging to this viewport in the
201 lines[] array */
202 int first_line, last_line;
203 char hidden_flags;
204 char label;
207 #ifdef HAVE_TOUCHSCREEN
208 struct touchregion {
209 struct wps_viewport* wvp;/* The viewport this region is in */
210 short int x; /* x-pos */
211 short int y; /* y-pos */
212 short int width; /* width */
213 short int height; /* height */
214 enum {
215 WPS_TOUCHREGION_ACTION,
216 WPS_TOUCHREGION_SCROLLBAR,
217 WPS_TOUCHREGION_VOLUME
218 } type; /* type of touch region */
219 bool repeat; /* requires the area be held for the action */
220 int action; /* action this button will return */
222 #endif
223 /* wps_data
224 this struct holds all necessary data which describes the
225 viewable content of a wps */
226 struct wps_data
228 #ifdef HAVE_LCD_BITMAP
229 bool wps_sb_tag;
230 bool show_sb_on_wps;
232 struct skin_token_list *images;
233 struct skin_token_list *progressbars;
235 bool peak_meter_enabled;
237 #ifdef HAVE_ALBUMART
238 /* Album art support */
239 unsigned char wps_uses_albumart; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
240 short albumart_x;
241 short albumart_y;
242 unsigned char albumart_xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
243 unsigned char albumart_yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
244 short albumart_max_width;
245 short albumart_max_height;
247 int albumart_cond_index;
248 #endif
250 #else /*HAVE_LCD_CHARCELLS */
251 unsigned short wps_progress_pat[8];
252 bool full_line_progressbar;
253 #endif
255 #ifdef HAVE_TOUCHSCREEN
256 struct skin_token_list *touchregions;
257 #endif
259 #ifdef HAVE_REMOTE_LCD
260 bool remote_wps;
261 #endif
263 /* Number of lines in the WPS. During WPS parsing, this is
264 the index of the line being parsed. */
265 int num_lines;
267 /* Number of viewports in the WPS */
268 int num_viewports;
269 struct wps_viewport viewports[WPS_MAX_VIEWPORTS];
271 struct wps_line lines[WPS_MAX_LINES];
273 /* Total number of sublines in the WPS. During WPS parsing, this is
274 the index of the subline where the parsed tokens are added to. */
275 int num_sublines;
276 struct wps_subline sublines[WPS_MAX_SUBLINES];
278 /* Total number of tokens in the WPS. During WPS parsing, this is
279 the index of the token being parsed. */
280 int num_tokens;
281 struct wps_token tokens[WPS_MAX_TOKENS];
283 struct skin_token_list *strings;
285 bool wps_loaded;
287 /* tick the volume button was last pressed */
288 unsigned int button_time_volume;
292 /* Redraw statusbars if necessary */
293 void gwps_draw_statusbars(void);
295 /* Returns the index of the last subline's token in the token array.
296 line - 0-based line number
297 subline - 0-based subline number within the line
299 int skin_last_token_index(struct wps_data *data, int line, int subline);
301 /* wps_data end */
303 /* wps_state
304 holds the data which belongs to the current played track,
305 the track which will be played afterwards, current path to the track
306 and some status infos */
307 struct wps_state
309 bool ff_rewind;
310 bool paused;
311 int ff_rewind_count;
312 bool wps_time_countup;
313 struct mp3entry* id3;
314 struct mp3entry* nid3;
315 bool do_full_update;
319 /* change the ff/rew-status
320 if ff_rew = true then we are in skipping mode
321 else we are in normal mode */
322 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
324 /* change the tag-information of the current played track
325 and the following track */
326 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
327 /* wps_state end*/
329 /* gui_wps
330 defines a wps with its data, state,
331 and the screen on which the wps-content should be drawn */
332 struct gui_wps
334 struct screen *display;
335 struct wps_data *data;
336 struct wps_state *state;
339 /* gui_wps end */
342 /***** wps_tokens.c ******/
344 const char *get_token_value(struct gui_wps *gwps,
345 struct wps_token *token,
346 char *buf, int buf_size,
347 int *intval);
351 struct gui_img* find_image(int n, struct wps_data *data);
353 #endif