mm_appref_t *ui_selected = NULL;
unsigned char ui_category = 0; // current category
unsigned char ui_catshift = 0; // how many cats are offscreen to the left
-ui_viewmode_e ui_viewmode = uiv_list; // default to traditional icon view; why or why is viewstate not per-viewmode :/
+ui_viewmode_e ui_viewmode = uiv_icons; // default to traditional icon view; why or why is viewstate not per-viewmode :/
ui_context_t ui_display_context; // display paramaters: see mmui_context.h
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 );
} 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 );
}
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 );
// 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 {
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++;
}
// show icon
mm_cache_t *ic = cache_query_icon ( appiter -> ref -> unique_id );
+ SDL_Surface *iconsurface = NULL;
+
+ // if icon not in cache, and its a pnd-file source, perhaps try to load it right now..
+ if ( ( ! ic ) &&
+ ( load_visible ) &&
+ ( ! ( appiter -> ref -> object_flags & PND_DISCO_GENERATED ) )
+ )
+ {
+ // try to load any icons that..
+ // - are not yet loaded
+ // - did not fail a previous load attempt
+ // this way user can upfront load all icons, or defer all icons, or even defer all icons
+ // and still try to load visible ones 'just before needed'; so not at mmenu load time, but
+ // as needed (only the ones needed.)
+
+ if ( ( appiter -> ref -> pnd_icon_pos ) ||
+ ( appiter -> ref -> icon && appiter -> ref -> object_flags & PND_DISCO_LIBPND_DD )
+ )
+ {
+
+ // try to cache it?
+ if ( ! cache_icon ( appiter -> ref, ui_display_context.icon_max_width, ui_display_context.icon_max_width ) ) {
+ // erm..
+ }
+
+ // avoid churn
+ appiter -> ref -> pnd_icon_pos = 0;
+ if ( appiter -> ref -> icon ) {
+ free ( appiter -> ref -> icon );
+ appiter -> ref -> icon = NULL;
+ }
+
+ // pick up as if nothing happened..
+ ic = cache_query_icon ( appiter -> ref -> unique_id );
+
+ }
+
+ } // load icon during rendering?
+
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 );
- SDL_BlitSurface ( ic -> itiny, NULL, sdl_realscreen, dest );
+ 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++;
} else if ( event.key.keysym.sym == SDLK_LCTRL /*LALT*/ ) { // select button
char *opts [ 20 ] = {
+ "Toggle view icons<->list",
"Reveal hidden category",
"Shutdown Pandora",
"Configure Minimenu",
"Select a Minimenu skin",
"About Minimenu"
};
- int sel = ui_modal_single_menu ( opts, 11, "Minimenu", "Enter to select; other to return." );
+ int sel = ui_modal_single_menu ( opts, 12, "Minimenu", "Enter to select; other to return." );
char buffer [ 100 ];
if ( sel == 0 ) {
+ if ( ui_viewmode == uiv_list ) {
+ ui_viewmode = uiv_icons;
+ } else {
+ ui_viewmode = uiv_list;
+ }
+ } else if ( sel == 1 ) {
// do nothing
ui_revealscreen();
- } else if ( sel == 1 ) {
+ } else if ( sel == 2 ) {
// store conf on exit, so that last app/cat can be cached.. for ED :)
conf_write ( g_conf, conf_determine_location ( g_conf ) );
// shutdown
sprintf ( buffer, "sudo poweroff" );
system ( buffer );
- } else if ( sel == 2 ) {
+ } else if ( sel == 3 ) {
// configure mm
unsigned char restart = conf_run_menu ( NULL );
conf_write ( g_conf, conf_determine_location ( g_conf ) );
if ( restart ) {
emit_and_quit ( MM_RESTART );
}
- } else if ( sel == 3 ) {
+ } else if ( sel == 4 ) {
// manage custom categories
ui_manage_categories();
- } else if ( sel == 4 ) {
+ } else if ( sel == 5 ) {
// rescan apps
pnd_log ( pndn_debug, "Freeing up applications\n" );
applications_free();
pnd_log ( pndn_debug, "Rescanning applications\n" );
applications_scan();
- } else if ( sel == 5 ) {
+ } else if ( sel == 6 ) {
// cache preview to SD now
extern pnd_box_handle g_active_apps;
pnd_box_handle h = g_active_apps;
iter = pnd_box_get_next ( iter );
} // while
- } else if ( sel == 6 ) {
+ } else if ( sel == 7 ) {
// run terminal
char *argv[5];
argv [ 0 ] = pnd_conf_get_as_char ( g_conf, "utility.terminal" );
ui_forkexec ( argv );
}
- } else if ( sel == 7 ) {
+ } else if ( sel == 8 ) {
char buffer [ PATH_MAX ];
sprintf ( buffer, "%s %s\n", MM_RUN, "/usr/pandora/scripts/op_switchgui.sh" );
emit_and_quit ( buffer );
- } else if ( sel == 8 ) {
- emit_and_quit ( MM_QUIT );
} else if ( sel == 9 ) {
+ emit_and_quit ( MM_QUIT );
+ } else if ( sel == 10 ) {
// select skin
if ( ui_pick_skin() ) {
emit_and_quit ( MM_RESTART );
}
- } else if ( sel == 10 ) {
+ } else if ( sel == 11 ) {
// about
char buffer [ PATH_MAX ];
sprintf ( buffer, "%s/about.txt", g_skinpath );
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();
}
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();
}
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 ) {