From 3b75c86d74937a6bffcb371bb08bdfb182db9d2b Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Mon, 3 Aug 2009 15:06:30 +0000 Subject: A bit mroe wps/skin engine cleanup so that the structs the wps uses can be static: -add wrappers wps_data_load() and wps_data_init() so that other code doesn't need the structs for that -change (and rename) gui_sync_wps_uses_albumart() to take points to be filled as parameter to get the AA size of a wps git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22139 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_engine.h | 11 ++--------- apps/gui/skin_engine/wps_internals.h | 7 ------- apps/gui/skin_engine/wps_parser.c | 12 ++++++------ apps/gui/wps.c | 30 ++++++++++++++++++++++++------ apps/gui/wps.h | 13 +++++++++++++ 5 files changed, 45 insertions(+), 28 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/skin_engine/skin_engine.h b/apps/gui/skin_engine/skin_engine.h index 00232a327a..498444e8ea 100644 --- a/apps/gui/skin_engine/skin_engine.h +++ b/apps/gui/skin_engine/skin_engine.h @@ -30,11 +30,6 @@ int wps_get_touchaction(struct wps_data *data); #endif -#ifdef HAVE_ALBUMART -/* gives back if WPS contains an albumart tag */ -bool gui_sync_wps_uses_albumart(void); -#endif - /* setup and display a WPS for the first time */ bool gui_wps_display(struct gui_wps *gwps); @@ -52,8 +47,6 @@ void skin_data_load(struct wps_data *wps_data, bool isfile); - - - - +/* initial setup of wps_data */ +void skin_data_init(struct wps_data *wps_data); #endif diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 2dcaa504bb..c00a4f1945 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -470,9 +470,6 @@ struct wps_data unsigned int button_time_volume; }; -/* initial setup of wps_data */ -void wps_data_init(struct wps_data *wps_data); - /* Redraw statusbars if necessary */ void gwps_draw_statusbars(void); @@ -536,10 +533,6 @@ struct gui_wps /* gui_wps end */ -/* currently only on wps_state is needed */ -extern struct wps_state wps_state; -extern struct gui_wps gui_wps[NB_SCREENS]; - /***** wps_tokens.c ******/ const char *get_token_value(struct gui_wps *gwps, diff --git a/apps/gui/skin_engine/wps_parser.c b/apps/gui/skin_engine/wps_parser.c index a3e5f6861d..2c6d5ded95 100644 --- a/apps/gui/skin_engine/wps_parser.c +++ b/apps/gui/skin_engine/wps_parser.c @@ -1552,7 +1552,7 @@ static void wps_images_clear(struct wps_data *data) #endif /* initial setup of wps_data */ -void wps_data_init(struct wps_data *wps_data) +void skin_data_init(struct wps_data *wps_data) { #ifdef HAVE_LCD_BITMAP wps_images_clear(wps_data); @@ -1581,7 +1581,7 @@ static void wps_reset(struct wps_data *data) bool rwps = data->remote_wps; /* remember whether the data is for a RWPS */ #endif memset(data, 0, sizeof(*data)); - wps_data_init(data); + skin_data_init(data); #ifdef HAVE_REMOTE_LCD data->remote_wps = rwps; #endif @@ -1666,7 +1666,7 @@ static bool load_wps_bitmaps(struct wps_data *wps_data, char *bmpdir) /* to setup up the wps-data from a format-buffer (isfile = false) from a (wps-)file (isfile = true)*/ -static bool wps_data_load(struct wps_data *wps_data, +static bool _skin_data_load(struct wps_data *wps_data, struct screen *display, const char *buf, bool isfile) @@ -1820,7 +1820,7 @@ void skin_data_load(struct wps_data *wps_data, const char *buf, bool isfile) { - bool loaded_ok = buf && wps_data_load(wps_data, display, buf, isfile); + bool loaded_ok = buf && _skin_data_load(wps_data, display, buf, isfile); if (!loaded_ok) /* load the hardcoded default */ { /* set the default wps for the main-screen */ @@ -1829,7 +1829,7 @@ void skin_data_load(struct wps_data *wps_data, #if LCD_DEPTH > 1 unload_wps_backdrop(); #endif - wps_data_load(wps_data, + _skin_data_load(wps_data, display, #ifdef HAVE_LCD_BITMAP "%s%?it<%?in<%in. |>%it|%fn>\n" @@ -1852,7 +1852,7 @@ void skin_data_load(struct wps_data *wps_data, #if LCD_REMOTE_DEPTH > 1 unload_remote_wps_backdrop(); #endif - wps_data_load(wps_data, + _skin_data_load(wps_data, display, "%s%?ia<%ia|%?d2<%d2|(root)>>\n" "%s%?it<%?in<%in. |>%it|%fn>\n" diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 4a7de875d2..447c1d6b00 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -75,8 +75,8 @@ static int wpsbars; /* currently only one wps_state is needed */ -struct wps_state wps_state; -struct gui_wps gui_wps[NB_SCREENS]; +static struct wps_state wps_state; +static struct gui_wps gui_wps[NB_SCREENS]; static struct wps_data wps_datas[NB_SCREENS]; /* initial setup of wps_data */ @@ -90,6 +90,19 @@ static void nextid3available_callback(void* param); /* 3% of 30min file == 54s step size */ #define MIN_FF_REWIND_STEP 500 +void wps_data_load(enum screen_type screen, const char *buf, bool is_file) +{ + skin_data_load(gui_wps[screen].data, &screens[screen], buf, is_file); +#ifdef HAVE_REMOVE_LCD + gui_wps[screen].data->remote_wps = !(screen == SCREEN_MAIN); +#endif +} + +void wps_data_init(enum screen_type screen) +{ + skin_data_init(gui_wps[screen].data); +} + bool wps_fading_out = false; void fade(bool fade_in, bool updatewps) { @@ -165,6 +178,7 @@ bool update_onvol_change(struct gui_wps * gwps) return false; } + bool ffwd_rew(int button) { unsigned int step = 0; /* current ff/rewind step */ @@ -1176,7 +1190,7 @@ void gui_sync_wps_init(void) int i; FOR_NB_SCREENS(i) { - wps_data_init(&wps_datas[i]); + skin_data_init(&wps_datas[i]); #ifdef HAVE_ALBUMART wps_datas[i].wps_uses_albumart = 0; #endif @@ -1201,15 +1215,19 @@ void gui_sync_wps_init(void) } #ifdef HAVE_ALBUMART -/* Returns true if at least one of the gui_wps screens has an album art - tag in its wps structure */ -bool gui_sync_wps_uses_albumart(void) +bool wps_uses_albumart(int *width, int *height) { int i; FOR_NB_SCREENS(i) { struct gui_wps *gwps = &gui_wps[i]; if (gwps->data && (gwps->data->wps_uses_albumart != WPS_ALBUMART_NONE)) + { + if (width) + *width = gui_wps[0].data->albumart_max_width; + if (height) + *height = gui_wps[0].data->albumart_max_height; return true; + } } return false; } diff --git a/apps/gui/wps.h b/apps/gui/wps.h index 90614cb65b..b8cb7d2ffa 100644 --- a/apps/gui/wps.h +++ b/apps/gui/wps.h @@ -34,4 +34,17 @@ bool ffwd_rew(int button); void display_keylock_text(bool locked); bool is_wps_fading(void); + +/* wrapper for the wps to load the skin (.wps/.rwps) files */ +void wps_data_load(enum screen_type, const char *, bool); +void wps_data_init(enum screen_type); + +#ifdef HAVE_ALBUMART +/* + * Returns true if at least one of the gui_wps screens has an album art + * tag in its wps structure and writes the width and height into the passed + * pointers + */ +bool wps_uses_albumart(int*, int*); +#endif #endif -- cgit v1.2.3