Index: apps/onplay.c =================================================================== --- apps/onplay.c (Revision 18178) +++ apps/onplay.c (Arbeitskopie) @@ -64,6 +64,7 @@ #endif #include "cuesheet.h" #include "backdrop.h" +#include "pitchscreen.h" static int context; static char* selected_file = NULL; @@ -1001,7 +1002,7 @@ browse_id3, NULL, NULL, Icon_NOICON); #ifdef HAVE_PITCHSCREEN MENUITEM_FUNCTION(pitch_screen_item, 0, ID2P(LANG_PITCH), - pitch_screen, NULL, NULL, Icon_Audio); + gui_pitchscreen_run, NULL, NULL, Icon_Audio); #endif /* CONTEXT_[TREE|ID3DB] items */ Index: apps/gui/pitchscreen.c =================================================================== --- apps/gui/pitchscreen.c (Revision 18178) +++ apps/gui/pitchscreen.c (Arbeitskopie) @@ -7,6 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * + * Copyright (C) 2008 Thomas Martitz * Copyright (C) 2002 Björn Stenberg * * This program is free software; you can redistribute it and/or @@ -36,7 +37,11 @@ #include "icons.h" #include "screen_access.h" #include "screens.h" +#include "statusbar.h" +#include "viewport.h" +#include "pitchscreen.h" +#include "debug.h" #define PITCH_MAX 2000 #define PITCH_MIN 500 #define PITCH_SMALL_DELTA 1 @@ -52,73 +57,120 @@ 0 if no key was pressed 1 if USB was connected */ -static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) +static void pitchscreen_fix_viewports(struct screen *display, struct viewport *parent, + struct viewport pitch_viewports[NB_SCREENS][PITCH_ITEM_COUNT]) { + int n, width, height; + display->getstringsize("+2%",&width,&height); +#ifdef HAVE_REMOTE_LCD + short screen = display->screen_type; +#else + const short screen = 0; + (void)display; +#endif + short icon_border = 12; + for (n = 0; n < PITCH_ITEM_COUNT; n++) + { + pitch_viewports[screen][n] = *parent; + pitch_viewports[screen][n].height = height; + } + pitch_viewports[screen][PITCH_TOP].y += icon_border; + + pitch_viewports[screen][PITCH_MID].x = icon_border; + pitch_viewports[screen][PITCH_MID].width = parent->width - icon_border*2; + pitch_viewports[screen][PITCH_MID].height = height * 2; + pitch_viewports[screen][PITCH_MID].y += parent->height / 2 - + pitch_viewports[screen][PITCH_MID].height / 2; + pitch_viewports[screen][PITCH_BOTTOM].y += parent->height - height - icon_border; +} + +static void pitchscreen_draw_icons(struct screen *display, struct viewport *parent) +{ + struct viewport pitch_icons = *parent; + screens[display->screen_type].set_viewport(&pitch_icons); + display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], + pitch_icons.width/2 - 3, + 2, 7, 8); + display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], + pitch_icons.width /2 - 3, + pitch_icons.height - 10, 7, 8); + display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], + pitch_icons.width - 10, + pitch_icons.height /2 - 4, 7, 8); + display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], + 2, + pitch_icons.height /2 - 4, 7, 8); +} + +static void pitchscreen_draw(struct screen *display, int pitch, int pitch_mode) +{ unsigned char* ptr; unsigned char buf[32]; - int w, h; - + int w, h, lines; +#ifdef HAVE_REMOTE_LCD + short screen = display->screen_type; +#else + const short screen = 0; +#endif + struct viewport parent[NB_SCREENS]; + struct viewport pitch_viewports[NB_SCREENS][PITCH_ITEM_COUNT]; + screens[screen].set_viewport(NULL); + screens[screen].stop_scroll(); + viewport_set_defaults(&parent[screen], screen); + pitchscreen_fix_viewports(display, &parent[screen], pitch_viewports); display->clear_display(); - - if (display->nb_lines < 4) /* very small screen, just show the pitch value */ + lines = viewport_get_nb_lines(&parent[screen]); + if (lines >= 4 || parent[screen].width >= 50) /* Only show pitch for a very small screen */ { - w = snprintf((char *)buf, sizeof(buf), "%s: %d.%d%%",str(LANG_PITCH), - pitch / 10, pitch % 10 ); - display->putsxy((display->lcdwidth-(w*display->char_width))/2, - display->nb_lines/2,buf); - } - else /* bigger screen, show everything... */ - { + /* down show "Pitch up/Pitch down" for a small screen */ + if (lines >= 6) + { + /* UP: Pitch Up */ + screens[screen].set_viewport(&pitch_viewports[screen][PITCH_TOP]); - /* UP: Pitch Up */ - if (pitch_mode == PITCH_MODE_ABSOLUTE) { - ptr = str(LANG_PITCH_UP); - } else { - ptr = str(LANG_PITCH_UP_SEMITONE); - } - display->getstringsize(ptr,&w,&h); - display->putsxy((display->lcdwidth-w)/2, 0, ptr); - display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], - display->lcdwidth/2 - 3, h, 7, 8); + if (pitch_mode == PITCH_MODE_ABSOLUTE) { + ptr = str(LANG_PITCH_UP); + } else { + ptr = str(LANG_PITCH_UP_SEMITONE); + } + display->getstringsize(ptr,&w,&h); + display->putsxy((pitch_viewports[screen][PITCH_TOP].width / 2) - (w / 2), 0, ptr); - /* DOWN: Pitch Down */ - if (pitch_mode == PITCH_MODE_ABSOLUTE) { - ptr = str(LANG_PITCH_DOWN); - } else { - ptr = str(LANG_PITCH_DOWN_SEMITONE); + /* DOWN: Pitch Down */ + screens[screen].set_viewport(&pitch_viewports[screen][PITCH_BOTTOM]); + if (pitch_mode == PITCH_MODE_ABSOLUTE) { + ptr = str(LANG_PITCH_DOWN); + } else { + ptr = str(LANG_PITCH_DOWN_SEMITONE); + } + display->getstringsize(ptr,&w,&h); + display->putsxy((pitch_viewports[screen][PITCH_BOTTOM].width / 2) - (w / 2), 0, ptr); } - display->getstringsize(ptr,&w,&h); - display->putsxy((display->lcdwidth-w)/2, display->lcdheight - h, ptr); - display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], - display->lcdwidth/2 - 3, - display->lcdheight - h*2, 7, 8); - /* RIGHT: +2% */ + screens[screen].set_viewport(&pitch_viewports[screen][PITCH_MID]); ptr = "+2%"; display->getstringsize(ptr,&w,&h); - display->putsxy(display->lcdwidth-w, (display->lcdheight-h)/2, ptr); - display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], - display->lcdwidth-w-8, - (display->lcdheight-h)/2, 7, 8); + display->putsxy(pitch_viewports[screen][PITCH_MID].width - w, h /2, ptr); /* LEFT: -2% */ ptr = "-2%"; - display->getstringsize(ptr,&w,&h); - display->putsxy(0, (display->lcdheight-h)/2, ptr); - display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], - w+1, (display->lcdheight-h)/2, 7, 8); - - /* "Pitch" */ - snprintf((char *)buf, sizeof(buf), str(LANG_PITCH)); - display->getstringsize(buf,&w,&h); - display->putsxy((display->lcdwidth-w)/2, (display->lcdheight/2)-h, buf); - /* "XX.X%" */ - snprintf((char *)buf, sizeof(buf), "%d.%d%%", - pitch / 10, pitch % 10 ); - display->getstringsize(buf,&w,&h); - display->putsxy((display->lcdwidth-w)/2, display->lcdheight/2, buf); + display->putsxy(0, h / 2, ptr); } + /* "Pitch" */ + screens[screen].set_viewport(&pitch_viewports[screen][PITCH_MID]); + snprintf((char *)buf, sizeof(buf), str(LANG_PITCH)); + display->getstringsize(buf,&w,&h); + display->putsxy((pitch_viewports[screen][PITCH_MID].width / 2) - (w / 2), 0, buf); + /* "XX.X%" */ + snprintf((char *)buf, sizeof(buf), "%d.%d%%", + pitch / 10, pitch % 10 ); + display->getstringsize(buf,&w,&h); + display->putsxy((pitch_viewports[screen][PITCH_MID].width / 2) - (w / 2), h, buf); + pitchscreen_draw_icons(display, &parent[screen]); + + display->update_viewport(); + display->set_viewport(NULL); display->update(); } @@ -188,7 +240,7 @@ return pitch_increase(pitch, tmp - pitch, false); } -bool pitch_screen(void) +bool gui_pitchscreen_run(void) { int button; int pitch = sound_get_pitch(); @@ -204,7 +256,10 @@ while (!exit) { FOR_NB_SCREENS(i) - pitch_screen_draw(&screens[i], pitch, pitch_mode); + { + pitchscreen_draw(&screens[i], pitch, pitch_mode); + } + gui_syncstatusbar_draw(&statusbars, true); button = get_action(CONTEXT_PITCHSCREEN,TIMEOUT_BLOCK); switch (button) { Index: apps/gui/pitchscreen.h =================================================================== --- apps/gui/pitchscreen.h (Revision 0) +++ apps/gui/pitchscreen.h (Revision 0) @@ -0,0 +1,37 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 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. + * + ****************************************************************************/ + +#ifdef HAVE_PITCHSCREEN + +#ifndef _PITCHSCREEN_H_ +#define _PITCHSCREEN_H_ + +enum PITCHSCREEN_ITEMS +{ + PITCH_TOP = 0, + PITCH_MID, + PITCH_BOTTOM, + PITCH_ITEM_COUNT, +}; + +bool gui_pitchscreen_run(void); +#endif /* _PITCHSCREEN_H_ */ +#endif /* HAVE_PITCHSCREEN */ Index: apps/gui/gwps.c =================================================================== --- apps/gui/gwps.c (Revision 18178) +++ apps/gui/gwps.c (Arbeitskopie) @@ -60,6 +60,7 @@ #include "root_menu.h" #include "backdrop.h" #include "quickscreen.h" +#include "pitchscreen.h" /* currently only on wps_state is needed */ struct wps_state wps_state; @@ -567,7 +568,7 @@ #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 show_remote_main_backdrop(); #endif - if (1 == pitch_screen()) + if (1 == gui_pitchscreen_run()) return SYS_USB_CONNECTED; #if LCD_DEPTH > 1 show_wps_backdrop();