minimenu: added special case for rightmost tab for davec, so can now specialise tab...
[pandora-libraries.git] / minimenu / mmui.c
index e589ce9..954e50e 100644 (file)
@@ -195,7 +195,11 @@ mm_imgcache_t g_imagecache [ IMG_TRUEMAX ] = {
   { IMG_DETAIL_BG,            "graphics.IMG_DETAIL_BG" },
   { IMG_SELECTED_ALPHAMASK,   "graphics.IMG_SELECTED_ALPHAMASK" },
   { IMG_TAB_SEL,              "graphics.IMG_TAB_SEL" },
+  { IMG_TAB_SEL_L,            "graphics.IMG_TAB_SEL_L" },
+  { IMG_TAB_SEL_R,            "graphics.IMG_TAB_SEL_R" },
   { IMG_TAB_UNSEL,            "graphics.IMG_TAB_UNSEL" },
+  { IMG_TAB_UNSEL_L,          "graphics.IMG_TAB_UNSEL_L" },
+  { IMG_TAB_UNSEL_R,          "graphics.IMG_TAB_UNSEL_R" },
   { IMG_TAB_LINE,             "graphics.IMG_TAB_LINE" },
   { IMG_TAB_LINEL,            "graphics.IMG_TAB_LINEL" },
   { IMG_TAB_LINER,            "graphics.IMG_TAB_LINER" },
@@ -361,7 +365,7 @@ void ui_render ( void ) {
     int topleft = col_max * ui_rows_scrolled_down;
     int botright = ( col_max * ( ui_rows_scrolled_down + row_max ) - 1 );
 
-    //pnd_log ( PND_LOG_DEFAULT, "index %u tl %u br %u\n", index, topleft, botright );
+    pnd_log ( PND_LOG_DEFAULT, "index %u tl %u br %u\n", index, topleft, botright );
 
     if ( index < topleft ) {
       ui_rows_scrolled_down -= pnd_conf_get_as_int_d ( g_conf, "grid.scroll_increment", 1 );
@@ -423,21 +427,52 @@ void ui_render ( void ) {
     {
 
       SDL_Surface *s;
-      if ( col == ui_category ) {
-       s = g_imagecache [ IMG_TAB_SEL ].i;
+
+      // if this is the first (leftmost) tab, we use different artwork
+      // than if the other tabs (so skinner can link lines up nicely.)
+      if ( col == ui_catshift ) {
+       // leftmost tab, special case
+
+       if ( col == ui_category ) {
+         s = g_imagecache [ IMG_TAB_SEL_L ].i;
+       } else {
+         s = g_imagecache [ IMG_TAB_UNSEL_L ].i;
+       }
+
+      } else if ( col == maxtab - 1 ) {
+       // rightmost tab, special case
+
+       if ( col == ui_category ) {
+         s = g_imagecache [ IMG_TAB_SEL_R ].i;
+       } else {
+         s = g_imagecache [ IMG_TAB_UNSEL_R ].i;
+       }
+
       } else {
-       s = g_imagecache [ IMG_TAB_UNSEL ].i;
-      }
+       // normal (not leftmost) tab
+
+       if ( col == ui_category ) {
+         s = g_imagecache [ IMG_TAB_SEL ].i;
+       } else {
+         s = g_imagecache [ IMG_TAB_UNSEL ].i;
+       }
+
+      } // first col, or not first col?
 
       // draw tab
       src.x = 0;
       src.y = 0;
+#if 0
       src.w = tab_width;
       if ( col == ui_category ) {
        src.h = tab_selheight;
       } else {
        src.h = tab_height;
       }
+#else
+      src.w = s -> w;
+      src.h = s -> h;
+#endif
       dest -> x = tab_offset_x + ( (col-ui_catshift) * tab_width );
       dest -> y = tab_offset_y;
 
@@ -1303,13 +1338,13 @@ void ui_push_left ( unsigned char forcecoil ) {
   // what column we in?
   unsigned int col = ui_determine_screen_col ( ui_selected );
 
-  // are we alreadt at first item?
+  // are we already at first item?
   if ( forcecoil == 0 &&
        pnd_conf_get_as_int_d ( g_conf, "grid.wrap_horiz_samerow", 0 ) &&
        col == 0 )
   {
     unsigned int i = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 ) - 1;
-    while ( i ) {
+    while ( i && ui_selected -> next ) {
       ui_push_right ( 0 );
       i--;
     }
@@ -1344,13 +1379,16 @@ void ui_push_right ( unsigned char forcecoil ) {
     // wrap same or no?
     if ( forcecoil == 0 &&
         pnd_conf_get_as_int_d ( g_conf, "grid.wrap_horiz_samerow", 0 ) &&
-        col == pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 ) - 1 )
+        // and selected is far-right, or last icon in category (might not be far right)
+        ( ( col == pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 ) - 1 ) ||
+          ( ui_selected -> next == NULL ) )
+       )
     {
       // same wrap
-      unsigned int i = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 ) - 1;
-      while ( i ) {
+      //unsigned int i = pnd_conf_get_as_int_d ( g_conf, "grid.col_max", 5 ) - 1;
+      while ( col /*i*/ ) {
        ui_push_left ( 0 );
-       i--;
+       col--; //i--;
       }
 
     } else {
@@ -1453,6 +1491,8 @@ void ui_push_down ( void ) {
 
       ui_rows_scrolled_down = 0;
 
+      render_mask |= CHANGED_EVERYTHING;
+
     } else {
 
       while ( col_max ) {