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,10 @@ #include "icons.h" #include "screen_access.h" #include "screens.h" +#include "viewport.h" +#include "pitchscreen.h" +#include "debug.h" #define PITCH_MAX 2000 #define PITCH_MIN 500 #define PITCH_SMALL_DELTA 1 @@ -46,18 +50,105 @@ #define PITCH_MODE_ABSOLUTE 1 #define PITCH_MODE_SEMITONE -PITCH_MODE_ABSOLUTE +#define DEBUG_VP(vp, string) DEBUGF("%s\nvp.x\tvp.y\tvp.width\tvp.height\n%d\t%d\t%d\t\t%d\n", \ + string, \ + vp.x,\ + vp.y,\ + vp.width,\ + vp.height) + +#define DEBUG_VP_PTR(vp, string) DEBUGF("%s\nvp.x\tvp.y\tvp.width\tvp.height\n%d\t%d\t%d\t\t%d\n", \ + string, \ + vp->x,\ + vp->y,\ + vp->width,\ + vp->height) + static int pitch_mode = PITCH_MODE_ABSOLUTE; /* 1 - absolute, -1 - semitone */ /* returns: 0 if no key was pressed 1 if USB was connected */ +static struct viewport pitch_viewports[NB_SCREENS][PITCH_ITEM_COUNT]; +/* +static struct viewport pitch_icons[NB_SCREENS]; +*/ -static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) +static void pitchscreen_fix_viewports(struct screen *display, struct viewport *parent) { + int n, width, height; + display->getstringsize("+2%",&width,&height); + DEBUGF("width: %d\n", width); +#ifdef HAVE_REMOTE_LCD + short screen = display->screen_type; +#else + const short screen = 0; + (void)display; +#endif + 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 += 10; + + pitch_viewports[screen][PITCH_CENTER].x = parent->width / 3; + pitch_viewports[screen][PITCH_CENTER].width = parent->width / 3; + pitch_viewports[screen][PITCH_CENTER].y = parent->height / 2; + + pitch_viewports[screen][PITCH_RIGHT].width = width; + pitch_viewports[screen][PITCH_RIGHT].x = parent->width - width - 12; + pitch_viewports[screen][PITCH_RIGHT].y = parent->height / 2; + + pitch_viewports[screen][PITCH_BOTTOM].y = parent->height - height - 10; + + pitch_viewports[screen][PITCH_LEFT].width = width; + pitch_viewports[screen][PITCH_LEFT].x = 12; + pitch_viewports[screen][PITCH_LEFT].y = parent->height / 2; + DEBUG_VP(pitch_viewports[screen][PITCH_RIGHT], "parent"); +} + +static void pitchscreen_draw_icons(struct screen *display, struct viewport *parent) +{ + struct viewport pitch_icons = *parent; + DEBUG_VP(pitch_icons, "pitch_icons"); + 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, 7, 8); + display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], + 2, + pitch_icons.height/2, 7, 8); +/* + screens[display->screen_type].set_viewport(NULL); +*/ +/* + screens[display->screen_type].update(); +*/ +} + +static void pitchscreen_draw(struct screen *display, int pitch, int pitch_mode) +{ unsigned char* ptr; unsigned char buf[32]; int w, h; +#ifdef HAVE_REMOTE_LCD + short screen = display->screen_type; +#else + const short screen = 0; +#endif + struct viewport parent[NB_SCREENS]; + screens[screen].set_viewport(NULL); + screens[screen].stop_scroll(); + viewport_set_defaults(&parent[screen], screen); + pitchscreen_fix_viewports(display, &parent[screen]); display->clear_display(); if (display->nb_lines < 4) /* very small screen, just show the pitch value */ @@ -70,55 +161,65 @@ else /* bigger screen, show everything... */ { +DEBUGF("screen: %d\n", screen); /* UP: Pitch Up */ + screens[screen].set_viewport(&pitch_viewports[screen][PITCH_TOP]); +/* + DEBUG_VP(pitch_viewports[screen][PITCH_TOP], "pitch_viewports[screen][PITCH_TOP]"); +*/ + display->scroll_stop(&pitch_viewports[screen][PITCH_TOP]); + 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); + display->putsxy((pitch_viewports[screen][PITCH_TOP].width / 2) - (w / 2), 0, ptr); /* DOWN: Pitch Down */ + screens[screen].set_viewport(&pitch_viewports[screen][PITCH_BOTTOM]); + display->scroll_stop(&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((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); + display->putsxy((pitch_viewports[screen][PITCH_BOTTOM].width / 2) - (w / 2), 0, ptr); /* RIGHT: +2% */ + screens[screen].set_viewport(&pitch_viewports[screen][PITCH_RIGHT]); + display->scroll_stop(&pitch_viewports[screen][PITCH_RIGHT]); 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_RIGHT].width / 2) - (w / 2), 0, ptr); /* LEFT: -2% */ + screens[screen].set_viewport(&pitch_viewports[screen][PITCH_LEFT]); + display->scroll_stop(&pitch_viewports[screen][PITCH_LEFT]); 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); + display->putsxy((pitch_viewports[screen][PITCH_LEFT].width / 2) - (w / 2), 0, ptr); /* "Pitch" */ + screens[screen].set_viewport(&pitch_viewports[screen][PITCH_CENTER]); + display->scroll_stop(&pitch_viewports[screen][PITCH_CENTER]); + snprintf((char *)buf, sizeof(buf), str(LANG_PITCH)); display->getstringsize(buf,&w,&h); - display->putsxy((display->lcdwidth-w)/2, (display->lcdheight/2)-h, buf); + display->putsxy((pitch_viewports[screen][PITCH_CENTER].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((display->lcdwidth-w)/2, display->lcdheight/2, buf); + display->putsxy((pitch_viewports[screen][PITCH_CENTER].width / 2) - (w / 2), 0, buf); + + pitchscreen_draw_icons(display, &parent[screen]); } + display->update_viewport(); + display->set_viewport(NULL); display->update(); } @@ -204,7 +305,7 @@ while (!exit) { FOR_NB_SCREENS(i) - pitch_screen_draw(&screens[i], pitch, pitch_mode); + pitchscreen_draw(&screens[i], pitch, pitch_mode); 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,36 @@ +/*************************************************************************** + * __________ __ ___. + * 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. + * + ****************************************************************************/ + + +#ifndef _PITCHSCREEN_H +#define _PITCHSCREEN_H + +enum PITCHSCREEN_ITEMS +{ + PITCH_CENTER = 0, + PITCH_TOP, + PITCH_RIGHT, + PITCH_BOTTOM, + PITCH_LEFT, + PITCH_ITEM_COUNT, +}; + +#endif /* _PITCHSCREEN_H_ */