### Eclipse Workspace Patch 1.0 #P rockbox-devel Index: apps/gui/list.c =================================================================== --- apps/gui/list.c.orig +++ apps/gui/list.c @@ -146,6 +146,15 @@ static void gui_list_flash(struct gui_li gui_list->cursor_flash_state=!gui_list->cursor_flash_state; int selected_line=gui_list->selected_item-gui_list->start_item+SHOW_LIST_TITLE; #ifdef HAVE_LCD_BITMAP + + int nb_lines; + bool use_custom_list=display->screen_type==SCREEN_MAIN && global_settings.listlines; + if (use_custom_list) { + nb_lines = global_settings.listlines; + } else { + nb_lines = display->nb_lines; + } + int line_ypos=display->getymargin()+display->char_height*selected_line; if (global_settings.invert_cursor) { @@ -159,7 +168,7 @@ static void gui_list_flash(struct gui_li else { int cursor_xpos=(global_settings.scrollbar && - display->nb_lines < gui_list->nb_items)?1:0; + nb_lines < gui_list->nb_items)?1:0; screen_put_cursorxy(display, cursor_xpos, selected_line, gui_list->cursor_flash_state); } @@ -225,6 +234,8 @@ static void gui_list_draw_smart(struct g #endif int start, end; bool partial_draw = false; + int icon_width=get_icon_width(display->screen_type); + int icon_height=get_icon_height(display->screen_type); #ifdef HAVE_LCD_BITMAP switch (gui_list_context) /* Set appropriate font */ @@ -238,9 +249,19 @@ static void gui_list_draw_smart(struct g default: debugf("gui_list_put_selection_in_screen(): unknown font context: %i\n", gui_list_context); } + int width, height; + display->getstringsize((unsigned char *)"M", &width, &height); #endif gui_textarea_update_nblines(display); - + int nb_lines; + + bool use_custom_list=display->screen_type==SCREEN_MAIN && global_settings.listlines; + if (use_custom_list) { + nb_lines = global_settings.listlines; + } else { + nb_lines = gui_list->display->nb_lines; + } + /* Speed up UI by drawing the changed contents only. */ if (gui_list == last_list_displayed[gui_list->display->screen_type] && gui_list->last_displayed_start_item == gui_list->start_item @@ -249,7 +270,7 @@ static void gui_list_draw_smart(struct g partial_draw = true; } - lines = display->nb_lines - SHOW_LIST_TITLE; + lines = nb_lines - SHOW_LIST_TITLE; if (last_lines[display->screen_type] != lines) { gui_list_select_at_offset(gui_list, 0); @@ -275,7 +296,7 @@ static void gui_list_draw_smart(struct g { gui_textarea_clear(display); start = 0; - end = display->nb_lines; + end=nb_lines; gui_list->last_displayed_start_item = gui_list->start_item; last_list_displayed[gui_list->display->screen_type] = gui_list; } @@ -287,9 +308,21 @@ static void gui_list_draw_smart(struct g { if (gui_list->title_icon != NOICON && draw_icons) { - screen_put_icon(display, 0, 0, gui_list->title_icon); + if (use_custom_list) { #ifdef HAVE_LCD_BITMAP - text_pos = get_icon_width(display->screen_type)+2; /* pixels */ + int icon_pos_x=global_settings.listxpos; + int icon_pos_y=global_settings.listypos; + + if ( height > icon_height )/* center the cursor */ + icon_pos_y += (height - icon_height) / 2; + + screen_put_iconxy(display, icon_pos_x, icon_pos_y, gui_list->title_icon); +#endif + } else { + screen_put_icon(display, 0, 0, gui_list->title_icon); + } +#ifdef HAVE_LCD_BITMAP + text_pos = icon_width+2; /* pixels */ #else text_pos = 1; /* chars */ #endif @@ -308,10 +341,15 @@ static void gui_list_draw_smart(struct g title_style |= gui_list->title_color; } #endif - screen_set_xmargin(display, text_pos); /* margin for title */ + if (use_custom_list) { + display->setmargins(global_settings.listxpos+text_pos, global_settings.listxpos+text_pos+global_settings.listwidth, global_settings.listypos); + } else { + screen_set_xmargin(display, text_pos); /* margin for title */ + } + item_offset = gui_list_get_item_offset(gui_list, gui_list->title_width, text_pos); - if (item_offset > gui_list->title_width - (display->width - text_pos)) + if (item_offset > gui_list->title_width - (display->getrightmargin()-display->getleftmargin() - text_pos)) display->puts_style_offset(0, 0, gui_list->title, title_style, item_offset); else @@ -332,16 +370,17 @@ static void gui_list_draw_smart(struct g draw_cursor = !global_settings.invert_cursor && gui_list->show_selection_marker; text_pos = 0; /* here it's in pixels */ + if(draw_scrollbar || SHOW_LIST_TITLE) /* indent if there's a title */ { text_pos += SCROLLBAR_WIDTH; } if(draw_cursor) - text_pos += get_icon_width(display->screen_type) + 2; + text_pos += icon_width + 2; if(draw_icons) - text_pos += get_icon_width(display->screen_type) + 2; + text_pos += icon_width + 2; #else draw_cursor = true; if(draw_icons) @@ -351,16 +390,21 @@ static void gui_list_draw_smart(struct g #endif #ifdef HAVE_LCD_BITMAP - screen_set_xmargin(display, text_pos); /* margin for list */ + if (use_custom_list) { + display->setmargins(global_settings.listxpos+text_pos, global_settings.listxpos+text_pos+global_settings.listwidth- + (draw_icons?icon_width:0)-(draw_scrollbar?SCROLLBAR_WIDTH:0), global_settings.listypos); + } else { + screen_set_xmargin(display, text_pos); + } #endif if (SHOW_LIST_TITLE) { start++; - if (end < display->nb_lines) + if (end < nb_lines) end++; } - + for (i = start; i < end; i++) { unsigned char *s; @@ -416,7 +460,7 @@ static void gui_list_draw_smart(struct g draw_cursor = false; } /* if the text is smaller than the viewport size */ - if (item_offset > item_width - (display->width - text_pos)) + if (item_offset > item_width - (display->getrightmargin()-display->getleftmargin() - text_pos)) { /* don't scroll */ display->puts_style_offset(0, i, entry_name, @@ -470,8 +514,19 @@ static void gui_list_draw_smart(struct g #ifdef HAVE_LCD_BITMAP int x = draw_cursor?1:0; int x_off = (draw_scrollbar || SHOW_LIST_TITLE) ? SCROLLBAR_WIDTH: 0; - screen_put_icon_with_offset(display, x, i, + + if (use_custom_list) { + int icon_pos_x=global_settings.listxpos+x_off; + int icon_pos_y=global_settings.listypos+i*height; + + if ( height > icon_height)/* center the cursor */ + icon_pos_y += (height - icon_height) / 2; + + screen_put_iconxy(display, icon_pos_x, icon_pos_y, icon); + } else { + screen_put_icon_with_offset(display, x, i, x_off, 0, icon); + } #else screen_put_icon(display, 1, i, icon); #endif @@ -483,16 +538,26 @@ static void gui_list_draw_smart(struct g /* Draw the scrollbar if needed*/ if(draw_scrollbar) { - int y_start = gui_textarea_get_ystart(display); + int y_start = gui_textarea_get_ystart(display); + int x_start =0; if (SHOW_LIST_TITLE) y_start += display->char_height; int scrollbar_y_end = display->char_height * lines + y_start; - gui_scrollbar_draw(display, 0, y_start, SCROLLBAR_WIDTH-1, - scrollbar_y_end - y_start, gui_list->nb_items, - gui_list->start_item, - gui_list->start_item + lines, VERTICAL); - } + + if (use_custom_list) + { + y_start=global_settings.listypos; + if (SHOW_LIST_TITLE) + y_start += display->char_height; + x_start=global_settings.listxpos; + scrollbar_y_end = display->char_height * lines + y_start; + } + gui_scrollbar_draw(display, x_start, y_start, SCROLLBAR_WIDTH-1, + scrollbar_y_end - y_start, gui_list->nb_items, + gui_list->start_item, + gui_list->start_item + lines, VERTICAL); + } screen_set_xmargin(display, old_margin); #endif @@ -645,7 +710,13 @@ static void gui_list_select_below(struct static void gui_list_select_at_offset(struct gui_list * gui_list, int offset) { /* do this here instead of in both select_above and select_below */ - int nb_lines = gui_list->display->nb_lines; + bool use_custom_list=gui_list->display->screen_type==SCREEN_MAIN &&global_settings.listlines; + int nb_lines; + if (use_custom_list) { + nb_lines = global_settings.listlines; + } else { + nb_lines = gui_list->display->nb_lines; + } if (SHOW_LIST_TITLE) nb_lines--; @@ -701,7 +772,15 @@ static void gui_list_del_item(struct gui } #endif gui_textarea_update_nblines(gui_list->display); - int nb_lines = gui_list->display->nb_lines; + int nb_lines; + struct screen * display=gui_list->display; + bool use_custom_list=display->screen_type==SCREEN_MAIN &&global_settings.listlines; + + if (use_custom_list) { + nb_lines = global_settings.listlines; + } else { + nb_lines = gui_list->display->nb_lines; + } int dist_selected_from_end = gui_list->nb_items - gui_list->selected_item - 1; @@ -850,18 +929,37 @@ static void gui_synclist_select_next_pag enum screen_type screen) { int i; - FOR_NB_SCREENS(i) + + FOR_NB_SCREENS(i){ + int nb_lines; + bool use_custom_list=screen==SCREEN_MAIN && global_settings.listlines; + if (use_custom_list) { + nb_lines = global_settings.listlines; + } else { + nb_lines = screens[screen].nb_lines; + } + gui_list_select_at_offset(&(lists->gui_list[i]), - screens[screen].nb_lines); + nb_lines); + } } static void gui_synclist_select_previous_page(struct gui_synclist * lists, enum screen_type screen) { int i; - FOR_NB_SCREENS(i) + FOR_NB_SCREENS(i){ + int nb_lines; + bool use_custom_list=screen==SCREEN_MAIN && global_settings.listlines; + if (use_custom_list) { + nb_lines = global_settings.listlines; + } else { + nb_lines = screens[screen].nb_lines; + } + gui_list_select_at_offset(&(lists->gui_list[i]), - -screens[screen].nb_lines); + -nb_lines); + } } void gui_synclist_add_item(struct gui_synclist * lists) Index: apps/gui/quickscreen.c =================================================================== --- apps/gui/quickscreen.c.orig +++ apps/gui/quickscreen.c @@ -72,10 +72,14 @@ static void gui_quickscreen_draw(struct /* Displays the first line of text */ option=(unsigned char *)option_select_get_text(qs->left_option); title=(unsigned char *)qs->left_option->title; - display->puts_scroll(2, PUTS_CENTER-4+!statusbar, title); - display->puts_scroll(2, PUTS_CENTER-3+!statusbar, option); - display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 1, - PUTSXY_CENTER-(font_h*3), 7, 8); + int ypos=PUTS_CENTER-4; + if(ypos<0){ + ypos=0; + } + display->puts_scroll(2, ypos, title); + ypos++; + display->puts_scroll(2, ypos, option); + display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], 1, ypos*font_h, 7, 8); /* Displays the second line of text */ option=(unsigned char *)option_select_get_text(qs->right_option); @@ -83,21 +87,21 @@ static void gui_quickscreen_draw(struct display->getstringsize(title, &w, NULL); if(w > display->width - 8) { - display->puts_scroll(2, PUTS_CENTER-2+!statusbar, title); + display->puts_scroll(2, PUTS_CENTER-2, title); display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], 1, PUTSXY_CENTER-font_h, 7, 8); } else { - display->putsxy(display->width - w - 12, PUTSXY_CENTER-font_h, title); + display->putsxy(display->width - w - 12, PUTSXY_CENTER-2*font_h, title); display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], display->width - 8, PUTSXY_CENTER-font_h, 7, 8); } display->getstringsize(option, &w, NULL); if(w > display->width) - display->puts_scroll(0, PUTS_CENTER-1+!statusbar, option); + display->puts_scroll(0, PUTS_CENTER-1, option); else - display->putsxy(display->width -w-12, PUTSXY_CENTER, option); + display->putsxy(display->width -w-12, PUTSXY_CENTER-font_h, option); /* Displays the third line of text */ option=(unsigned char *)option_select_get_text(qs->bottom_option); @@ -105,13 +109,13 @@ static void gui_quickscreen_draw(struct display->getstringsize(title, &w, NULL); if(w > display->width) - display->puts_scroll(0, PUTS_BOTTOM-4+!statusbar, title); + display->puts_scroll(0, PUTS_BOTTOM-4, title); else display->putsxy(display->width/2-w/2, PUTSXY_BOTTOM-(font_h*3), title); display->getstringsize(option, &w, NULL); if(w > display->width) - display->puts_scroll(0, PUTS_BOTTOM-3+!statusbar, option); + display->puts_scroll(0, PUTS_BOTTOM-3, option); else display->putsxy(display->width/2-w/2, PUTSXY_BOTTOM-(font_h*2), option); display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], display->width/2-4, Index: apps/settings.h =================================================================== --- apps/settings.h.orig +++ apps/settings.h @@ -713,6 +713,14 @@ struct user_settings int fm_region; #endif bool audioscrobbler; /* Audioscrobbler logging */ + +#ifdef HAVE_LCD_BITMAP + /* custom coordinates/settings for the lists (Menus/File list) */ + int listxpos; + int listypos; + int listlines; + int listwidth; +#endif /* If values are just added to the end, no need to bump plugin API version. */ Index: apps/settings.c =================================================================== --- apps/settings.c.orig +++ apps/settings.c @@ -284,6 +284,20 @@ void theme_settings_reset(void) global_settings.fg_color=LCD_DEFAULT_FG; global_settings.bg_color=LCD_DEFAULT_BG; #endif + global_settings.userfont1[0] = '\0'; + global_settings.userfont2[0] = '\0'; + global_settings.userfont3[0] = '\0'; + global_settings.userfont4[0] = '\0'; + global_settings.userfont5[0] = '\0'; + global_settings.userfont6[0] = '\0'; + global_settings.userfont7[0] = '\0'; + +#ifdef HAVE_LCD_BITMAP + global_settings.listxpos=0; + global_settings.listypos=0; + global_settings.listlines=0; + global_settings.listwidth=0; +#endif } bool settings_load_config(const char* file, bool apply) @@ -1078,13 +1092,6 @@ void settings_reset(void) { #if defined (HAVE_RECORDING) && CONFIG_CODEC == SWCODEC enc_global_settings_reset(); #endif - global_settings.userfont1[0] = '\0'; - global_settings.userfont2[0] = '\0'; - global_settings.userfont3[0] = '\0'; - global_settings.userfont4[0] = '\0'; - global_settings.userfont5[0] = '\0'; - global_settings.userfont6[0] = '\0'; - global_settings.userfont7[0] = '\0'; } /** Changing setting values **/ Index: apps/settings_list.c =================================================================== --- apps/settings_list.c.orig +++ apps/settings_list.c @@ -1185,6 +1185,14 @@ const struct settings_list settings[] = #endif #endif OFFON_SETTING(0,cuesheet,LANG_CUESHEET_ENABLE,false,"cuesheet support", NULL), + +#ifdef HAVE_LCD_BITMAP + {F_T_INT,&global_settings.listxpos,-1,INT(0),"listxpos",NULL,UNUSED}, + {F_T_INT,&global_settings.listypos,-1,INT(0),"listypos",NULL,UNUSED}, + {F_T_INT,&global_settings.listlines,-1,INT(0),"listlines",NULL,UNUSED}, + {F_T_INT,&global_settings.listwidth,-1,INT(0),"listwidth",NULL,UNUSED}, +#endif + CHOICE_SETTING(0, start_in_screen, LANG_START_SCREEN, 1, "start in screen", "previous,root,files,db,wps,menu," #ifdef HAVE_RECORDING Index: apps/gui/icon.c =================================================================== --- apps/gui/icon.c.orig +++ apps/gui/icon.c @@ -267,3 +267,8 @@ int get_icon_width(enum screen_type scre { return ICON_WIDTH(screen_type); } + +int get_icon_height(enum screen_type screen_type) +{ + return ICON_HEIGHT(screen_type); +} Index: apps/gui/icon.h =================================================================== --- apps/gui/icon.h.orig +++ apps/gui/icon.h @@ -110,6 +110,7 @@ void icons_init(void); # define get_icon_width(a) 6 #else int get_icon_width(enum screen_type screen_type); +int get_icon_height(enum screen_type screen_type); #endif #endif /*_GUI_ICON_H_*/