[MPlayer-cvslog] r25465 - trunk/libmenu/menu_list.c

ulion subversion at mplayerhq.hu
Thu Dec 20 03:17:29 CET 2007


Author: ulion
Date: Thu Dec 20 03:17:29 2007
New Revision: 25465

Log:
Add local variable 'line_h' to simplify code of function menu_list_draw.


Modified:
   trunk/libmenu/menu_list.c

Modified: trunk/libmenu/menu_list.c
==============================================================================
--- trunk/libmenu/menu_list.c	(original)
+++ trunk/libmenu/menu_list.c	Thu Dec 20 03:17:29 2007
@@ -31,6 +31,7 @@ void menu_list_draw(menu_t* menu,mp_imag
   int need_h = 0,need_w = 0,ptr_l,sidx = 0;
   int th,count = 0;
   int bg_w;
+  int line_h;
   list_entry_t* m;
 
   if(mpriv->count < 1)
@@ -45,7 +46,8 @@ void menu_list_draw(menu_t* menu,mp_imag
   if(h - vo_font->height <= 0 || w - ptr_l <= 0 || dw <= 0 || dh <= 0)
     return;
 
-  th = menu_text_num_lines(mpriv->title,dw) * (mpriv->vspace + vo_font->height) + mpriv->vspace;
+  line_h = mpriv->vspace + vo_font->height;
+  th = menu_text_num_lines(mpriv->title,dw) * line_h + mpriv->vspace;
 
   // the selected item is hidden, find a visible one
   if(mpriv->current->hide) {
@@ -75,17 +77,17 @@ void menu_list_draw(menu_t* menu,mp_imag
   else 
     y = mpriv->minb;
 
-  need_h = count * (mpriv->vspace + vo_font->height) - mpriv->vspace;
+  need_h = count * line_h - mpriv->vspace;
   if( need_h + th > dh) {
     int start,end;
-    mpriv->disp_lines = (dh + mpriv->vspace - th) / (mpriv->vspace + vo_font->height);
+    mpriv->disp_lines = (dh + mpriv->vspace - th) / line_h;
     if(mpriv->disp_lines < 4) {
       th = 0;
-      mpriv->disp_lines = (dh + mpriv->vspace) / ( vo_font->height + mpriv->vspace);
+      mpriv->disp_lines = (dh + mpriv->vspace) / line_h;
     }
     // Too smoll
     if(mpriv->disp_lines < 1) return;
-    need_h = mpriv->disp_lines*(mpriv->vspace + vo_font->height) - mpriv->vspace;
+    need_h = mpriv->disp_lines * line_h - mpriv->vspace;
 
     start = sidx - (mpriv->disp_lines/2);
     if(start < 0) start = 0;
@@ -129,7 +131,7 @@ void menu_list_draw(menu_t* menu,mp_imag
       if(mpriv->ptr_bg >= 0)
         menu_draw_box(mpi,mpriv->ptr_bg,mpriv->ptr_bg_alpha,
                       x < 0 ? (mpi->w-bg_w)/2 : x-mpriv->minb,dy+y-mpriv->vspace/2,
-                      bg_w,vo_font->height + mpriv->vspace);
+                      bg_w, line_h);
       if(ptr_l > 0)
         menu_draw_text_full(mpi,mpriv->ptr,
                             x < 0 ? (mpi->w - need_w) / 2 + ptr_l : x,
@@ -140,14 +142,14 @@ void menu_list_draw(menu_t* menu,mp_imag
     } else if(mpriv->item_bg >= 0)
       menu_draw_box(mpi,mpriv->item_bg,mpriv->item_bg_alpha,
                     x < 0 ? (mpi->w-bg_w)/2 : x-mpriv->minb,dy+y-mpriv->vspace/2,
-                    bg_w,vo_font->height + mpriv->vspace);
+                    bg_w, line_h);
     menu_draw_text_full(mpi,m->txt,
 			x < 0 ? (mpi->w - need_w) / 2  + ptr_l : x + ptr_l,
 			dy+y,dw-ptr_l,dh - dy,
 			mpriv->vspace,0,
 			MENU_TEXT_TOP|MENU_TEXT_LEFT,
 			MENU_TEXT_TOP|MENU_TEXT_LEFT);
-    dy +=  vo_font->height + mpriv->vspace;
+    dy += line_h;
   }
 
 }



More information about the MPlayer-cvslog mailing list