minimenu; repaired 'more or less' touchscreen to run apps bug; shoudl probabyl still...
[pandora-libraries.git] / minimenu / mmui.c
index 39c2a64..c1a8c68 100644 (file)
@@ -365,7 +365,9 @@ void ui_render ( void ) {
 #endif
 
   // reset touchscreen regions
-  ui_register_reset();
+  if ( render_jobs_b ) {
+    ui_register_reset();
+  }
 
   // ensure selection is visible
   if ( ui_selected ) {
@@ -1195,13 +1197,13 @@ void ui_process_input ( unsigned char block_p ) {
       } else if ( event.key.keysym.sym == SDLK_SPACE || event.key.keysym.sym == SDLK_END ) {
        ui_push_exec();
        ui_event++;
-      } else if ( event.key.keysym.sym == SDLK_z || event.key.keysym.sym == SDLK_RSHIFT ) {
+      } else if ( event.key.keysym.sym == SDLK_RSHIFT ) {
        ui_push_ltrigger();
        ui_event++;
-      } else if ( event.key.keysym.sym == SDLK_x || event.key.keysym.sym == SDLK_RCTRL ) {
+      } else if ( event.key.keysym.sym == SDLK_RCTRL ) {
        ui_push_rtrigger();
        ui_event++;
-      } else if ( event.key.keysym.sym == SDLK_y || event.key.keysym.sym == SDLK_PAGEUP ) {
+      } else if ( event.key.keysym.sym == SDLK_PAGEUP ) {
        // info
        if ( ui_selected ) {
          ui_show_info ( pnd_run_script, ui_selected -> ref );
@@ -1240,12 +1242,6 @@ void ui_process_input ( unsigned char block_p ) {
          applications_free();
          pnd_log ( pndn_debug, "Rescanning applications\n" );
          applications_scan();
-         // reset view
-         ui_selected = NULL;
-         ui_rows_scrolled_down = 0;
-         // set back to first tab, to be safe
-         ui_category = 0;
-         ui_catshift = 0;
        } else if ( sel == 3 ) {
          // cache preview to SD now
          extern pnd_box_handle g_active_apps;
@@ -1299,12 +1295,60 @@ void ui_process_input ( unsigned char block_p ) {
 
        ui_event++;
        render_mask |= CHANGED_EVERYTHING;
-      }
+
+      } else {
+       // unknown SDLK_ keycode?
+
+       // many SDLK_keycodes map to ASCII ("a" is ascii(a)), so try to jump to a filename of that name, in this category?
+       // and if already there, try to jump to next, maybe?
+       // future: look for sequence typing? ie: user types 'm' then 'a', look for 'ma*' instead of 'm' then 'a' matching
+       if ( isalpha ( event.key.keysym.sym ) && g_categories [ ui_category ].refcount > 0 ) {
+         mm_appref_t *app = g_categories [ ui_category ].refs;
+
+         //fprintf ( stderr, "sel %s next %s\n", ui_selected -> ref -> title_en, ui_selected -> next -> ref -> title_en );
+
+         // are we already matching the same char? and next item is also same char?
+         if ( app && ui_selected &&
+              ui_selected -> ref -> title_en && ui_selected -> next -> ref -> title_en &&
+              toupper ( ui_selected -> ref -> title_en [ 0 ] ) == toupper ( ui_selected -> next -> ref -> title_en [ 0 ] ) &&
+              toupper ( ui_selected -> ref -> title_en [ 0 ] ) == toupper ( event.key.keysym.sym )
+            )
+         {
+           // just skip down one
+           app = ui_selected -> next;
+         } else {
+
+           // walk the category, looking for a first-char match
+           while ( app ) {
+             if ( app -> ref -> title_en && toupper ( app -> ref -> title_en [ 0 ] ) == toupper ( event.key.keysym.sym ) ) {
+               break;
+             }
+             app = app -> next;
+           }
+
+         } // same start letter, or new run?
+
+         // found something, or no?
+         if ( app ) {
+           // looks like we found a potential match; try switching it to visible selection
+           ui_selected = app;
+           ui_set_selected ( ui_selected );
+         }
+
+
+
+
+
+       } // SDLK_alphanumeric?
+
+      } // SDLK_....
 
       // extras
+#if 0
       if ( event.key.keysym.sym == SDLK_q ) {
        emit_and_quit ( MM_QUIT );
       }
+#endif
 
       break;
 #endif
@@ -2070,11 +2114,13 @@ int ui_modal_single_menu ( char *argv[], unsigned int argc, char *title, char *f
 
          }
 
-       } else if ( event.key.keysym.sym == SDLK_RETURN ) {
+       } else if ( event.key.keysym.sym == SDLK_RETURN || event.key.keysym.sym == SDLK_END ) { // return, or "B"
          return ( sel );
 
+#if 0
        } else if ( event.key.keysym.sym == SDLK_q ) {
          exit ( 0 );
+#endif
 
        } else {
          return ( -1 ); // nada
@@ -2336,6 +2382,42 @@ void ui_post_scan ( void ) {
 
   } // deferred icon load
 
+  // reset view
+  ui_selected = NULL;
+  ui_rows_scrolled_down = 0;
+  // set back to first tab, to be safe
+  ui_category = 0;
+  ui_catshift = 0;
+
+  // do we have a preferred category to jump to?
+  char *dc = pnd_conf_get_as_char ( g_conf, "categories.default_cat" );
+  if ( dc ) {
+
+    // attempt to find default cat; if we do find it, select it; otherwise
+    // default behaviour will pick first cat (ie: usually All)
+    unsigned int i;
+    for ( i = 0; i < g_categorycount; i++ ) {
+      if ( strcasecmp ( g_categories [ i ].catname, dc ) == 0 ) {
+       ui_category = i;
+       // ensure visibility
+       unsigned int screen_width = pnd_conf_get_as_int_d ( g_conf, "display.screen_width", 800 );
+       unsigned int tab_width = pnd_conf_get_as_int ( g_conf, "tabs.tab_width" );
+       if ( ui_category > ui_catshift + ( screen_width / tab_width ) - 1 ) {
+         ui_catshift = ui_category - ( screen_width / tab_width ) + 1;
+       }
+       break;
+      }
+    }
+
+    if ( i == g_categorycount ) {
+      pnd_log ( pndn_warning, "  User defined default category '%s' but not found, so using default behaviour\n", dc );
+    }
+
+  } // default cat
+
+  // redraw all
+  render_mask |= CHANGED_EVERYTHING;
+
   return;
 }