From 0d9c7b5bcbc1fd90a810780b5b58835ee8590f54 Mon Sep 17 00:00:00 2001 From: Kevin Ferrare Date: Sun, 20 Nov 2005 22:13:52 +0000 Subject: Applied Stephan Wezel's patch for the new wps %wd/%we tags (disable/enable statusbar in wps mode independantly from the global setting) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8015 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps-common.c | 81 ++++++++++++++++++++++++++++++++++++-------------- apps/gui/gwps-common.h | 3 +- apps/gui/gwps.c | 80 +++++++++++++++++++++++++++++++++++-------------- apps/gui/gwps.h | 6 +++- apps/gui/statusbar.c | 9 +++--- 5 files changed, 128 insertions(+), 51 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 92d7ded740..c2a4dff3b6 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c @@ -17,7 +17,6 @@ * ****************************************************************************/ #include "gwps-common.h" -#include "gwps.h" #include "font.h" #include #include @@ -37,7 +36,6 @@ #include "lang.h" #include "misc.h" -#include "statusbar.h" #include "splash.h" #include "scrollbar.h" #ifdef HAVE_LCD_BITMAP @@ -57,6 +55,24 @@ static void draw_player_fullbar(struct gui_wps *gwps, /* 3% of 30min file == 54s step size */ #define MIN_FF_REWIND_STEP 500 +/* draws the statusbar on the given wps-screen */ +#ifdef HAVE_LCD_BITMAP +static void gui_wps_statusbar_draw(struct gui_wps *wps, bool force) +{ + bool draw = global_settings.statusbar; + if(wps->data->wps_sb_tag + && gui_wps->data->show_sb_on_wps) + draw = true; + else if(wps->data->wps_sb_tag) + draw = false; + if(draw) + gui_statusbar_draw(wps->statusbar, force); +} +#else +#define gui_wps_statusbar_draw(wps, force) \ + gui_statusbar_draw((wps)->statusbar, (force)) +#endif + /* Format time into buf. * * buf - buffer to format to. @@ -944,6 +960,11 @@ void gui_wps_format(struct wps_data *data, const char *bmpdir, subline = 0; data->format_lines[line][subline] = buf; +#ifdef HAVE_LCD_BITMAP + bool wps_tag_found = false; + data->wps_sb_tag = false; + data->show_sb_on_wps = false; +#endif while ((*buf) && (line < WPS_MAX_LINES)) { c = *buf; @@ -955,10 +976,19 @@ void gui_wps_format(struct wps_data *data, const char *bmpdir, * don't skip %x lines (pre-load bitmaps) */ case '%': +#ifdef HAVE_LCD_BITMAP + if(*(buf+1) == 'w' && (*(buf+2) == 'd' || *(buf+2) == 'e') + && !wps_tag_found) + { + data->wps_sb_tag = true; + if( *(buf+1) == 'w' && *(buf+2) == 'e' ) + data->show_sb_on_wps = true; + wps_tag_found = true; + } if (*(buf+1) != 'x') buf++; break; - +#endif case '\r': /* CR */ *buf = 0; break; @@ -1177,7 +1207,13 @@ bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset, } #ifdef HAVE_LCD_BITMAP int h = font_get(FONT_UI)->height; - int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; + int offset = 0; + gui_wps_statusbar_draw(gwps, true); + if(data->wps_sb_tag && data->show_sb_on_wps) + offset = STATUSBAR_HEIGHT; + else if ( global_settings.statusbar && !data->wps_sb_tag) + offset = STATUSBAR_HEIGHT; + /* to find out wether the peak meter is enabled we assume it wasn't until we find a line that contains the peak meter. We can't use peak_meter_enabled itself @@ -1774,24 +1810,26 @@ static void draw_player_fullbar(struct gui_wps *gwps, char* buf, int buf_size) } #endif -/* set volume - return true if screen restore is needed - return false otherwise -*/ -bool setvol(void) +/* set volume */ +void setvol(void) { if (global_settings.volume < sound_min(SOUND_VOLUME)) global_settings.volume = sound_min(SOUND_VOLUME); if (global_settings.volume > sound_max(SOUND_VOLUME)) global_settings.volume = sound_max(SOUND_VOLUME); sound_set_volume(global_settings.volume); - gui_syncstatusbar_draw(&statusbars, false); - int i; - FOR_NB_SCREENS(i) - gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC); settings_save(); +} +/* return true if screen restore is needed + return false otherwise +*/ +bool update_onvol_change(struct gui_wps * gwps) +{ + gui_wps_statusbar_draw(gwps, false); + gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); + #ifdef HAVE_LCD_CHARCELLS - gui_syncsplash(0, false, "Vol: %d %% ", + gui_splash(gwps->display,0, false, "Vol: %d %% ", sound_val2phys(SOUND_VOLUME, global_settings.volume)); return true; #endif @@ -1837,13 +1875,13 @@ bool ffwd_rew(int button) max_step = (wps_state.id3->length - (wps_state.id3->elapsed + ff_rewind_count)) * - FF_REWIND_MAX_PERCENT / 100; + FF_REWIND_MAX_PERCENT / 100; } else { /* rewinding, calc max step relative to start */ max_step = (wps_state.id3->elapsed + ff_rewind_count) * - FF_REWIND_MAX_PERCENT / 100; + FF_REWIND_MAX_PERCENT / 100; } max_step = MAX(max_step, MIN_FF_REWIND_STEP); @@ -2002,11 +2040,10 @@ bool gui_wps_display(void) } } yield(); - FOR_NB_SCREENS(i) - gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL); - gui_syncstatusbar_draw(&statusbars, true); FOR_NB_SCREENS(i) { + gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL); + #ifdef HAVE_LCD_BITMAP wps_display_images(&gui_wps[i]); gui_wps[i].display->update(); @@ -2039,9 +2076,9 @@ bool update(struct gui_wps *gwps) if (gwps->state->id3) gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC); - gui_syncstatusbar_draw(&statusbars, false); - - return retcode; + gui_wps_statusbar_draw(gwps, false); + + return retcode; } #ifdef WPS_KEYLOCK diff --git a/apps/gui/gwps-common.h b/apps/gui/gwps-common.h index fe7f2f66da..e9c1a42299 100644 --- a/apps/gui/gwps-common.h +++ b/apps/gui/gwps-common.h @@ -30,7 +30,8 @@ void gui_wps_format(struct wps_data *data, const char *bmpdir, bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset, unsigned char refresh_mode); bool gui_wps_display(void); -bool setvol(void); +void setvol(void); +bool update_onvol_change(struct gui_wps * gwps); bool update(struct gui_wps *gwps); bool ffwd_rew(int button); #ifdef WPS_KEYLOCK diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 5877cf7c4b..a93750770f 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -53,7 +53,6 @@ #include "abrepeat.h" #include "playback.h" -#include "statusbar.h" #include "splash.h" #define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" @@ -68,6 +67,19 @@ bool keys_locked = false; /* change the path to the current played track */ static void wps_state_update_ctp(const char *path); +#ifdef HAVE_LCD_BITMAP +static void gui_wps_set_margine(struct gui_wps *gwps) +{ + int offset = 0; + struct wps_data *data = gwps->data; + if(data->wps_sb_tag && data->show_sb_on_wps) + offset = STATUSBAR_HEIGHT; + else if ( global_settings.statusbar && !data->wps_sb_tag) + offset = STATUSBAR_HEIGHT; + gwps->display->setmargins(0, offset); +} +#endif + long gui_wps_show(void) { long button = 0, lastbutton = 0; @@ -88,8 +100,7 @@ long gui_wps_show(void) #else FOR_NB_SCREENS(i) { - gui_wps[i].display->setmargins(0, global_settings.statusbar? - STATUSBAR_HEIGHT:0); + gui_wps_set_margine(&gui_wps[i]); } #endif @@ -156,12 +167,12 @@ long gui_wps_show(void) if (TIME_AFTER(current_tick, next_refresh)) { FOR_NB_SCREENS(i) - { - if(gui_wps[i].data->peak_meter_enabled) - gui_wps_refresh(&gui_wps[i], 0, - WPS_REFRESH_PEAK_METER); - next_refresh += HZ / PEAK_METER_FPS; - } + { + if(gui_wps[i].data->peak_meter_enabled) + gui_wps_refresh(&gui_wps[i], 0, + WPS_REFRESH_PEAK_METER); + next_refresh += HZ / PEAK_METER_FPS; + } } } @@ -215,6 +226,12 @@ long gui_wps_show(void) case WPS_RC_CONTEXT: #endif onplay(wps_state.id3->path, TREE_ATTR_MPA, CONTEXT_WPS); +#ifdef HAVE_LCD_BITMAP + FOR_NB_SCREENS(i) + { + gui_wps_set_margine(&gui_wps[i]); + } +#endif restore = true; break; #endif @@ -289,11 +306,20 @@ long gui_wps_show(void) case WPS_RC_INCVOL: case WPS_RC_INCVOL | BUTTON_REPEAT: #endif + { global_settings.volume++; - if (setvol()) { + bool res = false; + setvol(); + FOR_NB_SCREENS(i) + { + if(update_onvol_change(&gui_wps[i])) + res = true; + } + if (res) { restore = true; restoretimer = current_tick + HZ; } + } break; /* volume down */ @@ -303,11 +329,20 @@ long gui_wps_show(void) case WPS_RC_DECVOL: case WPS_RC_DECVOL | BUTTON_REPEAT: #endif + { global_settings.volume--; - if (setvol()) { + setvol(); + bool res = false; + FOR_NB_SCREENS(i) + { + if(update_onvol_change(&gui_wps[i])) + res = true; + } + if (res) { restore = true; restoretimer = current_tick + HZ; } + } break; /* fast forward / rewind */ @@ -450,9 +485,7 @@ long gui_wps_show(void) #ifdef HAVE_LCD_BITMAP FOR_NB_SCREENS(i) { - gui_wps[i].display->setmargins(0, - global_settings.statusbar? - STATUSBAR_HEIGHT:0); + gui_wps_set_margine(&gui_wps[i]); } #endif restore = true; @@ -581,13 +614,13 @@ long gui_wps_show(void) if (update_track) { - bool upt = false; + bool update_failed = false; FOR_NB_SCREENS(i) { if(update(&gui_wps[i])) - upt = true; + update_failed = true; } - if (upt) + if (update_failed) { /* set dir browser to current playing song */ if (global_settings.browse_current && @@ -670,6 +703,8 @@ void wps_data_init(struct wps_data *wps_data) wps_data->img[i].display = false; wps_data->img[i].always_display = false; } + wps_data->wps_sb_tag = false; + wps_data->show_sb_on_wps = false; #else /* HAVE_LCD_CHARCELLS */ for(i = 0; i < 8; i++) wps_data->wps_progress_pat[i] = 0; @@ -861,6 +896,7 @@ void gui_wps_init(struct gui_wps *gui_wps) { gui_wps->data = NULL; gui_wps->display = NULL; + gui_wps->statusbar = NULL; /* Currently no seperate wps_state needed/possible so use the only aviable ( "global" ) one */ gui_wps->state = &wps_state; @@ -877,14 +913,12 @@ void gui_wps_set_disp(struct gui_wps *gui_wps, struct screen *display) { gui_wps->display = display; } -/* gui_wps end */ -void gui_sync_data_wps_init(void) +void gui_wps_set_statusbar(struct gui_wps *gui_wps, struct gui_statusbar *statusbar) { - int i; - FOR_NB_SCREENS(i) - wps_data_init(&wps_datas[i]); + gui_wps->statusbar = statusbar; } +/* gui_wps end */ void gui_sync_wps_screen_init(void) { @@ -898,7 +932,9 @@ void gui_sync_wps_init(void) int i; FOR_NB_SCREENS(i) { + wps_data_init(&wps_datas[i]); gui_wps_init(&gui_wps[i]); gui_wps_set_data(&gui_wps[i], &wps_datas[i]); + gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]); } } diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h index 5c2bd925ab..40b9a7424d 100644 --- a/apps/gui/gwps.h +++ b/apps/gui/gwps.h @@ -20,6 +20,7 @@ #define _WPS_H #include "screen_access.h" +#include "statusbar.h" #include "id3.h" #include "playlist.h" @@ -319,6 +320,7 @@ struct gui_wps struct screen * display; struct wps_data *data; struct wps_state *state; + struct gui_statusbar *statusbar; }; /* initial setup of a wps */ @@ -329,6 +331,9 @@ void gui_wps_set_data(struct gui_wps *gui_wps, struct wps_data *data); /* connects a wps with a screen */ void gui_wps_set_disp(struct gui_wps *gui_wps, struct screen *display); + +/* connects a wps with a statusbar*/ +void gui_wps_set_statusbar(struct gui_wps *gui_wps, struct gui_statusbar *statusbar); /* gui_wps end */ long gui_wps_show(void); @@ -338,7 +343,6 @@ extern struct wps_state wps_state; extern struct gui_wps gui_wps[NB_SCREENS]; void gui_sync_wps_init(void); -void gui_sync_data_wps_init(void); void gui_sync_wps_screen_init(void); #endif diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index 02c69815a1..70fe77facd 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -104,11 +104,6 @@ void gui_statusbar_set_screen(struct gui_statusbar * bar, void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) { -#ifdef HAVE_LCD_BITMAP - if(!global_settings.statusbar) - return; -#endif /* HAVE_LCD_BITMAP */ - struct screen * display = bar->display; #ifdef HAVE_RTC @@ -505,6 +500,10 @@ void gui_syncstatusbar_init(struct gui_syncstatusbar * bars) void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars, bool force_redraw) { +#ifdef HAVE_LCD_BITMAP + if(!global_settings.statusbar) + return; +#endif /* HAVE_LCD_BITMAP */ int i; FOR_NB_SCREENS(i) { gui_statusbar_draw( &(bars->statusbars[i]), force_redraw ); -- cgit v1.2.3