From 205f3df7816a1eea9c812ea285d74a4f8ecfad2a Mon Sep 17 00:00:00 2001 From: Peter D'Hoye Date: Sat, 28 Jun 2008 20:45:21 +0000 Subject: Remove a viewport ambiguity by changing the screens width/heigth members into lcdwidth/lcdheight. Normal usercode should always use getwidth()/getheigth() as that returns the viewport width/height. Fixes issues that would have appeared in many places when introducing viewports with sizes != lcd sizes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17857 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/color_picker.c | 30 +++++++++++++++--------------- apps/gui/gwps.c | 6 +++--- apps/gui/list.c | 2 +- apps/gui/pitchscreen.c | 26 ++++++++++++++------------ apps/gui/quickscreen.c | 2 +- apps/gui/splash.c | 14 +++++++------- apps/gui/statusbar.c | 8 ++++---- apps/gui/viewport.c | 6 +++--- apps/gui/wps_parser.c | 7 ++++--- 9 files changed, 52 insertions(+), 49 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c index 239a8b4c81..4ac4fa7fff 100644 --- a/apps/gui/color_picker.c +++ b/apps/gui/color_picker.c @@ -158,11 +158,11 @@ static void draw_screen(struct screen *display, char *title, enough to display the selected slider - calculate total height of display with three sliders present */ display_three_rows = - display->height >= MARGIN_TOP + - display->char_height*4 + /* Title + 3 sliders */ - TITLE_MARGIN_BOTTOM + - SELECTOR_TB_MARGIN*6 + /* 2 margins/slider */ - MARGIN_BOTTOM; + display->getheight() >= MARGIN_TOP + + display->char_height*4 + /* Title + 3 sliders */ + TITLE_MARGIN_BOTTOM + + SELECTOR_TB_MARGIN*6 + /* 2 margins/slider */ + MARGIN_BOTTOM; /* Figure out widest label character in case they vary - this function assumes labels are one character */ @@ -178,13 +178,13 @@ static void draw_screen(struct screen *display, char *title, /* Draw title string */ set_drawinfo(display, DRMODE_SOLID, text_color, background_color); display->getstringsize(title, &x, &y); - display->putsxy((display->width - x) / 2, MARGIN_TOP, title); + display->putsxy((display->getwidth() - x) / 2, MARGIN_TOP, title); /* Get slider positions and top starting position */ text_top = MARGIN_TOP + y + TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN; slider_left = MARGIN_LEFT + SELECTOR_WIDTH + SELECTOR_LR_MARGIN + max_label_width + SLIDER_MARGIN_LEFT; - slider_width = display->width - slider_left - SLIDER_MARGIN_RIGHT - + slider_width = display->getwidth() - slider_left - SLIDER_MARGIN_RIGHT - display->char_width*2 - SELECTOR_LR_MARGIN - SELECTOR_WIDTH - MARGIN_RIGHT; @@ -208,7 +208,7 @@ static void draw_screen(struct screen *display, char *title, /* Draw solid bar selection bar */ display->fillrect(0, text_top - SELECTOR_TB_MARGIN, - display->width, + display->getwidth(), display->char_height + SELECTOR_TB_MARGIN*2); @@ -225,8 +225,8 @@ static void draw_screen(struct screen *display, char *title, SELECTOR_HEIGHT) / 2; screen_put_iconxy(display, MARGIN_LEFT, top, Icon_Cursor); screen_put_iconxy(display, - display->width - MARGIN_RIGHT - - get_icon_width(display->screen_type), + display->getwidth() - MARGIN_RIGHT - + get_icon_width(display->screen_type), top, Icon_Cursor); } @@ -282,9 +282,9 @@ static void draw_screen(struct screen *display, char *title, /* Display color swatch on color screens only */ int left = MARGIN_LEFT + SELECTOR_WIDTH + SELECTOR_LR_MARGIN; int top = text_top + SWATCH_TOP_MARGIN; - int width = display->width - left - SELECTOR_LR_MARGIN - + int width = display->getwidth() - left - SELECTOR_LR_MARGIN - SELECTOR_WIDTH - MARGIN_RIGHT; - int height = display->height - top - MARGIN_BOTTOM; + int height = display->getheight() - top - MARGIN_BOTTOM; /* Only draw if room */ if (height >= display->char_height + 2) @@ -314,11 +314,11 @@ static void draw_screen(struct screen *display, char *title, display->getstringsize(buf, &x, &y); i = text_top + SWATCH_TOP_MARGIN; - if (i + y <= display->height - MARGIN_BOTTOM) + if (i + y <= display->getheight() - MARGIN_BOTTOM) { set_drawinfo(display, DRMODE_SOLID, text_color, background_color); - x = (display->width - x) / 2; - y = (i + display->height - MARGIN_BOTTOM - y) / 2; + x = (display->getwidth() - x) / 2; + y = (i + display->getheight() - MARGIN_BOTTOM - y) / 2; display->putsxy(x, y, buf); } } diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index d752cb3da5..a7c5295f48 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -788,17 +788,17 @@ static void statusbar_toggle_handler(void *data) if (!global_settings.statusbar && !draw) { vp->vp.y = 0; - vp->vp.height = screens[i].height; + vp->vp.height = screens[i].lcdheight; } else { vp->vp.y = STATUSBAR_HEIGHT; - vp->vp.height = screens[i].height - STATUSBAR_HEIGHT; + vp->vp.height = screens[i].lcdheight - STATUSBAR_HEIGHT; } } } #endif - + void gui_sync_wps_init(void) { int i; diff --git a/apps/gui/list.c b/apps/gui/list.c index 0ec40d3aed..96652ce0a9 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -78,7 +78,7 @@ void list_init_viewports(struct gui_synclist *list) { viewport_set_defaults(vp, i); list->parent[i]->y = gui_statusbar_height(); - list->parent[i]->height = screens[i].height - list->parent[i]->y; + list->parent[i]->height = screens[i].lcdheight - list->parent[i]->y; } } #ifdef HAVE_BUTTONBAR diff --git a/apps/gui/pitchscreen.c b/apps/gui/pitchscreen.c index c9d6750242..e0a7416ac6 100644 --- a/apps/gui/pitchscreen.c +++ b/apps/gui/pitchscreen.c @@ -64,7 +64,7 @@ static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) { w = snprintf((char *)buf, sizeof(buf), "%s: %d.%d%%",str(LANG_PITCH), pitch / 10, pitch % 10 ); - display->putsxy((display->width-(w*display->char_width))/2, + display->putsxy((display->lcdwidth-(w*display->char_width))/2, display->nb_lines/2,buf); } else /* bigger screen, show everything... */ @@ -77,9 +77,9 @@ static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) ptr = str(LANG_PITCH_UP_SEMITONE); } display->getstringsize(ptr,&w,&h); - display->putsxy((display->width-w)/2, 0, ptr); + display->putsxy((display->lcdwidth-w)/2, 0, ptr); display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], - display->width/2 - 3, h, 7, 8); + display->lcdwidth/2 - 3, h, 7, 8); /* DOWN: Pitch Down */ if (pitch_mode == PITCH_MODE_ABSOLUTE) { @@ -88,33 +88,35 @@ static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) ptr = str(LANG_PITCH_DOWN_SEMITONE); } display->getstringsize(ptr,&w,&h); - display->putsxy((display->width-w)/2, display->height - h, ptr); + display->putsxy((display->lcdwidth-w)/2, display->lcdheight - h, ptr); display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], - display->width/2 - 3, display->height - h*2, 7, 8); + display->lcdwidth/2 - 3, + display->lcdheight - h*2, 7, 8); /* RIGHT: +2% */ ptr = "+2%"; display->getstringsize(ptr,&w,&h); - display->putsxy(display->width-w, (display->height-h)/2, ptr); + display->putsxy(display->lcdwidth-w, (display->lcdheight-h)/2, ptr); display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], - display->width-w-8, (display->height-h)/2, 7, 8); + display->lcdwidth-w-8, + (display->lcdheight-h)/2, 7, 8); /* LEFT: -2% */ ptr = "-2%"; display->getstringsize(ptr,&w,&h); - display->putsxy(0, (display->height-h)/2, ptr); + display->putsxy(0, (display->lcdheight-h)/2, ptr); display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], - w+1, (display->height-h)/2, 7, 8); + 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->width-w)/2, (display->height/2)-h, buf); + 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->width-w)/2, display->height/2, buf); + display->putsxy((display->lcdwidth-w)/2, display->lcdheight/2, buf); } display->update(); @@ -123,7 +125,7 @@ static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) static int pitch_increase(int pitch, int delta, bool allow_cutoff) { int new_pitch; - + if (delta < 0) { if (pitch + delta >= PITCH_MIN) { new_pitch = pitch + delta; diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 3eb9426c39..ef1111fe3e 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -107,7 +107,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs, vp_icons[screen].height = vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y; - if (left_width + right_width > display->width - CENTER_ICONAREA_WIDTH) + if (left_width + right_width > display->lcdwidth - CENTER_ICONAREA_WIDTH) { /* scrolling needed */ int width = (parent->width - CENTER_ICONAREA_WIDTH)/2; diff --git a/apps/gui/splash.c b/apps/gui/splash.c index 0405c0586d..b4b451eed6 100644 --- a/apps/gui/splash.c +++ b/apps/gui/splash.c @@ -91,14 +91,14 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) #endif if (lastbreak) { - if (x + (next - lastbreak) * space_w + w > screen->width) + if (x + (next - lastbreak) * space_w + w > screen->lcdwidth) { /* too wide, wrap */ widths[line] = x; #ifdef HAVE_LCD_BITMAP if (x > maxw) maxw = x; #endif - if ((y + h > screen->height) || (line >= (MAXLINES-1))) + if ((y + h > screen->lcdheight) || (line >= (MAXLINES-1))) break; /* screen full or out of lines */ x = 0; y += h; @@ -132,8 +132,8 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) #ifdef HAVE_LCD_BITMAP /* If we center the display, then just clear the box we need and put a nice little frame and put the text in there! */ - y = (screen->height - y) / 2; /* height => y start position */ - x = (screen->width - maxw) / 2 - 2; + y = (screen->lcdheight - y) / 2; /* height => y start position */ + x = (screen->lcdwidth - maxw) / 2 - 2; #if LCD_DEPTH > 1 if (screen->depth > 1) @@ -147,7 +147,7 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) #endif screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); - screen->fillrect(x, y-2, maxw+4, screen->height-y*2+4); + screen->fillrect(x, y-2, maxw+4, screen->lcdheight-y*2+4); #if LCD_DEPTH > 1 if (screen->depth > 1) @@ -156,7 +156,7 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) #endif screen->set_drawmode(DRMODE_SOLID); - screen->drawrect(x, y-2, maxw+4, screen->height-y*2+4); + screen->drawrect(x, y-2, maxw+4, screen->lcdheight-y*2+4); #else /* HAVE_LCD_CHARCELLS */ y = 0; /* vertical centering on 2 lines would be silly */ x = 0; @@ -167,7 +167,7 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) for (i = 0; i <= line; i++) { - x = MAX((screen->width - widths[i]) / 2, 0); + x = MAX((screen->lcdwidth - widths[i]) / 2, 0); #ifdef HAVE_LCD_BITMAP screen->putsxy(x, y, lines[i]); diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index b9941eb061..0a421e8b16 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -256,7 +256,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) memcmp(&(bar->info), &(bar->lastinfo), sizeof(struct status_info))) { display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); - display->fillrect(0, 0, display->width, STATUSBAR_HEIGHT); + display->fillrect(0, 0, display->getwidth(), STATUSBAR_HEIGHT); display->set_drawmode(DRMODE_SOLID); if (bar->info.battery_state) @@ -329,7 +329,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) if(!display->has_disk_led && bar->info.led) gui_statusbar_led(display); #endif - display->update_rect(0, 0, display->width, STATUSBAR_HEIGHT); + display->update_rect(0, 0, display->getwidth(), STATUSBAR_HEIGHT); bar->lastinfo = bar->info; } #endif /* HAVE_LCD_BITMAP */ @@ -573,7 +573,7 @@ static void gui_statusbar_icon_lock_remote(struct screen * display) static void gui_statusbar_led(struct screen * display) { display->mono_bitmap(bitmap_icon_disk, - STATUSBAR_DISK_X_POS(display->width), + STATUSBAR_DISK_X_POS(display->getwidth()), STATUSBAR_Y_POS, STATUSBAR_DISK_WIDTH, STATUSBAR_HEIGHT); } @@ -605,7 +605,7 @@ static void gui_statusbar_time(struct screen * display, struct tm *time) display->setfont(FONT_SYSFIXED); display->getstringsize(buffer, &width, &height); if (height <= STATUSBAR_HEIGHT) { - display->putsxy(STATUSBAR_TIME_X_END(display->width) - width, + display->putsxy(STATUSBAR_TIME_X_END(display->getwidth()) - width, STATUSBAR_Y_POS, buffer); } display->setfont(FONT_UI); diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index 6aad7c5b05..ef61494b71 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -48,10 +48,10 @@ int viewport_get_nb_lines(struct viewport *vp) void viewport_set_defaults(struct viewport *vp, enum screen_type screen) { vp->x = 0; - vp->width = screens[screen].width; - + vp->width = screens[screen].lcdwidth; + vp->y = gui_statusbar_height(); - vp->height = screens[screen].height - vp->y; + vp->height = screens[screen].lcdheight - vp->y; #ifdef HAVE_LCD_BITMAP vp->drawmode = DRMODE_SOLID; vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index e89f2692cf..73516f604d 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -1550,16 +1550,17 @@ bool wps_data_load(struct wps_data *wps_data, /* Initialise the first (default) viewport */ wps_data->viewports[0].vp.x = 0; - wps_data->viewports[0].vp.width = display->width; + wps_data->viewports[0].vp.width = display->getwidth(); if (!global_settings.statusbar) { wps_data->viewports[0].vp.y = 0; - wps_data->viewports[0].vp.height = display->height; + wps_data->viewports[0].vp.height = display->getheight(); } else { wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT; - wps_data->viewports[0].vp.height = display->height - STATUSBAR_HEIGHT; + wps_data->viewports[0].vp.height = display->getheight() - + STATUSBAR_HEIGHT; } #ifdef HAVE_LCD_BITMAP wps_data->viewports[0].vp.font = FONT_UI; -- cgit v1.2.3