From 3c7843b4ae999e81e1c984e83adde493be213884 Mon Sep 17 00:00:00 2001 From: skeezix Date: Tue, 9 Mar 2010 10:30:06 -0500 Subject: [PATCH] Minor cleanups; possibly fixed Makefile for djw and mmenu --- Makefile | 4 ++-- minimenu/TODO.txt | 2 ++ minimenu/mmcache.c | 12 +++++----- minimenu/mmenu.c | 8 +++---- minimenu/mmui.c | 57 ++++++++++++++++++++++++++++------------------ minimenu/mmui.h | 2 +- 6 files changed, 50 insertions(+), 35 deletions(-) diff --git a/Makefile b/Makefile index 93b567a..c88049e 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ RM = rm # environment VPATH = lib test apps minimenu CFLAG_SO = -fPIC #-fPIC not always needed, but good to have -CFLAGS = -Wall -I./include -g ${CFLAG_SO} -I/usr/include/SDL +CFLAGS = -Wall -I./include -g ${CFLAG_SO} -I${PNDSTUFF}/usr/include/SDL CXXFLAGS = -Wall -I./include -g ${CFLAG_SO} # code @@ -61,7 +61,7 @@ pndevmapperd: pndevmapperd.o ${SOLIB1} ${CC} -lstdc++ -o bin/pndevmapperd pndevmapperd.o ${SOLIB1} mmenu: mmenu.o mmui.o mmcache.o mmcat.o ${SOLIB1} - ${CC} -lstdc++ -o bin/mmenu mmenu.o mmui.o mmcache.o mmcat.o ${SOLIB1} -lSDL -lSDL_image -lSDL_ttf -lSDL_gfx + ${CC} -lstdc++ -o bin/mmenu mmenu.o mmui.o mmcache.o mmcat.o ${SOLIB1} -L${PNDSTUFF}/usr/lib -lSDL -lSDL_image -lSDL_ttf -lSDL_gfx mmwrapper: mmwrapper.o ${SOLIB1} ${CC} -lstdc++ -o bin/mmwrapper mmwrapper.o ${SOLIB1} diff --git a/minimenu/TODO.txt b/minimenu/TODO.txt index 35c3db1..554ad59 100644 --- a/minimenu/TODO.txt +++ b/minimenu/TODO.txt @@ -33,5 +33,7 @@ - defer icon or preview-pics - future + - make mmwrapper take all input and.. + - make the commanbd line have unique token up front ("--->"), so that the command can be found in the mess anyway? - add callback to pnd_disco_Search (maybe new func to not break cpas code), so can show number apps found so far - note taking field diff --git a/minimenu/mmcache.c b/minimenu/mmcache.c index cd7c8b2..7df2c63 100644 --- a/minimenu/mmcache.c +++ b/minimenu/mmcache.c @@ -68,20 +68,20 @@ unsigned char cache_preview ( pnd_disco_t *app, unsigned char maxwidth, unsigned return ( 0 ); } - pnd_log ( pndn_debug, "Image size is %u x %u (max %u x %u)\n", s -> w, s -> h, maxwidth, maxheight ); + //pnd_log ( pndn_debug, "Image size is %u x %u (max %u x %u)\n", s -> w, s -> h, maxwidth, maxheight ); // scale if ( s -> w < maxwidth ) { SDL_Surface *scaled; double scale = (double)maxwidth / (double)s -> w; - pnd_log ( pndn_debug, " Upscaling; scale factor %f\n", scale ); + //pnd_log ( pndn_debug, " Upscaling; scale factor %f\n", scale ); scaled = rotozoomSurface ( s, 0 /* angle*/, scale /* scale */, 1 /* smooth==1*/ ); SDL_FreeSurface ( s ); s = scaled; } else if ( s -> w > maxwidth ) { SDL_Surface *scaled; double scale = (double)maxwidth / (double)s -> w; - pnd_log ( pndn_debug, " Downscaling; scale factor %f\n", scale ); + //pnd_log ( pndn_debug, " Downscaling; scale factor %f\n", scale ); scaled = rotozoomSurface ( s, 0 /* angle*/, scale /* scale */, 1 /* smooth==1*/ ); SDL_FreeSurface ( s ); s = scaled; @@ -136,20 +136,20 @@ unsigned char cache_icon ( pnd_disco_t *app, unsigned char maxwidth, unsigned ch free ( iconbuf ); // ditch the icon from ram - pnd_log ( pndn_debug, "Image size is %u x %u (max %u x %u)\n", s -> w, s -> h, maxwidth, maxheight ); + //pnd_log ( pndn_debug, "Image size is %u x %u (max %u x %u)\n", s -> w, s -> h, maxwidth, maxheight ); // scale the icon? if ( s -> w < maxwidth ) { SDL_Surface *scaled; double scale = (double)maxwidth / (double)s -> w; - pnd_log ( pndn_debug, " Upscaling; scale factor %f\n", scale ); + //pnd_log ( pndn_debug, " Upscaling; scale factor %f\n", scale ); scaled = rotozoomSurface ( s, 0 /* angle*/, scale /* scale */, 1 /* smooth==1*/ ); SDL_FreeSurface ( s ); s = scaled; } else if ( s -> w > maxwidth ) { SDL_Surface *scaled; double scale = (double)maxwidth / (double)s -> w; - pnd_log ( pndn_debug, " Downscaling; scale factor %f\n", scale ); + //pnd_log ( pndn_debug, " Downscaling; scale factor %f\n", scale ); scaled = rotozoomSurface ( s, 0 /* angle*/, scale /* scale */, 1 /* smooth==1*/ ); SDL_FreeSurface ( s ); s = scaled; diff --git a/minimenu/mmenu.c b/minimenu/mmenu.c index 9ff0cdb..c2eb25e 100644 --- a/minimenu/mmenu.c +++ b/minimenu/mmenu.c @@ -198,15 +198,15 @@ int main ( int argc, char *argv[] ) { maxheight = pnd_conf_get_as_int_d ( g_conf, MMENU_DISP_ICON_MAX_HEIGHT, 50 ); // show cache screen - ui_cachescreen ( 1 /* clear screen */ ); + ui_cachescreen ( 1 /* clear screen */, NULL ); pnd_log ( pndn_debug, "Found pnd applications, and caching icons:\n" ); pnd_disco_t *iter = pnd_box_get_head ( g_active_apps ); while ( iter ) { - pnd_log ( pndn_debug, " App: '%s'\n", IFNULL(iter->title_en,"No Name") ); + //pnd_log ( pndn_debug, " App: '%s'\n", IFNULL(iter->title_en,"No Name") ); // update cachescreen - ui_cachescreen ( 1 /* clear screen */ ); + ui_cachescreen ( 1 /* clear screen */, IFNULL(iter->title_en,"No Name") ); // cache the icon if ( iter -> pnd_icon_pos && @@ -242,7 +242,7 @@ int main ( int argc, char *argv[] ) { } // while // dump categories - category_dump(); + //category_dump(); /* actual work now */ diff --git a/minimenu/mmui.c b/minimenu/mmui.c index 9d6401b..d8d108a 100644 --- a/minimenu/mmui.c +++ b/minimenu/mmui.c @@ -303,7 +303,7 @@ void ui_render ( unsigned int render_mask ) { int topleft = col_max * ui_rows_scrolled_down; int botright = ( col_max * ( ui_rows_scrolled_down + row_max ) - 1 ); - pnd_log ( PND_LOG_DEFAULT, "index %u tl %u br %u\n", index, topleft, botright ); + //pnd_log ( PND_LOG_DEFAULT, "index %u tl %u br %u\n", index, topleft, botright ); if ( index < topleft ) { ui_rows_scrolled_down -= pnd_conf_get_as_int_d ( g_conf, "grid.scroll_increment", 1 ); @@ -499,7 +499,7 @@ void ui_render ( unsigned int render_mask ) { if ( ic ) { iconsurface = ic -> i; } else { - pnd_log ( pndn_warning, "WARNING: TBD: Need Missin-icon icon for '%s'\n", IFNULL(appiter -> ref -> title_en,"No Name") ); + //pnd_log ( pndn_warning, "WARNING: TBD: Need Missin-icon icon for '%s'\n", IFNULL(appiter -> ref -> title_en,"No Name") ); iconsurface = g_imagecache [ IMG_ICON_MISSING ].i; } if ( iconsurface ) { @@ -763,7 +763,7 @@ void ui_process_input ( unsigned char block_p ) { #if 1 // keyboard events case SDL_KEYUP: - pnd_log ( pndn_debug, "key up %u\n", event.key.keysym.sym ); + //pnd_log ( pndn_debug, "key up %u\n", event.key.keysym.sym ); // directional if ( event.key.keysym.sym == SDLK_RIGHT ) { @@ -781,10 +781,10 @@ void ui_process_input ( unsigned char block_p ) { } else if ( event.key.keysym.sym == SDLK_SPACE || event.key.keysym.sym == SDLK_END ) { ui_push_exec(); ui_event++; - } else if ( event.key.keysym.sym == SDLK_z ) { + } else if ( event.key.keysym.sym == SDLK_z || event.key.keysym.sym == SDLK_RSHIFT ) { ui_push_ltrigger(); ui_event++; - } else if ( event.key.keysym.sym == SDLK_x ) { + } else if ( event.key.keysym.sym == SDLK_x || event.key.keysym.sym == SDLK_RCTRL ) { ui_push_rtrigger(); ui_event++; } @@ -1053,9 +1053,11 @@ void ui_discoverscreen ( unsigned char clearscreen ) { return; } -void ui_cachescreen ( unsigned char clearscreen ) { +void ui_cachescreen ( unsigned char clearscreen, char *filename ) { - SDL_Rect dest; + SDL_Rect rects [ 4 ]; + SDL_Rect *dest = rects; + bzero ( dest, sizeof(SDL_Rect)* 4 ); unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 ); unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 ); @@ -1070,12 +1072,12 @@ void ui_cachescreen ( unsigned char clearscreen ) { // render background if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) { - dest.x = 0; - dest.y = 0; - dest.w = sdl_realscreen -> w; - dest.h = sdl_realscreen -> h; + dest -> x = 0; + dest -> y = 0; + dest -> w = sdl_realscreen -> w; + dest -> h = sdl_realscreen -> h; SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, NULL /* 0,0 */ ); - SDL_UpdateRects ( sdl_realscreen, 1, &dest ); + dest++; } } @@ -1085,21 +1087,30 @@ void ui_cachescreen ( unsigned char clearscreen ) { SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a }; rtext = TTF_RenderText_Blended ( g_big_font, "Caching applications artwork...", tmpfontcolor ); if ( clearscreen ) { - dest.x = 20; - dest.y = 20; + dest -> x = 20; + dest -> y = 20; } else { - dest.x = 20; - dest.y = 40; + dest -> x = 20; + dest -> y = 40; } - SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, &dest ); - SDL_UpdateRects ( sdl_realscreen, 1, &dest ); + SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest ); + dest++; // render icon if ( g_imagecache [ IMG_ICON_MISSING ].i ) { - dest.x = rtext -> w + 30 + stepx; - dest.y = 20; - SDL_BlitSurface ( g_imagecache [ IMG_ICON_MISSING ].i, NULL, sdl_realscreen, &dest ); - SDL_UpdateRects ( sdl_realscreen, 1, &dest ); + dest -> x = rtext -> w + 30 + stepx; + dest -> y = 20; + SDL_BlitSurface ( g_imagecache [ IMG_ICON_MISSING ].i, NULL, sdl_realscreen, dest ); + dest++; + } + + // filename + if ( filename ) { + rtext = TTF_RenderText_Blended ( g_tab_font, filename, tmpfontcolor ); + dest -> x = 20; + dest -> y = 50; + SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest ); + dest++; } // move across @@ -1109,6 +1120,8 @@ void ui_cachescreen ( unsigned char clearscreen ) { stepx = 0; } + SDL_UpdateRects ( sdl_realscreen, dest - rects, rects ); + return; } diff --git a/minimenu/mmui.h b/minimenu/mmui.h index e22ee32..ec9ce6c 100644 --- a/minimenu/mmui.h +++ b/minimenu/mmui.h @@ -63,7 +63,7 @@ void ui_render ( unsigned int render_mask ); void ui_loadscreen ( void ); // show screen while loading the menu void ui_discoverscreen ( unsigned char clearscreen ); // screen to show while scanning for apps -void ui_cachescreen ( unsigned char clearscreen ); // while caching icons, categories and preview-pics-Now-mode +void ui_cachescreen ( unsigned char clearscreen, char *filename ); // while caching icons, categories and preview-pics-Now-mode /* internal functions follow */ -- 2.39.2