9 #include "SDL_gfxPrimitives.h"
10 #include "SDL_rotozoom.h"
13 #include "pnd_logger.h"
15 #include "pnd_container.h"
16 #include "pnd_discovery.h"
18 #include "pnd_device.h"
24 #include "mmwrapcmd.h"
28 SDL_Surface *sdl_realscreen = NULL;
29 unsigned int sdl_ticks = 0;
33 unsigned short int g_scale = 1; // 1 == noscale
35 SDL_Surface *g_imgcache [ IMG_MAX ];
37 TTF_Font *g_big_font = NULL;
38 TTF_Font *g_grid_font = NULL;
39 TTF_Font *g_detailtext_font = NULL;
40 TTF_Font *g_tab_font = NULL;
42 extern pnd_conf_handle g_conf;
44 /* current display state
46 int ui_rows_scrolled_down = 0; // number of rows that should be missing from top of the display
47 mm_appref_t *ui_selected = NULL;
48 unsigned char ui_category = 0; // current category
49 unsigned char ui_catshift = 0; // how many cats are offscreen to the left
51 extern mm_category_t g_categories [ MAX_CATS ];
52 extern unsigned char g_categorycount;
54 static SDL_Surface *ui_scale_image ( SDL_Surface *s, unsigned int maxwidth, int maxheight ); // height -1 means ignore
55 static int ui_selected_index ( void );
57 unsigned char ui_setup ( void ) {
62 SDL_Init ( SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE );
64 SDL_JoystickOpen ( 0 ); // turn on joy-0
66 SDL_WM_SetCaption ( "mmenu", "mmenu" );
68 // hide the mouse cursor if we can
69 if ( SDL_ShowCursor ( -1 ) == 1 ) {
76 unsigned int svm = SDL_SWSURFACE /*| SDL_FULLSCREEN*/ /* 0*/;
77 if ( pnd_conf_get_as_int_d ( g_conf, "display.fullscreen", 0 ) > 0 ) {
78 svm |= SDL_FULLSCREEN;
82 SDL_SetVideoMode ( 800 * g_scale, 480 * g_scale, 16 /*bpp*/, svm );
84 if ( ! sdl_realscreen ) {
85 pnd_log ( pndn_error, "ERROR: Couldn't open SDL real screen; dieing." );
89 pnd_log ( pndn_debug, "Pixel format:" );
90 pnd_log ( pndn_debug, "bpp b: %u\n", sdl_realscreen -> format -> BitsPerPixel );
91 pnd_log ( pndn_debug, "bpp B: %u\n", sdl_realscreen -> format -> BytesPerPixel );
92 pnd_log ( pndn_debug, "R mask: %08x\n", sdl_realscreen -> format -> Rmask );
93 pnd_log ( pndn_debug, "G mask: %08x\n", sdl_realscreen -> format -> Gmask );
94 pnd_log ( pndn_debug, "B mask: %08x\n", sdl_realscreen -> format -> Bmask );
100 /* Set 16-bit stereo audio at 22Khz */
101 fmt.freq = 44100; //22050;
102 fmt.format = AUDIO_S16; //AUDIO_S16;
104 fmt.samples = 2048; /* A good value for games */
105 fmt.callback = mixaudio;
108 /* Open the audio device and start playing sound! */
109 if ( SDL_OpenAudio ( &fmt, NULL ) < 0 ) {
110 zotlog ( "Unable to open audio: %s\n", SDL_GetError() );
114 SDL_PauseAudio ( 0 );
119 //IMG_Init ( IMG_INIT_JPG | IMG_INIT_PNG );
125 if ( TTF_Init() == -1 ) {
126 pnd_log ( pndn_error, "ERROR: Couldn't set up SDL TTF lib\n" );
127 return ( 0 ); // couldn't set up SDL TTF
130 char fullpath [ PATH_MAX ];
132 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "minimenu.font" ) );
133 g_big_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "minimenu.font_ptsize", 24 ) );
134 if ( ! g_big_font ) {
135 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
136 pnd_conf_get_as_char ( g_conf, "minimenu.font" ), pnd_conf_get_as_int_d ( g_conf, "minimenu.font_ptsize", 24 ) );
137 return ( 0 ); // couldn't set up SDL TTF
141 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, MMENU_GRID_FONT ) );
142 g_grid_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, MMENU_GRID_FONTSIZE, 10 ) );
143 if ( ! g_grid_font ) {
144 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
145 pnd_conf_get_as_char ( g_conf, MMENU_GRID_FONT ), pnd_conf_get_as_int_d ( g_conf, MMENU_GRID_FONTSIZE, 10 ) );
146 return ( 0 ); // couldn't set up SDL TTF
150 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "detailtext.font" ) );
151 g_detailtext_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "detailtext.font_ptsize", 10 ) );
152 if ( ! g_detailtext_font ) {
153 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
154 pnd_conf_get_as_char ( g_conf, "detailtext.font" ), pnd_conf_get_as_int_d ( g_conf, "detailtext.font_ptsize", 10 ) );
155 return ( 0 ); // couldn't set up SDL TTF
159 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "tabs.font" ) );
160 g_tab_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "tabs.font_ptsize", 10 ) );
161 if ( ! g_tab_font ) {
162 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
163 pnd_conf_get_as_char ( g_conf, "tabs.font" ), pnd_conf_get_as_int_d ( g_conf, "tabs.font_ptsize", 10 ) );
164 return ( 0 ); // couldn't set up SDL TTF
170 mm_imgcache_t g_imagecache [ IMG_TRUEMAX ] = {
171 { IMG_BACKGROUND_800480, "graphics.IMG_BACKGROUND_800480" },
172 { IMG_BACKGROUND_TABMASK, "graphics.IMG_BACKGROUND_TABMASK" },
173 { IMG_DETAIL_PANEL, "graphics.IMG_DETAIL_PANEL" },
174 { IMG_DETAIL_BG, "graphics.IMG_DETAIL_BG" },
175 { IMG_SELECTED_ALPHAMASK, "graphics.IMG_SELECTED_ALPHAMASK" },
176 { IMG_TAB_SEL, "graphics.IMG_TAB_SEL" },
177 { IMG_TAB_UNSEL, "graphics.IMG_TAB_UNSEL" },
178 { IMG_ICON_MISSING, "graphics.IMG_ICON_MISSING" },
179 { IMG_SELECTED_HILITE, "graphics.IMG_SELECTED_HILITE" },
180 { IMG_PREVIEW_MISSING, "graphics.IMG_PREVIEW_MISSING" },
181 { IMG_ARROW_UP, "graphics.IMG_ARROW_UP", },
182 { IMG_ARROW_DOWN, "graphics.IMG_ARROW_DOWN", },
183 { IMG_ARROW_SCROLLBAR, "graphics.IMG_ARROW_SCROLLBAR", },
187 unsigned char ui_imagecache ( char *basepath ) {
189 char fullpath [ PATH_MAX ];
193 for ( i = 0; i < IMG_MAX; i++ ) {
195 if ( g_imagecache [ i ].id != i ) {
196 pnd_log ( pndn_error, "ERROR: Internal table mismatch during caching [%u]\n", i );
200 char *filename = pnd_conf_get_as_char ( g_conf, g_imagecache [ i ].confname );
203 pnd_log ( pndn_error, "ERROR: Missing filename in conf for key: %s\n", g_imagecache [ i ].confname );
207 sprintf ( fullpath, "%s/%s", basepath, filename );
209 if ( ! ( g_imagecache [ i ].i = IMG_Load ( fullpath ) ) ) {
210 pnd_log ( pndn_error, "ERROR: Couldn't load static cache image: %s\n", fullpath );
217 //g_imagecache [ IMG_SELECTED_ALPHAMASK ].i = SDL_CreateRGBSurface ( SDL_SWSURFACE, 60, 60, 32, 0xFF0000, 0x00FF00, 0xFF, 0xFF000000 );
218 //boxRGBA ( g_imagecache [ IMG_SELECTED_ALPHAMASK ].i, 0, 0, 60, 60, 100, 100, 100, 250 );
224 g_imagecache [ IMG_SELECTED_ALPHAMASK ].i = ui_scale_image ( g_imagecache [ IMG_SELECTED_ALPHAMASK ].i, pnd_conf_get_as_int_d ( g_conf, "grid.icon_max_width", 50 ), -1 );
225 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 );
226 // scale text hilight
227 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 );
228 // scale preview no-pic
229 g_imagecache [ IMG_PREVIEW_MISSING ].i = ui_scale_image ( g_imagecache [ IMG_PREVIEW_MISSING ].i,
230 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 50 ),
231 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 50 ) );
233 // set alpha on detail panel
234 SDL_SetAlpha ( g_imagecache [ IMG_DETAIL_BG ].i, SDL_SRCALPHA, pnd_conf_get_as_int_d ( g_conf, "display.detail_bg_alpha", 50 ) );
239 void ui_render ( unsigned int render_mask ) {
242 // divide width: 550 / 250
243 // divide left side: 5 columns == 110px width
244 // 20px buffer either side == 70px wide icon + 20 + 20?
246 unsigned int icon_rows;
249 SDL_Rect rects [ MAXRECTS ], src;
250 SDL_Rect *dest = rects;
251 bzero ( dest, sizeof(SDL_Rect)*MAXRECTS );
253 unsigned int row, displayrow, col;
254 mm_appref_t *appiter;
256 unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
258 unsigned char row_max = pnd_conf_get_as_int_d ( g_conf, MMENU_DISP_ROWMAX, 4 );
259 unsigned char col_max = pnd_conf_get_as_int_d ( g_conf, MMENU_DISP_COLMAX, 5 );
261 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
262 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
263 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
264 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
266 unsigned int grid_offset_x = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_x" );
267 unsigned int grid_offset_y = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_y" );
269 unsigned int icon_offset_x = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_x" );
270 unsigned int icon_offset_y = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_y" );
272 unsigned int text_width = pnd_conf_get_as_int ( g_conf, "grid.text_width" );
273 unsigned int text_clip_x = pnd_conf_get_as_int ( g_conf, "grid.text_clip_x" );
274 unsigned int text_offset_x = pnd_conf_get_as_int ( g_conf, "grid.text_offset_x" );
275 unsigned int text_offset_y = pnd_conf_get_as_int ( g_conf, "grid.text_offset_y" );
277 unsigned int cell_width = pnd_conf_get_as_int ( g_conf, "grid.cell_width" );
278 unsigned int cell_height = pnd_conf_get_as_int ( g_conf, "grid.cell_height" );
280 // how many total rows do we need?
281 icon_rows = g_categories [ ui_category ].refcount / col_max;
282 if ( g_categories [ ui_category ].refcount % col_max > 0 ) {
286 // if no selected app yet, select the first one
288 if ( ! ui_selected ) {
289 ui_selected = g_categories [ ui_category ].refs;
293 // ensure selection is visible
296 int index = ui_selected_index();
297 int topleft = col_max * ui_rows_scrolled_down;
298 int botright = ( col_max * ( ui_rows_scrolled_down + row_max ) - 1 );
300 //pnd_log ( PND_LOG_DEFAULT, "index %u tl %u br %u\n", index, topleft, botright );
302 if ( index < topleft ) {
303 ui_rows_scrolled_down -= pnd_conf_get_as_int_d ( g_conf, "grid.scroll_increment", 1 );
304 } else if ( index > botright ) {
305 ui_rows_scrolled_down += pnd_conf_get_as_int_d ( g_conf, "grid.scroll_increment", 1 );
308 if ( ui_rows_scrolled_down < 0 ) {
309 ui_rows_scrolled_down = 0;
310 } else if ( ui_rows_scrolled_down > icon_rows ) {
311 ui_rows_scrolled_down = icon_rows;
317 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
320 dest -> w = sdl_realscreen -> w;
321 dest -> h = sdl_realscreen -> h;
322 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, dest /* 0,0 */ );
323 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
328 if ( g_imagecache [ IMG_BACKGROUND_TABMASK ].i ) {
331 dest -> w = sdl_realscreen -> w;
332 dest -> h = sdl_realscreen -> h;
333 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_TABMASK ].i, NULL /* whole image */, sdl_realscreen, dest /* 0,0 */ );
334 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
339 if ( g_imagecache [ IMG_TAB_SEL ].i && g_imagecache [ IMG_TAB_UNSEL ].i ) {
340 unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
341 unsigned int tab_height = pnd_conf_get_as_int ( g_conf, "tabs.tab_height" );
342 unsigned int tab_offset_x = pnd_conf_get_as_int ( g_conf, "tabs.tab_offset_x" );
343 unsigned int tab_offset_y = pnd_conf_get_as_int ( g_conf, "tabs.tab_offset_y" );
344 unsigned int text_offset_x = pnd_conf_get_as_int ( g_conf, "tabs.text_offset_x" );
345 unsigned int text_offset_y = pnd_conf_get_as_int ( g_conf, "tabs.text_offset_y" );
346 unsigned int text_width = pnd_conf_get_as_int ( g_conf, "tabs.text_width" );
348 for ( col = ui_catshift;
350 ( screen_width / tab_width ) < g_categorycount ? ( screen_width / tab_width ) + ui_catshift : g_categorycount + ui_catshift
356 if ( col == ui_category ) {
357 s = g_imagecache [ IMG_TAB_SEL ].i;
359 s = g_imagecache [ IMG_TAB_UNSEL ].i;
367 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
368 dest -> y = tab_offset_y;
369 //pnd_log ( pndn_debug, "tab %u at %ux%u\n", col, dest.x, dest.y );
370 SDL_BlitSurface ( s, &src, sdl_realscreen, dest );
371 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
376 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
377 rtext = TTF_RenderText_Blended ( g_tab_font, g_categories [ col ].catname, tmpfontcolor );
380 src.w = rtext -> w < text_width ? rtext -> w : text_width;
382 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width ) + text_offset_x;
383 dest -> y = tab_offset_y + text_offset_y;
384 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
385 SDL_FreeSurface ( rtext );
392 // scroll bars and arrows
394 unsigned char show_bar = 0;
397 if ( ui_rows_scrolled_down && g_imagecache [ IMG_ARROW_UP ].i ) {
398 dest -> x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_x", 450 );
399 dest -> y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_y", 80 );
400 SDL_BlitSurface ( g_imagecache [ IMG_ARROW_UP ].i, NULL /* whole image */, sdl_realscreen, dest );
401 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
408 if ( ui_rows_scrolled_down + row_max < icon_rows && g_imagecache [ IMG_ARROW_DOWN ].i ) {
409 dest -> x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_x", 450 );
410 dest -> y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_y", 80 );
411 SDL_BlitSurface ( g_imagecache [ IMG_ARROW_DOWN ].i, NULL /* whole image */, sdl_realscreen, dest );
412 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
419 // show scrollbar as well
422 src.w = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_w", 10 );
423 src.h = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_h", 100 );
424 dest -> x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_x", 450 );
425 dest -> y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_y", 100 );
426 SDL_BlitSurface ( g_imagecache [ IMG_ARROW_SCROLLBAR ].i, &src /* whole image */, sdl_realscreen, dest );
427 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
433 // render detail pane bg
434 if ( pnd_conf_get_as_int_d ( g_conf, "detailpane.show", 1 ) ) {
436 if ( g_imagecache [ IMG_DETAIL_BG ].i ) {
437 src.x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
438 src.y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
439 src.w = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> w;
440 src.h = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> h;
441 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
442 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
443 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
444 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
448 // render detail pane
449 if ( g_imagecache [ IMG_DETAIL_PANEL ].i ) {
450 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
451 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
452 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_PANEL ].i, NULL /* whole image */, sdl_realscreen, dest );
453 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
457 } // detailpane frame/bg
459 // anything to render?
460 if ( g_categories [ ui_category ].refs ) {
462 appiter = g_categories [ ui_category ].refs;
466 // until we run out of apps, or run out of space
467 while ( appiter != NULL ) {
469 for ( col = 0; col < col_max && appiter != NULL; col++ ) {
471 // do we even need to render it? or are we suppressing it due to rows scrolled off the top?
472 if ( row >= ui_rows_scrolled_down ) {
474 // selected? show hilights
475 if ( appiter == ui_selected ) {
477 dest -> x = grid_offset_x + ( col * cell_width ) + icon_offset_x;
478 dest -> y = grid_offset_y + ( displayrow * cell_height ) + icon_offset_y;
479 SDL_BlitSurface ( g_imagecache [ IMG_SELECTED_ALPHAMASK ].i, NULL /* all */, sdl_realscreen, dest );
480 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
483 dest -> x = grid_offset_x + ( col * cell_width ) + text_clip_x;
484 dest -> y = grid_offset_y + ( displayrow * cell_height ) + pnd_conf_get_as_int ( g_conf, "grid.text_hilite_offset_y" );
485 SDL_BlitSurface ( g_imagecache [ IMG_SELECTED_HILITE ].i, NULL /* all */, sdl_realscreen, dest );
486 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
491 mm_cache_t *ic = cache_query_icon ( appiter -> ref -> unique_id );
492 SDL_Surface *iconsurface;
494 iconsurface = ic -> i;
496 //pnd_log ( pndn_warning, "WARNING: TBD: Need Missin-icon icon for '%s'\n", IFNULL(appiter -> ref -> title_en,"No Name") );
497 iconsurface = g_imagecache [ IMG_ICON_MISSING ].i;
500 //pnd_log ( pndn_debug, "Got an icon for '%s'\n", IFNULL(appiter -> ref -> title_en,"No Name") );
506 dest -> x = grid_offset_x + ( col * cell_width ) + icon_offset_x;
507 dest -> y = grid_offset_y + ( displayrow * cell_height ) + icon_offset_y;
509 SDL_BlitSurface ( iconsurface, &src, sdl_realscreen, dest );
510 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
516 if ( appiter -> ref -> title_en ) {
518 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
519 rtext = TTF_RenderText_Blended ( g_grid_font, appiter -> ref -> title_en, tmpfontcolor );
522 src.w = text_width < rtext -> w ? text_width : rtext -> w;
524 if ( rtext -> w > text_width ) {
525 dest -> x = grid_offset_x + ( col * cell_width ) + text_clip_x;
527 dest -> x = grid_offset_x + ( col * cell_width ) + text_offset_x - ( rtext -> w / 2 );
529 dest -> y = grid_offset_y + ( displayrow * cell_height ) + text_offset_y;
530 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
531 SDL_FreeSurface ( rtext );
535 } // display now? or scrolled away..
538 appiter = appiter -> next;
540 } // for column 1...X
542 if ( row >= ui_rows_scrolled_down ) {
548 // are we done displaying rows?
549 if ( displayrow >= row_max ) {
556 // no apps to render?
557 pnd_log ( pndn_rem, "No applications to render?\n" );
563 unsigned int cell_offset_x = pnd_conf_get_as_int ( g_conf, "detailtext.cell_offset_x" );
564 unsigned int cell_offset_y = pnd_conf_get_as_int ( g_conf, "detailtext.cell_offset_y" );
565 unsigned int cell_width = pnd_conf_get_as_int ( g_conf, "detailtext.cell_width" );
567 unsigned int desty = cell_offset_y;
572 if ( ui_selected -> ref -> title_en ) {
574 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
575 rtext = TTF_RenderText_Blended ( g_detailtext_font, ui_selected -> ref -> title_en, tmpfontcolor );
578 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
580 dest -> x = cell_offset_x;
582 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
583 SDL_FreeSurface ( rtext );
589 if ( ui_selected -> ref -> main_category ) {
591 sprintf ( buffer, "Category: %s", ui_selected -> ref -> main_category );
594 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
595 rtext = TTF_RenderText_Blended ( g_detailtext_font, buffer, tmpfontcolor );
598 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
600 dest -> x = cell_offset_x;
602 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
603 SDL_FreeSurface ( rtext );
609 if ( ui_selected -> ref -> clockspeed ) {
611 sprintf ( buffer, "CPU Clock: %s", ui_selected -> ref -> clockspeed );
614 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
615 rtext = TTF_RenderText_Blended ( g_detailtext_font, buffer, tmpfontcolor );
618 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
620 dest -> x = cell_offset_x;
622 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
623 SDL_FreeSurface ( rtext );
629 mm_cache_t *ic = cache_query_preview ( ui_selected -> ref -> unique_id );
630 SDL_Surface *previewpic;
633 previewpic = ic -> i;
635 previewpic = g_imagecache [ IMG_PREVIEW_MISSING ].i;
639 dest -> x = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_offset_x", 50 ) +
640 ( ( pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 50 ) - previewpic -> w ) / 2 );
641 dest -> y = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_offset_y", 50 );
642 SDL_BlitSurface ( previewpic, NULL /* whole image */, sdl_realscreen, dest );
643 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
654 unsigned char batterylevel = pnd_device_get_battery_gauge_perc();
657 sprintf ( buffer, "Battery: %u%%", batterylevel );
660 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
661 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, tmpfontcolor );
662 dest -> x = pnd_conf_get_as_int_d ( g_conf, "display.battery_x", 20 );
663 dest -> y = pnd_conf_get_as_int_d ( g_conf, "display.battery_y", 450 );
664 SDL_BlitSurface ( rtext, NULL /* all */, sdl_realscreen, dest );
665 SDL_FreeSurface ( rtext );
670 if ( pnd_conf_get_as_char ( g_conf, "display.hintline" ) ) {
671 char *buffer = pnd_conf_get_as_char ( g_conf, "display.hintline" );
673 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
674 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, tmpfontcolor );
675 dest -> x = pnd_conf_get_as_int_d ( g_conf, "display.hint_x", 40 );
676 dest -> y = pnd_conf_get_as_int_d ( g_conf, "display.hint_y", 450 );
677 SDL_BlitSurface ( rtext, NULL /* all */, sdl_realscreen, dest );
678 SDL_FreeSurface ( rtext );
682 // update all the rects and send it all to sdl
683 SDL_UpdateRects ( sdl_realscreen, dest - rects, rects );
687 void ui_process_input ( unsigned char block_p ) {
690 unsigned char ui_event = 0; // if we get a ui event, flip to 1 and break
691 static ui_sdl_button_e ui_mask = uisb_none; // current buttons down
693 while ( ! ui_event &&
694 block_p ? SDL_WaitEvent ( &event ) : SDL_PollEvent ( &event ) )
697 switch ( event.type ) {
702 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.load_previews_later", 0 ) ) {
704 pnd_log ( pndn_debug, "Deferred preview pic load ----------\n" );
706 // load the preview pics now!
707 pnd_disco_t *iter = ui_selected -> ref;
709 if ( iter -> preview_pic1 &&
710 ! cache_preview ( iter, pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 200 ), pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 180 ) ) )
712 pnd_log ( pndn_debug, " Couldn't load preview pic: '%s' -> '%s'\n", IFNULL(iter->title_en,"No Name"), iter -> preview_pic1 );
715 pnd_log ( pndn_debug, "Deferred preview pic load finish ---\n" );
722 #if 0 // joystick motion
723 case SDL_JOYAXISMOTION:
725 pnd_log ( PND_LOG_DEFAULT, "joystick axis\n" );
727 if ( event.jaxis.axis == 0 ) {
729 if ( event.jaxis.value < 0 ) {
731 pnd_log ( PND_LOG_DEFAULT, "joystick axis - LEFT\n" );
732 } else if ( event.jaxis.value > 0 ) {
734 pnd_log ( PND_LOG_DEFAULT, "joystick axis - RIGHT\n" );
736 } else if ( event.jaxis.axis == 1 ) {
738 if ( event.jaxis.value < 0 ) {
740 } else if ( event.jaxis.value > 0 ) {
750 #if 0 // joystick buttons
751 case SDL_JOYBUTTONDOWN:
753 pnd_log ( PND_LOG_DEFAULT, "joystick button down %u\n", event.jbutton.button );
755 if ( event.jbutton.button == 0 ) { // B
757 } else if ( event.jbutton.button == 1 ) { // Y
759 } else if ( event.jbutton.button == 2 ) { // X
761 } else if ( event.jbutton.button == 3 ) { // A
764 } else if ( event.jbutton.button == 4 ) { // Select
765 ui_mask |= uisb_select;
766 } else if ( event.jbutton.button == 5 ) { // Start
767 ui_mask |= uisb_start;
769 } else if ( event.jbutton.button == 7 ) { // L
771 } else if ( event.jbutton.button == 8 ) { // R
780 case SDL_JOYBUTTONUP:
782 pnd_log ( PND_LOG_DEFAULT, "joystick button up %u\n", event.jbutton.button );
784 if ( event.jbutton.button == 0 ) { // B
787 } else if ( event.jbutton.button == 1 ) { // Y
789 } else if ( event.jbutton.button == 2 ) { // X
791 } else if ( event.jbutton.button == 3 ) { // A
794 } else if ( event.jbutton.button == 4 ) { // Select
795 ui_mask &= ~uisb_select;
796 } else if ( event.jbutton.button == 5 ) { // Start
797 ui_mask &= ~uisb_start;
799 } else if ( event.jbutton.button == 7 ) { // L
802 } else if ( event.jbutton.button == 8 ) { // R
813 #if 1 // keyboard events
816 //pnd_log ( pndn_debug, "key up %u\n", event.key.keysym.sym );
818 // SDLK_LALT -> Start
821 if ( event.key.keysym.sym == SDLK_RIGHT ) {
824 } else if ( event.key.keysym.sym == SDLK_LEFT ) {
827 } else if ( event.key.keysym.sym == SDLK_UP ) {
830 } else if ( event.key.keysym.sym == SDLK_DOWN ) {
833 } else if ( event.key.keysym.sym == SDLK_SPACE || event.key.keysym.sym == SDLK_END ) {
836 } else if ( event.key.keysym.sym == SDLK_z || event.key.keysym.sym == SDLK_RSHIFT ) {
839 } else if ( event.key.keysym.sym == SDLK_x || event.key.keysym.sym == SDLK_RCTRL ) {
843 } else if ( event.key.keysym.sym == SDLK_LALT ) { // start button
844 char *opts [ 10 ] = {
845 "Return to Minimenu",
847 "Rescan for Applications",
848 "Set to full desktop and reboot",
849 "Set to pmenu and reboot",
853 int sel = ui_modal_single_menu ( opts, 7, "Minimenu", "Enter to select; other to return." );
858 } else if ( sel == 1 ) {
859 sprintf ( buffer, "sudo poweroff" );
861 } else if ( sel == 2 ) {
863 } else if ( sel == 3 ) {
865 sprintf ( buffer, "echo startxfce4 > /tmp/gui.load" );
867 sprintf ( buffer, "sudo poweroff" );
869 } else if ( sel == 4 ) {
871 sprintf ( buffer, "echo pmenu > /tmp/gui.load" );
873 sprintf ( buffer, "sudo poweroff" );
875 } else if ( sel == 5 ) {
876 emit_and_quit ( MM_QUIT );
877 } else if ( sel == 6 ) {
885 if ( event.key.keysym.sym == SDLK_q ) {
886 emit_and_quit ( MM_QUIT );
892 #if 0 // mouse / touchscreen
893 case SDL_MOUSEBUTTONDOWN:
894 if ( event.button.button == SDL_BUTTON_LEFT ) {
895 cb_pointer_press ( gc, event.button.x / g_scale, event.button.y / g_scale );
900 case SDL_MOUSEBUTTONUP:
901 if ( event.button.button == SDL_BUTTON_LEFT ) {
902 cb_pointer_release ( gc, event.button.x / g_scale, event.button.y / g_scale );
916 } // switch event type
923 void ui_push_left ( void ) {
925 if ( ! ui_selected ) {
930 // are we alreadt at first item?
931 if ( g_categories [ ui_category ].refs == ui_selected ) {
932 // can't go any more left, we're at the head
934 // figure out the previous item; yay for singly linked list :/
935 mm_appref_t *i = g_categories [ ui_category ].refs;
937 if ( i -> next == ui_selected ) {
945 ui_set_selected ( ui_selected );
950 void ui_push_right ( void ) {
954 if ( ui_selected -> next ) {
955 ui_selected = ui_selected -> next;
959 ui_selected = g_categories [ ui_category ].refs;
962 ui_set_selected ( ui_selected );
967 void ui_push_up ( void ) {
968 unsigned char col_max = pnd_conf_get_as_int ( g_conf, MMENU_DISP_COLMAX );
978 void ui_push_down ( void ) {
979 unsigned char col_max = pnd_conf_get_as_int ( g_conf, MMENU_DISP_COLMAX );
993 void ui_push_exec ( void ) {
996 char buffer [ PATH_MAX ];
997 sprintf ( buffer, "%s/%s", ui_selected -> ref -> object_path, ui_selected -> ref -> object_filename );
998 pnd_apps_exec ( pnd_run_script,
1000 ui_selected -> ref -> unique_id,
1001 ui_selected -> ref -> exec,
1002 ui_selected -> ref -> startdir,
1003 ui_selected -> ref -> execargs,
1004 atoi ( ui_selected -> ref -> clockspeed ),
1005 PND_EXEC_OPTION_NORUN );
1006 sprintf ( buffer, "%s %s\n", MM_RUN, pnd_apps_exec_runline() );
1007 emit_and_quit ( buffer );
1013 void ui_push_ltrigger ( void ) {
1014 unsigned char oldcat = ui_category;
1016 if ( ui_category > 0 ) {
1019 if ( pnd_conf_get_as_int_d ( g_conf, "tabs.wraparound", 0 ) > 0 ) {
1020 ui_category = g_categorycount - 1;
1024 if ( oldcat != ui_category ) {
1026 ui_set_selected ( ui_selected );
1029 // make tab visible?
1030 if ( ui_catshift > 0 && ui_category == ui_catshift - 1 ) {
1035 ui_rows_scrolled_down = 0;
1040 void ui_push_rtrigger ( void ) {
1041 unsigned char oldcat = ui_category;
1043 unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
1044 unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
1046 if ( ui_category < ( g_categorycount - 1 ) ) {
1049 if ( pnd_conf_get_as_int_d ( g_conf, "tabs.wraparound", 0 ) > 0 ) {
1054 if ( oldcat != ui_category ) {
1056 ui_set_selected ( ui_selected );
1059 // make tab visible?
1060 if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
1065 ui_rows_scrolled_down = 0;
1070 SDL_Surface *ui_scale_image ( SDL_Surface *s, unsigned int maxwidth, int maxheight ) {
1071 double scale = 1000000.0;
1072 double scalex = 1000000.0;
1073 double scaley = 1000000.0;
1074 SDL_Surface *scaled;
1076 scalex = (double)maxwidth / (double)s -> w;
1078 if ( maxheight == -1 ) {
1081 scaley = (double)maxheight / (double)s -> h;
1083 if ( scaley < scalex ) {
1091 pnd_log ( pndn_debug, " Upscaling; scale factor %f\n", scale );
1092 scaled = rotozoomSurface ( s, 0 /* angle*/, scale /* scale */, 1 /* smooth==1*/ );
1093 SDL_FreeSurface ( s );
1099 void ui_loadscreen ( void ) {
1103 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
1104 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
1105 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
1106 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
1109 SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
1113 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
1114 rtext = TTF_RenderText_Blended ( g_big_font, "Setting up menu...", tmpfontcolor );
1117 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, &dest );
1118 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1119 SDL_FreeSurface ( rtext );
1124 void ui_discoverscreen ( unsigned char clearscreen ) {
1128 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
1129 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
1130 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
1131 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
1134 if ( clearscreen ) {
1135 SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
1137 // render background
1138 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
1141 dest.w = sdl_realscreen -> w;
1142 dest.h = sdl_realscreen -> h;
1143 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, NULL /* 0,0 */ );
1144 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1151 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
1152 rtext = TTF_RenderText_Blended ( g_big_font, "Looking for applications...", tmpfontcolor );
1153 if ( clearscreen ) {
1160 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, &dest );
1161 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1162 SDL_FreeSurface ( rtext );
1165 if ( g_imagecache [ IMG_ICON_MISSING ].i ) {
1166 dest.x = rtext -> w + 30;
1168 SDL_BlitSurface ( g_imagecache [ IMG_ICON_MISSING ].i, NULL, sdl_realscreen, &dest );
1169 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1175 void ui_cachescreen ( unsigned char clearscreen, char *filename ) {
1177 SDL_Rect rects [ 4 ];
1178 SDL_Rect *dest = rects;
1179 bzero ( dest, sizeof(SDL_Rect)* 4 );
1181 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
1182 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
1183 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
1184 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
1186 static unsigned int stepx = 0;
1189 if ( clearscreen ) {
1190 SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
1192 // render background
1193 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
1196 dest -> w = sdl_realscreen -> w;
1197 dest -> h = sdl_realscreen -> h;
1198 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, NULL /* 0,0 */ );
1206 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
1207 rtext = TTF_RenderText_Blended ( g_big_font, "Caching applications artwork...", tmpfontcolor );
1208 if ( clearscreen ) {
1215 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1216 SDL_FreeSurface ( rtext );
1220 if ( g_imagecache [ IMG_ICON_MISSING ].i ) {
1221 dest -> x = rtext -> w + 30 + stepx;
1223 SDL_BlitSurface ( g_imagecache [ IMG_ICON_MISSING ].i, NULL, sdl_realscreen, dest );
1229 rtext = TTF_RenderText_Blended ( g_tab_font, filename, tmpfontcolor );
1232 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1233 SDL_FreeSurface ( rtext );
1240 if ( stepx > 350 ) {
1244 SDL_UpdateRects ( sdl_realscreen, dest - rects, rects );
1249 int ui_selected_index ( void ) {
1251 if ( ! ui_selected ) {
1252 return ( -1 ); // no index
1255 mm_appref_t *r = g_categories [ ui_category ].refs;
1258 if ( r == ui_selected ) {
1268 static mm_appref_t *timer_ref = NULL;
1269 void ui_set_selected ( mm_appref_t *r ) {
1271 if ( ! pnd_conf_get_as_int_d ( g_conf, "minimenu.load_previews_later", 0 ) ) {
1272 return; // no desire to defer anything
1277 SDL_SetTimer ( 0, NULL );
1282 SDL_SetTimer ( pnd_conf_get_as_int_d ( g_conf, "previewpic.defer_timer_ms", 1000 ), ui_callback_f );
1288 unsigned int ui_callback_f ( unsigned int t ) {
1290 if ( ui_selected != timer_ref ) {
1291 return ( 0 ); // user has moved it, who cares
1295 e.type = SDL_USEREVENT;
1296 SDL_PushEvent ( &e );
1301 int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *footer ) {
1302 SDL_Rect rects [ 40 ];
1303 SDL_Rect *dest = rects;
1307 bzero ( rects, sizeof(SDL_Rect) * 40 );
1309 unsigned int sel = 0;
1311 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
1312 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
1313 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
1314 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
1316 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
1318 SDL_Color selfontcolor = { 0/*font_rgba_r*/, font_rgba_g, font_rgba_b, font_rgba_a };
1326 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
1327 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
1328 dest -> w = ((SDL_Surface*) g_imagecache [ IMG_DETAIL_PANEL ].i) -> w;
1329 dest -> h = ((SDL_Surface*) g_imagecache [ IMG_DETAIL_PANEL ].i) -> h;
1330 SDL_FillRect( sdl_realscreen, dest, 0 );
1332 // show dialog background
1333 if ( g_imagecache [ IMG_DETAIL_BG ].i ) {
1334 src.x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
1335 src.y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
1336 src.w = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> w;
1337 src.h = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> h;
1338 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
1339 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
1340 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
1341 // repeat for darken?
1342 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
1343 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
1344 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1348 // show dialog frame
1349 if ( g_imagecache [ IMG_DETAIL_PANEL ].i ) {
1350 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
1351 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
1352 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_PANEL ].i, NULL /* whole image */, sdl_realscreen, dest );
1353 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
1359 rtext = TTF_RenderText_Blended ( g_tab_font, title, tmpfontcolor );
1360 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
1361 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) + 20;
1362 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1363 SDL_FreeSurface ( rtext );
1369 rtext = TTF_RenderText_Blended ( g_tab_font, footer, tmpfontcolor );
1370 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
1371 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) +
1372 ((SDL_Surface*) g_imagecache [ IMG_DETAIL_PANEL ].i) -> h
1374 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1375 SDL_FreeSurface ( rtext );
1380 for ( i = 0; i < argc; i++ ) {
1384 rtext = TTF_RenderText_Blended ( g_tab_font, argv [ i ], selfontcolor );
1386 rtext = TTF_RenderText_Blended ( g_tab_font, argv [ i ], tmpfontcolor );
1388 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
1389 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) + 40 + ( 20 * ( i + 1 ) );
1390 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
1391 SDL_FreeSurface ( rtext );
1396 // update all the rects and send it all to sdl
1397 SDL_UpdateRects ( sdl_realscreen, dest - rects, rects );
1401 while ( SDL_WaitEvent ( &event ) ) {
1403 switch ( event.type ) {
1407 if ( event.key.keysym.sym == SDLK_UP ) {
1411 } else if ( event.key.keysym.sym == SDLK_DOWN ) {
1412 if ( sel < argc - 1 ) {
1416 } else if ( event.key.keysym.sym == SDLK_RETURN ) {
1419 } else if ( event.key.keysym.sym == SDLK_q ) {
1423 return ( -1 ); // nada