Allow viewport labels to be mostly free text instead of only one character. If this...
[kugel-rb.git] / apps / gui / skin_engine / wps_internals.h
blob709dbc6ff732dc83c0832e3ae35a0e6628e4219b
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_
29 /* Timeout unit expressed in HZ. In WPS, all timeouts are given in seconds
30 (possibly with a decimal fraction) but stored as integer values.
31 E.g. 2.5 is stored as 25. This means 25 tenth of a second, i.e. 25 units.
33 #define TIMEOUT_UNIT (HZ/10) /* I.e. 0.1 sec */
34 #define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* In TIMEOUT_UNIT's */
36 #include "skin_tokens.h"
37 #include "tag_table.h"
38 #include "skin_parser.h"
41 /* TODO: sort this mess out */
43 #include "screen_access.h"
44 #include "statusbar.h"
45 #include "metadata.h"
47 /* alignments */
48 #define WPS_ALIGN_RIGHT 32
49 #define WPS_ALIGN_CENTER 64
50 #define WPS_ALIGN_LEFT 128
52 #ifdef HAVE_ALBUMART
54 /* albumart definitions */
55 #define WPS_ALBUMART_NONE 0 /* WPS does not contain AA tag */
56 #define WPS_ALBUMART_CHECK 1 /* WPS contains AA conditional tag */
57 #define WPS_ALBUMART_LOAD 2 /* WPS contains AA tag */
59 #define WPS_ALBUMART_ALIGN_RIGHT 1 /* x align: right */
60 #define WPS_ALBUMART_ALIGN_CENTER 2 /* x/y align: center */
61 #define WPS_ALBUMART_ALIGN_LEFT 4 /* x align: left */
62 #define WPS_ALBUMART_ALIGN_TOP 1 /* y align: top */
63 #define WPS_ALBUMART_ALIGN_BOTTOM 4 /* y align: bottom */
65 #endif /* HAVE_ALBUMART */
67 /* wps_data*/
69 #ifdef HAVE_LCD_BITMAP
70 struct gui_img {
71 struct viewport* vp; /* The viewport to display this image in */
72 short int x; /* x-pos */
73 short int y; /* y-pos */
74 short int num_subimages; /* number of sub-images */
75 short int subimage_height; /* height of each sub-image */
76 struct bitmap bm;
77 char label;
78 bool loaded; /* load state */
79 bool always_display; /* not using the preload/display mechanism */
80 int display;
84 struct progressbar {
85 enum skin_token_type type;
86 struct viewport *vp;
87 /* regular pb */
88 short x;
89 /* >=0: explicitly set in the tag -> y-coord within the viewport
90 <0 : not set in the tag -> negated 1-based line number within
91 the viewport. y-coord will be computed based on the font height */
92 short y;
93 short width;
94 short height;
95 bool follow_lang_direction;
96 /*progressbar image*/
97 struct bitmap bm;
98 bool have_bitmap_pb;
100 #endif
104 struct align_pos {
105 char* left;
106 char* center;
107 char* right;
110 #ifdef HAVE_LCD_BITMAP
112 #define MAX_IMAGES (26*2) /* a-z and A-Z */
113 #define MAX_PROGRESSBARS 3
115 /* The image buffer is big enough to store one full-screen native bitmap,
116 plus two full-screen mono bitmaps. */
118 #define WPS_MAX_VIEWPORTS 24
119 #define WPS_MAX_LINES ((LCD_HEIGHT/5+1) * 2)
120 #define WPS_MAX_SUBLINES (WPS_MAX_LINES*3)
121 #define WPS_MAX_TOKENS 1024
122 #define WPS_MAX_STRINGS 128
123 #define STRING_BUFFER_SIZE 1024
124 #define WPS_MAX_COND_LEVEL 10
126 #else
128 #define WPS_MAX_VIEWPORTS 2
129 #define WPS_MAX_LINES 2
130 #define WPS_MAX_SUBLINES 12
131 #define WPS_MAX_TOKENS 64
132 #define WPS_MAX_STRINGS 32
133 #define STRING_BUFFER_SIZE 64
134 #define WPS_MAX_COND_LEVEL 5
136 #endif
138 #define SUBLINE_RESET -1
140 enum wps_parse_error {
141 PARSE_OK,
142 PARSE_FAIL_UNCLOSED_COND,
143 PARSE_FAIL_INVALID_CHAR,
144 PARSE_FAIL_COND_SYNTAX_ERROR,
145 PARSE_FAIL_COND_INVALID_PARAM,
146 PARSE_FAIL_LIMITS_EXCEEDED,
149 #define VP_DRAW_HIDEABLE 0x1
150 #define VP_DRAW_HIDDEN 0x2
151 #define VP_DRAW_WASHIDDEN 0x4
152 /* these are never drawn, nor cleared, i.e. just ignored */
153 #define VP_NEVER_VISIBLE 0x8
154 #define VP_DEFAULT_LABEL "|"
155 struct skin_viewport {
156 struct viewport vp; /* The LCD viewport struct */
157 char hidden_flags;
158 bool is_infovp;
159 char* label;
160 unsigned start_fgcolour;
161 unsigned start_bgcolour;
163 struct viewport_colour {
164 struct viewport *vp;
165 unsigned colour;
167 #ifdef HAVE_TOUCHSCREEN
168 struct touchregion {
169 struct skin_viewport* wvp;/* The viewport this region is in */
170 short int x; /* x-pos */
171 short int y; /* y-pos */
172 short int width; /* width */
173 short int height; /* height */
174 enum {
175 WPS_TOUCHREGION_ACTION,
176 WPS_TOUCHREGION_SCROLLBAR,
177 WPS_TOUCHREGION_VOLUME
178 } type; /* type of touch region */
179 bool reverse_bar; /* if true 0% is the left or top */
180 bool repeat; /* requires the area be held for the action */
181 int action; /* action this button will return */
182 bool armed; /* A region is armed on press. Only armed regions are triggered
183 on repeat or release. */
185 #endif
187 enum info_line_type {
188 TRACK_HAS_INFO = 0,
189 TRACK_HAS_NO_INFO
191 struct playlistviewer {
192 struct viewport *vp;
193 bool show_icons;
194 int start_offset;
195 #ifdef HAVE_TC_RAMCACHE
196 struct mp3entry tempid3;
197 #endif
198 struct skin_element *lines[2];
202 #ifdef HAVE_ALBUMART
203 struct skin_albumart {
204 /* Album art support */
205 int x;
206 int y;
207 int width;
208 int height;
210 unsigned char xalign; /* WPS_ALBUMART_ALIGN_LEFT, _CENTER, _RIGHT */
211 unsigned char yalign; /* WPS_ALBUMART_ALIGN_TOP, _CENTER, _BOTTOM */
212 unsigned char state; /* WPS_ALBUMART_NONE, _CHECK, _LOAD */
214 struct viewport *vp;
215 int draw_handle;
217 #endif
220 struct line {
221 int timeout; /* if inside a line alternator */
222 unsigned update_mode;
225 struct line_alternator {
226 int current_line;
227 unsigned long last_change_tick;
230 struct conditional {
231 int last_value;
232 struct wps_token *token;
236 /* wps_data
237 this struct holds all necessary data which describes the
238 viewable content of a wps */
239 struct wps_data
241 struct skin_element *tree;
242 #ifdef HAVE_LCD_BITMAP
243 struct skin_token_list *images;
244 struct skin_token_list *progressbars;
245 #endif
246 #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
247 char *backdrop;
248 #endif
250 #ifdef HAVE_TOUCHSCREEN
251 struct skin_token_list *touchregions;
252 #endif
253 #ifdef HAVE_ALBUMART
254 struct skin_albumart *albumart;
255 int playback_aa_slot;
256 #endif
258 #ifdef HAVE_LCD_BITMAP
259 bool peak_meter_enabled;
260 bool wps_sb_tag;
261 bool show_sb_on_wps;
262 #else /*HAVE_LCD_CHARCELLS */
263 unsigned short wps_progress_pat[8];
264 bool full_line_progressbar;
265 #endif
266 bool wps_loaded;
269 /* wps_data end */
271 /* wps_state
272 holds the data which belongs to the current played track,
273 the track which will be played afterwards, current path to the track
274 and some status infos */
275 struct wps_state
277 struct mp3entry* id3;
278 struct mp3entry* nid3;
279 int ff_rewind_count;
280 bool ff_rewind;
281 bool paused;
282 bool wps_time_countup;
283 bool is_fading;
286 /* Holds data for all screens in a skin. */
287 struct wps_sync_data
289 /* suitable for the viewportmanager, possibly only temporary here
290 * needs to be same for all screens! can't be split up for screens
291 * due to what viewportmanager_set_statusbar() accepts
292 * (FIXME?) */
293 int statusbars;
294 /* indicates whether the skin needs a full update for all screens */
295 bool do_full_update;
298 /* change the ff/rew-status
299 if ff_rew = true then we are in skipping mode
300 else we are in normal mode */
301 /* void wps_state_update_ff_rew(bool ff_rew); Currently unused */
303 /* change the tag-information of the current played track
304 and the following track */
305 /* void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3); Currently unused */
306 /* wps_state end*/
308 /* gui_wps
309 defines a wps with its data, state,
310 and the screen on which the wps-content should be drawn */
311 struct gui_wps
313 struct screen *display;
314 struct wps_data *data;
315 struct wps_state *state;
316 /* must point to the same struct for all screens */
317 struct wps_sync_data *sync_data;
320 /* gui_wps end */
322 char *get_image_filename(const char *start, const char* bmpdir,
323 char *buf, int buf_size);
324 /***** wps_tokens.c ******/
326 const char *get_token_value(struct gui_wps *gwps,
327 struct wps_token *token,
328 char *buf, int buf_size,
329 int *intval);
331 /* Get the id3 fields from the cuesheet */
332 const char *get_cuesheetid3_token(struct wps_token *token, struct mp3entry *id3,
333 int offset_tracks, char *buf, int buf_size);
334 const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
335 char *buf, int buf_size, int limit, int *intval);
336 #if CONFIG_TUNER
337 const char *get_radio_token(struct wps_token *token, int preset_offset,
338 char *buf, int buf_size, int limit, int *intval);
339 #endif
341 struct gui_img* find_image(char label, struct wps_data *data);
342 struct skin_viewport* find_viewport(char *label, bool uivp, struct wps_data *data);
345 #ifdef SIMULATOR
346 #define DEBUG_SKIN_ENGINE
347 extern bool debug_wps;
348 #endif
350 #endif