2 #include <stdio.h> /* for FILE etc */
3 #include <stdlib.h> /* for malloc */
4 #include <unistd.h> /* for unlink */
5 #include <limits.h> /* for PATH_MAX */
8 #define __USE_GNU /* for strcasestr */
9 #include <string.h> /* for making ftw.h happy */
13 #include "SDL_audio.h"
14 #include "SDL_image.h"
16 #include "SDL_gfxPrimitives.h"
17 #include "SDL_rotozoom.h"
18 #include "SDL_thread.h"
22 #include "pnd_logger.h"
24 #include "pnd_container.h"
25 #include "pnd_discovery.h"
27 #include "pnd_device.h"
28 #include "../lib/pnd_pathiter.h"
29 #include "pnd_utility.h"
30 #include "pnd_pndfiles.h"
31 #include "pnd_notify.h"
32 #include "pnd_dbusnotify.h"
38 #include "mmwrapcmd.h"
40 #include "mmui_context.h"
42 #define CHANGED_NOTHING (0)
43 #define CHANGED_CATEGORY (1<<0) /* changed to different category */
44 #define CHANGED_SELECTION (1<<1) /* changed app selection */
45 #define CHANGED_DATAUPDATE (1<<2) /* deferred preview pic or icon came in */
46 #define CHANGED_APPRELOAD (1<<3) /* new set of applications entirely */
47 #define CHANGED_EVERYTHING (1<<4) /* redraw it all! */
48 unsigned int render_mask = CHANGED_EVERYTHING;
50 #define MIMETYPE_EXE "/usr/bin/file" /* check for file type prior to invocation */
54 SDL_Surface *sdl_realscreen = NULL;
55 unsigned int sdl_ticks = 0;
56 SDL_Thread *g_preview_thread = NULL;
57 SDL_Thread *g_timer_thread = NULL;
59 enum { sdl_user_ticker = 0,
60 sdl_user_finishedpreview = 1,
61 sdl_user_finishedicon = 2,
67 unsigned short int g_scale = 1; // 1 == noscale
69 SDL_Surface *g_imgcache [ IMG_MAX ];
71 TTF_Font *g_big_font = NULL;
72 TTF_Font *g_grid_font = NULL;
73 TTF_Font *g_detailtext_font = NULL;
74 TTF_Font *g_tab_font = NULL;
76 extern pnd_conf_handle g_conf;
78 /* current display state
80 int ui_rows_scrolled_down = 0; // number of rows that should be missing from top of the display
81 mm_appref_t *ui_selected = NULL;
82 unsigned char ui_category = 0; // current category
83 unsigned char ui_catshift = 0; // how many cats are offscreen to the left
84 ui_context_t ui_display_context; // display paramaters: see mmui_context.h
85 unsigned char ui_detail_hidden = 0; // if >0, detail panel is hidden
86 // FUTURE: If multiple panels can be shown/hidden, convert ui_detail_hidden to a bitmask
88 static SDL_Surface *ui_scale_image ( SDL_Surface *s, unsigned int maxwidth, int maxheight ); // height -1 means ignore
89 static int ui_selected_index ( void );
91 unsigned char ui_setup ( void ) {
96 SDL_Init ( SDL_INIT_EVERYTHING | SDL_INIT_NOPARACHUTE );
98 SDL_JoystickOpen ( 0 ); // turn on joy-0
100 SDL_WM_SetCaption ( "mmenu", "mmenu" );
102 // hide the mouse cursor if we can
103 if ( SDL_ShowCursor ( -1 ) == 1 ) {
104 SDL_ShowCursor ( 0 );
110 unsigned int svm = SDL_SWSURFACE /*| SDL_FULLSCREEN*/ /* 0*/;
111 if ( pnd_conf_get_as_int_d ( g_conf, "display.fullscreen", 0 ) > 0 ) {
112 svm |= SDL_FULLSCREEN;
116 SDL_SetVideoMode ( 800 * g_scale, 480 * g_scale, 16 /*bpp*/, svm );
118 if ( ! sdl_realscreen ) {
119 pnd_log ( pndn_error, "ERROR: Couldn't open SDL real screen; dieing." );
123 pnd_log ( pndn_debug, "Pixel format:" );
124 pnd_log ( pndn_debug, "bpp b: %u\n", sdl_realscreen -> format -> BitsPerPixel );
125 pnd_log ( pndn_debug, "bpp B: %u\n", sdl_realscreen -> format -> BytesPerPixel );
126 pnd_log ( pndn_debug, "R mask: %08x\n", sdl_realscreen -> format -> Rmask );
127 pnd_log ( pndn_debug, "G mask: %08x\n", sdl_realscreen -> format -> Gmask );
128 pnd_log ( pndn_debug, "B mask: %08x\n", sdl_realscreen -> format -> Bmask );
134 /* Set 16-bit stereo audio at 22Khz */
135 fmt.freq = 44100; //22050;
136 fmt.format = AUDIO_S16; //AUDIO_S16;
138 fmt.samples = 2048; /* A good value for games */
139 fmt.callback = mixaudio;
142 /* Open the audio device and start playing sound! */
143 if ( SDL_OpenAudio ( &fmt, NULL ) < 0 ) {
144 zotlog ( "Unable to open audio: %s\n", SDL_GetError() );
148 SDL_PauseAudio ( 0 );
153 SDL_EnableKeyRepeat ( 500, 150 );
156 //IMG_Init ( IMG_INIT_JPG | IMG_INIT_PNG );
162 if ( TTF_Init() == -1 ) {
163 pnd_log ( pndn_error, "ERROR: Couldn't set up SDL TTF lib\n" );
164 return ( 0 ); // couldn't set up SDL TTF
167 char fullpath [ PATH_MAX ];
169 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "minimenu.font" ) );
170 g_big_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "minimenu.font_ptsize", 24 ) );
171 if ( ! g_big_font ) {
172 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
173 pnd_conf_get_as_char ( g_conf, "minimenu.font" ), pnd_conf_get_as_int_d ( g_conf, "minimenu.font_ptsize", 24 ) );
174 return ( 0 ); // couldn't set up SDL TTF
178 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "grid.font" ) );
179 g_grid_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "grid.font_ptsize", 10 ) );
180 if ( ! g_grid_font ) {
181 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
182 pnd_conf_get_as_char ( g_conf, "grid.font" ), pnd_conf_get_as_int_d ( g_conf, "grid.font_ptsize", 10 ) );
183 return ( 0 ); // couldn't set up SDL TTF
187 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "detailtext.font" ) );
188 g_detailtext_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "detailtext.font_ptsize", 10 ) );
189 if ( ! g_detailtext_font ) {
190 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
191 pnd_conf_get_as_char ( g_conf, "detailtext.font" ), pnd_conf_get_as_int_d ( g_conf, "detailtext.font_ptsize", 10 ) );
192 return ( 0 ); // couldn't set up SDL TTF
196 sprintf ( fullpath, "%s/%s", g_skinpath, pnd_conf_get_as_char ( g_conf, "tabs.font" ) );
197 g_tab_font = TTF_OpenFont ( fullpath, pnd_conf_get_as_int_d ( g_conf, "tabs.font_ptsize", 10 ) );
198 if ( ! g_tab_font ) {
199 pnd_log ( pndn_error, "ERROR: Couldn't load font '%s' for size %u\n",
200 pnd_conf_get_as_char ( g_conf, "tabs.font" ), pnd_conf_get_as_int_d ( g_conf, "tabs.font_ptsize", 10 ) );
201 return ( 0 ); // couldn't set up SDL TTF
204 // determine display context
205 if ( pnd_conf_get_as_int_d ( g_conf, "display.show_detail_pane", 1 ) > 0 ) {
206 ui_detail_hidden = 0;
208 ui_detail_hidden = 1;
210 ui_recache_context ( &ui_display_context );
215 mm_imgcache_t g_imagecache [ IMG_TRUEMAX ] = {
216 { IMG_BACKGROUND_800480, "graphics.IMG_BACKGROUND_800480" },
217 { IMG_BACKGROUND_TABMASK, "graphics.IMG_BACKGROUND_TABMASK" },
218 { IMG_DETAIL_PANEL, "graphics.IMG_DETAIL_PANEL" },
219 { IMG_DETAIL_BG, "graphics.IMG_DETAIL_BG" },
220 { IMG_SELECTED_ALPHAMASK, "graphics.IMG_SELECTED_ALPHAMASK" },
221 { IMG_TAB_SEL, "graphics.IMG_TAB_SEL" },
222 { IMG_TAB_SEL_L, "graphics.IMG_TAB_SEL_L" },
223 { IMG_TAB_SEL_R, "graphics.IMG_TAB_SEL_R" },
224 { IMG_TAB_UNSEL, "graphics.IMG_TAB_UNSEL" },
225 { IMG_TAB_UNSEL_L, "graphics.IMG_TAB_UNSEL_L" },
226 { IMG_TAB_UNSEL_R, "graphics.IMG_TAB_UNSEL_R" },
227 { IMG_TAB_LINE, "graphics.IMG_TAB_LINE" },
228 { IMG_TAB_LINEL, "graphics.IMG_TAB_LINEL" },
229 { IMG_TAB_LINER, "graphics.IMG_TAB_LINER" },
230 { IMG_ICON_MISSING, "graphics.IMG_ICON_MISSING" },
231 { IMG_SELECTED_HILITE, "graphics.IMG_SELECTED_HILITE" },
232 { IMG_PREVIEW_MISSING, "graphics.IMG_PREVIEW_MISSING" },
233 { IMG_ARROW_UP, "graphics.IMG_ARROW_UP", },
234 { IMG_ARROW_DOWN, "graphics.IMG_ARROW_DOWN", },
235 { IMG_ARROW_SCROLLBAR, "graphics.IMG_ARROW_SCROLLBAR", },
236 { IMG_HOURGLASS, "graphics.IMG_HOURGLASS", },
237 { IMG_FOLDER, "graphics.IMG_FOLDER", },
238 { IMG_EXECBIN, "graphics.IMG_EXECBIN", },
242 unsigned char ui_imagecache ( char *basepath ) {
244 char fullpath [ PATH_MAX ];
248 for ( i = 0; i < IMG_MAX; i++ ) {
250 if ( g_imagecache [ i ].id != i ) {
251 pnd_log ( pndn_error, "ERROR: Internal table mismatch during caching [%u]\n", i );
255 char *filename = pnd_conf_get_as_char ( g_conf, g_imagecache [ i ].confname );
258 pnd_log ( pndn_error, "ERROR: Missing filename in conf for key: %s\n", g_imagecache [ i ].confname );
262 if ( filename [ 0 ] == '/' ) {
263 strncpy ( fullpath, filename, PATH_MAX );
265 sprintf ( fullpath, "%s/%s", basepath, filename );
268 if ( ! ( g_imagecache [ i ].i = IMG_Load ( fullpath ) ) ) {
269 pnd_log ( pndn_error, "ERROR: Couldn't load static cache image: %s\n", fullpath );
276 //g_imagecache [ IMG_SELECTED_ALPHAMASK ].i = SDL_CreateRGBSurface ( SDL_SWSURFACE, 60, 60, 32, 0xFF0000, 0x00FF00, 0xFF, 0xFF000000 );
277 //boxRGBA ( g_imagecache [ IMG_SELECTED_ALPHAMASK ].i, 0, 0, 60, 60, 100, 100, 100, 250 );
283 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 );
284 // scale text hilight
285 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 );
286 // scale preview no-pic
287 g_imagecache [ IMG_PREVIEW_MISSING ].i = ui_scale_image ( g_imagecache [ IMG_PREVIEW_MISSING ].i,
288 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 50 ),
289 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 50 ) );
291 // set alpha on detail panel
292 //SDL_SetAlpha ( g_imagecache [ IMG_DETAIL_BG ].i, SDL_SRCALPHA, pnd_conf_get_as_int_d ( g_conf, "display.detail_bg_alpha", 50 ) );
297 void ui_render ( void ) {
300 // divide width: 550 / 250
301 // divide left side: 5 columns == 110px width
302 // 20px buffer either side == 70px wide icon + 20 + 20?
304 // what jobs to do during render?
308 #define R_TABS (1<<1)
309 #define R_DETAIL (1<<2)
310 #define R_GRID (1<<3)
312 #define R_ALL (R_BG|R_TABS|R_DETAIL|R_GRID)
314 unsigned int render_jobs_b = 0;
316 if ( render_mask & CHANGED_EVERYTHING ) {
317 render_jobs_b |= R_ALL;
320 if ( render_mask & CHANGED_SELECTION ) {
321 render_jobs_b |= R_GRID;
322 render_jobs_b |= R_DETAIL;
325 if ( render_mask & CHANGED_CATEGORY ) {
326 render_jobs_b |= R_ALL;
329 render_mask = CHANGED_NOTHING;
333 unsigned int icon_rows;
336 SDL_Rect rects [ MAXRECTS ], src;
337 SDL_Rect *dest = rects;
338 bzero ( dest, sizeof(SDL_Rect)*MAXRECTS );
340 unsigned int row, displayrow, col;
341 mm_appref_t *appiter;
343 ui_context_t *c = &ui_display_context; // for convenience and shorthand
345 // how many total rows do we need?
346 if ( g_categorycount ) {
347 icon_rows = g_categories [ ui_category ] -> refcount / c -> col_max;
348 if ( g_categories [ ui_category ] -> refcount % c -> col_max > 0 ) {
356 // if no selected app yet, select the first one
357 if ( ! ui_selected && pnd_conf_get_as_int_d ( g_conf, "minimenu.start_selected", 0 ) ) {
358 ui_selected = g_categories [ ui_category ] -> refs;
362 // reset touchscreen regions
363 if ( render_jobs_b ) {
367 // ensure selection is visible
370 int index = ui_selected_index();
371 int topleft = c -> col_max * ui_rows_scrolled_down;
372 int botright = ( c -> col_max * ( ui_rows_scrolled_down + c -> row_max ) - 1 );
374 if ( index < topleft ) {
375 ui_rows_scrolled_down -= pnd_conf_get_as_int_d ( g_conf, "grid.scroll_increment", 1 );
376 render_jobs_b |= R_ALL;
377 } else if ( index > botright ) {
378 ui_rows_scrolled_down += pnd_conf_get_as_int_d ( g_conf, "grid.scroll_increment", 1 );
379 render_jobs_b |= R_ALL;
382 if ( ui_rows_scrolled_down < 0 ) {
383 ui_rows_scrolled_down = 0;
384 } else if ( ui_rows_scrolled_down > icon_rows ) {
385 ui_rows_scrolled_down = icon_rows;
391 if ( render_jobs_b & R_BG ) {
393 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
396 dest -> w = sdl_realscreen -> w;
397 dest -> h = sdl_realscreen -> h;
398 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, dest /* 0,0 */ );
403 if ( g_imagecache [ IMG_BACKGROUND_TABMASK ].i ) {
406 dest -> w = sdl_realscreen -> w;
407 dest -> h = sdl_realscreen -> h;
408 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_TABMASK ].i, NULL /* whole image */, sdl_realscreen, dest /* 0,0 */ );
415 if ( g_imagecache [ IMG_TAB_SEL ].i && g_imagecache [ IMG_TAB_UNSEL ].i ) {
416 static unsigned int tab_width;
417 static unsigned int tab_height;
418 static unsigned int tab_offset_x;
419 static unsigned int tab_offset_y;
420 static unsigned int text_offset_x;
421 static unsigned int text_offset_y;
422 static unsigned int text_width;
424 static unsigned char tab_first_run = 1;
425 if ( tab_first_run ) {
427 tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
428 tab_height = pnd_conf_get_as_int ( g_conf, "tabs.tab_height" );
429 tab_offset_x = pnd_conf_get_as_int ( g_conf, "tabs.tab_offset_x" );
430 tab_offset_y = pnd_conf_get_as_int ( g_conf, "tabs.tab_offset_y" );
431 text_offset_x = pnd_conf_get_as_int ( g_conf, "tabs.text_offset_x" );
432 text_offset_y = pnd_conf_get_as_int ( g_conf, "tabs.text_offset_y" );
433 text_width = pnd_conf_get_as_int ( g_conf, "tabs.text_width" );
436 unsigned int maxtab = ( c -> screen_width / tab_width ) < g_categorycount ? ( c -> screen_width / tab_width ) + ui_catshift : g_categorycount + ui_catshift;
437 unsigned int maxtabspot = ( c -> screen_width / tab_width );
439 if ( g_categorycount > 0 ) {
441 // draw tabs with categories
442 for ( col = ui_catshift;
449 // if this is the first (leftmost) tab, we use different artwork
450 // than if the other tabs (so skinner can link lines up nicely.)
451 if ( col == ui_catshift ) {
452 // leftmost tab, special case
454 if ( col == ui_category ) {
455 s = g_imagecache [ IMG_TAB_SEL_L ].i;
457 s = g_imagecache [ IMG_TAB_UNSEL_L ].i;
460 } else if ( col == maxtab - 1 ) {
461 // rightmost tab, special case
463 if ( col == ui_category ) {
464 s = g_imagecache [ IMG_TAB_SEL_R ].i;
466 s = g_imagecache [ IMG_TAB_UNSEL_R ].i;
470 // normal (not leftmost) tab
472 if ( col == ui_category ) {
473 s = g_imagecache [ IMG_TAB_SEL ].i;
475 s = g_imagecache [ IMG_TAB_UNSEL ].i;
478 } // first col, or not first col?
485 if ( col == ui_category ) {
486 src.h = tab_selheight;
494 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
495 dest -> y = tab_offset_y;
498 ui_register_tab ( col, dest -> x, dest -> y, tab_width, tab_height );
500 if ( render_jobs_b & R_TABS ) {
501 //pnd_log ( pndn_debug, "tab %u at %ux%u\n", col, dest.x, dest.y );
502 SDL_BlitSurface ( s, &src, sdl_realscreen, dest );
506 if ( col == ui_category ) {
507 // no line for selected tab
509 if ( col - ui_catshift == 0 ) {
510 s = g_imagecache [ IMG_TAB_LINEL ].i;
511 } else if ( col - ui_catshift == maxtabspot - 1 ) {
512 s = g_imagecache [ IMG_TAB_LINER ].i;
514 s = g_imagecache [ IMG_TAB_LINE ].i;
516 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
517 dest -> y = tab_offset_y + tab_height;
518 SDL_BlitSurface ( s, NULL /* whole image */, sdl_realscreen, dest );
524 rtext = TTF_RenderText_Blended ( g_tab_font, g_categories [ col ] -> catname, c -> fontcolor );
527 src.w = rtext -> w < text_width ? rtext -> w : text_width;
529 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width ) + text_offset_x;
530 dest -> y = tab_offset_y + text_offset_y;
531 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
532 SDL_FreeSurface ( rtext );
539 } // if we got categories
541 if ( render_jobs_b & R_TABS ) {
543 // draw tab lines under where tabs would be if we had categories
544 for ( /* foo */; col < maxtabspot; col++ ) {
547 if ( col - ui_catshift == 0 ) {
548 s = g_imagecache [ IMG_TAB_LINEL ].i;
549 } else if ( col - ui_catshift == maxtabspot - 1 ) {
550 s = g_imagecache [ IMG_TAB_LINER ].i;
552 s = g_imagecache [ IMG_TAB_LINE ].i;
554 dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
555 dest -> y = tab_offset_y + tab_height;
556 SDL_BlitSurface ( s, NULL /* whole image */, sdl_realscreen, dest );
565 // scroll bars and arrows
566 if ( render_jobs_b & R_BG ) {
567 unsigned char show_bar = 0;
570 if ( ui_rows_scrolled_down && g_imagecache [ IMG_ARROW_UP ].i ) {
571 dest -> x = c -> arrow_up_x;
572 dest -> y = c -> arrow_up_y;
573 SDL_BlitSurface ( g_imagecache [ IMG_ARROW_UP ].i, NULL /* whole image */, sdl_realscreen, dest );
580 if ( ui_rows_scrolled_down + c -> row_max < icon_rows && g_imagecache [ IMG_ARROW_DOWN ].i ) {
581 dest -> x = c -> arrow_down_x;
582 dest -> y = c -> arrow_down_y;
583 SDL_BlitSurface ( g_imagecache [ IMG_ARROW_DOWN ].i, NULL /* whole image */, sdl_realscreen, dest );
590 // show scrollbar as well
593 src.w = c -> arrow_bar_clip_w;
594 src.h = c -> arrow_bar_clip_h;
595 dest -> x = c -> arrow_bar_x;
596 dest -> y = c -> arrow_bar_y;
597 SDL_BlitSurface ( g_imagecache [ IMG_ARROW_SCROLLBAR ].i, &src /* whole image */, sdl_realscreen, dest );
601 } // r_bg, scroll bars
603 // render detail pane bg
604 if ( render_jobs_b & R_DETAIL && ui_detail_hidden == 0 ) {
606 if ( pnd_conf_get_as_int_d ( g_conf, "detailpane.show", 1 ) ) {
609 if ( g_imagecache [ IMG_DETAIL_BG ].i ) {
610 src.x = 0; // pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
611 src.y = 0; // pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
612 src.w = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> w;
613 src.h = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_PANEL ].i)) -> h;
614 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
615 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
616 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
620 // render detail pane
621 if ( g_imagecache [ IMG_DETAIL_PANEL ].i ) {
622 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
623 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
624 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_PANEL ].i, NULL /* whole image */, sdl_realscreen, dest );
628 } // detailpane frame/bg
632 // anything to render?
633 if ( render_jobs_b & R_GRID && g_categorycount ) {
635 // if just rendering grid, and nothing else, better clear it first
636 if ( ! ( render_jobs_b & R_BG ) ) {
637 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
638 src.x = c -> grid_offset_x;
639 src.y = c -> grid_offset_y + c -> sel_icon_offset_y;
640 src.w = c -> col_max * c -> cell_width;
641 src.h = c -> row_max * c -> cell_height;
643 dest -> x = c -> grid_offset_x;
644 dest -> y = c -> grid_offset_y + c -> sel_icon_offset_y;
646 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, &src, sdl_realscreen, dest );
652 if ( g_categories [ ui_category ] -> refs ) {
654 appiter = g_categories [ ui_category ] -> refs;
658 // until we run out of apps, or run out of space
659 while ( appiter != NULL ) {
661 for ( col = 0; col < c -> col_max && appiter != NULL; col++ ) {
663 // do we even need to render it? or are we suppressing it due to rows scrolled off the top?
664 if ( row >= ui_rows_scrolled_down ) {
666 // selected? show hilights
667 if ( appiter == ui_selected ) {
668 SDL_Surface *s = g_imagecache [ IMG_SELECTED_ALPHAMASK ].i;
670 //dest -> x = grid_offset_x + ( col * cell_width ) + icon_offset_x + ( ( icon_max_width - s -> w ) / 2 );
671 dest -> x = c -> grid_offset_x + ( col * c -> cell_width ) + c -> icon_offset_x + c -> sel_icon_offset_x;
672 //dest -> y = grid_offset_y + ( displayrow * cell_height ) + icon_offset_y + ( ( icon_max_height - s -> h ) / 2 );
673 dest -> y = c -> grid_offset_y + ( displayrow * c -> cell_height ) + c -> icon_offset_y + c -> sel_icon_offset_y;
674 SDL_BlitSurface ( s, NULL /* all */, sdl_realscreen, dest );
677 dest -> x = c -> grid_offset_x + ( col * c -> cell_width ) + c -> text_clip_x;
678 dest -> y = c -> grid_offset_y + ( displayrow * c -> cell_height ) + c -> text_hilite_offset_y;
679 SDL_BlitSurface ( g_imagecache [ IMG_SELECTED_HILITE ].i, NULL /* all */, sdl_realscreen, dest );
684 mm_cache_t *ic = cache_query_icon ( appiter -> ref -> unique_id );
685 SDL_Surface *iconsurface;
687 iconsurface = ic -> i;
689 //pnd_log ( pndn_warning, "WARNING: TBD: Need Missin-icon icon for '%s'\n", IFNULL(appiter -> ref -> title_en,"No Name") );
691 // no icon override; was this a pnd-file (show the unknown icon then), or was this generated from
692 // filesystem (file or directory icon)
693 if ( appiter -> ref -> object_flags & PND_DISCO_GENERATED ) {
694 if ( appiter -> ref -> object_type == pnd_object_type_directory ) {
695 iconsurface = g_imagecache [ IMG_FOLDER ].i;
697 iconsurface = g_imagecache [ IMG_EXECBIN ].i;
700 iconsurface = g_imagecache [ IMG_ICON_MISSING ].i;
705 // got an icon I hope?
707 //pnd_log ( pndn_debug, "Got an icon for '%s'\n", IFNULL(appiter -> ref -> title_en,"No Name") );
713 dest -> x = c -> grid_offset_x + ( col * c -> cell_width ) + c -> icon_offset_x + (( c -> icon_max_width - iconsurface -> w ) / 2);
714 dest -> y = c -> grid_offset_y + ( displayrow * c -> cell_height ) + c -> icon_offset_y + (( c -> icon_max_height - iconsurface -> h ) / 2);
716 SDL_BlitSurface ( iconsurface, &src, sdl_realscreen, dest );
719 ui_register_app ( appiter, dest -> x, dest -> y, src.w, src.h );
726 if ( appiter -> ref -> title_en ) {
728 rtext = TTF_RenderText_Blended ( g_grid_font, appiter -> ref -> title_en, c -> fontcolor );
731 src.w = c -> text_width < rtext -> w ? c -> text_width : rtext -> w;
733 if ( rtext -> w > c -> text_width ) {
734 dest -> x = c -> grid_offset_x + ( col * c -> cell_width ) + c -> text_clip_x;
736 dest -> x = c -> grid_offset_x + ( col * c -> cell_width ) + c -> text_offset_x - ( rtext -> w / 2 );
738 dest -> y = c -> grid_offset_y + ( displayrow * c -> cell_height ) + c -> text_offset_y;
739 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
740 SDL_FreeSurface ( rtext );
744 } // display now? or scrolled away..
747 appiter = appiter -> next;
749 } // for column 1...X
751 if ( row >= ui_rows_scrolled_down ) {
757 // are we done displaying rows?
758 if ( displayrow >= c -> row_max ) {
765 // no apps to render?
766 pnd_log ( pndn_rem, "No applications to render?\n" );
771 // detail panel - show app details or blank-message
772 if ( render_jobs_b & R_DETAIL && ui_detail_hidden == 0 ) {
774 unsigned int cell_offset_x = pnd_conf_get_as_int ( g_conf, "detailtext.cell_offset_x" );
775 unsigned int cell_offset_y = pnd_conf_get_as_int ( g_conf, "detailtext.cell_offset_y" );
776 unsigned int cell_width = pnd_conf_get_as_int ( g_conf, "detailtext.cell_width" );
778 unsigned int desty = cell_offset_y;
785 if ( ui_selected -> ref -> title_en ) {
787 rtext = TTF_RenderText_Blended ( g_detailtext_font, ui_selected -> ref -> title_en, c -> fontcolor );
790 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
792 dest -> x = cell_offset_x;
794 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
795 SDL_FreeSurface ( rtext );
802 if ( ui_selected -> ref -> main_category ) {
804 sprintf ( buffer, "Category: %s", ui_selected -> ref -> main_category );
807 rtext = TTF_RenderText_Blended ( g_detailtext_font, buffer, c -> fontcolor );
810 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
812 dest -> x = cell_offset_x;
814 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
815 SDL_FreeSurface ( rtext );
822 if ( ui_selected -> ref -> clockspeed ) {
824 sprintf ( buffer, "CPU Clock: %s", ui_selected -> ref -> clockspeed );
827 rtext = TTF_RenderText_Blended ( g_detailtext_font, buffer, c -> fontcolor );
830 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
832 dest -> x = cell_offset_x;
834 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
835 SDL_FreeSurface ( rtext );
840 // show sub-app# on right side of cpu clock?
841 //if ( ui_selected -> ref -> subapp_number )
843 sprintf ( buffer, "(app#%u)", ui_selected -> ref -> subapp_number );
846 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, c -> fontcolor );
847 dest -> x = cell_offset_x + cell_width - rtext -> w;
848 dest -> y = desty - src.h;
849 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
850 SDL_FreeSurface ( rtext );
855 #if 0 // merged into hint-line
856 if ( ui_selected -> ref -> info_filename ) {
858 sprintf ( buffer, "Documentation - hit Y" );
861 rtext = TTF_RenderText_Blended ( g_detailtext_font, buffer, c -> fontcolor );
864 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
866 dest -> x = cell_offset_x;
868 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
869 SDL_FreeSurface ( rtext );
876 if ( ui_selected -> ovrh ) {
881 desty += 5; // a touch of spacing can't hurt
883 for ( i = 1; i < 4; i++ ) {
884 sprintf ( buffer, "Application-%u.note-%u", ui_selected -> ref -> subapp_number, i );
885 n = pnd_conf_get_as_char ( ui_selected -> ovrh, buffer );
889 rtext = TTF_RenderText_Blended ( g_detailtext_font, n, c -> fontcolor );
892 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
894 dest -> x = cell_offset_x;
896 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
897 SDL_FreeSurface ( rtext );
903 } // r_detail -> notes
906 mm_cache_t *ic = cache_query_preview ( ui_selected -> ref -> unique_id );
907 SDL_Surface *previewpic;
910 previewpic = ic -> i;
912 previewpic = g_imagecache [ IMG_PREVIEW_MISSING ].i;
916 dest -> x = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_offset_x", 50 ) +
917 ( ( pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 50 ) - previewpic -> w ) / 2 );
918 dest -> y = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_offset_y", 50 );
919 SDL_BlitSurface ( previewpic, NULL /* whole image */, sdl_realscreen, dest );
925 char *empty_message = "Press SELECT for menu";
929 rtext = TTF_RenderText_Blended ( g_detailtext_font, empty_message, c -> fontcolor );
933 src.w = rtext -> w < cell_width ? rtext -> w : cell_width;
935 dest -> x = cell_offset_x;
937 SDL_BlitSurface ( rtext, &src, sdl_realscreen, dest );
938 SDL_FreeSurface ( rtext );
943 } // r_detail && selected?
951 if ( render_jobs_b & R_BG ) {
952 static int last_battlevel = 0;
953 static unsigned char batterylevel = 0;
956 if ( time ( NULL ) - last_battlevel > 60 ) {
957 batterylevel = pnd_device_get_battery_gauge_perc();
958 last_battlevel = time ( NULL );
961 sprintf ( buffer, "Battery: %u%%", batterylevel );
964 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, c -> fontcolor );
965 dest -> x = pnd_conf_get_as_int_d ( g_conf, "display.battery_x", 20 );
966 dest -> y = pnd_conf_get_as_int_d ( g_conf, "display.battery_y", 450 );
967 SDL_BlitSurface ( rtext, NULL /* all */, sdl_realscreen, dest );
968 SDL_FreeSurface ( rtext );
973 if ( pnd_conf_get_as_char ( g_conf, "display.hintline" ) ) {
975 unsigned int hintx, hinty;
976 hintx = pnd_conf_get_as_int_d ( g_conf, "display.hint_x", 40 );
977 hinty = pnd_conf_get_as_int_d ( g_conf, "display.hint_y", 450 );
978 static unsigned int lastwidth = 3000;
980 if ( ui_selected && ui_selected -> ref -> info_filename ) {
981 buffer = "Documentation - hit Y";
983 buffer = pnd_conf_get_as_char ( g_conf, "display.hintline" );
987 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, c -> fontcolor );
990 if ( ! ( render_jobs_b & R_BG ) ) {
997 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_TABMASK ].i, &src, sdl_realscreen, dest );
999 lastwidth = rtext -> w;
1005 SDL_BlitSurface ( rtext, NULL /* all */, sdl_realscreen, dest );
1006 SDL_FreeSurface ( rtext );
1011 if ( render_jobs_b & R_BG &&
1012 pnd_conf_get_as_int_d ( g_conf, "display.clock_x", -1 ) != -1 )
1016 time_t t = time ( NULL );
1017 struct tm *tm = localtime ( &t );
1018 strftime ( buffer, 50, "%a %H:%M %F", tm );
1021 rtext = TTF_RenderText_Blended ( g_grid_font, buffer, c -> fontcolor );
1022 dest -> x = pnd_conf_get_as_int_d ( g_conf, "display.clock_x", 700 );
1023 dest -> y = pnd_conf_get_as_int_d ( g_conf, "display.clock_y", 450 );
1024 SDL_BlitSurface ( rtext, NULL /* all */, sdl_realscreen, dest );
1025 SDL_FreeSurface ( rtext );
1029 // update all the rects and send it all to sdl
1030 // - at this point, we could probably just do 1 rect, of the
1031 // whole screen, and be faster :/
1032 SDL_UpdateRects ( sdl_realscreen, dest - rects, rects );
1036 void ui_process_input ( pnd_dbusnotify_handle dbh, pnd_notify_handle nh ) {
1039 unsigned char ui_event = 0; // if we get a ui event, flip to 1 and break
1040 //static ui_sdl_button_e ui_mask = uisb_none; // current buttons down
1042 while ( ( ! ui_event ) &&
1043 /*block_p ?*/ SDL_WaitEvent ( &event ) /*: SDL_PollEvent ( &event )*/ )
1046 switch ( event.type ) {
1051 // the user-defined SDL events are all for threaded/delayed previews (and icons, which
1052 // generally are not used); if we're in wide mode, we can skip previews
1053 // to avoid slowing things down when they're not shown.
1055 if ( event.user.code == sdl_user_ticker ) {
1057 if ( ui_detail_hidden ) {
1058 break; // skip building previews when not showing them
1061 // timer went off, time to load something
1062 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.load_previews_later", 0 ) ) {
1064 if ( ! ui_selected ) {
1068 // load the preview pics now!
1069 pnd_disco_t *iter = ui_selected -> ref;
1071 if ( iter -> preview_pic1 ) {
1073 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.threaded_preview", 0 ) ) {
1074 // load in bg thread, make user experience chuggy
1076 g_preview_thread = SDL_CreateThread ( (void*)ui_threaded_defered_preview, iter );
1078 if ( ! g_preview_thread ) {
1079 pnd_log ( pndn_error, "ERROR: Couldn't create preview thread\n" );
1083 // load it now, make user wait
1085 if ( ! cache_preview ( iter, pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 200 ),
1086 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 180 ) )
1089 pnd_log ( pndn_debug, " Couldn't load preview pic: '%s' -> '%s'\n",
1090 IFNULL(iter->title_en,"No Name"), iter -> preview_pic1 );
1095 } // got a preview at all?
1100 } else if ( event.user.code == sdl_user_finishedpreview ) {
1102 // if we just finished the one we happen to be looking at, better redraw now; otherwise, if
1103 // we finished another, no big woop
1104 if ( ui_selected && event.user.data1 == ui_selected -> ref ) {
1108 } else if ( event.user.code == sdl_user_finishedicon ) {
1109 // redraw, so we can show the newly loaded icon
1112 } else if ( event.user.code == sdl_user_checksd ) {
1113 // check if any inotify-type events occured, forcing us to rescan/re-disco the SDs
1115 unsigned char watch_dbus = 0;
1116 unsigned char watch_inotify = 0;
1119 watch_dbus = pnd_dbusnotify_rediscover_p ( dbh );
1123 watch_inotify = pnd_notify_rediscover_p ( nh );
1126 if ( watch_dbus || watch_inotify ) {
1127 pnd_log ( pndn_debug, "dbusnotify detected SD event\n" );
1128 applications_free();
1129 applications_scan();
1136 render_mask |= CHANGED_EVERYTHING;
1140 #if 0 // joystick motion
1141 case SDL_JOYAXISMOTION:
1143 pnd_log ( PND_LOG_DEFAULT, "joystick axis\n" );
1145 if ( event.jaxis.axis == 0 ) {
1147 if ( event.jaxis.value < 0 ) {
1149 pnd_log ( PND_LOG_DEFAULT, "joystick axis - LEFT\n" );
1150 } else if ( event.jaxis.value > 0 ) {
1151 ui_push_right ( 0 );
1152 pnd_log ( PND_LOG_DEFAULT, "joystick axis - RIGHT\n" );
1154 } else if ( event.jaxis.axis == 1 ) {
1156 if ( event.jaxis.value < 0 ) {
1158 } else if ( event.jaxis.value > 0 ) {
1168 #if 0 // joystick buttons
1169 case SDL_JOYBUTTONDOWN:
1171 pnd_log ( PND_LOG_DEFAULT, "joystick button down %u\n", event.jbutton.button );
1173 if ( event.jbutton.button == 0 ) { // B
1175 } else if ( event.jbutton.button == 1 ) { // Y
1177 } else if ( event.jbutton.button == 2 ) { // X
1179 } else if ( event.jbutton.button == 3 ) { // A
1182 } else if ( event.jbutton.button == 4 ) { // Select
1183 ui_mask |= uisb_select;
1184 } else if ( event.jbutton.button == 5 ) { // Start
1185 ui_mask |= uisb_start;
1187 } else if ( event.jbutton.button == 7 ) { // L
1189 } else if ( event.jbutton.button == 8 ) { // R
1198 case SDL_JOYBUTTONUP:
1200 pnd_log ( PND_LOG_DEFAULT, "joystick button up %u\n", event.jbutton.button );
1202 if ( event.jbutton.button == 0 ) { // B
1205 } else if ( event.jbutton.button == 1 ) { // Y
1207 } else if ( event.jbutton.button == 2 ) { // X
1209 } else if ( event.jbutton.button == 3 ) { // A
1212 } else if ( event.jbutton.button == 4 ) { // Select
1213 ui_mask &= ~uisb_select;
1214 } else if ( event.jbutton.button == 5 ) { // Start
1215 ui_mask &= ~uisb_start;
1217 } else if ( event.jbutton.button == 7 ) { // L
1220 } else if ( event.jbutton.button == 8 ) { // R
1231 #if 1 // keyboard events
1235 //pnd_log ( pndn_debug, "key up %u\n", event.key.keysym.sym );
1237 // SDLK_LALT -> Start
1238 // page up/down for y/x
1239 // home/end for a and b
1242 if ( event.key.keysym.sym == SDLK_RIGHT ) {
1243 ui_push_right ( 0 );
1245 } else if ( event.key.keysym.sym == SDLK_LEFT ) {
1248 } else if ( event.key.keysym.sym == SDLK_UP ) {
1251 } else if ( event.key.keysym.sym == SDLK_DOWN ) {
1254 } else if ( event.key.keysym.sym == SDLK_SPACE || event.key.keysym.sym == SDLK_END ) { // space or B
1257 } else if ( event.key.keysym.sym == SDLK_TAB || event.key.keysym.sym == SDLK_HOME ) { // tab or A
1258 // if detail panel is togglable, then toggle it
1259 // if not, make sure its ruddy well shown!
1260 if ( ui_is_detail_hideable() ) {
1261 ui_toggle_detail_pane();
1263 ui_detail_hidden = 0;
1266 } else if ( event.key.keysym.sym == SDLK_RSHIFT || event.key.keysym.sym == SDLK_COMMA ) { // left trigger or comma
1269 } else if ( event.key.keysym.sym == SDLK_RCTRL || event.key.keysym.sym == SDLK_PERIOD ) { // right trigger or period
1273 } else if ( event.key.keysym.sym == SDLK_PAGEUP ) { // Y
1275 if ( ui_selected ) {
1276 ui_show_info ( pnd_run_script, ui_selected -> ref );
1279 } else if ( event.key.keysym.sym == SDLK_PAGEDOWN ) { // X
1282 // forget the selection, nolonger applies
1284 ui_set_selected ( ui_selected );
1286 if ( g_categories [ ui_category ] -> fspath ) {
1287 category_fs_restock ( g_categories [ ui_category ] );
1290 render_mask |= CHANGED_EVERYTHING;
1293 } else if ( event.key.keysym.sym == SDLK_LALT ) { // start button
1297 } else if ( event.key.keysym.sym == SDLK_LCTRL /*LALT*/ ) { // select button
1298 char *opts [ 20 ] = {
1299 "Reveal hidden category",
1301 "Configure Minimenu",
1302 "Rescan for applications",
1303 "Cache previews to SD now",
1304 "Run a terminal/console",
1305 "Run another GUI (xfce, etc)",
1307 "Select a Minimenu skin",
1310 int sel = ui_modal_single_menu ( opts, 10, "Minimenu", "Enter to select; other to return." );
1312 char buffer [ 100 ];
1316 } else if ( sel == 1 ) {
1318 sprintf ( buffer, "sudo poweroff" );
1320 } else if ( sel == 2 ) {
1322 unsigned char restart = conf_run_menu ( NULL );
1323 conf_write ( g_conf, conf_determine_location ( g_conf ) );
1325 emit_and_quit ( MM_RESTART );
1327 } else if ( sel == 3 ) {
1329 pnd_log ( pndn_debug, "Freeing up applications\n" );
1330 applications_free();
1331 pnd_log ( pndn_debug, "Rescanning applications\n" );
1332 applications_scan();
1333 } else if ( sel == 4 ) {
1334 // cache preview to SD now
1335 extern pnd_box_handle g_active_apps;
1336 pnd_box_handle h = g_active_apps;
1338 unsigned int maxwidth, maxheight;
1339 maxwidth = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 200 );
1340 maxheight = pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 180 );
1342 pnd_disco_t *iter = pnd_box_get_head ( h );
1347 if ( ! cache_preview ( iter, maxwidth, maxheight ) ) {
1348 pnd_log ( pndn_debug, "Force cache: Couldn't load preview pic: '%s' -> '%s'\n",
1349 IFNULL(iter->title_en,"No Name"), iter -> preview_pic1 );
1353 iter = pnd_box_get_next ( iter );
1356 } else if ( sel == 5 ) {
1359 argv [ 0 ] = pnd_conf_get_as_char ( g_conf, "utility.terminal" );
1363 ui_forkexec ( argv );
1366 } else if ( sel == 6 ) {
1367 char buffer [ PATH_MAX ];
1368 sprintf ( buffer, "%s %s\n", MM_RUN, "/usr/pandora/scripts/op_switchgui.sh" );
1369 emit_and_quit ( buffer );
1370 } else if ( sel == 7 ) {
1371 emit_and_quit ( MM_QUIT );
1372 } else if ( sel == 8 ) {
1374 if ( ui_pick_skin() ) {
1375 emit_and_quit ( MM_RESTART );
1377 } else if ( sel == 9 ) {
1379 char buffer [ PATH_MAX ];
1380 sprintf ( buffer, "%s/about.txt", g_skinpath );
1381 ui_aboutscreen ( buffer );
1385 render_mask |= CHANGED_EVERYTHING;
1388 // unknown SDLK_ keycode?
1390 // many SDLK_keycodes map to ASCII ("a" is ascii(a)), so try to jump to a filename of that name, in this category?
1391 // and if already there, try to jump to next, maybe?
1392 // future: look for sequence typing? ie: user types 'm' then 'a', look for 'ma*' instead of 'm' then 'a' matching
1393 if ( isalpha ( event.key.keysym.sym ) && g_categories [ ui_category ] -> refcount > 0 ) {
1394 mm_appref_t *app = g_categories [ ui_category ] -> refs;
1396 //fprintf ( stderr, "sel %s next %s\n", ui_selected -> ref -> title_en, ui_selected -> next -> ref -> title_en );
1398 // are we already matching the same char? and next item is also same char?
1399 if ( app && ui_selected &&
1400 ui_selected -> ref -> title_en && ui_selected -> next -> ref -> title_en &&
1401 toupper ( ui_selected -> ref -> title_en [ 0 ] ) == toupper ( ui_selected -> next -> ref -> title_en [ 0 ] ) &&
1402 toupper ( ui_selected -> ref -> title_en [ 0 ] ) == toupper ( event.key.keysym.sym )
1405 // just skip down one
1406 app = ui_selected -> next;
1409 // walk the category, looking for a first-char match
1411 if ( app -> ref -> title_en && toupper ( app -> ref -> title_en [ 0 ] ) == toupper ( event.key.keysym.sym ) ) {
1417 } // same start letter, or new run?
1419 // found something, or no?
1421 // looks like we found a potential match; try switching it to visible selection
1423 ui_set_selected ( ui_selected );
1430 } // SDLK_alphanumeric?
1436 if ( event.key.keysym.sym == SDLK_ESCAPE ) {
1437 emit_and_quit ( MM_QUIT );
1444 #if 1 // mouse / touchscreen
1446 case SDL_MOUSEBUTTONDOWN:
1447 if ( event.button.button == SDL_BUTTON_LEFT ) {
1448 cb_pointer_press ( gc, event.button.x / g_scale, event.button.y / g_scale );
1454 case SDL_MOUSEBUTTONUP:
1455 if ( event.button.button == SDL_BUTTON_LEFT ) {
1456 ui_touch_act ( event.button.x, event.button.y );
1469 } // switch event type
1476 void ui_push_left ( unsigned char forcecoil ) {
1478 if ( ! ui_selected ) {
1479 ui_push_right ( 0 );
1483 // what column we in?
1484 unsigned int col = ui_determine_screen_col ( ui_selected );
1486 // are we already at first item?
1487 if ( forcecoil == 0 &&
1488 pnd_conf_get_as_int_d ( g_conf, "grid.wrap_horiz_samerow", 0 ) &&
1491 unsigned int i = ui_display_context.col_max - 1;
1492 while ( i && ui_selected -> next ) {
1493 ui_push_right ( 0 );
1497 } else if ( g_categories [ ui_category ] -> refs == ui_selected ) {
1498 // can't go any more left, we're at the head
1501 // figure out the previous item; yay for singly linked list :/
1502 mm_appref_t *i = g_categories [ ui_category ] -> refs;
1504 if ( i -> next == ui_selected ) {
1512 ui_set_selected ( ui_selected );
1517 void ui_push_right ( unsigned char forcecoil ) {
1519 if ( ui_selected ) {
1521 // what column we in?
1522 unsigned int col = ui_determine_screen_col ( ui_selected );
1525 if ( forcecoil == 0 &&
1526 pnd_conf_get_as_int_d ( g_conf, "grid.wrap_horiz_samerow", 0 ) &&
1527 // and selected is far-right, or last icon in category (might not be far right)
1528 ( ( col == ui_display_context.col_max - 1 ) ||
1529 ( ui_selected -> next == NULL ) )
1533 //unsigned int i = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 ) - 1;
1534 while ( col /*i*/ ) {
1540 // just go to the next
1542 if ( ui_selected -> next ) {
1543 ui_selected = ui_selected -> next;
1549 ui_selected = g_categories [ ui_category ] -> refs;
1552 ui_set_selected ( ui_selected );
1557 void ui_push_up ( void ) {
1558 unsigned char col_max = ui_display_context.col_max;
1560 if ( ! ui_selected ) {
1565 unsigned int row = ui_determine_row ( ui_selected );
1568 pnd_conf_get_as_int_d ( g_conf, "grid.wrap_vert_stop", 0 ) == 0 )
1570 // wrap around instead
1572 unsigned int col = ui_determine_screen_col ( ui_selected );
1575 ui_selected = g_categories [ ui_category ] -> refs;
1576 while ( ui_selected -> next ) {
1577 ui_selected = ui_selected -> next;
1580 // try to move to same column
1581 unsigned int newcol = ui_determine_screen_col ( ui_selected );
1582 if ( newcol > col ) {
1590 // scroll down to show it
1591 int r = ui_determine_row ( ui_selected ) - 1;
1592 if ( r - ui_display_context.row_max > 0 ) {
1593 ui_rows_scrolled_down = (unsigned int) r;
1597 // stop at top/bottom
1609 void ui_push_down ( void ) {
1610 unsigned char col_max = ui_display_context.col_max;
1612 if ( ui_selected ) {
1615 unsigned int row = ui_determine_row ( ui_selected );
1618 unsigned int icon_rows = g_categories [ ui_category ] -> refcount / col_max;
1619 if ( g_categories [ ui_category ] -> refcount % col_max > 0 ) {
1624 if ( row == ( icon_rows - 1 ) &&
1625 pnd_conf_get_as_int_d ( g_conf, "grid.wrap_vert_stop", 0 ) == 0 )
1628 unsigned char col = ui_determine_screen_col ( ui_selected );
1630 ui_selected = g_categories [ ui_category ] -> refs;
1633 ui_selected = ui_selected -> next;
1637 ui_rows_scrolled_down = 0;
1639 render_mask |= CHANGED_EVERYTHING;
1644 ui_push_right ( 1 );
1651 ui_push_right ( 0 );
1657 // 'backup' is currently 'X', for going back up in a folder/subcat without having to hit exec on the '..' entry
1658 void ui_push_backup ( void ) {
1660 // a subcat-as-dir, or a dir browser?
1661 if ( g_categories [ ui_category] -> fspath ) {
1662 // dir browser, just climb our way back up
1667 // lop off last word; if the thing ends with /, lop that one, then the next word.
1668 while ( ( c = strrchr ( g_categories [ ui_category] -> fspath, '/' ) ) ) {
1669 *c = '\0'; // lop off the last hunk
1670 if ( *(c+1) != '\0' ) {
1676 if ( g_categories [ ui_category] -> fspath [ 0 ] == '\0' ) {
1677 free ( g_categories [ ui_category] -> fspath );
1678 g_categories [ ui_category] -> fspath = strdup ( "/" );
1682 // a pnd subcat .. are we in one, or at the 'top'?
1683 char *pcatname = g_categories [ ui_category ] -> parent_catname;
1686 return; // we're at the 'top' already
1689 // set to first cat!
1691 // republish cats .. shoudl just be the one
1692 category_publish ( CFNORMAL, NULL );
1695 ui_category = category_index ( pcatname );
1703 void ui_push_exec ( void ) {
1705 if ( ! ui_selected ) {
1709 // was this icon generated from filesystem, or from pnd-file?
1710 if ( ui_selected -> ref -> object_flags & PND_DISCO_GENERATED ) {
1712 if ( ! ui_selected -> ref -> title_en ) {
1713 return; // no filename
1716 if ( ui_selected -> ref -> object_type == pnd_object_type_directory ) {
1718 // check if this guy is a dir-browser tab, or is a directory on a pnd tab
1719 if ( ! g_categories [ ui_category] -> fspath ) {
1720 // pnd subcat as dir
1722 // are we already in a subcat? if so, go back to parent; there is no grandparenting or deeper
1723 if ( g_categories [ ui_category ] -> parent_catname ) {
1728 // delve into subcat
1730 // set to first cat!
1732 // republish cats .. shoudl just be the one
1733 category_publish ( CFBYNAME, ui_selected -> ref -> object_path );
1737 // forget the selection, nolonger applies
1739 ui_set_selected ( ui_selected );
1741 render_mask |= CHANGED_EVERYTHING;
1745 // delve up/down the dir tree
1746 if ( strcmp ( ui_selected -> ref -> title_en, ".." ) == 0 ) {
1751 char *temp = malloc ( strlen ( g_categories [ ui_category] -> fspath ) + strlen ( ui_selected -> ref -> title_en ) + 1 + 1 );
1752 sprintf ( temp, "%s/%s", g_categories [ ui_category] -> fspath, ui_selected -> ref -> title_en );
1753 free ( g_categories [ ui_category] -> fspath );
1754 g_categories [ ui_category] -> fspath = temp;
1757 pnd_log ( pndn_debug, "Cat %s is now in path %s\n", g_categories [ ui_category ] -> catname, g_categories [ ui_category ]-> fspath );
1759 // forget the selection, nolonger applies
1761 ui_set_selected ( ui_selected );
1763 category_fs_restock ( g_categories [ ui_category ] );
1765 render_mask |= CHANGED_SELECTION;
1767 } // directory browser or pnd subcat?
1770 // just run it arbitrarily?
1772 // if this a pnd-file, or just some executable?
1773 if ( strcasestr ( ui_selected -> ref -> object_filename, PND_PACKAGE_FILEEXT ) ) {
1774 // looks like a pnd, now what do we do..
1775 pnd_box_handle h = pnd_disco_file ( ui_selected -> ref -> object_path, ui_selected -> ref -> object_filename );
1778 pnd_disco_t *d = pnd_box_get_head ( h );
1779 pnd_apps_exec_disco ( pnd_run_script, d, PND_EXEC_OPTION_NORUN, NULL );
1780 char buffer [ PATH_MAX ];
1781 sprintf ( buffer, "%s %s\n", MM_RUN, pnd_apps_exec_runline() );
1782 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.live_on_run", 0 ) == 0 ) {
1783 emit_and_quit ( buffer );
1785 emit_and_run ( buffer );
1792 // is it even executable? if we don't have handlers for non-executables yet (Jan 2011 we don't),
1793 // then don't even try to run things not-flagged as executable.. but wait most people are on
1794 // FAT filesystems, what a drag, we can't tell at the fs level.
1795 // ... but we can still invoke 'file' and grep out the good bits, at least.
1797 // open a stream reading 'file /path/to/file' and check output for 'executable'
1798 // -- not checking for "ARM" so it can pick up x86 (or whatever native) executables in build environment
1799 unsigned char is_executable = 0;
1803 char popenbuf [ FILENAME_MAX ];
1804 snprintf ( popenbuf, FILENAME_MAX, "%s %s/%s", MIMETYPE_EXE, g_categories [ ui_category ] -> fspath, ui_selected -> ref -> title_en );
1807 if ( ! ( marceau = popen ( popenbuf, "r" ) ) ) {
1808 return; // error, we need some useful error handling and dialog boxes here
1811 if ( fgets ( popenbuf, FILENAME_MAX, marceau ) ) {
1812 //printf ( "File test returns: %s\n", popenbuf );
1813 if ( strstr ( popenbuf, "executable" ) != NULL ) {
1822 if ( ! is_executable ) {
1823 fprintf ( stderr, "ERROR: File to invoke is not executable, skipping. (%s)\n", ui_selected -> ref -> title_en );
1824 return; // need some error handling here
1827 #if 0 // eat up any pending SDL events and toss 'em?
1831 while ( SDL_PeepEvents ( &e, 1, SDL_GETEVENT, SDL_ALLEVENTS ) > 0 ) {
1841 // get CWD so we can restore it on return
1842 char cwd [ PATH_MAX ];
1843 getcwd ( cwd, PATH_MAX );
1845 // full path to executable so we don't rely on implicit "./"
1846 char execbuf [ FILENAME_MAX ];
1847 snprintf ( execbuf, FILENAME_MAX, "%s/%s", g_categories [ ui_category ] -> fspath, ui_selected -> ref -> title_en );
1850 chdir ( g_categories [ ui_category ] -> fspath );
1851 exec_raw_binary ( execbuf /*ui_selected -> ref -> title_en*/ );
1854 // DEPRECATED / NOT TESTED
1855 // get mmwrapper to run it
1856 char buffer [ PATH_MAX ];
1857 sprintf ( buffer, "%s %s/%s\n", MM_RUN, g_categories [ ui_category ] -> fspath, ui_selected -> ref -> title_en );
1858 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.live_on_run", 0 ) == 0 ) {
1859 emit_and_quit ( buffer );
1861 emit_and_run ( buffer );
1870 // set app-run speed
1871 int use_run_speed = pnd_conf_get_as_int_d ( g_conf, "minimenu.use_run_speed", 0 );
1872 if ( use_run_speed > 0 ) {
1873 int mm_speed = pnd_conf_get_as_int_d ( g_conf, "minimenu.run_speed", -1 );
1874 if ( mm_speed > -1 ) {
1875 char buffer [ 512 ];
1876 snprintf ( buffer, 500, "sudo /usr/pandora/scripts/op_cpuspeed.sh %d", mm_speed );
1879 } // do speed change?
1881 // request app to run and quit mmenu
1882 pnd_apps_exec_disco ( pnd_run_script, ui_selected -> ref, PND_EXEC_OPTION_NORUN, NULL );
1883 char buffer [ PATH_MAX ];
1884 sprintf ( buffer, "%s %s\n", MM_RUN, pnd_apps_exec_runline() );
1885 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.live_on_run", 0 ) == 0 ) {
1886 emit_and_quit ( buffer );
1888 emit_and_run ( buffer );
1895 void ui_push_ltrigger ( void ) {
1896 unsigned char oldcat = ui_category;
1897 unsigned int screen_width = ui_display_context.screen_width;
1898 unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
1900 if ( g_categorycount == 0 ) {
1904 if ( ui_category > 0 ) {
1906 category_fs_restock ( g_categories [ ui_category ] );
1908 if ( pnd_conf_get_as_int_d ( g_conf, "tabs.wraparound", 0 ) > 0 ) {
1909 ui_category = g_categorycount - 1;
1911 if ( ui_category >= ( screen_width / tab_width ) ) {
1912 ui_catshift = ui_category - ( screen_width / tab_width ) + 1;
1914 category_fs_restock ( g_categories [ ui_category ] );
1918 if ( oldcat != ui_category ) {
1920 ui_set_selected ( ui_selected );
1923 // make tab visible?
1924 if ( ui_catshift > 0 && ui_category == ui_catshift - 1 ) {
1929 ui_rows_scrolled_down = 0;
1931 render_mask |= CHANGED_CATEGORY;
1936 void ui_push_rtrigger ( void ) {
1937 unsigned char oldcat = ui_category;
1939 if ( g_categorycount == 0 ) {
1943 unsigned int screen_width = ui_display_context.screen_width;
1944 unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
1946 if ( ui_category < ( g_categorycount - 1 ) ) {
1948 category_fs_restock ( g_categories [ ui_category ] );
1950 if ( pnd_conf_get_as_int_d ( g_conf, "tabs.wraparound", 0 ) > 0 ) {
1953 category_fs_restock ( g_categories [ ui_category ] );
1957 if ( oldcat != ui_category ) {
1959 ui_set_selected ( ui_selected );
1962 // make tab visible?
1963 if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
1968 ui_rows_scrolled_down = 0;
1970 render_mask |= CHANGED_CATEGORY;
1975 SDL_Surface *ui_scale_image ( SDL_Surface *s, unsigned int maxwidth, int maxheight ) {
1976 double scale = 1000000.0;
1977 double scalex = 1000000.0;
1978 double scaley = 1000000.0;
1979 SDL_Surface *scaled;
1981 scalex = (double)maxwidth / (double)s -> w;
1983 if ( maxheight == -1 ) {
1986 scaley = (double)maxheight / (double)s -> h;
1988 if ( scaley < scalex ) {
1996 scaled = rotozoomSurface ( s, 0 /* angle*/, scale /* scale */, 1 /* smooth==1*/ );
1997 SDL_FreeSurface ( s );
2003 void ui_loadscreen ( void ) {
2008 SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
2012 rtext = TTF_RenderText_Blended ( g_big_font, "Setting up menu...", ui_display_context.fontcolor );
2015 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, &dest );
2016 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
2017 SDL_FreeSurface ( rtext );
2022 void ui_discoverscreen ( unsigned char clearscreen ) {
2027 if ( clearscreen ) {
2028 SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
2030 // render background
2031 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
2034 dest.w = sdl_realscreen -> w;
2035 dest.h = sdl_realscreen -> h;
2036 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, NULL /* 0,0 */ );
2037 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
2044 rtext = TTF_RenderText_Blended ( g_big_font, "Looking for applications...", ui_display_context.fontcolor );
2045 if ( clearscreen ) {
2052 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, &dest );
2053 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
2054 SDL_FreeSurface ( rtext );
2057 if ( g_imagecache [ IMG_ICON_MISSING ].i ) {
2058 dest.x = rtext -> w + 30;
2060 SDL_BlitSurface ( g_imagecache [ IMG_ICON_MISSING ].i, NULL, sdl_realscreen, &dest );
2061 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
2067 void ui_cachescreen ( unsigned char clearscreen, char *filename ) {
2069 SDL_Rect rects [ 4 ];
2070 SDL_Rect *dest = rects;
2072 bzero ( dest, sizeof(SDL_Rect)* 4 );
2074 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
2075 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
2076 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
2077 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
2079 static unsigned int stepx = 0;
2082 if ( clearscreen ) {
2083 SDL_FillRect( SDL_GetVideoSurface(), NULL, 0 );
2085 // render background
2086 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
2089 dest -> w = sdl_realscreen -> w;
2090 dest -> h = sdl_realscreen -> h;
2091 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, NULL /* whole image */, sdl_realscreen, NULL /* 0,0 */ );
2097 // render background
2098 if ( g_imagecache [ IMG_BACKGROUND_800480 ].i ) {
2101 src.w = sdl_realscreen -> w;
2105 dest -> w = sdl_realscreen -> w;
2106 dest -> h = sdl_realscreen -> h;
2107 SDL_BlitSurface ( g_imagecache [ IMG_BACKGROUND_800480 ].i, &src, sdl_realscreen, dest );
2115 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
2116 rtext = TTF_RenderText_Blended ( g_big_font, "Caching applications artwork...", tmpfontcolor );
2119 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
2120 SDL_FreeSurface ( rtext );
2124 if ( g_imagecache [ IMG_ICON_MISSING ].i ) {
2125 dest -> x = rtext -> w + 30 + stepx;
2127 SDL_BlitSurface ( g_imagecache [ IMG_ICON_MISSING ].i, NULL, sdl_realscreen, dest );
2133 rtext = TTF_RenderText_Blended ( g_tab_font, filename, tmpfontcolor );
2136 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
2137 SDL_FreeSurface ( rtext );
2144 if ( stepx > 350 ) {
2148 SDL_UpdateRects ( sdl_realscreen, dest - rects, rects );
2153 int ui_selected_index ( void ) {
2155 if ( ! ui_selected ) {
2156 return ( -1 ); // no index
2159 mm_appref_t *r = g_categories [ ui_category ] -> refs;
2162 if ( r == ui_selected ) {
2172 static mm_appref_t *timer_ref = NULL;
2173 void ui_set_selected ( mm_appref_t *r ) {
2175 render_mask |= CHANGED_SELECTION;
2177 if ( ! pnd_conf_get_as_int_d ( g_conf, "minimenu.load_previews_later", 0 ) ) {
2178 return; // no desire to defer anything
2183 SDL_SetTimer ( 0, NULL );
2188 SDL_SetTimer ( pnd_conf_get_as_int_d ( g_conf, "previewpic.defer_timer_ms", 1000 ), ui_callback_f );
2194 unsigned int ui_callback_f ( unsigned int t ) {
2196 if ( ui_selected != timer_ref ) {
2197 return ( 0 ); // user has moved it, who cares
2201 bzero ( &e, sizeof(SDL_Event) );
2202 e.type = SDL_USEREVENT;
2203 e.user.code = sdl_user_ticker;
2204 SDL_PushEvent ( &e );
2209 int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *footer ) {
2210 SDL_Rect rects [ 40 ];
2211 SDL_Rect *dest = rects;
2214 unsigned char max_visible = pnd_conf_get_as_int_d ( g_conf, "detailtext.max_visible" , 11 );
2215 unsigned char first_visible = 0;
2217 bzero ( rects, sizeof(SDL_Rect) * 40 );
2219 unsigned int sel = 0;
2221 unsigned int font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
2222 unsigned int font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
2223 unsigned int font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
2224 unsigned int font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
2226 SDL_Color tmpfontcolor = { font_rgba_r, font_rgba_g, font_rgba_b, font_rgba_a };
2228 SDL_Color selfontcolor = { 0/*font_rgba_r*/, font_rgba_g, font_rgba_b, font_rgba_a };
2236 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
2237 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
2238 dest -> w = ((SDL_Surface*) g_imagecache [ IMG_DETAIL_PANEL ].i) -> w;
2239 dest -> h = ((SDL_Surface*) g_imagecache [ IMG_DETAIL_PANEL ].i) -> h;
2240 SDL_FillRect( sdl_realscreen, dest, 0 );
2242 // show dialog background
2243 if ( g_imagecache [ IMG_DETAIL_BG ].i ) {
2246 src.w = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_BG ].i)) -> w;
2247 src.h = ((SDL_Surface*)(g_imagecache [ IMG_DETAIL_BG ].i)) -> h;
2248 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
2249 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
2250 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
2251 // repeat for darken?
2252 //SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
2253 //SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_BG ].i, &src, sdl_realscreen, dest );
2254 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
2258 // show dialog frame
2259 if ( g_imagecache [ IMG_DETAIL_PANEL ].i ) {
2260 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 );
2261 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 );
2262 SDL_BlitSurface ( g_imagecache [ IMG_DETAIL_PANEL ].i, NULL /* whole image */, sdl_realscreen, dest );
2263 //SDL_UpdateRects ( sdl_realscreen, 1, &dest );
2269 rtext = TTF_RenderText_Blended ( g_tab_font, title, tmpfontcolor );
2270 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
2271 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) + 20;
2272 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
2273 SDL_FreeSurface ( rtext );
2279 rtext = TTF_RenderText_Blended ( g_tab_font, footer, tmpfontcolor );
2280 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
2281 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) +
2282 ((SDL_Surface*) g_imagecache [ IMG_DETAIL_PANEL ].i) -> h
2284 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
2285 SDL_FreeSurface ( rtext );
2290 for ( i = first_visible; i < first_visible + max_visible && i < argc; i++ ) {
2294 rtext = TTF_RenderText_Blended ( g_tab_font, argv [ i ], selfontcolor );
2296 rtext = TTF_RenderText_Blended ( g_tab_font, argv [ i ], tmpfontcolor );
2298 dest -> x = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_x", 460 ) + 20;
2299 dest -> y = pnd_conf_get_as_int_d ( g_conf, "detailpane.pane_offset_y", 60 ) + 40 + ( 20 * ( i + 1 - first_visible ) );
2300 SDL_BlitSurface ( rtext, NULL /* full src */, sdl_realscreen, dest );
2301 SDL_FreeSurface ( rtext );
2306 // update all the rects and send it all to sdl
2307 SDL_UpdateRects ( sdl_realscreen, dest - rects, rects );
2311 while ( SDL_WaitEvent ( &event ) ) {
2313 switch ( event.type ) {
2318 if ( event.key.keysym.sym == SDLK_UP ) {
2322 if ( sel < first_visible ) {
2327 } else if ( event.key.keysym.sym == SDLK_DOWN ) {
2329 if ( sel < argc - 1 ) {
2332 // ensure visibility
2333 if ( sel >= first_visible + max_visible ) {
2339 } else if ( event.key.keysym.sym == SDLK_RETURN || event.key.keysym.sym == SDLK_END ) { // return, or "B"
2343 } else if ( event.key.keysym.sym == SDLK_q ) {
2348 return ( -1 ); // nada
2363 unsigned char ui_determine_row ( mm_appref_t *a ) {
2364 unsigned int row = 0;
2366 mm_appref_t *i = g_categories [ ui_category ] -> refs;
2371 row /= ui_display_context.col_max;
2376 unsigned char ui_determine_screen_row ( mm_appref_t *a ) {
2377 return ( ui_determine_row ( a ) % ui_display_context.row_max );
2380 unsigned char ui_determine_screen_col ( mm_appref_t *a ) {
2381 unsigned int col = 0;
2383 mm_appref_t *i = g_categories [ ui_category ] -> refs;
2388 col %= ui_display_context.col_max;
2393 unsigned char ui_show_info ( char *pndrun, pnd_disco_t *p ) {
2394 char *viewer, *searchpath;
2395 pnd_conf_handle desktoph;
2398 searchpath = pnd_conf_query_searchpath();
2400 desktoph = pnd_conf_fetch_by_id ( pnd_conf_desktop, searchpath );
2406 viewer = pnd_conf_get_as_char ( desktoph, "info.viewer" );
2409 return ( 0 ); // no way to view the file
2413 if ( ! p -> unique_id ) {
2417 if ( ! p -> info_filename ) {
2421 if ( ! p -> info_name ) {
2432 if ( pnd_conf_get_as_char ( desktoph, "info.viewer_args" ) ) {
2433 snprintf ( pargs, 1001, "%s %s",
2434 pnd_conf_get_as_char ( desktoph, "info.viewer_args" ), p -> info_filename );
2439 char pndfile [ 1024 ];
2440 if ( p -> object_type == pnd_object_type_directory ) {
2441 // for PXML-app-dir, pnd_run.sh doesn't want the PXML.xml.. it just wants the dir-name
2442 strncpy ( pndfile, p -> object_path, 1000 );
2443 } else if ( p -> object_type == pnd_object_type_pnd ) {
2444 // pnd_run.sh wants the full path and filename for the .pnd file
2445 snprintf ( pndfile, 1020, "%s/%s", p -> object_path, p -> object_filename );
2448 if ( ! pnd_apps_exec ( pndrun, pndfile, p -> unique_id, viewer, p -> startdir, pargs,
2449 p -> clockspeed ? atoi ( p -> clockspeed ) : 0, PND_EXEC_OPTION_NORUN ) )
2454 pnd_log ( pndn_debug, "Info Exec=%s\n", pnd_apps_exec_runline() );
2458 if ( ( x = fork() ) < 0 ) {
2459 pnd_log ( pndn_error, "ERROR: Couldn't fork()\n" );
2464 execl ( "/bin/sh", "/bin/sh", "-c", pnd_apps_exec_runline(), (char*)NULL );
2465 pnd_log ( pndn_error, "ERROR: Couldn't exec(%s)\n", pnd_apps_exec_runline() );
2477 #define MAXTOUCH 100
2478 ui_touch_t ui_touchrects [ MAXTOUCH ];
2479 unsigned char ui_touchrect_count = 0;
2481 void ui_register_reset ( void ) {
2482 bzero ( ui_touchrects, sizeof(ui_touch_t)*MAXTOUCH );
2483 ui_touchrect_count = 0;
2487 void ui_register_tab ( unsigned char catnum, unsigned int x, unsigned int y, unsigned int w, unsigned int h ) {
2489 if ( ui_touchrect_count == MAXTOUCH ) {
2493 ui_touchrects [ ui_touchrect_count ].r.x = x;
2494 ui_touchrects [ ui_touchrect_count ].r.y = y;
2495 ui_touchrects [ ui_touchrect_count ].r.w = w;
2496 ui_touchrects [ ui_touchrect_count ].r.h = h;
2497 ui_touchrects [ ui_touchrect_count ].catnum = catnum;
2498 ui_touchrect_count++;
2503 void ui_register_app ( mm_appref_t *app, unsigned int x, unsigned int y, unsigned int w, unsigned int h ) {
2505 if ( ui_touchrect_count == MAXTOUCH ) {
2509 ui_touchrects [ ui_touchrect_count ].r.x = x;
2510 ui_touchrects [ ui_touchrect_count ].r.y = y;
2511 ui_touchrects [ ui_touchrect_count ].r.w = w;
2512 ui_touchrects [ ui_touchrect_count ].r.h = h;
2513 ui_touchrects [ ui_touchrect_count ].ref = app;
2514 ui_touchrect_count++;
2519 void ui_touch_act ( unsigned int x, unsigned int y ) {
2524 for ( i = 0; i < ui_touchrect_count; i++ ) {
2525 t = &(ui_touchrects [ i ]);
2527 if ( x >= t -> r.x &&
2528 x <= t -> r.x + t -> r.w &&
2530 y <= t -> r.y + t -> r.h
2535 ui_selected = t -> ref;
2538 if ( ui_category != t -> catnum ) {
2541 ui_category = t -> catnum;
2542 render_mask |= CHANGED_CATEGORY;
2544 category_fs_restock ( g_categories [ ui_category ] );
2555 unsigned char ui_forkexec ( char *argv[] ) {
2556 char *fooby = argv[0];
2559 if ( ( x = fork() ) < 0 ) {
2560 pnd_log ( pndn_error, "ERROR: Couldn't fork() for '%s'\n", fooby );
2564 if ( x == 0 ) { // child
2565 execv ( fooby, argv );
2566 pnd_log ( pndn_error, "ERROR: Couldn't exec(%s)\n", fooby );
2574 unsigned char ui_threaded_timer_create ( void ) {
2576 g_timer_thread = SDL_CreateThread ( (void*)ui_threaded_timer, NULL );
2578 if ( ! g_timer_thread ) {
2579 pnd_log ( pndn_error, "ERROR: Couldn't create timer thread\n" );
2586 int ui_threaded_timer ( pnd_disco_t *p ) {
2588 // this timer's job is to ..
2589 // - do nothing for quite awhile
2590 // - on wake, post event to SDL event queue, so that main thread will check if SD insert/eject occurred
2593 unsigned int delay_s = 2; // seconds
2600 // .. trigger SD check
2602 bzero ( &e, sizeof(SDL_Event) );
2603 e.type = SDL_USEREVENT;
2604 e.user.code = sdl_user_checksd;
2605 SDL_PushEvent ( &e );
2612 unsigned char ui_threaded_defered_preview ( pnd_disco_t *p ) {
2614 if ( ! cache_preview ( p, pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_width", 200 ),
2615 pnd_conf_get_as_int_d ( g_conf, "previewpic.cell_height", 180 ) )
2618 pnd_log ( pndn_debug, "THREAD: Couldn't load preview pic: '%s' -> '%s'\n",
2619 IFNULL(p->title_en,"No Name"), p -> preview_pic1 );
2622 // trigger that we completed
2624 bzero ( &e, sizeof(SDL_Event) );
2625 e.type = SDL_USEREVENT;
2626 e.user.code = sdl_user_finishedpreview;
2628 SDL_PushEvent ( &e );
2633 SDL_Thread *g_icon_thread = NULL;
2634 void ui_post_scan ( void ) {
2636 // if deferred icon load, kick off the thread now
2637 if ( pnd_conf_get_as_int_d ( g_conf, "minimenu.load_icons_later", 0 ) == 1 ) {
2639 g_icon_thread = SDL_CreateThread ( (void*)ui_threaded_defered_icon, NULL );
2641 if ( ! g_icon_thread ) {
2642 pnd_log ( pndn_error, "ERROR: Couldn't create icon thread\n" );
2645 } // deferred icon load
2649 ui_rows_scrolled_down = 0;
2650 // set back to first tab, to be safe
2654 // do we have a preferred category to jump to?
2655 char *dc = pnd_conf_get_as_char ( g_conf, "categories.default_cat" );
2658 // attempt to find default cat; if we do find it, select it; otherwise
2659 // default behaviour will pick first cat (ie: usually All)
2661 for ( i = 0; i < g_categorycount; i++ ) {
2662 if ( strcasecmp ( g_categories [ i ] -> catname, dc ) == 0 ) {
2664 // ensure visibility
2665 unsigned int screen_width = ui_display_context.screen_width;
2666 unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
2667 if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
2668 ui_catshift = ui_category - ( screen_width / tab_width ) + 1;
2674 if ( i == g_categorycount ) {
2675 pnd_log ( pndn_warning, " User defined default category '%s' but not found, so using default behaviour\n", dc );
2680 // if we're sent right to a dirbrowser tab, restock it now (normally we restock on entry)
2681 if ( g_categories [ ui_category ] -> fspath ) {
2682 printf ( "Restock on start: '%s'\n", g_categories [ ui_category ] -> fspath );
2683 category_fs_restock ( g_categories [ ui_category ] );
2687 render_mask |= CHANGED_EVERYTHING;
2692 unsigned char ui_threaded_defered_icon ( void *p ) {
2693 extern pnd_box_handle g_active_apps;
2694 pnd_box_handle h = g_active_apps;
2696 unsigned char maxwidth, maxheight;
2697 maxwidth = pnd_conf_get_as_int_d ( g_conf, "grid.icon_max_width", 50 );
2698 maxheight = pnd_conf_get_as_int_d ( g_conf, "grid.icon_max_height", 50 );
2700 pnd_disco_t *iter = pnd_box_get_head ( h );
2705 if ( iter -> pnd_icon_pos &&
2706 ! cache_icon ( iter, maxwidth, maxheight ) )
2708 pnd_log ( pndn_warning, " Couldn't load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
2711 // trigger that we completed
2713 bzero ( &e, sizeof(SDL_Event) );
2714 e.type = SDL_USEREVENT;
2715 e.user.code = sdl_user_finishedicon;
2716 SDL_PushEvent ( &e );
2718 //pnd_log ( pndn_warning, " Finished deferred load icon: '%s'\n", IFNULL(iter->title_en,"No Name") );
2719 usleep ( pnd_conf_get_as_int_d ( g_conf, "minimenu.defer_icon_us", 50000 ) );
2724 iter = pnd_box_get_next ( iter );
2730 void ui_show_hourglass ( unsigned char updaterect ) {
2733 SDL_Surface *s = g_imagecache [ IMG_HOURGLASS ].i;
2735 dest.x = ( 800 - s -> w ) / 2;
2736 dest.y = ( 480 - s -> h ) / 2;
2738 SDL_BlitSurface ( s, NULL /* whole image */, sdl_realscreen, &dest );
2741 SDL_UpdateRects ( sdl_realscreen, 1, &dest );
2747 unsigned char ui_pick_skin ( void ) {
2749 char *skins [ MAXSKINS ];
2752 char *searchpath = pnd_conf_get_as_char ( g_conf, "minimenu.skin_searchpath" );
2753 char tempname [ 100 ];
2757 skins [ iter++ ] = "No skin change";
2761 DIR *d = opendir ( buffer );
2766 while ( ( dd = readdir ( d ) ) ) {
2768 if ( dd -> d_name [ 0 ] == '.' ) {
2770 } else if ( ( dd -> d_type == DT_DIR || dd -> d_type == DT_UNKNOWN ) &&
2773 snprintf ( tempname, 100, "Skin: %s", dd -> d_name );
2774 skins [ iter++ ] = strdup ( tempname );
2785 int sel = ui_modal_single_menu ( skins, iter, "Skins", "Enter to select; other to return." );
2787 // did they pick one?
2791 char *s = strdup ( pnd_conf_get_as_char ( g_conf, "minimenu.skin_selected" ) );
2792 s = pnd_expand_tilde ( s );
2794 f = fopen ( s, "w" );
2799 fprintf ( f, "%s\n", skins [ sel ] + 6 );
2809 void ui_aboutscreen ( char *textpath ) {
2816 #define ROWS SCRH / ( PIXELH + MARGINH )
2817 #define COLS SCRW / ( PIXELW + MARGINW )
2819 unsigned char pixelboard [ ROWS * COLS ]; // pixel heat
2820 bzero ( pixelboard, ROWS * COLS );
2825 SDL_Color rtextc = { 200, 200, 200, 100 };
2828 char *textloop [ 500 ];
2829 unsigned int textmax = 0;
2830 bzero ( textloop, 500 * sizeof(char*) );
2833 char cbuffer [ 50000 ];
2834 bzero ( cbuffer, 50000 );
2835 unsigned int crevealed = 0;
2837 FILE *f = fopen ( textpath, "r" );
2840 pnd_log ( pndn_error, "ERROR: Couldn't open about text: %s\n", textpath );
2844 char textbuf [ 100 ];
2845 while ( fgets ( textbuf, 100, f ) ) {
2847 // add to full buffer
2848 strncat ( cbuffer, textbuf, 50000 );
2851 if ( strchr ( textbuf, '\n' ) ) {
2852 * strchr ( textbuf, '\n' ) = '\0';
2855 // add to pixel loop
2856 if ( 1||textbuf [ 0 ] ) {
2857 textloop [ textmax ] = strdup ( textbuf );
2865 unsigned int textiter = 0;
2866 while ( textiter < textmax ) {
2867 char *text = textloop [ textiter ];
2871 // render to surface
2872 rtext = TTF_RenderText_Blended ( g_grid_font, text, rtextc );
2874 // render font to pixelboard
2875 unsigned int px, py;
2877 unsigned int *pixels = rtext -> pixels;
2878 unsigned char cr, cg, cb, ca;
2879 for ( py = 0; py < rtext -> h; py ++ ) {
2880 for ( px = 0; px < ( rtext -> w > COLS ? COLS : rtext -> w ); px++ ) {
2882 SDL_GetRGBA ( pixels [ ( py * rtext -> pitch / 4 ) + px ],
2883 rtext -> format, &cr, &cg, &cb, &ca );
2887 ph = pixelboard + ( /*y offset */ 30 * COLS ) + ( py * COLS ) + px /* / 2 */;
2894 if ( *ph + ca < 250 ) {
2905 unsigned int runcount = 10;
2906 while ( runcount-- ) {
2909 SDL_FillRect( sdl_realscreen, NULL /* whole */, 0 );
2911 // render pixelboard
2914 for ( y = 0; y < ROWS; y++ ) {
2915 for ( x = 0; x < COLS; x++ ) {
2917 if ( 1||pixelboard [ ( y * COLS ) + x ] ) {
2920 r.x = x * ( PIXELW + MARGINW );
2921 r.y = y * ( PIXELH + MARGINH );
2925 c = SDL_MapRGB ( sdl_realscreen -> format, 100 /* r */, 0 /* g */, pixelboard [ ( y * COLS ) + x ] );
2927 SDL_FillRect( sdl_realscreen, &r /* whole */, c );
2935 unsigned char *pc = pixelboard;
2936 for ( y = 0; y < ROWS; y++ ) {
2937 for ( x = 0; x < COLS; x++ ) {
2947 // slide pixels upwards
2948 memmove ( pixelboard, pixelboard + COLS, ( COLS * ROWS ) - COLS );
2950 // render actual readable text
2953 // display up to cursor
2955 unsigned int cdraw = 0;
2959 if ( crevealed > 200 ) {
2960 cdraw = crevealed - 200;
2966 for ( ; cdraw < crevealed; cdraw++ ) {
2967 ctb [ 0 ] = cbuffer [ cdraw ];
2969 // move over or down
2970 if ( cbuffer [ cdraw ] == '\n' ) {
2975 if ( dest.y > 450 ) {
2981 cs = TTF_RenderText_Blended ( g_tab_font, ctb, rtextc );
2983 SDL_BlitSurface ( cs, NULL /* all */, sdl_realscreen, &dest );
2984 SDL_FreeSurface ( cs );
2994 SDL_FillRect ( sdl_realscreen, &dest /* whole */, 220 );
2996 // increment cursor to next character
2997 if ( cbuffer [ crevealed ] != '\0' ) {
3001 } // draw cursor text
3005 SDL_UpdateRect ( sdl_realscreen, 0, 0, 0, 0 ); // whole screen
3009 // any button? if so, about
3015 if ( SDL_PeepEvents ( &e, 1, SDL_GETEVENT, SDL_EVENTMASK(/*SDL_KEYUP|*/SDL_KEYDOWN) ) > 0 ) {
3024 SDL_FreeSurface ( rtext );
3028 } // while more text
3032 for ( i = 0; i < textmax; i++ ) {
3033 if ( textloop [ i ] ) {
3034 free ( textloop [ i ] );
3042 void ui_revealscreen ( void ) {
3043 char *labels [ 500 ];
3044 unsigned int labelmax = 0;
3046 char fulllabel [ 200 ];
3048 if ( ! category_count ( CFHIDDEN ) ) {
3049 return; // nothing to do
3052 // switch to hidden categories
3053 category_publish ( CFHIDDEN, NULL );
3055 // build up labels to show in menu
3056 for ( i = 0; i < g_categorycount; i++ ) {
3058 if ( g_categories [ i ] -> parent_catname ) {
3059 sprintf ( fulllabel, "%s [%s]", g_categories [ i ] -> catname, g_categories [ i ] -> parent_catname );
3061 sprintf ( fulllabel, "%s", g_categories [ i ] -> catname );
3064 labels [ labelmax++ ] = strdup ( fulllabel );
3068 int sel = ui_modal_single_menu ( labels, labelmax, "Temporary Category Reveal",
3069 "Enter to select; other to return." );
3071 // if selected, try to set this guy to visible
3074 // fix up category name, if its been hacked
3075 if ( strchr ( g_categories [ sel ] -> catname, '.' ) ) {
3076 char *t = g_categories [ sel ] -> catname;
3077 g_categories [ sel ] -> catname = strdup ( strchr ( g_categories [ sel ] -> catname, '.' ) + 1 );
3081 // reflag this guy to be visible
3082 g_categories [ sel ] -> catflags = CFNORMAL;
3084 // switch to the new category.. cache name.
3085 char *switch_to_name = g_categories [ sel ] -> catname;
3087 // republish categories
3088 category_publish ( CFNORMAL, NULL );
3090 // switch to the new category.. with the cached name!
3091 ui_category = category_index ( switch_to_name );
3093 // ensure visibility
3094 unsigned int screen_width = ui_display_context.screen_width;
3095 unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
3096 if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
3097 ui_catshift = ui_category - ( screen_width / tab_width ) + 1;
3101 render_mask |= CHANGED_CATEGORY;
3104 for ( i = 0; i < g_categorycount; i++ ) {
3105 free ( labels [ i ] );
3111 void ui_recache_context ( ui_context_t *c ) {
3113 c -> screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
3115 c -> font_rgba_r = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_r", 200 );
3116 c -> font_rgba_g = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_g", 200 );
3117 c -> font_rgba_b = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_b", 200 );
3118 c -> font_rgba_a = pnd_conf_get_as_int_d ( g_conf, "display.font_rgba_a", 100 );
3120 c -> grid_offset_x = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_x" );
3121 c -> grid_offset_y = pnd_conf_get_as_int ( g_conf, "grid.grid_offset_y" );
3123 c -> icon_offset_x = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_x" );
3124 c -> icon_offset_y = pnd_conf_get_as_int ( g_conf, "grid.icon_offset_y" );
3125 c -> icon_max_width = pnd_conf_get_as_int ( g_conf, "grid.icon_max_width" );
3126 c -> icon_max_height = pnd_conf_get_as_int ( g_conf, "grid.icon_max_height" );
3127 c -> sel_icon_offset_x = pnd_conf_get_as_int_d ( g_conf, "grid.sel_offoffset_x", 0 );
3128 c -> sel_icon_offset_y = pnd_conf_get_as_int_d ( g_conf, "grid.sel_offoffset_y", 0 );
3130 c -> text_width = pnd_conf_get_as_int ( g_conf, "grid.text_width" );
3131 c -> text_clip_x = pnd_conf_get_as_int ( g_conf, "grid.text_clip_x" );
3132 c -> text_offset_x = pnd_conf_get_as_int ( g_conf, "grid.text_offset_x" );
3133 c -> text_offset_y = pnd_conf_get_as_int ( g_conf, "grid.text_offset_y" );
3134 c -> text_hilite_offset_y = pnd_conf_get_as_int ( g_conf, "grid.text_hilite_offset_y" );
3136 c -> row_max = pnd_conf_get_as_int_d ( g_conf, "grid.row_max", 4 );
3137 c -> col_max = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 );
3139 c -> cell_width = pnd_conf_get_as_int ( g_conf, "grid.cell_width" );
3140 c -> cell_height = pnd_conf_get_as_int ( g_conf, "grid.cell_height" );
3142 c -> arrow_bar_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_x", 450 );
3143 c -> arrow_bar_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_y", 100 );
3144 c -> arrow_bar_clip_w = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_w", 10 );
3145 c -> arrow_bar_clip_h = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_clip_h", 100 );
3146 c -> arrow_up_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_x", 450 );
3147 c -> arrow_up_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_y", 80 );
3148 c -> arrow_down_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_x", 450 );
3149 c -> arrow_down_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_y", 80 );
3152 SDL_Color tmp = { c -> font_rgba_r, c -> font_rgba_g, c -> font_rgba_b, c -> font_rgba_a };
3153 c -> fontcolor = tmp;
3155 // now that we've got 'normal' (detail pane shown) param's, lets check if detail pane
3156 // is hidden; if so, override some values with those alternate skin values where possible.
3157 if ( ui_detail_hidden ) {
3158 // if detail panel is hidden, and theme cannot support it, unhide the bloody thing. (This may help
3159 // when someone is amid theme hacking or changing.)
3160 if ( ! ui_is_detail_hideable() ) {
3161 ui_detail_hidden = 0;
3165 if ( ui_detail_hidden ) {
3167 c -> row_max = pnd_conf_get_as_int_d ( g_conf, "grid.row_max_w", c -> row_max );
3168 c -> col_max = pnd_conf_get_as_int_d ( g_conf, "grid.col_max_w", c -> col_max );
3170 c -> cell_width = pnd_conf_get_as_int_d ( g_conf, "grid.cell_width_w", c -> cell_width );
3171 c -> cell_height = pnd_conf_get_as_int_d ( g_conf, "grid.cell_height_w", c -> cell_height );
3173 c -> arrow_bar_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_x_w", 450 );
3174 c -> arrow_bar_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_bar_y_w", 100 );
3175 c -> arrow_up_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_x_w", 450 );
3176 c -> arrow_up_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_up_y_w", 80 );
3177 c -> arrow_down_x = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_x_w", 450 );
3178 c -> arrow_down_y = pnd_conf_get_as_int_d ( g_conf, "grid.arrow_down_y_w", 80 );
3180 } // if detail hidden.. still.
3182 } // if detail hidden
3187 unsigned char ui_is_detail_hideable ( void ) {
3189 // if skin has a bit of info for wide-mode, we assume wide-mode is available
3190 if ( pnd_conf_get_as_char ( g_conf, "grid.row_max_w" ) != NULL ) {
3198 void ui_toggle_detail_pane ( void ) {
3200 // no bitmask trickery here; I like it to be stand-out obvious at 3am.
3202 if ( ui_detail_hidden ) {
3203 ui_detail_hidden = 0;
3205 ui_detail_hidden = 1;
3208 // repull skin config
3209 ui_recache_context ( &ui_display_context );
3212 render_mask |= CHANGED_EVERYTHING;