diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-10-19 15:28:15 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-10-19 15:28:15 +0000 |
commit | 1016ee4e809776619fa9e4e773ceb1523bd7bc66 (patch) | |
tree | 585cd873c118bee7c2459205e6eb54ff3e76a21b /apps/gui | |
parent | 00695baac0b797cbe46e7bc2999a83f73b36aae8 (diff) |
Initial custom statusbar commit.
The custom statusbar can be used as a WPS for the main UI, using .(r)sbs files. It's using the skin engine and knows all tags the WPS also knows.
The default folder for .sbs is the wps folder to reuse images used in the WPS.
As it can be shown in the WPS also, it's useful to move shared parts to the custom statusbar in order to save skin buffer space.
There are a few restrictions/TODOs:
*) Peak meter doesn't redraw nicely(not frequent enough), as very frequent updates would slow the UI down as hell (some targets fight with it in the WPS already: FS#10686)
*) No touchregion support as the statusbar doesn't have any action handling (it won't fail to parse though).
*) Drawing stuff into the default VP is forbidden (loading images in it is not). You *need* to use viewports for the displaying stuff (parsing fails if no viewport is used).
*) Themes that don't use a custom ui viewport can be fixed up using the new %Vi tag to avoid nasty redraw effectts (you must not draw into it as well, it's used to fix up the ui viewport). %Vi describes the viewport that the lists can use without getting in the way of the statusbar.
Otherwise, it behaves like the classic statusbar, it can be configured in the theme settings, and can be turned off in the wps using %wd.
Note to translaters: When translating LANG_STATUSBAR_CUSTOM, please consider using the same translation as for LANG_CHANNEL_CUSTOM if it's compatible. They could be combined later then.
Flyspray: FS#10566
Author: myself
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23258 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 57 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_engine.h | 2 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 42 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 13 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.c | 152 | ||||
-rw-r--r-- | apps/gui/statusbar-skinned.h | 51 | ||||
-rw-r--r-- | apps/gui/statusbar.c | 3 | ||||
-rw-r--r-- | apps/gui/statusbar.h | 3 | ||||
-rw-r--r-- | apps/gui/viewport.c | 101 | ||||
-rw-r--r-- | apps/gui/viewport.h | 20 | ||||
-rw-r--r-- | apps/gui/wps.c | 26 |
11 files changed, 355 insertions, 115 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 8abbcddb39..66675ce95a 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -64,6 +64,7 @@ #include "wps_internals.h" #include "skin_engine.h" +#include "statusbar-skinned.h" static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode); @@ -83,7 +84,6 @@ bool gui_wps_display(struct gui_wps *gwps) vp->bg_pattern = display->get_background(); } #endif - display->clear_display(); display->backdrop_show(BACKDROP_SKIN_WPS); return skin_redraw(gwps, WPS_REFRESH_ALL); } @@ -115,28 +115,30 @@ void skin_statusbar_changed(struct gui_wps *skin) return; struct wps_data *data = skin->data; const struct screen *display = skin->display; + const int screen = display->screen_type; struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL, data)->vp; - viewport_set_fullscreen(vp, display->screen_type); + viewport_set_fullscreen(vp, screen); if (data->wps_sb_tag) { /* fix up the default viewport */ if (data->show_sb_on_wps) { - bool bar_at_top = - statusbar_position(display->screen_type) != STATUSBAR_BOTTOM; + if (statusbar_position(screen) != STATUSBAR_OFF) + return; /* vp is fixed already */ - vp->y = bar_at_top?STATUSBAR_HEIGHT:0; + vp->y = STATUSBAR_HEIGHT; vp->height = display->lcdheight - STATUSBAR_HEIGHT; } else { - vp->y = 0; + if (statusbar_position(screen) == STATUSBAR_OFF) + return; /* vp is fixed already */ + vp->y = vp->x = 0; vp->height = display->lcdheight; + vp->width = display->lcdwidth; } } - - } static void draw_progressbar(struct gui_wps *gwps, @@ -168,7 +170,7 @@ static void draw_progressbar(struct gui_wps *gwps, elapsed = 0; length = 0; } - + if (pb->have_bitmap_pb) gui_bitmap_scrollbar_draw(display, pb->bm, pb->x, y, pb->width, pb->bm.height, @@ -256,7 +258,7 @@ static void wps_display_images(struct gui_wps *gwps, struct viewport* vp) } #ifdef HAVE_ALBUMART /* now draw the AA */ - if (data->albumart && data->albumart->vp == vp + if (data->albumart && data->albumart->vp == vp && data->albumart->draw) { draw_album_art(gwps, playback_current_aa_hid(data->playback_aa_slot), @@ -496,6 +498,7 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index) return true; } + #ifdef HAVE_LCD_BITMAP struct gui_img* find_image(char label, struct wps_data *data) { @@ -946,15 +949,19 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) if (refresh_mode == WPS_REFRESH_ALL) { struct skin_line *line; + struct skin_viewport *skin_viewport = find_viewport(VP_DEFAULT_LABEL, data); - display->set_viewport(&find_viewport(VP_DEFAULT_LABEL, data)->vp); - display->clear_viewport(); + if (!(skin_viewport->hidden_flags & VP_NEVER_VISIBLE)) + { + display->set_viewport(&skin_viewport->vp); + display->clear_viewport(); + } for (viewport_list = data->viewports; viewport_list; viewport_list = viewport_list->next) { - struct skin_viewport *skin_viewport = - (struct skin_viewport *)viewport_list->token->value.data; + skin_viewport = + (struct skin_viewport *)viewport_list->token->value.data; for(line = skin_viewport->lines; line; line = line->next) { line->curr_subline = NULL; @@ -977,6 +984,10 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) { struct skin_viewport *skin_viewport = (struct skin_viewport *)viewport_list->token->value.data; + if (skin_viewport->hidden_flags&VP_NEVER_VISIBLE) + { + continue; + } if (skin_viewport->hidden_flags&VP_DRAW_HIDEABLE) { if (skin_viewport->hidden_flags&VP_DRAW_HIDDEN) @@ -992,8 +1003,11 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) struct skin_viewport *skin_viewport = (struct skin_viewport *)viewport_list->token->value.data; unsigned vp_refresh_mode = refresh_mode; + display->set_viewport(&skin_viewport->vp); + int hidden_vp = 0; + #ifdef HAVE_LCD_BITMAP /* Set images to not to be displayed */ struct skin_token_list *imglist = data->images; @@ -1005,7 +1019,11 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) } #endif /* dont redraw the viewport if its disabled */ - if ((skin_viewport->hidden_flags&VP_DRAW_HIDDEN)) + if (skin_viewport->hidden_flags&VP_NEVER_VISIBLE) + { /* don't draw anything into this one */ + vp_refresh_mode = 0; hidden_vp = true; + } + else if ((skin_viewport->hidden_flags&VP_DRAW_HIDDEN)) { if (!(skin_viewport->hidden_flags&VP_DRAW_WASHIDDEN)) display->scroll_stop(&skin_viewport->vp); @@ -1019,6 +1037,7 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) vp_refresh_mode = WPS_REFRESH_ALL; skin_viewport->hidden_flags = VP_DRAW_HIDEABLE; } + if (vp_refresh_mode == WPS_REFRESH_ALL) { display->clear_viewport(); @@ -1040,7 +1059,7 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) flags = line->curr_subline->line_type; if (vp_refresh_mode == WPS_REFRESH_ALL || (flags & vp_refresh_mode) - || new_subline_refresh) + || new_subline_refresh || hidden_vp) { /* get_line tells us if we need to update the line */ update_line = get_line(gwps, subline, @@ -1086,7 +1105,7 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) } #endif - if (update_line && + if (update_line && !hidden_vp && /* conditionals clear the line which means if the %Vd is put into the default viewport there will be a blank line. To get around this we dont allow any actual drawing to happen in the @@ -1105,7 +1124,6 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) write_line(display, &align, line_count, false); } } - #ifdef HAVE_LCD_BITMAP /* progressbar */ if (vp_refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) @@ -1116,7 +1134,8 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) } } /* Now display any images in this viewport */ - wps_display_images(gwps, &skin_viewport->vp); + if (!hidden_vp) + wps_display_images(gwps, &skin_viewport->vp); #endif } diff --git a/apps/gui/skin_engine/skin_engine.h b/apps/gui/skin_engine/skin_engine.h index c52f720d06..704a7851c2 100644 --- a/apps/gui/skin_engine/skin_engine.h +++ b/apps/gui/skin_engine/skin_engine.h @@ -27,7 +27,6 @@ #include "wps_internals.h" /* TODO: remove this line.. shoudlnt be needed */ - #ifdef HAVE_TOUCHSCREEN int wps_get_touchaction(struct wps_data *data); #endif @@ -44,7 +43,6 @@ bool skin_update(struct gui_wps *gwps, unsigned int update_type); * or from a skinfile (isfile = true) */ bool skin_data_load(struct wps_data *wps_data, - struct screen *display, const char *buf, bool isfile); diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index fa35ed994f..434e7c9fa5 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -683,8 +683,15 @@ static int parse_viewport(const char *wps_bufptr, curr_line = NULL; if (!skin_start_new_line(skin_vp, wps_data->num_tokens)) return WPS_ERROR_INVALID_PARAM; - - if (*ptr == 'l') + + + if (*ptr == 'i') + { + skin_vp->label = VP_INFO_LABEL; + skin_vp->hidden_flags = VP_NEVER_VISIBLE; + ++ptr; + } + else if (*ptr == 'l') { if (*(ptr+1) == '|') { @@ -1674,7 +1681,6 @@ static bool load_skin_bmp(struct wps_data *wps_data, struct bitmap *bitmap, char else { /* Abort if we can't load an image */ - DEBUGF("ERR: Failed to load image - %s\n",img_path); loaded = false; } return loaded; @@ -1733,7 +1739,6 @@ static bool load_skin_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 skin_data_load(struct wps_data *wps_data, - struct screen *display, const char *buf, bool isfile) { @@ -1755,6 +1760,7 @@ bool skin_data_load(struct wps_data *wps_data, skin_data_reset(wps_data); + /* alloc default viewport, will be fixed up later */ curr_vp = skin_buffer_alloc(sizeof(struct skin_viewport)); if (!curr_vp) return false; @@ -1766,9 +1772,6 @@ bool skin_data_load(struct wps_data *wps_data, /* Initialise the first (default) viewport */ curr_vp->label = VP_DEFAULT_LABEL; - curr_vp->vp.x = 0; - curr_vp->vp.width = display->getwidth(); - curr_vp->vp.height = display->getheight(); curr_vp->pb = NULL; curr_vp->hidden_flags = 0; curr_vp->lines = NULL; @@ -1777,31 +1780,6 @@ bool skin_data_load(struct wps_data *wps_data, if (!skin_start_new_line(curr_vp, 0)) return false; - switch (statusbar_position(display->screen_type)) - { - case STATUSBAR_OFF: - curr_vp->vp.y = 0; - break; - case STATUSBAR_TOP: - curr_vp->vp.y = STATUSBAR_HEIGHT; - curr_vp->vp.height -= STATUSBAR_HEIGHT; - break; - case STATUSBAR_BOTTOM: - curr_vp->vp.y = 0; - curr_vp->vp.height -= STATUSBAR_HEIGHT; - break; - } -#ifdef HAVE_LCD_BITMAP - curr_vp->vp.font = FONT_UI; - curr_vp->vp.drawmode = DRMODE_SOLID; -#endif -#if LCD_DEPTH > 1 - if (display->depth > 1) - { - curr_vp->vp.fg_pattern = display->get_foreground(); - curr_vp->vp.bg_pattern = display->get_background(); - } -#endif if (!isfile) { return wps_parse(wps_data, buf, false); diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index e0e2882556..3dbf4e0087 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -191,11 +191,14 @@ struct skin_line { struct skin_line *next; }; -#define VP_DRAW_HIDEABLE 0x1 -#define VP_DRAW_HIDDEN 0x2 -#define VP_DRAW_WASHIDDEN 0x4 -#define VP_DEFAULT_LABEL '|' -#define VP_NO_LABEL '-' +#define VP_DRAW_HIDEABLE 0x1 +#define VP_DRAW_HIDDEN 0x2 +#define VP_DRAW_WASHIDDEN 0x4 +/* these are never drawn, nor cleared, i.e. just ignored */ +#define VP_NEVER_VISIBLE 0x8 +#define VP_DEFAULT_LABEL '|' +#define VP_NO_LABEL '-' +#define VP_INFO_LABEL '_' struct skin_viewport { struct viewport vp; /* The LCD viewport struct */ struct progressbar *pb; diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c new file mode 100644 index 0000000000..1cb6aa3623 --- /dev/null +++ b/apps/gui/statusbar-skinned.c @@ -0,0 +1,152 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Thomas Martitz + * + * 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. + * + ****************************************************************************/ + +#include "config.h" + +#include "system.h" +#include "settings.h" +#include "appevents.h" +#include "screens.h" +#include "screen_access.h" +#include "skin_engine/skin_engine.h" +#include "skin_engine/wps_internals.h" +#include "viewport.h" +#include "statusbar.h" +#include "statusbar-skinned.h" +#include "debug.h" + + +/* currently only one wps_state is needed */ +extern struct wps_state wps_state; /* from wps.c */ +static struct gui_wps sb_skin[NB_SCREENS] = {{ .data = NULL }}; +static struct wps_data sb_skin_data[NB_SCREENS] = {{ .wps_loaded = 0 }}; + +/* initial setup of wps_data */ +static void sb_skin_update(void*); +static bool loaded_ok[NB_SCREENS] = { false }; +static int skinbars = 0; +static int update_delay = DEFAULT_UPDATE_DELAY; + + +void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile) +{ + struct wps_data *data = sb_skin[screen].data; + + int success; + success = buf && skin_data_load(data, buf, isfile); + + if (success) + { /* hide the sb's default viewport because it has nasty effect with stuff + * not part of the statusbar, + * hence .sbs's without any other vps are unsupported*/ + struct skin_viewport *vp = find_viewport(VP_DEFAULT_LABEL, data); + struct skin_token_list *next_vp = data->viewports->next; + + if (!next_vp) + { /* no second viewport, let parsing fail */ + success = false; + } + /* hide this viewport, forever */ + vp->hidden_flags = VP_NEVER_VISIBLE; + } + + if (!success) + remove_event(GUI_EVENT_ACTIONUPDATE, sb_skin_update); + +#ifdef HAVE_REMOVE_LCD + data->remote_wps = !(screen == SCREEN_MAIN); +#endif + loaded_ok[screen] = success; +} + +struct viewport *sb_skin_get_info_vp(enum screen_type screen) +{ + return &find_viewport(VP_INFO_LABEL, sb_skin[screen].data)->vp; +} + +inline bool sb_skin_get_state(enum screen_type screen) +{ + return loaded_ok[screen] && (skinbars & VP_SB_ONSCREEN(screen)); +} + +void sb_skin_set_state(int state, enum screen_type screen) +{ + sb_skin[screen].state->do_full_update = true; + if (state) + { + skinbars |= VP_SB_ONSCREEN(screen); + } + else + { + skinbars &= ~VP_SB_ONSCREEN(screen); + } + + if (skinbars) + add_event(GUI_EVENT_ACTIONUPDATE, false, sb_skin_update); + else + remove_event(GUI_EVENT_ACTIONUPDATE, sb_skin_update); +} + +static void sb_skin_update(void* param) +{ + static long next_update = 0; + int i; + int forced_draw = param || sb_skin[SCREEN_MAIN].state->do_full_update; + if (TIME_AFTER(current_tick, next_update) || forced_draw) + { + FOR_NB_SCREENS(i) + { + if (sb_skin_get_state(i)) + { + skin_update(&sb_skin[i], forced_draw? + WPS_REFRESH_ALL : WPS_REFRESH_NON_STATIC); + } + } + next_update = current_tick + update_delay; /* don't update too often */ + sb_skin[SCREEN_MAIN].state->do_full_update = false; + } +} + +void sb_skin_set_update_delay(int delay) +{ + update_delay = delay; +} + +void sb_skin_init(void) +{ + int i; + FOR_NB_SCREENS(i) + { +#ifdef HAVE_ALBUMART + sb_skin_data[i].albumart = NULL; + sb_skin_data[i].playback_aa_slot = -1; +#endif +#ifdef HAVE_REMOTE_LCD + sb_skin_data[i].remote_wps = (i == SCREEN_REMOTE); +#endif + sb_skin[i].data = &sb_skin_data[i]; + sb_skin[i].display = &screens[i]; + /* Currently no seperate wps_state needed/possible + so use the only available ( "global" ) one */ + sb_skin[i].state = &wps_state; + sb_skin[i].statusbars = &skinbars; + } +} diff --git a/apps/gui/statusbar-skinned.h b/apps/gui/statusbar-skinned.h new file mode 100644 index 0000000000..7c81eb8d01 --- /dev/null +++ b/apps/gui/statusbar-skinned.h @@ -0,0 +1,51 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Thomas Martitz + * + * 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. + * + ****************************************************************************/ +#ifndef __STATUSBAR_SKINNED_H__ +#define __STATUSBAR_SKINNED_H__ + +#define DEFAULT_UPDATE_DELAY (HZ/7) + +#ifdef HAVE_LCD_BITMAP + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include "config.h" + + +void sb_skin_data_load(enum screen_type screen, const char *buf, bool isfile); + +/* probably temporary, to shut the classic statusbar up */ +bool sb_skin_get_state(enum screen_type screen); +void sb_skin_set_state(int state, enum screen_type screen); +void sb_skin_init(void); +struct viewport *sb_skin_get_info_vp(enum screen_type screen); + +void sb_skin_set_update_delay(int delay); + +#else /* CHARCELL */ +#define sb_skin_init() +#define sb_skin_data_load(a,b,c) +#define sb_skin_set_update_delay(a) +#define sb_skin_set_state(a,b) +#define sb_skin_get_state(a) +#endif +#endif /* __STATUSBAR_SKINNED_H__ */ diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index 5aac200157..4710ebac42 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -188,6 +188,9 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) { struct screen * display = bar->display; + if (!display) + return; + #ifdef HAVE_LCD_CHARCELLS int val; (void)force_redraw; /* The Player always has "redraw" */ diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index 84d37858e2..b25edbfab3 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h @@ -55,7 +55,8 @@ struct status_info { }; /* statusbar visibility/position, used for settings also */ -enum statusbar_values { STATUSBAR_OFF = 0, STATUSBAR_TOP, STATUSBAR_BOTTOM }; +enum statusbar_values { STATUSBAR_OFF = 0, STATUSBAR_TOP, STATUSBAR_BOTTOM, + STATUSBAR_CUSTOM }; struct gui_statusbar { diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index fdd06bdc46..f39a299521 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -58,6 +58,9 @@ #ifdef HAVE_LCD_BITMAP #include "language.h" #endif +#include "statusbar-skinned.h" +#include "debug.h" + static int statusbar_enabled = 0; @@ -93,8 +96,9 @@ static bool showing_bars(enum screen_type screen) if (statusbar_enabled & VP_SB_ONSCREEN(screen)) { #ifdef HAVE_LCD_BITMAP - bool ignore = statusbar_enabled & VP_SB_IGNORE_SETTING(screen); - return ignore || (statusbar_position(screen)); + int ignore; + ignore = statusbar_enabled & VP_SB_IGNORE_SETTING(screen); + return ignore || (statusbar_position(screen) != STATUSBAR_OFF); #else return true; #endif @@ -109,22 +113,30 @@ void viewport_set_fullscreen(struct viewport *vp, vp->width = screens[screen].lcdwidth; #ifdef HAVE_LCD_BITMAP - set_default_align_flags(vp); - vp->drawmode = DRMODE_SOLID; - vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ - - vp->height = screens[screen].lcdheight; - if (statusbar_position(screen) != STATUSBAR_BOTTOM - && showing_bars(screen)) - vp->y = STATUSBAR_HEIGHT; - else - vp->y = 0; + struct viewport *sb_skin_vp = sb_skin_get_info_vp(screen); + if (sb_skin_vp && sb_skin_get_state(screen) + && statusbar_enabled & VP_SB_ONSCREEN(screen)) + { + *vp = *sb_skin_vp; + } + else + { + if (statusbar_position(screen) != STATUSBAR_BOTTOM && showing_bars(screen)) + vp->y = STATUSBAR_HEIGHT; + else + vp->y = 0; #else - vp->y = 0; + { + vp->y = 0; #endif - vp->height = screens[screen].lcdheight - - (showing_bars(screen)?STATUSBAR_HEIGHT:0); + vp->height = screens[screen].lcdheight + - (showing_bars(screen)?STATUSBAR_HEIGHT:0); + } +#ifdef HAVE_LCD_BITMAP + set_default_align_flags(vp); + vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ + vp->drawmode = DRMODE_SOLID; #if LCD_DEPTH > 1 #ifdef HAVE_REMOTE_LCD /* We only need this test if there is a remote LCD */ @@ -144,7 +156,7 @@ void viewport_set_fullscreen(struct viewport *vp, vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; } #endif - +#endif } void viewport_set_defaults(struct viewport *vp, @@ -180,21 +192,29 @@ int viewportmanager_get_statusbar(void) int viewportmanager_set_statusbar(const int enabled) { int old = statusbar_enabled; + int i; + statusbar_enabled = enabled; - if (enabled) + + FOR_NB_SCREENS(i) { - int i; - FOR_NB_SCREENS(i) + if (showing_bars(i) + && statusbar_position(i) != STATUSBAR_CUSTOM) { - if (showing_bars(i)) - gui_statusbar_draw(&statusbars.statusbars[i], true); + add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw); + gui_statusbar_draw(&statusbars.statusbars[i], true); } - add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw); + else + remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw); } - else + +#ifdef HAVE_LCD_BITMAP + FOR_NB_SCREENS(i) { - remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw); + sb_skin_set_state(showing_bars(i) + && statusbar_position(i) == STATUSBAR_CUSTOM, i); } +#endif return old; } @@ -204,7 +224,8 @@ static void viewportmanager_redraw(void* data) FOR_NB_SCREENS(i) { - if (showing_bars(i)) + if (showing_bars(i) + && statusbar_position(i) != STATUSBAR_CUSTOM) gui_statusbar_draw(&statusbars.statusbars[i], NULL != data); } } @@ -234,11 +255,6 @@ void viewportmanager_theme_changed(const int which) /* reset the ui viewport */ FOR_NB_SCREENS(i) ui_vp_info.active[i] = retval & BIT_N(i); - - if (retval != 0) - add_event(GUI_EVENT_REFRESH, false, viewportmanager_ui_vp_changed); - else - remove_event(GUI_EVENT_REFRESH, viewportmanager_ui_vp_changed); /* and point to it */ ui_vp_info.vp = custom_vp; } @@ -249,18 +265,14 @@ void viewportmanager_theme_changed(const int which) } if (which & THEME_STATUSBAR) { - statusbar_enabled = VP_SB_HIDE_ALL; - + statusbar_enabled = 0; FOR_NB_SCREENS(i) { if (statusbar_position(i) != STATUSBAR_OFF) statusbar_enabled |= VP_SB_ONSCREEN(i); } - if (statusbar_enabled != VP_SB_HIDE_ALL) - add_event(GUI_EVENT_ACTIONUPDATE, false, viewportmanager_redraw); - else - remove_event(GUI_EVENT_ACTIONUPDATE, viewportmanager_redraw); + viewportmanager_set_statusbar(statusbar_enabled); /* reposition viewport to fit statusbar, only if not using the ui vp */ @@ -270,6 +282,19 @@ void viewportmanager_theme_changed(const int which) viewport_set_fullscreen(&custom_vp[i], i); } } + + int event_add = 0; + FOR_NB_SCREENS(i) + { + event_add |= ui_vp_info.active[i]; + event_add |= (statusbar_position(i) == STATUSBAR_CUSTOM); + } + + if (event_add) + add_event(GUI_EVENT_REFRESH, false, viewportmanager_ui_vp_changed); + else + remove_event(GUI_EVENT_REFRESH, viewportmanager_ui_vp_changed); + send_event(GUI_EVENT_THEME_CHANGED, NULL); } @@ -283,10 +308,10 @@ static void viewportmanager_ui_vp_changed(void *param) FOR_NB_SCREENS(i) screens[i].clear_display(); /* redraw the statusbar if it was enabled */ - viewportmanager_set_statusbar(statusbar_enabled); + send_event(GUI_EVENT_ACTIONUPDATE, (void*)true); /* call the passed function which will redraw the content of * the current screen */ - if (param != NULL) + if (draw_func != NULL) draw_func(); FOR_NB_SCREENS(i) screens[i].update(); diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h index cffc7fbaef..0e5ad30f35 100644 --- a/apps/gui/viewport.h +++ b/apps/gui/viewport.h @@ -56,16 +56,16 @@ void viewport_set_defaults(struct viewport *vp, */ -#define THEME_STATUSBAR (BIT_N(0)) -#define THEME_UI_VIEWPORT (BIT_N(1)) -#define THEME_BUTTONBAR (BIT_N(2)) -#define THEME_LANGUAGE (BIT_N(3)) -#define THEME_ALL (~(0u)) - -#define VP_SB_HIDE_ALL 0 -#define VP_SB_ONSCREEN(screen) BIT_N(screen) -#define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen) -#define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1)) +#define THEME_STATUSBAR (BIT_N(0)) +#define THEME_UI_VIEWPORT (BIT_N(1)) +#define THEME_BUTTONBAR (BIT_N(2)) +#define THEME_LANGUAGE (BIT_N(3)) +#define THEME_ALL (~(0u)) + +#define VP_SB_HIDE_ALL 0 +#define VP_SB_ONSCREEN(screen) BIT_N(screen) +#define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen) +#define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1)) #ifndef __PCTOOL__ /* diff --git a/apps/gui/wps.c b/apps/gui/wps.c index a74e3d449d..11ce946e98 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -31,7 +31,6 @@ #include "action.h" #include "kernel.h" #include "filetypes.h" -#include "debug.h" #include "sprintf.h" #include "settings.h" #include "skin_engine/skin_engine.h" @@ -67,6 +66,7 @@ #include "dsp.h" #include "playlist_viewer.h" #include "wps.h" +#include "statusbar-skinned.h" #define RESTORE_WPS_INSTANTLY 0l #define RESTORE_WPS_NEXT_SECOND ((long)(HZ+current_tick)) @@ -82,7 +82,7 @@ static int wpsbars = 0; /* currently only one wps_state is needed, initialize to 0 */ -static struct wps_state wps_state = { .id3 = NULL }; + struct wps_state wps_state = { .id3 = NULL }; static struct gui_wps gui_wps[NB_SCREENS] = {{ .data = NULL }}; static struct wps_data wps_datas[NB_SCREENS] = {{ .wps_loaded = 0 }}; @@ -129,8 +129,8 @@ void wps_data_load(enum screen_type screen, const char *buf, bool isfile) #endif /* __PCTOOL__ */ - loaded_ok = buf && skin_data_load(gui_wps[screen].data, - &screens[screen], buf, isfile); + loaded_ok = buf && skin_data_load(gui_wps[screen].data, buf, isfile); + if (!loaded_ok) /* load the hardcoded default */ { char *skin_buf[NB_SCREENS] = { @@ -153,11 +153,11 @@ void wps_data_load(enum screen_type screen, const char *buf, bool isfile) "%pb\n", #endif }; - skin_data_load(gui_wps[screen].data, &screens[screen], - skin_buf[screen], false); + skin_data_load(gui_wps[screen].data, skin_buf[screen], false); } #ifdef HAVE_REMOVE_LCD gui_wps[screen].data->remote_wps = !(screen == SCREEN_MAIN); + #endif } @@ -587,6 +587,8 @@ static void gwps_leave_wps(void) /* Play safe and unregister the hook */ lcd_activation_set_hook(NULL); #endif + /* unhandle statusbar update delay */ + sb_skin_set_update_delay(DEFAULT_UPDATE_DELAY); send_event(GUI_EVENT_REFRESH, NULL); } @@ -739,7 +741,6 @@ long gui_wps_show(void) #endif } } - #ifdef HAVE_LCD_BITMAP /* when the peak meter is enabled we want to have a few extra updates to make it look smooth. On the @@ -1175,7 +1176,13 @@ long gui_wps_show(void) skin_update(&gui_wps[i], WPS_REFRESH_NON_STATIC); } } - wps_state.do_full_update = false; + /* currently skinned statusbar and wps share the same wps_state, + * don't steal do_full_update away */ + if (wps_state.do_full_update) + { + send_event(GUI_EVENT_ACTIONUPDATE, (void*)true); + wps_state.do_full_update = false; + } update = false; } @@ -1188,6 +1195,9 @@ long gui_wps_show(void) #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) lcd_activation_set_hook(wps_lcd_activation_hook); #endif + /* we remove the update delay since it's not very usable in the wps, + * e.g. during volume changing or ffwd/rewind */ + sb_skin_set_update_delay(0); FOR_NB_SCREENS(i) { screens[i].stop_scroll(); |