From 53da44b302ea609f219ffdc8da53d708476979d6 Mon Sep 17 00:00:00 2001 From: jdgordon Date: Mon, 3 Aug 2009 04:43:34 +0000 Subject: [PATCH] part two of the grand overall wps/skinning engine cleanup work: * rename wps_engine to skin_engine as that was agreed on * rename music_screen back to wps * clean up the skin display/update functions a bit * make skin_data_load setup the hardcoded default if a skin cant be loaded for whatever reason instead of doing it when it is first displayed ignore any gui_wps or wps_ or gwps_ nameing in skin_engine/ ... these will be renamed as this work gets finished git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22135 a1c6a512-1295-4272-9138-f99709370657 --- apps/SOURCES | 10 +- apps/filetree.c | 6 +- apps/gui/{wps_engine => skin_engine}/wps_debug.c | 0 apps/gui/{wps_engine => skin_engine}/wps_display.c | 89 +++++------------ .../{wps_engine => skin_engine}/wps_internals.h | 11 --- apps/gui/{wps_engine => skin_engine}/wps_parser.c | 106 ++++++++++++++------- apps/gui/{wps_engine => skin_engine}/wps_tokens.c | 2 +- apps/gui/wps_engine/wps_engine.h | 49 ---------- apps/iap.c | 2 +- apps/main.c | 2 +- apps/menus/main_menu.c | 2 +- apps/misc.c | 2 +- apps/recorder/albumart.h | 2 +- apps/root_menu.c | 2 +- apps/settings.c | 8 +- apps/tree.c | 2 +- 16 files changed, 115 insertions(+), 180 deletions(-) rename apps/gui/{wps_engine => skin_engine}/wps_debug.c (100%) rename apps/gui/{wps_engine => skin_engine}/wps_display.c (93%) rename apps/gui/{wps_engine => skin_engine}/wps_internals.h (97%) rename apps/gui/{wps_engine => skin_engine}/wps_parser.c (96%) rename apps/gui/{wps_engine => skin_engine}/wps_tokens.c (99%) delete mode 100644 apps/gui/wps_engine/wps_engine.h diff --git a/apps/SOURCES b/apps/SOURCES index e1d85a75f..12ac54f38 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -77,17 +77,17 @@ gui/pitchscreen.c gui/quickscreen.c #endif -gui/music_screen.c +gui/wps.c gui/scrollbar.c gui/splash.c gui/statusbar.c gui/yesno.c gui/viewport.c -gui/wps_engine/wps_debug.c -gui/wps_engine/wps_display.c -gui/wps_engine/wps_parser.c -gui/wps_engine/wps_tokens.c +gui/skin_engine/wps_debug.c +gui/skin_engine/wps_display.c +gui/skin_engine/wps_parser.c +gui/skin_engine/wps_tokens.c #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) gui/backdrop.c diff --git a/apps/filetree.c b/apps/filetree.c index 458d553e2..8e97a0d13 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -51,7 +51,7 @@ #if CONFIG_TUNER #include "radio.h" #endif -#include "wps_engine/wps_internals.h" /* FIXME: REMOVE ME */ +#include "skin_engine/skin_engine.h" #include "backdrop.h" static int compare_sort_dir; /* qsort key for sorting directories */ @@ -484,7 +484,7 @@ int ft_enter(struct tree_context* c) #if LCD_DEPTH > 1 unload_wps_backdrop(); #endif - wps_data_load(gui_wps[0].data, &screens[0], buf, true); + skin_data_load(gui_wps[0].data, &screens[0], buf, true); set_file(buf, (char *)global_settings.wps_file, MAX_FILENAME); break; @@ -496,7 +496,7 @@ int ft_enter(struct tree_context* c) #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 unload_remote_wps_backdrop(); #endif - wps_data_load(gui_wps[1].data, &screens[1], buf, true); + skin_data_load(gui_wps[1].data, &screens[1], buf, true); set_file(buf, (char *)global_settings.rwps_file, MAX_FILENAME); break; diff --git a/apps/gui/wps_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c similarity index 100% rename from apps/gui/wps_engine/wps_debug.c rename to apps/gui/skin_engine/wps_debug.c diff --git a/apps/gui/wps_engine/wps_display.c b/apps/gui/skin_engine/wps_display.c similarity index 93% rename from apps/gui/wps_engine/wps_display.c rename to apps/gui/skin_engine/wps_display.c index c74e2cedf..98050093c 100644 --- a/apps/gui/wps_engine/wps_display.c +++ b/apps/gui/skin_engine/wps_display.c @@ -63,89 +63,52 @@ #include "wps_internals.h" -#include "wps_engine.h" +#include "skin_engine.h" + +static bool gui_wps_redraw(struct gui_wps *gwps, unsigned refresh_mode); + bool gui_wps_display(struct gui_wps *gwps) { struct screen *display = gwps->display; - struct wps_data *data = gwps->data; - int screen = display->screen_type; /* Update the values in the first (default) viewport - in case the user has modified the statusbar or colour settings */ #if LCD_DEPTH > 1 if (display->depth > 1) { - data->viewports[0].vp.fg_pattern = display->get_foreground(); - data->viewports[0].vp.bg_pattern = display->get_background(); + gwps->data->viewports[0].vp.fg_pattern = display->get_foreground(); + gwps->data->viewports[0].vp.bg_pattern = display->get_background(); } #endif display->clear_display(); - if (!data->wps_loaded) { - if ( !data->num_tokens ) { - /* set the default wps for the main-screen */ - if(screen == SCREEN_MAIN) - { -#if LCD_DEPTH > 1 - unload_wps_backdrop(); -#endif - wps_data_load(data, - display, -#ifdef HAVE_LCD_BITMAP - "%s%?it<%?in<%in. |>%it|%fn>\n" - "%s%?ia<%ia|%?d2<%d2|(root)>>\n" - "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n" - "\n" - "%al%pc/%pt%ar[%pp:%pe]\n" - "%fbkBit %?fv %?iv<(id3v%iv)|(no id3)>\n" - "%pb\n" - "%pm\n", false); -#else - "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n" - "%pc%?ps<*|/>%pt\n", false); -#endif - } -#ifdef HAVE_REMOTE_LCD - /* set the default wps for the remote-screen */ - else if(screen == SCREEN_REMOTE) - { -#if LCD_REMOTE_DEPTH > 1 - unload_remote_wps_backdrop(); -#endif - wps_data_load(data, - display, - "%s%?ia<%ia|%?d2<%d2|(root)>>\n" - "%s%?it<%?in<%in. |>%it|%fn>\n" - "%al%pc/%pt%ar[%pp:%pe]\n" - "%fbkBit %?fv %?iv<(id3v%iv)|(no id3)>\n" - "%pb\n", false); - } -#endif - } - } - else - { #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 - if (screen == SCREEN_REMOTE) - show_remote_wps_backdrop(); - else if (screen == SCREEN_MAIN) + if (display->screen_type == SCREEN_REMOTE) + show_remote_wps_backdrop(); + else if (display->screen_type == SCREEN_MAIN) #endif #if LCD_DEPTH > 1 - show_wps_backdrop(); + show_wps_backdrop(); #endif - } - return gui_wps_redraw(gwps, 0, WPS_REFRESH_ALL); + return gui_wps_redraw(gwps, WPS_REFRESH_ALL); } -bool gui_wps_update(struct gui_wps *gwps) +/* update a skinned screen, update_type is WPS_REFRESH_* values. + * Usually it should only be WPS_REFRESH_NON_STATIC + * A full update will be done if required (state.do_full_update == true) + */ +bool skin_update(struct gui_wps *gwps, unsigned int update_type) { - struct mp3entry *id3 = gwps->state->id3; bool retval; + /* This maybe shouldnt be here, but while the skin is only used to + * display the music screen this is better than whereever we are being + * called from. This is also safe for skined screen which dont use the id3 */ + struct mp3entry *id3 = gwps->state->id3; bool cuesheet_update = (id3 != NULL ? cuesheet_subtrack_changed(id3) : false); gwps->state->do_full_update = cuesheet_update || gwps->state->do_full_update; - retval = gui_wps_redraw(gwps, 0, - gwps->state->do_full_update ? - WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC); + + retval = gui_wps_redraw(gwps, gwps->state->do_full_update ? + WPS_REFRESH_ALL : update_type); return retval; } @@ -883,9 +846,7 @@ static void write_line(struct screen *display, } } -bool gui_wps_redraw(struct gui_wps *gwps, - int ffwd_offset, - unsigned refresh_mode) +static bool gui_wps_redraw(struct gui_wps *gwps, unsigned refresh_mode) { struct wps_data *data = gwps->data; struct screen *display = gwps->display; @@ -943,8 +904,6 @@ bool gui_wps_redraw(struct gui_wps *gwps, } #endif - state->ff_rewind_count = ffwd_offset; - /* disable any viewports which are conditionally displayed */ for (v = 0; v < data->num_viewports; v++) { diff --git a/apps/gui/wps_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h similarity index 97% rename from apps/gui/wps_engine/wps_internals.h rename to apps/gui/skin_engine/wps_internals.h index ce9b4d3d4..2dcaa504b 100644 --- a/apps/gui/wps_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -390,11 +390,6 @@ struct touchregion { short int y; /* y-pos */ short int width; /* width */ short int height; /* height */ - enum { - WPS_TOUCHREGION_ACTION, - WPS_TOUCHREGION_SCROLLBAR, - WPS_TOUCHREGION_VOLUME - } type; /* type of touch region */ bool repeat; /* requires the area be held for the action */ int action; /* action this button will return */ }; @@ -478,12 +473,6 @@ struct wps_data /* initial setup of wps_data */ void wps_data_init(struct wps_data *wps_data); -/* to setup up the wps-data from a format-buffer (isfile = false) - from a (wps-)file (isfile = true)*/ -bool wps_data_load(struct wps_data *wps_data, - struct screen *display, - const char *buf, - bool isfile); /* Redraw statusbars if necessary */ void gwps_draw_statusbars(void); diff --git a/apps/gui/wps_engine/wps_parser.c b/apps/gui/skin_engine/wps_parser.c similarity index 96% rename from apps/gui/wps_engine/wps_parser.c rename to apps/gui/skin_engine/wps_parser.c index 91c63059b..a3e5f6861 100644 --- a/apps/gui/wps_engine/wps_parser.c +++ b/apps/gui/skin_engine/wps_parser.c @@ -1173,8 +1173,6 @@ static int parse_touchregion(const char *wps_bufptr, struct touchregion *region; const char *ptr = wps_bufptr; const char *action; - const char pb_string[] = "progressbar"; - const char vol_string[] = "volume"; int x,y,w,h; /* format: %T|x|y|width|height|action| @@ -1205,7 +1203,7 @@ static int parse_touchregion(const char *wps_bufptr, /* Check there is a terminating | */ if (*ptr != '|') return WPS_ERROR_INVALID_PARAM; - + /* should probably do some bounds checking here with the viewport... but later */ region = &wps_data->touchregion[wps_data->touchregion_count]; region->action = ACTION_NONE; @@ -1214,41 +1212,28 @@ static int parse_touchregion(const char *wps_bufptr, region->width = w; region->height = h; region->wvp = &wps_data->viewports[wps_data->num_viewports]; - - if(!strncmp(pb_string, action, sizeof(pb_string)-1) - && *(action + sizeof(pb_string)-1) == '|') - region->type = WPS_TOUCHREGION_SCROLLBAR; - else if(!strncmp(vol_string, action, sizeof(vol_string)-1) - && *(action + sizeof(vol_string)-1) == '|') - region->type = WPS_TOUCHREGION_VOLUME; - else + i = 0; + if (*action == '&') { - region->type = WPS_TOUCHREGION_ACTION; - - if (*action == '&') - { - action++; - region->repeat = true; - } - else - region->repeat = false; - - i = 0; - imax = ARRAYLEN(touchactions); - while ((region->action == ACTION_NONE) && - (i < imax)) - { - /* try to match with one of our touchregion screens */ - int len = strlen(touchactions[i].s); - if (!strncmp(touchactions[i].s, action, len) - && *(action+len) == '|') - region->action = touchactions[i].action; - i++; - } - if (region->action == ACTION_NONE) - return WPS_ERROR_INVALID_PARAM; + action++; + region->repeat = true; } + else + region->repeat = false; + imax = ARRAYLEN(touchactions); + while ((region->action == ACTION_NONE) && + (i < imax)) + { + /* try to match with one of our touchregion screens */ + int len = strlen(touchactions[i].s); + if (!strncmp(touchactions[i].s, action, len) + && *(action+len) == '|') + region->action = touchactions[i].action; + i++; + } + if (region->action == ACTION_NONE) + return WPS_ERROR_INVALID_PARAM; wps_data->touchregion_count++; return skip_end_of_line(wps_bufptr); } @@ -1681,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)*/ -bool wps_data_load(struct wps_data *wps_data, +static bool wps_data_load(struct wps_data *wps_data, struct screen *display, const char *buf, bool isfile) @@ -1830,6 +1815,55 @@ bool wps_data_load(struct wps_data *wps_data, } } +void skin_data_load(struct wps_data *wps_data, + struct screen *display, + const char *buf, + bool isfile) +{ + bool loaded_ok = buf && wps_data_load(wps_data, display, buf, isfile); + if (!loaded_ok) /* load the hardcoded default */ + { + /* set the default wps for the main-screen */ + if(display->screen_type == SCREEN_MAIN) + { +#if LCD_DEPTH > 1 + unload_wps_backdrop(); +#endif + wps_data_load(wps_data, + display, +#ifdef HAVE_LCD_BITMAP + "%s%?it<%?in<%in. |>%it|%fn>\n" + "%s%?ia<%ia|%?d2<%d2|(root)>>\n" + "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n" + "\n" + "%al%pc/%pt%ar[%pp:%pe]\n" + "%fbkBit %?fv %?iv<(id3v%iv)|(no id3)>\n" + "%pb\n" + "%pm\n", false); +#else + "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n" + "%pc%?ps<*|/>%pt\n", false); +#endif + } +#ifdef HAVE_REMOTE_LCD + /* set the default wps for the remote-screen */ + else if(display->screen_type == SCREEN_REMOTE) + { +#if LCD_REMOTE_DEPTH > 1 + unload_remote_wps_backdrop(); +#endif + wps_data_load(wps_data, + display, + "%s%?ia<%ia|%?d2<%d2|(root)>>\n" + "%s%?it<%?in<%in. |>%it|%fn>\n" + "%al%pc/%pt%ar[%pp:%pe]\n" + "%fbkBit %?fv %?iv<(id3v%iv)|(no id3)>\n" + "%pb\n", false); + } +#endif + } +} + int wps_subline_index(struct wps_data *data, int line, int subline) { return data->lines[line].first_subline_idx + subline; diff --git a/apps/gui/wps_engine/wps_tokens.c b/apps/gui/skin_engine/wps_tokens.c similarity index 99% rename from apps/gui/wps_engine/wps_tokens.c rename to apps/gui/skin_engine/wps_tokens.c index 385225191..b1163aa88 100644 --- a/apps/gui/wps_engine/wps_tokens.c +++ b/apps/gui/skin_engine/wps_tokens.c @@ -55,7 +55,7 @@ #include "viewport.h" #include "wps_internals.h" -#include "music_screen.h" +#include "wps.h" static char* get_codectype(const struct mp3entry* id3) { diff --git a/apps/gui/wps_engine/wps_engine.h b/apps/gui/wps_engine/wps_engine.h deleted file mode 100644 index fe034f913..000000000 --- a/apps/gui/wps_engine/wps_engine.h +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id: gwps.h 22003 2009-07-22 22:10:25Z kugel $ - * - * Copyright (C) 2007 Nicolas Pennequin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - - /** Use this for stuff which external code needs to include **/ - -#ifndef _WPS_ENGINE_H -#define _WPS_ENGINE_H -#include -#include "wps_internals.h" /* TODO: remove this line.. shoudlnt be needed */ - - -#ifdef HAVE_TOUCHSCREEN -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); -/* do a requested redraw */ -bool gui_wps_redraw(struct gui_wps *gwps, - int ffwd_offset, - unsigned refresh_mode); -/* do a partial redraw, or full if required, also do any housekeeping - * which might be needed */ -bool gui_wps_update(struct gui_wps *gwps); - -#endif diff --git a/apps/iap.c b/apps/iap.c index f7a808d8b..8dfef9516 100644 --- a/apps/iap.c +++ b/apps/iap.c @@ -36,7 +36,7 @@ #include "audio.h" #include "settings.h" #include "metadata.h" -#include "wps_engine/wps_engine.h" +#include "skin_engine/skin_engine.h" #include "action.h" diff --git a/apps/main.c b/apps/main.c index 2cf9ce717..d0fba3fcc 100644 --- a/apps/main.c +++ b/apps/main.c @@ -52,7 +52,7 @@ #include "sprintf.h" #include "font.h" #include "language.h" -#include "music_screen.h" +#include "wps.h" #include "playlist.h" #include "buffer.h" #include "rolo.h" diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 4009566c4..b535662f1 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c @@ -50,7 +50,7 @@ #endif #include "version.h" #include "time.h" -#include "gui/wps_engine/wps_engine.h" +#include "skin_engine/skin_engine.h" static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG}; diff --git a/apps/misc.c b/apps/misc.c index 2e7051cbd..b091cc6a6 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -76,7 +76,7 @@ #include "icons.h" #endif /* End HAVE_LCD_BITMAP */ #include "bookmark.h" -#include "music_screen.h" +#include "wps.h" #include "playback.h" #ifdef BOOTFILE diff --git a/apps/recorder/albumart.h b/apps/recorder/albumart.h index 82e0b79ae..d1c2dfa7b 100644 --- a/apps/recorder/albumart.h +++ b/apps/recorder/albumart.h @@ -26,7 +26,7 @@ #include #include "metadata.h" -#include "wps_engine/wps_engine.h" +#include "skin_engine/skin_engine.h" /* Look for albumart bitmap in the same dir as the track and in its parent dir. * Stores the found filename in the buf parameter. diff --git a/apps/root_menu.c b/apps/root_menu.c index 1c86b6fe2..03e63f907 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c @@ -53,7 +53,7 @@ #ifdef HAVE_RECORDING #include "recording.h" #endif -#include "music_screen.h" +#include "wps.h" #include "bookmark.h" #include "playlist.h" #include "tagtree.h" diff --git a/apps/settings.c b/apps/settings.c index 800cc59a5..8835b95b1 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -69,7 +69,7 @@ #if CONFIG_TUNER #include "radio.h" #endif -#include "wps_engine/wps_engine.h" +#include "skin_engine/skin_engine.h" #if CONFIG_CODEC == MAS3507D void dac_line_in(bool enable); @@ -848,11 +848,12 @@ void settings_apply(bool read_disk) global_settings.wps_file[0] != 0xff ) { snprintf(buf, sizeof buf, WPS_DIR "/%s.wps", global_settings.wps_file); - wps_data_load(gui_wps[0].data, &screens[0], buf, true); + skin_data_load(gui_wps[0].data, &screens[0], buf, true); } else { wps_data_init(gui_wps[0].data); + skin_data_load(gui_wps[0].data, &screens[0], NULL, true); #ifdef HAVE_REMOTE_LCD gui_wps[0].data->remote_wps = false; #endif @@ -877,11 +878,12 @@ void settings_apply(bool read_disk) if ( global_settings.rwps_file[0]) { snprintf(buf, sizeof buf, WPS_DIR "/%s.rwps", global_settings.rwps_file); - wps_data_load(gui_wps[1].data, &screens[1], buf, true); + skin_data_load(gui_wps[1].data, &screens[1], buf, true); } else { wps_data_init(gui_wps[1].data); + skin_data_load(gui_wps[1].data, &screens[1], NULL, true); gui_wps[1].data->remote_wps = true; } #endif diff --git a/apps/tree.c b/apps/tree.c index 71ec83ed1..667aea057 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -36,7 +36,7 @@ #include "audio.h" #include "playlist.h" #include "menu.h" -#include "wps_engine/wps_engine.h" +#include "skin_engine/skin_engine.h" #include "settings.h" #include "debug.h" #include "storage.h" -- 2.11.4.GIT