initial custom statusbar commit
[kugel-rb.git] / apps / gui / skin_engine / wps_internals.h
blob1d1bcbc8e4041bfe223cfa9e37fa3706b8e6863a
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 char label;
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 WPS_MAX_VIEWPORTS 24
125 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
126 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
127 #define WPS_MAX_TOKENS 1024
128 #define WPS_MAX_STRINGS 128
129 #define STRING_BUFFER_SIZE 1024
130 #define WPS_MAX_COND_LEVEL 10
132 #else
134 #define WPS_MAX_VIEWPORTS 2
135 #define WPS_MAX_LINES 2
136 #define WPS_MAX_SUBLINES 12
137 #define WPS_MAX_TOKENS 64
138 #define WPS_MAX_STRINGS 32
139 #define STRING_BUFFER_SIZE 64
140 #define WPS_MAX_COND_LEVEL 5
142 #endif
144 #define SUBLINE_RESET -1
146 enum wps_parse_error {
147 PARSE_OK,
148 PARSE_FAIL_UNCLOSED_COND,
149 PARSE_FAIL_INVALID_CHAR,
150 PARSE_FAIL_COND_SYNTAX_ERROR,
151 PARSE_FAIL_COND_INVALID_PARAM,
152 PARSE_FAIL_LIMITS_EXCEEDED,
156 /* Description of a subline on the WPS */
157 struct skin_subline {
159 /* Index of the first token for this subline in the token array.
160 Tokens of this subline end where tokens for the next subline
161 begin. */
162 unsigned short first_token_idx;
163 unsigned short last_token_idx;
165 /* Bit or'ed WPS_REFRESH_xxx */
166 unsigned char line_type;
168 /* How long the subline should be displayed, in 10ths of sec */
169 unsigned char time_mult;
171 /* pointer to the next subline in this line */
172 struct skin_subline *next;
175 /* Description of a line on the WPS. A line is a set of sublines.
176 A subline is displayed for a certain amount of time. After that,
177 the next subline of the line is displayed. And so on. */
178 struct skin_line {
180 /* Linked list of all the sublines on this line,
181 * a line *must* have at least one subline so no need to add an extra pointer */
182 struct skin_subline sublines;
183 /* pointer to the current subline */
184 struct skin_subline *curr_subline;
186 /* When the next subline of this line should be displayed
187 (absolute time value in ticks) */
188 long subline_expire_time;
190 /* pointer to the next line */
191 struct skin_line *next;
194 #define VP_DRAW_HIDEABLE 0x1
195 #define VP_DRAW_HIDDEN 0x2
196 #define VP_DRAW_WASHIDDEN 0x4
197 #define VP_DEFAULT_LABEL '|'
198 #define VP_NO_LABEL '-'
199 struct skin_viewport {
200 struct viewport vp; /* The LCD viewport struct */
201 struct progressbar *pb;
202 struct skin_line *lines;
203 char hidden_flags;
204 char label;
207 #ifdef HAVE_TOUCHSCREEN
208 struct touchregion {
209 struct skin_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
225 #ifdef HAVE_ALBUMART
226 struct skin_albumart {
227 /* Album art support */
228 struct viewport *vp;/* The viewport this is in */
229 int x;
230 int y;
231 int width;
232 int height;
234 bool draw;
235 unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
236 unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
237 unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
239 #endif
241 /* wps_data
242 this struct holds all necessary data which describes the
243 viewable content of a wps */
244 struct wps_data
246 #ifdef HAVE_LCD_BITMAP
247 struct skin_token_list *images;
248 struct skin_token_list *progressbars;
249 #endif
251 #ifdef HAVE_TOUCHSCREEN
252 struct skin_token_list *touchregions;
253 #endif
254 struct skin_token_list *viewports;
255 struct skin_token_list *strings;
256 #ifdef HAVE_ALBUMART
257 struct skin_albumart *albumart;
258 int playback_aa_slot;
259 #endif
260 struct wps_token *tokens;
261 /* Total number of tokens in the WPS. During WPS parsing, this is
262 the index of the token being parsed. */
263 int num_tokens;
264 /* tick the volume button was last pressed */
265 unsigned int button_time_volume;
266 #ifdef HAVE_LCD_BITMAP
267 bool peak_meter_enabled;
268 bool wps_sb_tag;
269 bool show_sb_on_wps;
270 #else /*HAVE_LCD_CHARCELLS */
271 unsigned short wps_progress_pat[8];
272 bool full_line_progressbar;
273 #endif
274 bool wps_loaded;
275 #ifdef HAVE_REMOTE_LCD
276 /* this must not be reset on skin loading */
277 bool remote_wps;
278 #endif
279 bool debug;
282 /* wps_data end */
284 /* wps_state
285 holds the data which belongs to the current played track,
286 the track which will be played afterwards, current path to the track
287 and some status infos */
288 struct wps_state
290 bool ff_rewind;
291 bool paused;
292 int ff_rewind_count;
293 bool wps_time_countup;
294 struct mp3entry* id3;
295 struct mp3entry* nid3;
296 bool do_full_update;
300 /* change the ff/rew-status
301 if ff_rew = true then we are in skipping mode
302 else we are in normal mode */
303 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
305 /* change the tag-information of the current played track
306 and the following track */
307 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
308 /* wps_state end*/
310 /* gui_wps
311 defines a wps with its data, state,
312 and the screen on which the wps-content should be drawn */
313 struct gui_wps
315 struct screen *display;
316 struct wps_data *data;
317 struct wps_state *state;
319 /* suitable for the viewportmanager, possibly only temporary here
320 * needs to be same for all screens! can't be split up for screens
321 * due to what viewportmanager_set_statusbar() accepts
322 * (FIXME?) */
323 int *statusbars;
326 /* gui_wps end */
329 /***** wps_tokens.c ******/
331 const char *get_token_value(struct gui_wps *gwps,
332 struct wps_token *token,
333 char *buf, int buf_size,
334 int *intval);
338 struct gui_img* find_image(char label, struct wps_data *data);
339 struct skin_viewport* find_viewport(char label, struct wps_data *data);
341 #endif