From: skeezix Date: Tue, 28 Feb 2012 20:32:37 +0000 (-0500) Subject: mmenu; larger font in list view; added to config file and config menu; default folders X-Git-Tag: sz_beta3~1 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-libraries.git;a=commitdiff_plain;h=7109a4ebacc4ec15f323b22ceb31103fa895939f mmenu; larger font in list view; added to config file and config menu; default folders --- diff --git a/minimenu/mmcache.c b/minimenu/mmcache.c index 8ecd92a..941aa74 100644 --- a/minimenu/mmcache.c +++ b/minimenu/mmcache.c @@ -45,6 +45,7 @@ extern pnd_conf_handle g_conf; extern unsigned char g_pvwcache; extern pnd_conf_handle g_desktopconf; +SDL_Surface *ui_scale_image ( SDL_Surface *s, unsigned int maxwidth, int maxheight ); // height -1 means ignore mm_cache_t *g_icon_cache = NULL; mm_cache_t *g_preview_cache = NULL; diff --git a/minimenu/mmconf.c b/minimenu/mmconf.c index dc75de8..2da4da8 100644 --- a/minimenu/mmconf.c +++ b/minimenu/mmconf.c @@ -33,6 +33,7 @@ confitem_t page_general[] = { { "Show 'All' tab", "Whethor an All tab is shown or not", "1", "categories.do_all_cat", ct_boolean }, { "Show directory browser tabs", "Show a tab for each SD card?", "0", "filesystem.do_browser", ct_boolean }, { "Detail panel on start?", "Show or hide the detail panel when menu starts", "1", "display.show_detail_pane", ct_boolean }, + { "Default list view not icons?", "Normally we default to icons view not list", "0", "display.viewmode_list", ct_boolean }, { "Sub-categories as folders?", "If no, uses tabs instead of folders within tabs.", "1", "tabs.subcat_as_folders", ct_boolean }, { "Sub-category apps in their main cat?","If no, apps with subcategories are only in subcategories","1", "tabs.subcat_to_parent", ct_boolean }, { "Remember selected app", "On return to menu select previous app; default to selected", "1", "minimenu.start_selected", ct_boolean }, diff --git a/minimenu/mmui.c b/minimenu/mmui.c index 3dd8eb7..571fd01 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -95,6 +95,7 @@ unsigned char ui_detail_hidden = 0; // if >0, detail panel is hidden // FUTURE: If multiple panels can be shown/hidden, convert ui_detail_hidden to a bitmask SDL_Surface *ui_scale_image ( SDL_Surface *s, unsigned int maxwidth, int maxheight ); // height -1 means ignore + static int ui_selected_index ( void ); static void ui_start_defered_icon_thread ( void ); static void ui_stop_defered_icon_thread ( void ); @@ -218,6 +219,18 @@ unsigned char ui_setup ( void ) { } else { ui_detail_hidden = 1; } + + // determine default viewmode + if ( pnd_conf_get_as_int_d ( g_conf, "display.viewmode_list", -1 ) != -1 ) { + int i = pnd_conf_get_as_int_d ( g_conf, "display.viewmode_list", 0 ); + if ( i >= uiv_max ) { + ui_viewmode = uiv_icons; + } else { + ui_viewmode = i; + } + } + + // update display context ui_recache_context ( &ui_display_context ); return ( 1 ); @@ -294,6 +307,14 @@ unsigned char ui_imagecache ( char *basepath ) { } if ( ( g_imagecache [ i ].i = IMG_Load ( fullpath ) ) ) { + + // also make a 'tiny' version.. + SDL_Surface *s = g_imagecache [ i ].i; + SDL_Surface *scaled_tiny = SDL_ConvertSurface ( s, s -> format, s -> flags ); // duplicate + extern ui_context_t ui_display_context; + scaled_tiny = ui_scale_image ( scaled_tiny, -1 , ui_display_context.text_height_tab ); // resize + g_imagecache [ i ].itiny = scaled_tiny; + break; // no retry needed } else { pnd_log ( pndn_error, "ERROR: (Try %u) Couldn't load static cache image: %s\n", try + 1, fullpath ); @@ -438,7 +459,7 @@ void ui_render ( void ) { // max visible --> row-max == grid height / ( font-height + padding ) icon_rows = g_categories [ ui_category ] -> refcount; // one app per row - icon_visible_rows = ( c -> cell_height * c -> row_max ) / ( c -> text_height + c -> icon_offset_y ); + icon_visible_rows = ( c -> cell_height * c -> row_max ) / ( c -> text_height_tab + c -> icon_offset_y ); } else { @@ -792,9 +813,9 @@ void ui_render ( void ) { src.x = 0; src.y = 0; src.w = hilight -> w; - src.h = c -> text_height + c -> icon_offset_y; + src.h = c -> text_height_tab + c -> icon_offset_y; dest -> x = c -> grid_offset_x + c -> text_clip_x; - dest -> y = c -> grid_offset_y + ( displayrow * ( c -> text_height + c -> icon_offset_y ) ) - ( c -> icon_offset_y / 2 ); + dest -> y = c -> grid_offset_y + ( displayrow * ( c -> text_height_tab + c -> icon_offset_y ) ) - ( c -> icon_offset_y / 2 ); SDL_BlitSurface ( hilight, &src, sdl_realscreen, dest ); dest++; } @@ -842,32 +863,57 @@ void ui_render ( void ) { if ( ic ) { iconsurface = ic -> itiny; + } else { + //pnd_log ( pndn_warning, "WARNING: TBD: Need Missin-icon icon for '%s'\n", IFNULL(appiter -> ref -> title_en,"No Name") ); + + // no icon override; was this a pnd-file (show the unknown icon then), or was this generated from + // filesystem (file or directory icon) + if ( appiter -> ref -> object_flags & PND_DISCO_GENERATED ) { + if ( appiter -> ref -> object_type == pnd_object_type_directory ) { + + // is this a subcat, a .., or a filesystem folder? + //iconsurface = g_imagecache [ IMG_FOLDER ].i; + if ( g_categories [ ui_category ] -> fspath ) { + iconsurface = g_imagecache [ IMG_FOLDER ].itiny; + } else if ( strcmp ( appiter -> ref -> title_en, ".." ) == 0 ) { + iconsurface = g_imagecache [ IMG_DOTDOTFOLDER ].itiny; + } else { + iconsurface = g_imagecache [ IMG_SUBCATFOLDER ].itiny; + } + + } else { + iconsurface = g_imagecache [ IMG_EXECBIN ].itiny; + } + } else { + iconsurface = g_imagecache [ IMG_ICON_MISSING ].itiny; + } + } if ( iconsurface ) { dest -> x = c -> grid_offset_x + c -> text_clip_x; - dest -> y = c -> grid_offset_y + ( displayrow * ( c -> text_height + c -> icon_offset_y ) ) - ( c -> icon_offset_y / 2 ); + dest -> y = c -> grid_offset_y + ( displayrow * ( c -> text_height_tab + c -> icon_offset_y ) ) - ( c -> icon_offset_y / 2 ); SDL_BlitSurface ( iconsurface, NULL, sdl_realscreen, dest ); } // show title text if ( appiter -> ref -> title_en ) { SDL_Surface *rtext; - rtext = TTF_RenderText_Blended ( g_grid_font, appiter -> ref -> title_en, c -> fontcolor ); + rtext = TTF_RenderText_Blended ( g_tab_font, appiter -> ref -> title_en, c -> fontcolor ); src.x = 0; src.y = 0; src.w = hilight -> w; //c -> text_width < rtext -> w ? c -> text_width : rtext -> w; src.h = rtext -> h; dest -> x = c -> grid_offset_x + c -> text_clip_x; - dest -> x += 20; // so all title-text line up, regardless of icon presence + dest -> x += 30; // so all title-text line up, regardless of icon presence #if 0 if ( ic ) { - dest -> x += 20; //((SDL_Surface*)ic -> i) -> w; + dest -> x += 30; //((SDL_Surface*)ic -> i) -> w; } #endif - dest -> y = c -> grid_offset_y + ( displayrow * ( c -> text_height + c -> icon_offset_y ) ); + dest -> y = c -> grid_offset_y + ( displayrow * ( c -> text_height_tab + c -> icon_offset_y ) ); SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest ); SDL_FreeSurface ( rtext ); dest++; @@ -1812,7 +1858,7 @@ void ui_push_left ( unsigned char forcecoil ) { if ( ui_viewmode == uiv_list ) { ui_context_t *c = &ui_display_context; int i; - int imax = ( c -> cell_height * c -> row_max ) / ( c -> text_height + c -> icon_offset_y ); // visible rows + int imax = ( c -> cell_height * c -> row_max ) / ( c -> text_height_tab + c -> icon_offset_y ); // visible rows for ( i = 0; i < imax; i++ ) { ui_push_up(); } @@ -1863,7 +1909,7 @@ void ui_push_right ( unsigned char forcecoil ) { if ( ui_viewmode == uiv_list ) { ui_context_t *c = &ui_display_context; int i; - int imax = ( c -> cell_height * c -> row_max ) / ( c -> text_height + c -> icon_offset_y ); // visible rows + int imax = ( c -> cell_height * c -> row_max ) / ( c -> text_height_tab + c -> icon_offset_y ); // visible rows for ( i = 0; i < imax; i++ ) { ui_push_down(); } @@ -3649,6 +3695,14 @@ void ui_recache_context ( ui_context_t *c ) { c -> text_height = 10; } + if ( g_tab_font ) { + SDL_Surface *rtext; + rtext = TTF_RenderText_Blended ( g_tab_font, "M", c -> fontcolor ); + c -> text_height_tab = rtext -> h; + } else { + c -> text_height_tab = 15; + } + // now that we've got 'normal' (detail pane shown) param's, lets check if detail pane // is hidden; if so, override some values with those alternate skin values where possible. if ( ui_detail_hidden ) { diff --git a/minimenu/mmui.h b/minimenu/mmui.h index a01d504..b6a0d68 100644 --- a/minimenu/mmui.h +++ b/minimenu/mmui.h @@ -47,6 +47,7 @@ typedef struct { char *confname; char *alt_confname; void /*SDL_Surface*/ *i; + void /*SDL_Surface*/ *itiny; } mm_imgcache_t; /* ui stuff diff --git a/minimenu/mmui_context.h b/minimenu/mmui_context.h index 3f6ceab..7dd5127 100644 --- a/minimenu/mmui_context.h +++ b/minimenu/mmui_context.h @@ -32,6 +32,7 @@ typedef struct { unsigned int text_width; unsigned int text_height; // grid text's height of an 'M' + unsigned int text_height_tab; // tab text's height of an 'M' unsigned int text_clip_x; unsigned int text_offset_x; unsigned int text_offset_y;