11 #include "SDL_gfxPrimitives.h"
12 #include "SDL_rotozoom.h"
13 #include "SDL_thread.h"
14 #include <sys/types.h>
18 #include "pnd_logger.h"
20 #include "pnd_container.h"
21 #include "pnd_discovery.h"
23 #include "pnd_device.h"
24 #include "../lib/pnd_pathiter.h"
25 #include "pnd_utility.h"
31 #include "mmwrapcmd.h"
33 #define CHANGED_NOTHING (0)
34 #define CHANGED_CATEGORY (1<<0) /* changed to different category */
35 #define CHANGED_SELECTION (1<<1) /* changed app selection */
36 #define CHANGED_DATAUPDATE (1<<2) /* deferred preview pic or icon came in */
37 #define CHANGED_APPRELOAD (1<<3) /* new set of applications entirely */
38 #define CHANGED_EVERYTHING (1<<4) /* redraw it all! */
39 unsigned int render_mask = CHANGED_EVERYTHING;
43 SDL_Surface *sdl_realscreen = NULL;
44 unsigned int sdl_ticks = 0;
45 SDL_Thread *g_preview_thread = NULL;
47 enum { sdl_user_ticker = 0,
48 sdl_user_finishedpreview = 1,
49 sdl_user_finishedicon = 2,
54 unsigned short int g_scale = 1; // 1 == noscale
56 SDL_Surface *g_imgcache [ IMG_MAX ];
58 TTF_Font *g_big_font = NULL;
59 TTF_Font *g_grid_font = NULL;
60 TTF_Font *g_detailtext_font = NULL;
61 TTF_Font *g_tab_font = NULL;
63 extern pnd_conf_handle g_conf;
65 /* current display state
67 int ui_rows_scrolled_down = 0; // number of rows that should be missing from top of the display
68 mm_appref_t *ui_selected = NULL;
69 unsigned char ui_category = 0; // current category
70 unsigned char ui_catshift = 0; // how many cats are offscreen to the left
72 extern mm_category_t g_categories [ MAX_CATS ];
73 extern unsigned char g_categorycount;
75 static SDL_Surface *ui_scale_image ( SDL_Surface *s, unsigned int maxwidth, int maxheight ); // height -1 means ignore
76 static int ui_selected_index ( void );
78 unsigned char ui_setup ( void ) {
83 SDL_Init ( SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE );
85 SDL_JoystickOpen ( 0 ); // turn on joy-0
87 SDL_WM_SetCaption ( "mmenu", "mmenu" );
89 // hide the mouse cursor if we can
90 if ( SDL_ShowCursor ( -1 ) == 1 ) {
97 unsigned int svm = SDL_SWSURFACE /*| SDL_FULLSCREEN*/ /* 0*/;
98 if ( pnd_conf_get_as_int_d ( g_conf, "display.fullscreen", 0 ) > 0 ) {
99 svm |= SDL_FULLSCREEN;
103 SDL_SetVideoMode ( 800 * g_scale, 480 * g_scale, 16 /*bpp*/, svm );
105 if ( ! sdl_realscreen ) {
106 pnd_log ( pndn_error, "ERROR: Couldn't open SDL real screen; dieing." );
110 pnd_log ( pndn_debug, "Pixel format:" );
111 pnd_log ( pndn_debug, "bpp b: %u\n", sdl_realscreen -> format -> BitsPerPixel );
112 pnd_log ( pndn_debug, "bpp B: %u\n", sdl_realscreen -> format -> BytesPerPixel );
113 pnd_log ( pndn_debug, "R mask: %08x\n", sdl_realscreen -> format -> Rmask );
114 pnd_log ( pndn_debug, "G mask: %08x\n", sdl_realscreen -> format -> Gmask );
115 pnd_log ( pndn_debug, "B mask: %08x\n", sdl_realscreen -> format -> Bmask );
121 /* Set 16-bit stereo audio at 22Khz */
122 fmt.freq = 44100; //22050;
123 fmt.format = AUDIO_S16; //AUDIO_S16;
125 fmt.samples = 2048; /* A good value for games */
126 fmt.callback = mixaudio;
129 /* Open the audio device and start playing sound! */
130 if ( SDL_OpenAudio ( &fmt, NULL ) < 0 ) {
131 zotlog ( "Unable to open audio: %s\n", SDL_GetError() );
135 SDL_PauseAudio ( 0 );
140 //IMG_Init ( IMG_INIT_JPG | IMG_INIT_PNG );
146 if ( TTF_Init() == -1 ) {
147 pnd_log ( pndn_error, "ERROR: Couldn't set up SDL TTF lib\n" );
148 return ( 0 ); // couldn't set up SDL TTF
151 char fullpath [ PATH_MAX ];
153 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "minimenu.font" ) );
154 g_big_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "minimenu.font_ptsize", 24 ) );
155 if ( ! g_big_font ) {
156 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
157 pnd_conf_get_as_char ( g_conf, "minimenu.font" ), pnd_conf_get_as_int_d ( g_conf, "minimenu.font_ptsize", 24 ) );
158 return ( 0 ); // couldn't set up SDL TTF
162 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "grid.font" ) );
163 g_grid_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "grid.font_ptsize", 10 ) );
164 if ( ! g_grid_font ) {
165 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
166 pnd_conf_get_as_char ( g_conf, "grid.font" ), pnd_conf_get_as_int_d ( g_conf, "grid.font_ptsize", 10 ) );
167 return ( 0 ); // couldn't set up SDL TTF
171 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "detailtext.font" ) );
172 g_detailtext_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "detailtext.font_ptsize", 10 ) );
173 if ( ! g_detailtext_font ) {
174 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
175 pnd_conf_get_as_char ( g_conf, "detailtext.font" ), pnd_conf_get_as_int_d ( g_conf, "detailtext.font_ptsize", 10 ) );
176 return ( 0 ); // couldn't set up SDL TTF
180 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "tabs.font" ) );
181 g_tab_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "tabs.font_ptsize", 10 ) );
182 if ( ! g_tab_font ) {
183 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
184 pnd_conf_get_as_char ( g_conf, "tabs.font" ), pnd_conf_get_as_int_d ( g_conf, "tabs.font_ptsize", 10 ) );
185 return ( 0 ); // couldn't set up SDL TTF
191 mm_imgcache_t g_imagecache [ IMG_TRUEMAX ] = {
192 { IMG_BACKGROUND_800480, "graphics.IMG_BACKGROUND_800480" },
193 { IMG_BACKGROUND_TABMASK, "graphics.IMG_BACKGROUND_TABMASK" },
194 { IMG_DETAIL_PANEL, "graphics.IMG_DETAIL_PANEL" },
195 { IMG_DETAIL_BG, "graphics.IMG_DETAIL_BG" },
196 { IMG_SELECTED_ALPHAMASK, "graphics.IMG_SELECTED_ALPHAMASK" },
197 { IMG_TAB_SEL, "graphics.IMG_TAB_SEL" },
198 { IMG_TAB_SEL_L, "graphics.IMG_TAB_SEL_L" },
199 { IMG_TAB_UNSEL, "graphics.IMG_TAB_UNSEL" },
200 { IMG_TAB_UNSEL_L, "graphics.IMG_TAB_UNSEL_L" },
201 { IMG_TAB_LINE, "graphics.IMG_TAB_LINE" },
202 { IMG_TAB_LINEL, "graphics.IMG_TAB_LINEL" },
203 { IMG_TAB_LINER, "graphics.IMG_TAB_LINER" },
204 { IMG_ICON_MISSING, "graphics.IMG_ICON_MISSING" },
205 { IMG_SELECTED_HILITE, "graphics.IMG_SELECTED_HILITE" },
206 { IMG_PREVIEW_MISSING, "graphics.IMG_PREVIEW_MISSING" },
207 { IMG_ARROW_UP, "graphics.IMG_ARROW_UP", },
208 { IMG_ARROW_DOWN, "graphics.IMG_ARROW_DOWN", },
209 { IMG_ARROW_SCROLLBAR, "graphics.IMG_ARROW_SCROLLBAR", },
210 { IMG_HOURGLASS, "graphics.IMG_HOURGLASS", },
214 unsigned char ui_imagecache ( char *basepath ) {
216 char fullpath [ PATH_MAX ];
220 for ( i = 0; i < IMG_MAX; i++ ) {
222 if ( g_imagecache [ i ].id != i ) {
223 pnd_log ( pndn_error, "ERROR: Internal table mismatch during caching [%u]\n", i );
227 char *filename = pnd_conf_get_as_char ( g_conf, g_imagecache [ i ].confname );
230 pnd_log ( pndn_error, "ERROR: Missing filename in conf for key: %s\n", g_imagecache [ i ].confname );
234 if ( filename [ 0 ] == '/' ) {
235 strncpy ( fullpath, filename, PATH_MAX );
237 sprintf ( fullpath, "%s/%s", basepath, filename );
240 if ( ! ( g_imagecache [ i ].i = IMG_Load ( fullpath ) ) ) {
241 pnd_log ( pndn_error, "ERROR: Couldn't load static cache image: %s\n", fullpath );
248 //g_imagecache [ IMG_SELECTED_ALPHAMASK ].i = SDL_CreateRGBSurface ( SDL_SWSURFACE, 60, 60, 32, 0xFF0000, 0x00FF00, 0xFF, 0xFF000000 );
249 //boxRGBA ( g_imagecache [ IMG_SELECTED_ALPHAMASK ].i, 0, 0, 60, 60, 100, 100, 100, 250 );
255 g_imagecache [ IMG_ICON_MISSING ].i = ui_scale_image ( g_imagecache [ IMG_ICON_MISSING ].i, pnd_conf_get_as_int_d ( g_conf, "grid.icon_max_width", 50 ), -1 );
256 // scale text hilight
257 g_imagecache [ IMG_SELECTED_HILITE ].i = ui_scale_image ( g_imagecache [ IMG_SELECTED_HILITE ].i, pnd_conf_get_as_int_d ( g_conf, "grid.text_width", 50 ), -1 );
258 // scale preview no-pic
259 g_imagecache [ IMG_PREVIEW_MISSING ].i = ui_scale_image ( g_imagecache [ IMG_PREVIEW_MISSING ].i,
260 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 50 ),
261 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 50 ) );
263 // set alpha on detail panel
264 //SDL_SetAlpha ( g_imagecache [ IMG_DETAIL_BG ].i, SDL_SRCALPHA, pnd_conf_get_as_int_d ( g_conf, "display.detail_bg_alpha", 50 ) );
269 void ui_render ( void ) {
272 // divide width: 550 / 250
273 // divide left side: 5 columns == 110px width
274 // 20px buffer either side == 70px wide icon + 20 + 20?
276 // what jobs to do during render?
280 #define R_TABS (1<<1)
281 #define R_DETAIL (1<<2)
282 #define R_GRID (1<<3)
284 #define R_ALL (R_BG|R_TABS|R_DETAIL|R_GRID)
286 unsigned int render_jobs_b = 0;
288 if ( render_mask & CHANGED_EVERYTHING ) {
289 render_jobs_b |= R_ALL;
292 if ( render_mask & CHANGED_SELECTION ) {
293 render_jobs_b |= R_GRID;
294 render_jobs_b |= R_DETAIL;
297 if ( render_mask & CHANGED_CATEGORY ) {
298 render_jobs_b |= R_ALL;
301 render_mask = CHANGED_NOTHING;
305 unsigned int icon_rows;
308 SDL_Rect rects [ MAXRECTS ], src;
309 SDL_Rect *dest = rects;
310 bzero ( dest, sizeof(SDL_Rect)*MAXRECTS );
312 unsigned int row, displayrow, col;
313 mm_appref_t *appiter;
315 unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
317 unsigned char row_max = pnd_conf_get_as_int_d ( g_conf, "grid.row_max", 4 );
318 unsigned char col_max = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 );
320 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
321 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
322 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
323 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
325 unsigned int grid_offset_x = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_x" );
326 unsigned int grid_offset_y = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_y" );
328 unsigned int icon_offset_x = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_x" );
329 unsigned int icon_offset_y = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_y" );
330 unsigned int icon_max_width = pnd_conf_get_as_int ( g_conf, "grid.icon_max_width" );
331 unsigned int icon_max_height = pnd_conf_get_as_int ( g_conf, "grid.icon_max_height" );
332 unsigned int sel_icon_offset_x = pnd_conf_get_as_int_d ( g_conf, "grid.sel_offoffset_x", 0 );
333 unsigned int sel_icon_offset_y = pnd_conf_get_as_int_d ( g_conf, "grid.sel_offoffset_y", 0 );
335 unsigned int text_width = pnd_conf_get_as_int ( g_conf, "grid.text_width" );
336 unsigned int text_clip_x = pnd_conf_get_as_int ( g_conf, "grid.text_clip_x" );
337 unsigned int text_offset_x = pnd_conf_get_as_int ( g_conf, "grid.text_offset_x" );
338 unsigned int text_offset_y = pnd_conf_get_as_int ( g_conf, "grid.text_offset_y" );
340 unsigned int cell_width = pnd_conf_get_as_int ( g_conf, "grid.cell_width" );
341 unsigned int cell_height = pnd_conf_get_as_int ( g_conf, "grid.cell_height" );
343 // how many total rows do we need?
344 icon_rows = g_categories [ ui_category ].refcount / col_max;
345 if ( g_categories [ ui_category ].refcount % col_max > 0 ) {
349 // if no selected app yet, select the first one
351 if ( ! ui_selected ) {
352 ui_selected = g_categories [ ui_category ].refs;
356 // reset touchscreen regions
359 // ensure selection is visible
362 int index = ui_selected_index();
363 int topleft = col_max * ui_rows_scrolled_down;
364 int botright = ( col_max * ( ui_rows_scrolled_down + row_max ) - 1 );
366 pnd_log ( PND_LOG_DEFAULT, "index %u tl %u br %u\n", index, topleft, botright );
368 if ( index < topleft ) {
369 ui_rows_scrolled_down -= pnd_conf_get_as_int_d ( g_conf, "grid.scroll_increment", 1 );
370 render_jobs_b |= R_ALL;
371 } else if ( index > botright ) {
372 ui_rows_scrolled_down += pnd_conf_get_as_int_d ( g_conf, "grid.scroll_increment", 1 );
373 render_jobs_b |= R_ALL;
376 if ( ui_rows_scrolled_down < 0 ) {
377 ui_rows_scrolled_down = 0;
378 } else if ( ui_rows_scrolled_down > icon_rows ) {
379 ui_rows_scrolled_down = icon_rows;
385 if ( render_jobs_b & R_BG ) {
387 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
390 dest -> w = sdl_realscreen -> w;
391 dest -> h = sdl_realscreen -> h;
392 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, dest /* 0,0 */ );
397 if ( g_imagecache [ IMG_BACKGROUND_TABMASK ].i ) {
400 dest -> w = sdl_realscreen -> w;
401 dest -> h = sdl_realscreen -> h;
402 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_TABMASK ].i, NULL /* whole image */, sdl_realscreen, dest /* 0,0 */ );
409 if ( g_imagecache [ IMG_TAB_SEL ].i && g_imagecache [ IMG_TAB_UNSEL ].i ) {
410 unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
411 unsigned int tab_height = pnd_conf_get_as_int ( g_conf, "tabs.tab_height" );
412 unsigned int tab_selheight = pnd_conf_get_as_int ( g_conf, "tabs.tab_selheight" );
413 unsigned int tab_offset_x = pnd_conf_get_as_int ( g_conf, "tabs.tab_offset_x" );
414 unsigned int tab_offset_y = pnd_conf_get_as_int ( g_conf, "tabs.tab_offset_y" );
415 unsigned int text_offset_x = pnd_conf_get_as_int ( g_conf, "tabs.text_offset_x" );
416 unsigned int text_offset_y = pnd_conf_get_as_int ( g_conf, "tabs.text_offset_y" );
417 unsigned int text_width = pnd_conf_get_as_int ( g_conf, "tabs.text_width" );
418 unsigned int maxtab = ( screen_width / tab_width ) < g_categorycount ? ( screen_width / tab_width ) + ui_catshift : g_categorycount + ui_catshift;
419 unsigned int maxtabspot = ( screen_width / tab_width );
421 // draw tabs with categories
422 for ( col = ui_catshift;
429 // if this is the first (leftmost) tab, we use different artwork
430 // than if the other tabs (so skinner can link lines up nicely.)
431 if ( col == ui_catshift ) {
432 // leftmost tab, special case
434 if ( col == ui_category ) {
435 s = g_imagecache [ IMG_TAB_SEL_L ].i;
437 s = g_imagecache [ IMG_TAB_UNSEL_L ].i;
441 // normal (not leftmost) tab
443 if ( col == ui_category ) {
444 s = g_imagecache [ IMG_TAB_SEL ].i;
446 s = g_imagecache [ IMG_TAB_UNSEL ].i;
449 } // first col, or not first col?
456 if ( col == ui_category ) {
457 src.h = tab_selheight;
465 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
466 dest -> y = tab_offset_y;
469 ui_register_tab ( col, dest -> x, dest -> y, tab_width, tab_height );
471 if ( render_jobs_b & R_TABS ) {
472 //pnd_log ( pndn_debug, "tab %u at %ux%u\n", col, dest.x, dest.y );
473 SDL_BlitSurface ( s, &src, sdl_realscreen, dest );
477 if ( col == ui_category ) {
478 // no line for selected tab
480 if ( col - ui_catshift == 0 ) {
481 s = g_imagecache [ IMG_TAB_LINEL ].i;
482 } else if ( col - ui_catshift == maxtabspot - 1 ) {
483 s = g_imagecache [ IMG_TAB_LINER ].i;
485 s = g_imagecache [ IMG_TAB_LINE ].i;
487 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
488 dest -> y = tab_offset_y + tab_height;
489 SDL_BlitSurface ( s, NULL /* whole image */, sdl_realscreen, dest );
495 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
496 rtext = TTF_RenderText_Blended ( g_tab_font, g_categories [ col ].catname, tmpfontcolor );
499 src.w = rtext -> w < text_width ? rtext -> w : text_width;
501 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width ) + text_offset_x;
502 dest -> y = tab_offset_y + text_offset_y;
503 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
504 SDL_FreeSurface ( rtext );
511 if ( render_jobs_b & R_TABS ) {
513 // draw tab lines under where tabs would be if we had categories
514 for ( /* foo */; col < maxtabspot; col++ ) {
517 if ( col - ui_catshift == 0 ) {
518 s = g_imagecache [ IMG_TAB_LINEL ].i;
519 } else if ( col - ui_catshift == maxtabspot - 1 ) {
520 s = g_imagecache [ IMG_TAB_LINER ].i;
522 s = g_imagecache [ IMG_TAB_LINE ].i;
524 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
525 dest -> y = tab_offset_y + tab_height;
526 SDL_BlitSurface ( s, NULL /* whole image */, sdl_realscreen, dest );
535 // scroll bars and arrows
536 if ( render_jobs_b & R_BG ) {
537 unsigned char show_bar = 0;
540 if ( ui_rows_scrolled_down && g_imagecache [ IMG_ARROW_UP ].i ) {
541 dest -> x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_x", 450 );
542 dest -> y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_y", 80 );
543 SDL_BlitSurface ( g_imagecache [ IMG_ARROW_UP ].i, NULL /* whole image */, sdl_realscreen, dest );
550 if ( ui_rows_scrolled_down + row_max < icon_rows && g_imagecache [ IMG_ARROW_DOWN ].i ) {
551 dest -> x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_x", 450 );
552 dest -> y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_y", 80 );
553 SDL_BlitSurface ( g_imagecache [ IMG_ARROW_DOWN ].i, NULL /* whole image */, sdl_realscreen, dest );
560 // show scrollbar as well
563 src.w = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_w", 10 );
564 src.h = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_h", 100 );
565 dest -> x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_x", 450 );
566 dest -> y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_y", 100 );
567 SDL_BlitSurface ( g_imagecache [ IMG_ARROW_SCROLLBAR ].i, &src /* whole image */, sdl_realscreen, dest );
571 } // r_bg, scroll bars
573 // render detail pane bg
574 if ( render_jobs_b & R_DETAIL ) {
576 if ( pnd_conf_get_as_int_d ( g_conf, "detailpane.show", 1 ) ) {
579 if ( g_imagecache [ IMG_DETAIL_BG ].i ) {
580 src.x = 0; // pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
581 src.y = 0; // pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
582 src.w = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> w;
583 src.h = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> h;
584 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
585 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
586 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
590 // render detail pane
591 if ( g_imagecache [ IMG_DETAIL_PANEL ].i ) {
592 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
593 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
594 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_PANEL ].i, NULL /* whole image */, sdl_realscreen, dest );
598 } // detailpane frame/bg
602 // anything to render?
603 if ( render_jobs_b & R_GRID ) {
605 // if just rendering grid, and nothing else, better clear it first
606 if ( ! ( render_jobs_b & R_BG ) ) {
607 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
608 src.x = grid_offset_x;
609 src.y = grid_offset_y + sel_icon_offset_y;
610 src.w = col_max * cell_width;
611 src.h = row_max * cell_height;
613 dest -> x = grid_offset_x;
614 dest -> y = grid_offset_y + sel_icon_offset_y;
616 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, &src, sdl_realscreen, dest );
622 if ( g_categories [ ui_category ].refs ) {
624 appiter = g_categories [ ui_category ].refs;
628 // until we run out of apps, or run out of space
629 while ( appiter != NULL ) {
631 for ( col = 0; col < col_max && appiter != NULL; col++ ) {
633 // do we even need to render it? or are we suppressing it due to rows scrolled off the top?
634 if ( row >= ui_rows_scrolled_down ) {
636 // selected? show hilights
637 if ( appiter == ui_selected ) {
638 SDL_Surface *s = g_imagecache [ IMG_SELECTED_ALPHAMASK ].i;
640 //dest -> x = grid_offset_x + ( col * cell_width ) + icon_offset_x + ( ( icon_max_width - s -> w ) / 2 );
641 dest -> x = grid_offset_x + ( col * cell_width ) + icon_offset_x + sel_icon_offset_x;
642 //dest -> y = grid_offset_y + ( displayrow * cell_height ) + icon_offset_y + ( ( icon_max_height - s -> h ) / 2 );
643 dest -> y = grid_offset_y + ( displayrow * cell_height ) + icon_offset_y + sel_icon_offset_y;
644 SDL_BlitSurface ( s, NULL /* all */, sdl_realscreen, dest );
647 dest -> x = grid_offset_x + ( col * cell_width ) + text_clip_x;
648 dest -> y = grid_offset_y + ( displayrow * cell_height ) + pnd_conf_get_as_int ( g_conf, "grid.text_hilite_offset_y" );
649 SDL_BlitSurface ( g_imagecache [ IMG_SELECTED_HILITE ].i, NULL /* all */, sdl_realscreen, dest );
654 mm_cache_t *ic = cache_query_icon ( appiter -> ref -> unique_id );
655 SDL_Surface *iconsurface;
657 iconsurface = ic -> i;
659 //pnd_log ( pndn_warning, "WARNING: TBD: Need Missin-icon icon for '%s'\n", IFNULL(appiter -> ref -> title_en,"No Name") );
660 iconsurface = g_imagecache [ IMG_ICON_MISSING ].i;
663 //pnd_log ( pndn_debug, "Got an icon for '%s'\n", IFNULL(appiter -> ref -> title_en,"No Name") );
669 dest -> x = grid_offset_x + ( col * cell_width ) + icon_offset_x + (( icon_max_width - iconsurface -> w ) / 2);
670 dest -> y = grid_offset_y + ( displayrow * cell_height ) + icon_offset_y + (( icon_max_height - iconsurface -> h ) / 2);
672 SDL_BlitSurface ( iconsurface, &src, sdl_realscreen, dest );
675 ui_register_app ( appiter, dest -> x, dest -> y, src.w, src.h );
682 if ( appiter -> ref -> title_en ) {
684 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
685 rtext = TTF_RenderText_Blended ( g_grid_font, appiter -> ref -> title_en, tmpfontcolor );
688 src.w = text_width < rtext -> w ? text_width : rtext -> w;
690 if ( rtext -> w > text_width ) {
691 dest -> x = grid_offset_x + ( col * cell_width ) + text_clip_x;
693 dest -> x = grid_offset_x + ( col * cell_width ) + text_offset_x - ( rtext -> w / 2 );
695 dest -> y = grid_offset_y + ( displayrow * cell_height ) + text_offset_y;
696 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
697 SDL_FreeSurface ( rtext );
701 } // display now? or scrolled away..
704 appiter = appiter -> next;
706 } // for column 1...X
708 if ( row >= ui_rows_scrolled_down ) {
714 // are we done displaying rows?
715 if ( displayrow >= row_max ) {
722 // no apps to render?
723 pnd_log ( pndn_rem, "No applications to render?\n" );
729 if ( ui_selected && render_jobs_b & R_DETAIL ) {
731 unsigned int cell_offset_x = pnd_conf_get_as_int ( g_conf, "detailtext.cell_offset_x" );
732 unsigned int cell_offset_y = pnd_conf_get_as_int ( g_conf, "detailtext.cell_offset_y" );
733 unsigned int cell_width = pnd_conf_get_as_int ( g_conf, "detailtext.cell_width" );
735 unsigned int desty = cell_offset_y;
740 if ( ui_selected -> ref -> title_en ) {
742 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
743 rtext = TTF_RenderText_Blended ( g_detailtext_font, ui_selected -> ref -> title_en, tmpfontcolor );
746 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
748 dest -> x = cell_offset_x;
750 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
751 SDL_FreeSurface ( rtext );
758 if ( ui_selected -> ref -> main_category ) {
760 sprintf ( buffer, "Category: %s", ui_selected -> ref -> main_category );
763 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
764 rtext = TTF_RenderText_Blended ( g_detailtext_font, buffer, tmpfontcolor );
767 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
769 dest -> x = cell_offset_x;
771 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
772 SDL_FreeSurface ( rtext );
779 if ( ui_selected -> ref -> clockspeed ) {
781 sprintf ( buffer, "CPU Clock: %s", ui_selected -> ref -> clockspeed );
784 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
785 rtext = TTF_RenderText_Blended ( g_detailtext_font, buffer, tmpfontcolor );
788 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
790 dest -> x = cell_offset_x;
792 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
793 SDL_FreeSurface ( rtext );
798 // show sub-app# on right side of cpu clock?
799 //if ( ui_selected -> ref -> subapp_number )
801 sprintf ( buffer, "(app#%u)", ui_selected -> ref -> subapp_number );
804 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
805 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, tmpfontcolor );
806 dest -> x = cell_offset_x + cell_width - rtext -> w;
807 dest -> y = desty - src.h;
808 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
809 SDL_FreeSurface ( rtext );
814 #if 0 // merged into hint-line
815 if ( ui_selected -> ref -> info_filename ) {
817 sprintf ( buffer, "Documentation - hit Y" );
820 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
821 rtext = TTF_RenderText_Blended ( g_detailtext_font, buffer, tmpfontcolor );
824 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
826 dest -> x = cell_offset_x;
828 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
829 SDL_FreeSurface ( rtext );
836 if ( ui_selected -> ovrh ) {
841 desty += 5; // a touch of spacing can't hurt
843 for ( i = 1; i < 4; i++ ) {
844 sprintf ( buffer, "Application-%u.note-%u", ui_selected -> ref -> subapp_number, i );
845 n = pnd_conf_get_as_char ( ui_selected -> ovrh, buffer );
849 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
850 rtext = TTF_RenderText_Blended ( g_detailtext_font, n, tmpfontcolor );
853 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
855 dest -> x = cell_offset_x;
857 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
858 SDL_FreeSurface ( rtext );
864 } // r_detail -> notes
867 mm_cache_t *ic = cache_query_preview ( ui_selected -> ref -> unique_id );
868 SDL_Surface *previewpic;
871 previewpic = ic -> i;
873 previewpic = g_imagecache [ IMG_PREVIEW_MISSING ].i;
877 dest -> x = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_offset_x", 50 ) +
878 ( ( pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 50 ) - previewpic -> w ) / 2 );
879 dest -> y = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_offset_y", 50 );
880 SDL_BlitSurface ( previewpic, NULL /* whole image */, sdl_realscreen, dest );
884 } // r_detail && selected?
890 if ( render_jobs_b & R_BG ) {
891 static int last_battlevel = 0;
892 static unsigned char batterylevel = 0;
895 if ( time ( NULL ) - last_battlevel > 60 ) {
896 batterylevel = pnd_device_get_battery_gauge_perc();
897 last_battlevel = time ( NULL );
900 sprintf ( buffer, "Battery: %u%%", batterylevel );
903 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
904 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, tmpfontcolor );
905 dest -> x = pnd_conf_get_as_int_d ( g_conf, "display.battery_x", 20 );
906 dest -> y = pnd_conf_get_as_int_d ( g_conf, "display.battery_y", 450 );
907 SDL_BlitSurface ( rtext, NULL /* all */, sdl_realscreen, dest );
908 SDL_FreeSurface ( rtext );
913 if ( pnd_conf_get_as_char ( g_conf, "display.hintline" ) ) {
915 unsigned int hintx, hinty;
916 hintx = pnd_conf_get_as_int_d ( g_conf, "display.hint_x", 40 );
917 hinty = pnd_conf_get_as_int_d ( g_conf, "display.hint_y", 450 );
918 static unsigned int lastwidth = 3000;
920 if ( ui_selected && ui_selected -> ref -> info_filename ) {
921 buffer = "Documentation - hit Y";
923 buffer = pnd_conf_get_as_char ( g_conf, "display.hintline" );
927 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
928 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, tmpfontcolor );
931 if ( ! ( render_jobs_b & R_BG ) ) {
938 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_TABMASK ].i, &src, sdl_realscreen, dest );
940 lastwidth = rtext -> w;
946 SDL_BlitSurface ( rtext, NULL /* all */, sdl_realscreen, dest );
947 SDL_FreeSurface ( rtext );
952 if ( render_jobs_b & R_BG &&
953 pnd_conf_get_as_int_d ( g_conf, "display.clock_x", -1 ) != -1 )
957 time_t t = time ( NULL );
958 struct tm *tm = localtime ( &t );
959 strftime ( buffer, 50, "%a %H:%M %F", tm );
962 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
963 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, tmpfontcolor );
964 dest -> x = pnd_conf_get_as_int_d ( g_conf, "display.clock_x", 700 );
965 dest -> y = pnd_conf_get_as_int_d ( g_conf, "display.clock_y", 450 );
966 SDL_BlitSurface ( rtext, NULL /* all */, sdl_realscreen, dest );
967 SDL_FreeSurface ( rtext );
971 // update all the rects and send it all to sdl
972 // - at this point, we could probably just do 1 rect, of the
973 // whole screen, and be faster :/
974 SDL_UpdateRects ( sdl_realscreen, dest - rects, rects );
978 void ui_process_input ( unsigned char block_p ) {
981 unsigned char ui_event = 0; // if we get a ui event, flip to 1 and break
982 //static ui_sdl_button_e ui_mask = uisb_none; // current buttons down
984 while ( ! ui_event &&
985 block_p ? SDL_WaitEvent ( &event ) : SDL_PollEvent ( &event ) )
988 switch ( event.type ) {
993 if ( event.user.code == sdl_user_ticker ) {
995 // timer went off, time to load something
996 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.load_previews_later", 0 ) ) {
998 // load the preview pics now!
999 pnd_disco_t *iter = ui_selected -> ref;
1001 if ( iter -> preview_pic1 ) {
1003 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.threaded_preview", 0 ) ) {
1004 // load in bg thread, make user experience chuggy
1006 g_preview_thread = SDL_CreateThread ( (void*)ui_threaded_defered_preview, iter );
1008 if ( ! g_preview_thread ) {
1009 pnd_log ( pndn_error, "ERROR: Couldn't create preview thread\n" );
1013 // load it now, make user wait
1015 if ( ! cache_preview ( iter, pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 200 ),
1016 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 180 ) )
1019 pnd_log ( pndn_debug, " Couldn't load preview pic: '%s' -> '%s'\n",
1020 IFNULL(iter->title_en,"No Name"), iter -> preview_pic1 );
1025 } // got a preview at all?
1030 } else if ( event.user.code == sdl_user_finishedpreview ) {
1032 // if we just finished the one we happen to be looking at, better redraw now; otherwise, if
1033 // we finished another, no big woop
1034 if ( ui_selected && event.user.data1 == ui_selected -> ref ) {
1038 } else if ( event.user.code == sdl_user_finishedicon ) {
1039 // redraw, so we can show the newly loaded icon
1044 render_mask |= CHANGED_EVERYTHING;
1048 #if 0 // joystick motion
1049 case SDL_JOYAXISMOTION:
1051 pnd_log ( PND_LOG_DEFAULT, "joystick axis\n" );
1053 if ( event.jaxis.axis == 0 ) {
1055 if ( event.jaxis.value < 0 ) {
1057 pnd_log ( PND_LOG_DEFAULT, "joystick axis - LEFT\n" );
1058 } else if ( event.jaxis.value > 0 ) {
1059 ui_push_right ( 0 );
1060 pnd_log ( PND_LOG_DEFAULT, "joystick axis - RIGHT\n" );
1062 } else if ( event.jaxis.axis == 1 ) {
1064 if ( event.jaxis.value < 0 ) {
1066 } else if ( event.jaxis.value > 0 ) {
1076 #if 0 // joystick buttons
1077 case SDL_JOYBUTTONDOWN:
1079 pnd_log ( PND_LOG_DEFAULT, "joystick button down %u\n", event.jbutton.button );
1081 if ( event.jbutton.button == 0 ) { // B
1083 } else if ( event.jbutton.button == 1 ) { // Y
1085 } else if ( event.jbutton.button == 2 ) { // X
1087 } else if ( event.jbutton.button == 3 ) { // A
1090 } else if ( event.jbutton.button == 4 ) { // Select
1091 ui_mask |= uisb_select;
1092 } else if ( event.jbutton.button == 5 ) { // Start
1093 ui_mask |= uisb_start;
1095 } else if ( event.jbutton.button == 7 ) { // L
1097 } else if ( event.jbutton.button == 8 ) { // R
1106 case SDL_JOYBUTTONUP:
1108 pnd_log ( PND_LOG_DEFAULT, "joystick button up %u\n", event.jbutton.button );
1110 if ( event.jbutton.button == 0 ) { // B
1113 } else if ( event.jbutton.button == 1 ) { // Y
1115 } else if ( event.jbutton.button == 2 ) { // X
1117 } else if ( event.jbutton.button == 3 ) { // A
1120 } else if ( event.jbutton.button == 4 ) { // Select
1121 ui_mask &= ~uisb_select;
1122 } else if ( event.jbutton.button == 5 ) { // Start
1123 ui_mask &= ~uisb_start;
1125 } else if ( event.jbutton.button == 7 ) { // L
1128 } else if ( event.jbutton.button == 8 ) { // R
1139 #if 1 // keyboard events
1142 //pnd_log ( pndn_debug, "key up %u\n", event.key.keysym.sym );
1144 // SDLK_LALT -> Start
1147 if ( event.key.keysym.sym == SDLK_RIGHT ) {
1148 ui_push_right ( 0 );
1150 } else if ( event.key.keysym.sym == SDLK_LEFT ) {
1153 } else if ( event.key.keysym.sym == SDLK_UP ) {
1156 } else if ( event.key.keysym.sym == SDLK_DOWN ) {
1159 } else if ( event.key.keysym.sym == SDLK_SPACE || event.key.keysym.sym == SDLK_END ) {
1162 } else if ( event.key.keysym.sym == SDLK_z || event.key.keysym.sym == SDLK_RSHIFT ) {
1165 } else if ( event.key.keysym.sym == SDLK_x || event.key.keysym.sym == SDLK_RCTRL ) {
1168 } else if ( event.key.keysym.sym == SDLK_y || event.key.keysym.sym == SDLK_PAGEUP ) {
1170 if ( ui_selected ) {
1171 ui_show_info ( pnd_run_script, ui_selected -> ref );
1175 } else if ( event.key.keysym.sym == SDLK_LALT ) { // start button
1179 } else if ( event.key.keysym.sym == SDLK_LCTRL /*LALT*/ ) { // select button
1180 char *opts [ 20 ] = {
1181 "Return to Minimenu",
1183 "Rescan for Applications",
1184 "Cache previews to SD now",
1185 "Run xfce4 from Minimenu",
1186 "Run a terminal/console",
1187 "Exit and run xfce4",
1188 "Exit and run pmenu",
1190 "Select a Minimenu skin",
1193 int sel = ui_modal_single_menu ( opts, 11, "Minimenu", "Enter to select; other to return." );
1195 char buffer [ 100 ];
1198 } else if ( sel == 1 ) {
1200 sprintf ( buffer, "sudo poweroff" );
1202 } else if ( sel == 2 ) {
1204 pnd_log ( pndn_debug, "Freeing up applications\n" );
1205 applications_free();
1206 pnd_log ( pndn_debug, "Rescanning applications\n" );
1207 applications_scan();
1210 ui_rows_scrolled_down = 0;
1211 } else if ( sel == 3 ) {
1212 // cache preview to SD now
1213 extern pnd_box_handle g_active_apps;
1214 pnd_box_handle h = g_active_apps;
1216 unsigned int maxwidth, maxheight;
1217 maxwidth = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 200 );
1218 maxheight = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 180 );
1220 pnd_disco_t *iter = pnd_box_get_head ( h );
1225 if ( ! cache_preview ( iter, maxwidth, maxheight ) ) {
1226 pnd_log ( pndn_debug, "Force cache: Couldn't load preview pic: '%s' -> '%s'\n",
1227 IFNULL(iter->title_en,"No Name"), iter -> preview_pic1 );
1231 iter = pnd_box_get_next ( iter );
1234 } else if ( sel == 4 ) {
1236 char buffer [ PATH_MAX ];
1237 sprintf ( buffer, "%s %s\n", MM_RUN, "/usr/bin/startxfce4" );
1238 emit_and_quit ( buffer );
1239 } else if ( sel == 5 ) {
1242 argv [ 0 ] = pnd_conf_get_as_char ( g_conf, "utility.terminal" );
1246 ui_forkexec ( argv );
1249 } else if ( sel == 6 ) {
1251 sprintf ( buffer, "echo startxfce4 > /tmp/gui.load" );
1253 emit_and_quit ( buffer );
1254 //sprintf ( buffer, "sudo poweroff" );
1255 //system ( buffer );
1257 } else if ( sel == 7 ) {
1259 sprintf ( buffer, "echo pmenu > /tmp/gui.load" );
1261 emit_and_quit ( buffer );
1262 //sprintf ( buffer, "sudo poweroff" );
1263 //system ( buffer );
1265 } else if ( sel == 8 ) {
1266 emit_and_quit ( MM_QUIT );
1267 } else if ( sel == 9 ) {
1269 if ( ui_pick_skin() ) {
1270 emit_and_quit ( MM_RESTART );
1272 } else if ( sel == 10 ) {
1277 render_mask |= CHANGED_EVERYTHING;
1281 if ( event.key.keysym.sym == SDLK_q ) {
1282 emit_and_quit ( MM_QUIT );
1288 #if 1 // mouse / touchscreen
1290 case SDL_MOUSEBUTTONDOWN:
1291 if ( event.button.button == SDL_BUTTON_LEFT ) {
1292 cb_pointer_press ( gc, event.button.x / g_scale, event.button.y / g_scale );
1298 case SDL_MOUSEBUTTONUP:
1299 if ( event.button.button == SDL_BUTTON_LEFT ) {
1300 ui_touch_act ( event.button.x, event.button.y );
1313 } // switch event type
1320 void ui_push_left ( unsigned char forcecoil ) {
1322 if ( ! ui_selected ) {
1323 ui_push_right ( 0 );
1327 // what column we in?
1328 unsigned int col = ui_determine_screen_col ( ui_selected );
1330 // are we already at first item?
1331 if ( forcecoil == 0 &&
1332 pnd_conf_get_as_int_d ( g_conf, "grid.wrap_horiz_samerow", 0 ) &&
1335 unsigned int i = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 ) - 1;
1336 while ( i && ui_selected -> next ) {
1337 ui_push_right ( 0 );
1341 } else if ( g_categories [ ui_category ].refs == ui_selected ) {
1342 // can't go any more left, we're at the head
1345 // figure out the previous item; yay for singly linked list :/
1346 mm_appref_t *i = g_categories [ ui_category ].refs;
1348 if ( i -> next == ui_selected ) {
1356 ui_set_selected ( ui_selected );
1361 void ui_push_right ( unsigned char forcecoil ) {
1363 if ( ui_selected ) {
1365 // what column we in?
1366 unsigned int col = ui_determine_screen_col ( ui_selected );
1369 if ( forcecoil == 0 &&
1370 pnd_conf_get_as_int_d ( g_conf, "grid.wrap_horiz_samerow", 0 ) &&
1371 // and selected is far-right, or last icon in category (might not be far right)
1372 ( ( col == pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 ) - 1 ) ||
1373 ( ui_selected -> next == NULL ) )
1377 //unsigned int i = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 ) - 1;
1378 while ( col /*i*/ ) {
1384 // just go to the next
1386 if ( ui_selected -> next ) {
1387 ui_selected = ui_selected -> next;
1393 ui_selected = g_categories [ ui_category ].refs;
1396 ui_set_selected ( ui_selected );
1401 void ui_push_up ( void ) {
1402 unsigned char col_max = pnd_conf_get_as_int ( g_conf, "grid.col_max" );
1404 if ( ! ui_selected ) {
1409 unsigned int row = ui_determine_row ( ui_selected );
1412 pnd_conf_get_as_int_d ( g_conf, "grid.wrap_vert_stop", 1 ) == 0 )
1414 // wrap around instead
1416 unsigned int col = ui_determine_screen_col ( ui_selected );
1419 ui_selected = g_categories [ ui_category ].refs;
1420 while ( ui_selected -> next ) {
1421 ui_selected = ui_selected -> next;
1424 // try to move to same column
1425 unsigned int newcol = ui_determine_screen_col ( ui_selected );
1426 if ( newcol > col ) {
1434 // scroll down to show it
1435 int r = ui_determine_row ( ui_selected ) - 1;
1436 if ( r - pnd_conf_get_as_int ( g_conf, "grid.row_max" ) > 0 ) {
1437 ui_rows_scrolled_down = (unsigned int) r;
1441 // stop at top/bottom
1453 void ui_push_down ( void ) {
1454 unsigned char col_max = pnd_conf_get_as_int ( g_conf, "grid.col_max" );
1456 if ( ui_selected ) {
1459 unsigned int row = ui_determine_row ( ui_selected );
1462 unsigned int icon_rows = g_categories [ ui_category ].refcount / col_max;
1463 if ( g_categories [ ui_category ].refcount % col_max > 0 ) {
1468 if ( row == ( icon_rows - 1 ) &&
1469 pnd_conf_get_as_int_d ( g_conf, "grid.wrap_vert_stop", 1 ) == 0 )
1472 unsigned char col = ui_determine_screen_col ( ui_selected );
1474 ui_selected = g_categories [ ui_category ].refs;
1477 ui_selected = ui_selected -> next;
1481 ui_rows_scrolled_down = 0;
1483 render_mask |= CHANGED_EVERYTHING;
1488 ui_push_right ( 1 );
1495 ui_push_right ( 0 );
1501 void ui_push_exec ( void ) {
1503 if ( ui_selected ) {
1504 pnd_apps_exec_disco ( pnd_run_script, ui_selected -> ref, PND_EXEC_OPTION_NORUN, NULL );
1505 char buffer [ PATH_MAX ];
1506 sprintf ( buffer, "%s %s\n", MM_RUN, pnd_apps_exec_runline() );
1507 emit_and_quit ( buffer );
1513 void ui_push_ltrigger ( void ) {
1514 unsigned char oldcat = ui_category;
1516 if ( ui_category > 0 ) {
1519 if ( pnd_conf_get_as_int_d ( g_conf, "tabs.wraparound", 0 ) > 0 ) {
1520 ui_category = g_categorycount - 1;
1524 if ( oldcat != ui_category ) {
1526 ui_set_selected ( ui_selected );
1529 // make tab visible?
1530 if ( ui_catshift > 0 && ui_category == ui_catshift - 1 ) {
1535 ui_rows_scrolled_down = 0;
1537 render_mask |= CHANGED_CATEGORY;
1542 void ui_push_rtrigger ( void ) {
1543 unsigned char oldcat = ui_category;
1545 unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
1546 unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
1548 if ( ui_category < ( g_categorycount - 1 ) ) {
1551 if ( pnd_conf_get_as_int_d ( g_conf, "tabs.wraparound", 0 ) > 0 ) {
1556 if ( oldcat != ui_category ) {
1558 ui_set_selected ( ui_selected );
1561 // make tab visible?
1562 if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
1567 ui_rows_scrolled_down = 0;
1569 render_mask |= CHANGED_CATEGORY;
1574 SDL_Surface *ui_scale_image ( SDL_Surface *s, unsigned int maxwidth, int maxheight ) {
1575 double scale = 1000000.0;
1576 double scalex = 1000000.0;
1577 double scaley = 1000000.0;
1578 SDL_Surface *scaled;
1580 scalex = (double)maxwidth / (double)s -> w;
1582 if ( maxheight == -1 ) {
1585 scaley = (double)maxheight / (double)s -> h;
1587 if ( scaley < scalex ) {
1595 scaled = rotozoomSurface ( s, 0 /* angle*/, scale /* scale */, 1 /* smooth==1*/ );
1596 SDL_FreeSurface ( s );
1602 void ui_loadscreen ( void ) {
1606 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
1607 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
1608 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
1609 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
1612 SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
1616 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
1617 rtext = TTF_RenderText_Blended ( g_big_font, "Setting up menu...", tmpfontcolor );
1620 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, &dest );
1621 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1622 SDL_FreeSurface ( rtext );
1627 void ui_discoverscreen ( unsigned char clearscreen ) {
1631 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
1632 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
1633 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
1634 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
1637 if ( clearscreen ) {
1638 SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
1640 // render background
1641 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
1644 dest.w = sdl_realscreen -> w;
1645 dest.h = sdl_realscreen -> h;
1646 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, NULL /* 0,0 */ );
1647 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1654 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
1655 rtext = TTF_RenderText_Blended ( g_big_font, "Looking for applications...", tmpfontcolor );
1656 if ( clearscreen ) {
1663 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, &dest );
1664 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1665 SDL_FreeSurface ( rtext );
1668 if ( g_imagecache [ IMG_ICON_MISSING ].i ) {
1669 dest.x = rtext -> w + 30;
1671 SDL_BlitSurface ( g_imagecache [ IMG_ICON_MISSING ].i, NULL, sdl_realscreen, &dest );
1672 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1678 void ui_cachescreen ( unsigned char clearscreen, char *filename ) {
1680 SDL_Rect rects [ 4 ];
1681 SDL_Rect *dest = rects;
1683 bzero ( dest, sizeof(SDL_Rect)* 4 );
1685 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
1686 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
1687 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
1688 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
1690 static unsigned int stepx = 0;
1693 if ( clearscreen ) {
1694 SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
1696 // render background
1697 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
1700 dest -> w = sdl_realscreen -> w;
1701 dest -> h = sdl_realscreen -> h;
1702 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, NULL /* 0,0 */ );
1708 // render background
1709 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
1712 src.w = sdl_realscreen -> w;
1716 dest -> w = sdl_realscreen -> w;
1717 dest -> h = sdl_realscreen -> h;
1718 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, &src, sdl_realscreen, dest );
1726 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
1727 rtext = TTF_RenderText_Blended ( g_big_font, "Caching applications artwork...", tmpfontcolor );
1730 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1731 SDL_FreeSurface ( rtext );
1735 if ( g_imagecache [ IMG_ICON_MISSING ].i ) {
1736 dest -> x = rtext -> w + 30 + stepx;
1738 SDL_BlitSurface ( g_imagecache [ IMG_ICON_MISSING ].i, NULL, sdl_realscreen, dest );
1744 rtext = TTF_RenderText_Blended ( g_tab_font, filename, tmpfontcolor );
1747 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1748 SDL_FreeSurface ( rtext );
1755 if ( stepx > 350 ) {
1759 SDL_UpdateRects ( sdl_realscreen, dest - rects, rects );
1764 int ui_selected_index ( void ) {
1766 if ( ! ui_selected ) {
1767 return ( -1 ); // no index
1770 mm_appref_t *r = g_categories [ ui_category ].refs;
1773 if ( r == ui_selected ) {
1783 static mm_appref_t *timer_ref = NULL;
1784 void ui_set_selected ( mm_appref_t *r ) {
1786 render_mask |= CHANGED_SELECTION;
1788 if ( ! pnd_conf_get_as_int_d ( g_conf, "minimenu.load_previews_later", 0 ) ) {
1789 return; // no desire to defer anything
1794 SDL_SetTimer ( 0, NULL );
1799 SDL_SetTimer ( pnd_conf_get_as_int_d ( g_conf, "previewpic.defer_timer_ms", 1000 ), ui_callback_f );
1805 unsigned int ui_callback_f ( unsigned int t ) {
1807 if ( ui_selected != timer_ref ) {
1808 return ( 0 ); // user has moved it, who cares
1812 bzero ( &e, sizeof(SDL_Event) );
1813 e.type = SDL_USEREVENT;
1814 e.user.code = sdl_user_ticker;
1815 SDL_PushEvent ( &e );
1820 int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *footer ) {
1821 SDL_Rect rects [ 40 ];
1822 SDL_Rect *dest = rects;
1826 bzero ( rects, sizeof(SDL_Rect) * 40 );
1828 unsigned int sel = 0;
1830 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
1831 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
1832 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
1833 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
1835 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
1837 SDL_Color selfontcolor = { 0/*font_rgba_r*/, font_rgba_g, font_rgba_b, font_rgba_a };
1845 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
1846 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
1847 dest -> w = ((SDL_Surface*) g_imagecache [ IMG_DETAIL_PANEL ].i) -> w;
1848 dest -> h = ((SDL_Surface*) g_imagecache [ IMG_DETAIL_PANEL ].i) -> h;
1849 SDL_FillRect( sdl_realscreen, dest, 0 );
1851 // show dialog background
1852 if ( g_imagecache [ IMG_DETAIL_BG ].i ) {
1853 src.x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
1854 src.y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
1855 src.w = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> w;
1856 src.h = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> h;
1857 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
1858 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
1859 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
1860 // repeat for darken?
1861 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
1862 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
1863 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1867 // show dialog frame
1868 if ( g_imagecache [ IMG_DETAIL_PANEL ].i ) {
1869 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
1870 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
1871 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_PANEL ].i, NULL /* whole image */, sdl_realscreen, dest );
1872 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1878 rtext = TTF_RenderText_Blended ( g_tab_font, title, tmpfontcolor );
1879 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
1880 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) + 20;
1881 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1882 SDL_FreeSurface ( rtext );
1888 rtext = TTF_RenderText_Blended ( g_tab_font, footer, tmpfontcolor );
1889 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
1890 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) +
1891 ((SDL_Surface*) g_imagecache [ IMG_DETAIL_PANEL ].i) -> h
1893 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1894 SDL_FreeSurface ( rtext );
1899 for ( i = 0; i < argc; i++ ) {
1903 rtext = TTF_RenderText_Blended ( g_tab_font, argv [ i ], selfontcolor );
1905 rtext = TTF_RenderText_Blended ( g_tab_font, argv [ i ], tmpfontcolor );
1907 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
1908 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) + 40 + ( 20 * ( i + 1 ) );
1909 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1910 SDL_FreeSurface ( rtext );
1915 // update all the rects and send it all to sdl
1916 SDL_UpdateRects ( sdl_realscreen, dest - rects, rects );
1920 while ( SDL_WaitEvent ( &event ) ) {
1922 switch ( event.type ) {
1926 if ( event.key.keysym.sym == SDLK_UP ) {
1930 } else if ( event.key.keysym.sym == SDLK_DOWN ) {
1931 if ( sel < argc - 1 ) {
1935 } else if ( event.key.keysym.sym == SDLK_RETURN ) {
1938 } else if ( event.key.keysym.sym == SDLK_q ) {
1942 return ( -1 ); // nada
1957 unsigned char ui_determine_row ( mm_appref_t *a ) {
1958 unsigned int row = 0;
1960 mm_appref_t *i = g_categories [ ui_category ].refs;
1965 row /= pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 );
1970 unsigned char ui_determine_screen_row ( mm_appref_t *a ) {
1971 return ( ui_determine_row ( a ) % pnd_conf_get_as_int_d ( g_conf, "grid.row_max", 5 ) );
1974 unsigned char ui_determine_screen_col ( mm_appref_t *a ) {
1975 unsigned int col = 0;
1977 mm_appref_t *i = g_categories [ ui_category ].refs;
1982 col %= pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 );
1987 unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p ) {
1988 char *viewer, *searchpath;
1989 pnd_conf_handle desktoph;
1992 searchpath = pnd_conf_query_searchpath();
1994 desktoph = pnd_conf_fetch_by_id ( pnd_conf_desktop, searchpath );
2000 viewer = pnd_conf_get_as_char ( desktoph, "info.viewer" );
2003 return ( 0 ); // no way to view the file
2007 if ( ! p -> unique_id ) {
2011 if ( ! p -> info_filename ) {
2015 if ( ! p -> info_name ) {
2026 if ( pnd_conf_get_as_char ( desktoph, "info.viewer_args" ) ) {
2027 snprintf ( pargs, 1001, "%s %s",
2028 pnd_conf_get_as_char ( desktoph, "info.viewer_args" ), p -> info_filename );
2033 char pndfile [ 1024 ];
2034 if ( p -> object_type == pnd_object_type_directory ) {
2035 // for PXML-app-dir, pnd_run.sh doesn't want the PXML.xml.. it just wants the dir-name
2036 strncpy ( pndfile, p -> object_path, 1000 );
2037 } else if ( p -> object_type == pnd_object_type_pnd ) {
2038 // pnd_run.sh wants the full path and filename for the .pnd file
2039 snprintf ( pndfile, 1020, "%s/%s", p -> object_path, p -> object_filename );
2042 if ( ! pnd_apps_exec ( pndrun, pndfile, p -> unique_id, viewer, p -> startdir, pargs,
2043 p -> clockspeed ? atoi ( p -> clockspeed ) : 0, PND_EXEC_OPTION_NORUN ) )
2048 pnd_log ( pndn_debug, "Info Exec=%s\n", pnd_apps_exec_runline() );
2052 if ( ( x = fork() ) < 0 ) {
2053 pnd_log ( pndn_error, "ERROR: Couldn't fork()\n" );
2058 execl ( "/bin/sh", "/bin/sh", "-c", pnd_apps_exec_runline(), (char*)NULL );
2059 pnd_log ( pndn_error, "ERROR: Couldn't exec(%s)\n", pnd_apps_exec_runline() );
2071 #define MAXTOUCH 100
2072 ui_touch_t ui_touchrects [ MAXTOUCH ];
2073 unsigned char ui_touchrect_count = 0;
2075 void ui_register_reset ( void ) {
2076 bzero ( ui_touchrects, sizeof(ui_touch_t)*MAXTOUCH );
2077 ui_touchrect_count = 0;
2081 void ui_register_tab ( unsigned char catnum, unsigned int x, unsigned int y, unsigned int w, unsigned int h ) {
2083 if ( ui_touchrect_count == MAXTOUCH ) {
2087 ui_touchrects [ ui_touchrect_count ].r.x = x;
2088 ui_touchrects [ ui_touchrect_count ].r.y = y;
2089 ui_touchrects [ ui_touchrect_count ].r.w = w;
2090 ui_touchrects [ ui_touchrect_count ].r.h = h;
2091 ui_touchrects [ ui_touchrect_count ].catnum = catnum;
2092 ui_touchrect_count++;
2097 void ui_register_app ( mm_appref_t *app, unsigned int x, unsigned int y, unsigned int w, unsigned int h ) {
2099 if ( ui_touchrect_count == MAXTOUCH ) {
2103 ui_touchrects [ ui_touchrect_count ].r.x = x;
2104 ui_touchrects [ ui_touchrect_count ].r.y = y;
2105 ui_touchrects [ ui_touchrect_count ].r.w = w;
2106 ui_touchrects [ ui_touchrect_count ].r.h = h;
2107 ui_touchrects [ ui_touchrect_count ].ref = app;
2108 ui_touchrect_count++;
2113 void ui_touch_act ( unsigned int x, unsigned int y ) {
2118 for ( i = 0; i < ui_touchrect_count; i++ ) {
2119 t = &(ui_touchrects [ i ]);
2121 if ( x >= t -> r.x &&
2122 x <= t -> r.x + t -> r.w &&
2124 y <= t -> r.y + t -> r.h
2129 ui_selected = t -> ref;
2132 if ( ui_category != t -> catnum ) {
2135 ui_category = t -> catnum;
2136 render_mask |= CHANGED_CATEGORY;
2147 unsigned char ui_forkexec ( char *argv[] ) {
2148 char *fooby = argv[0];
2151 if ( ( x = fork() ) < 0 ) {
2152 pnd_log ( pndn_error, "ERROR: Couldn't fork() for '%s'\n", fooby );
2156 if ( x == 0 ) { // child
2157 execv ( fooby, argv );
2158 pnd_log ( pndn_error, "ERROR: Couldn't exec(%s)\n", fooby );
2166 unsigned char ui_threaded_defered_preview ( pnd_disco_t *p ) {
2168 if ( ! cache_preview ( p, pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 200 ),
2169 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 180 ) )
2172 pnd_log ( pndn_debug, "THREAD: Couldn't load preview pic: '%s' -> '%s'\n",
2173 IFNULL(p->title_en,"No Name"), p -> preview_pic1 );
2176 // trigger that we completed
2178 bzero ( &e, sizeof(SDL_Event) );
2179 e.type = SDL_USEREVENT;
2180 e.user.code = sdl_user_finishedpreview;
2182 SDL_PushEvent ( &e );
2187 SDL_Thread *g_icon_thread = NULL;
2188 void ui_post_scan ( void ) {
2190 // if deferred icon load, kick off the thread now
2191 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.load_icons_later", 0 ) == 1 ) {
2193 g_icon_thread = SDL_CreateThread ( (void*)ui_threaded_defered_icon, NULL );
2195 if ( ! g_icon_thread ) {
2196 pnd_log ( pndn_error, "ERROR: Couldn't create icon thread\n" );
2199 } // deferred icon load
2204 unsigned char ui_threaded_defered_icon ( void *p ) {
2205 extern pnd_box_handle g_active_apps;
2206 pnd_box_handle h = g_active_apps;
2208 unsigned char maxwidth, maxheight;
2209 maxwidth = pnd_conf_get_as_int_d ( g_conf, "grid.icon_max_width", 50 );
2210 maxheight = pnd_conf_get_as_int_d ( g_conf, "grid.icon_max_height", 50 );
2212 pnd_disco_t *iter = pnd_box_get_head ( h );
2217 if ( iter -> pnd_icon_pos &&
2218 ! cache_icon ( iter, maxwidth, maxheight ) )
2220 pnd_log ( pndn_warning, " Couldn't load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
2223 // trigger that we completed
2225 bzero ( &e, sizeof(SDL_Event) );
2226 e.type = SDL_USEREVENT;
2227 e.user.code = sdl_user_finishedicon;
2228 SDL_PushEvent ( &e );
2230 //pnd_log ( pndn_warning, " Finished deferred load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
2231 usleep ( pnd_conf_get_as_int_d ( g_conf, "minimenu.defer_icon_us", 50000 ) );
2236 iter = pnd_box_get_next ( iter );
2242 void ui_show_hourglass ( unsigned char updaterect ) {
2245 SDL_Surface *s = g_imagecache [ IMG_HOURGLASS ].i;
2247 dest.x = ( 800 - s -> w ) / 2;
2248 dest.y = ( 480 - s -> h ) / 2;
2250 SDL_BlitSurface ( s, NULL /* whole image */, sdl_realscreen, &dest );
2253 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
2259 unsigned char ui_pick_skin ( void ) {
2261 char *skins [ MAXSKINS ];
2264 char *searchpath = pnd_conf_get_as_char ( g_conf, "minimenu.skin_searchpath" );
2265 char tempname [ 100 ];
2269 skins [ iter++ ] = "No skin change";
2273 DIR *d = opendir ( buffer );
2278 while ( ( dd = readdir ( d ) ) ) {
2280 if ( dd -> d_name [ 0 ] == '.' ) {
2282 } else if ( ( dd -> d_type == DT_DIR || dd -> d_type == DT_UNKNOWN ) &&
2285 snprintf ( tempname, 100, "Skin: %s", dd -> d_name );
2286 skins [ iter++ ] = strdup ( tempname );
2297 int sel = ui_modal_single_menu ( skins, iter, "Skins", "Enter to select; other to return." );
2299 // did they pick one?
2303 char *s = strdup ( pnd_conf_get_as_char ( g_conf, "minimenu.skin_selected" ) );
2304 s = pnd_expand_tilde ( s );
2306 f = fopen ( s, "w" );
2311 fprintf ( f, "%s\n", skins [ sel ] + 6 );