Change how touchscreen regions work slightly... "It modifies the behaviour of touch...
[kugel-rb.git] / apps / gui / skin_engine / wps_internals.h
blobf6c7463804ccf8544bf5f296f156e419ace9b740
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 struct viewport* vp; /* The viewport to display this image in */
81 short int x; /* x-pos */
82 short int y; /* y-pos */
83 short int num_subimages; /* number of sub-images */
84 short int subimage_height; /* height of each sub-image */
85 short int display; /* -1 for no display, 0..n to display a subimage */
86 struct bitmap bm;
87 char label;
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 bool follow_lang_direction;
103 /*progressbar image*/
104 struct bitmap bm;
105 bool have_bitmap_pb;
107 #endif
111 struct align_pos {
112 char* left;
113 char* center;
114 char* right;
117 #ifdef HAVE_LCD_BITMAP
119 #define MAX_IMAGES (26*2) /* a-z and A-Z */
120 #define MAX_PROGRESSBARS 3
122 /* The image buffer is big enough to store one full-screen native bitmap,
123 plus two full-screen mono bitmaps. */
125 #define WPS_MAX_VIEWPORTS 24
126 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
127 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
128 #define WPS_MAX_TOKENS 1024
129 #define WPS_MAX_STRINGS 128
130 #define STRING_BUFFER_SIZE 1024
131 #define WPS_MAX_COND_LEVEL 10
133 #else
135 #define WPS_MAX_VIEWPORTS 2
136 #define WPS_MAX_LINES 2
137 #define WPS_MAX_SUBLINES 12
138 #define WPS_MAX_TOKENS 64
139 #define WPS_MAX_STRINGS 32
140 #define STRING_BUFFER_SIZE 64
141 #define WPS_MAX_COND_LEVEL 5
143 #endif
145 #define SUBLINE_RESET -1
147 enum wps_parse_error {
148 PARSE_OK,
149 PARSE_FAIL_UNCLOSED_COND,
150 PARSE_FAIL_INVALID_CHAR,
151 PARSE_FAIL_COND_SYNTAX_ERROR,
152 PARSE_FAIL_COND_INVALID_PARAM,
153 PARSE_FAIL_LIMITS_EXCEEDED,
157 /* Description of a subline on the WPS */
158 struct skin_subline {
160 /* Index of the first token for this subline in the token array.
161 Tokens of this subline end where tokens for the next subline
162 begin. */
163 unsigned short first_token_idx;
164 unsigned short last_token_idx;
166 /* Bit or'ed WPS_REFRESH_xxx */
167 unsigned char line_type;
169 /* How long the subline should be displayed, in 10ths of sec */
170 unsigned char time_mult;
172 /* pointer to the next subline in this line */
173 struct skin_subline *next;
176 /* Description of a line on the WPS. A line is a set of sublines.
177 A subline is displayed for a certain amount of time. After that,
178 the next subline of the line is displayed. And so on. */
179 struct skin_line {
181 /* Linked list of all the sublines on this line,
182 * a line *must* have at least one subline so no need to add an extra pointer */
183 struct skin_subline sublines;
184 /* pointer to the current subline */
185 struct skin_subline *curr_subline;
187 /* When the next subline of this line should be displayed
188 (absolute time value in ticks) */
189 long subline_expire_time;
191 /* pointer to the next line */
192 struct skin_line *next;
195 #define VP_DRAW_HIDEABLE 0x1
196 #define VP_DRAW_HIDDEN 0x2
197 #define VP_DRAW_WASHIDDEN 0x4
198 /* these are never drawn, nor cleared, i.e. just ignored */
199 #define VP_NEVER_VISIBLE 0x8
200 #define VP_DEFAULT_LABEL '|'
201 #define VP_NO_LABEL '-'
202 #define VP_INFO_LABEL '_'
203 struct skin_viewport {
204 struct viewport vp; /* The LCD viewport struct */
205 struct progressbar *pb;
206 struct skin_line *lines;
207 char hidden_flags;
208 char label;
211 #ifdef HAVE_TOUCHSCREEN
212 struct touchregion {
213 struct skin_viewport* wvp;/* The viewport this region is in */
214 short int x; /* x-pos */
215 short int y; /* y-pos */
216 short int width; /* width */
217 short int height; /* height */
218 enum {
219 WPS_TOUCHREGION_ACTION,
220 WPS_TOUCHREGION_SCROLLBAR,
221 WPS_TOUCHREGION_VOLUME
222 } type; /* type of touch region */
223 bool repeat; /* requires the area be held for the action */
224 int action; /* action this button will return */
225 bool armed; /* A region is armed on press. Only armed regions are triggered
226 on repeat or release. */
228 #endif
230 #define MAX_PLAYLISTLINE_TOKENS 16
231 #define MAX_PLAYLISTLINE_STRINGS 8
232 #define MAX_PLAYLISTLINE_STRLEN 8
233 enum info_line_type {
234 TRACK_HAS_INFO = 0,
235 TRACK_HAS_NO_INFO
237 struct playlistviewer {
238 struct viewport *vp;
239 bool show_icons;
240 int start_offset;
241 struct {
242 enum wps_token_type tokens[MAX_PLAYLISTLINE_TOKENS];
243 char strings[MAX_PLAYLISTLINE_STRINGS][MAX_PLAYLISTLINE_STRLEN];
244 int count;
245 bool scroll;
246 } lines[2];
251 #ifdef HAVE_ALBUMART
252 struct skin_albumart {
253 /* Album art support */
254 struct viewport *vp;/* The viewport this is in */
255 int x;
256 int y;
257 int width;
258 int height;
260 bool draw;
261 unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
262 unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
263 unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
265 #endif
267 /* wps_data
268 this struct holds all necessary data which describes the
269 viewable content of a wps */
270 struct wps_data
272 #ifdef HAVE_LCD_BITMAP
273 struct skin_token_list *images;
274 struct skin_token_list *progressbars;
275 #endif
276 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
277 char *backdrop;
278 #endif
280 #ifdef HAVE_TOUCHSCREEN
281 struct skin_token_list *touchregions;
282 #endif
283 struct skin_token_list *viewports;
284 struct skin_token_list *strings;
285 #ifdef HAVE_ALBUMART
286 struct skin_albumart *albumart;
287 int playback_aa_slot;
288 #endif
289 struct wps_token *tokens;
290 /* Total number of tokens in the WPS. During WPS parsing, this is
291 the index of the token being parsed. */
292 int num_tokens;
294 #ifdef HAVE_LCD_BITMAP
295 bool peak_meter_enabled;
296 bool wps_sb_tag;
297 bool show_sb_on_wps;
298 #else /*HAVE_LCD_CHARCELLS */
299 unsigned short wps_progress_pat[8];
300 bool full_line_progressbar;
301 #endif
302 bool wps_loaded;
305 /* wps_data end */
307 /* wps_state
308 holds the data which belongs to the current played track,
309 the track which will be played afterwards, current path to the track
310 and some status infos */
311 struct wps_state
313 struct mp3entry* id3;
314 struct mp3entry* nid3;
315 int ff_rewind_count;
316 bool ff_rewind;
317 bool paused;
318 bool wps_time_countup;
319 bool is_fading;
322 /* Holds data for all screens in a skin. */
323 struct wps_sync_data
325 /* suitable for the viewportmanager, possibly only temporary here
326 * needs to be same for all screens! can't be split up for screens
327 * due to what viewportmanager_set_statusbar() accepts
328 * (FIXME?) */
329 int statusbars;
330 /* indicates whether the skin needs a full update for all screens */
331 bool do_full_update;
334 /* change the ff/rew-status
335 if ff_rew = true then we are in skipping mode
336 else we are in normal mode */
337 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
339 /* change the tag-information of the current played track
340 and the following track */
341 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
342 /* wps_state end*/
344 /* gui_wps
345 defines a wps with its data, state,
346 and the screen on which the wps-content should be drawn */
347 struct gui_wps
349 struct screen *display;
350 struct wps_data *data;
351 struct wps_state *state;
352 /* must point to the same struct for all screens */
353 struct wps_sync_data *sync_data;
356 /* gui_wps end */
358 char *get_image_filename(const char *start, const char* bmpdir,
359 char *buf, int buf_size);
360 /***** wps_tokens.c ******/
362 const char *get_token_value(struct gui_wps *gwps,
363 struct wps_token *token,
364 char *buf, int buf_size,
365 int *intval);
367 const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
368 char *buf, int buf_size, int limit, int *intval);
371 struct gui_img* find_image(char label, struct wps_data *data);
372 struct skin_viewport* find_viewport(char label, struct wps_data *data);
374 #endif