changeset 25437:2664bccccb80

Add local variable 'line_h' to simplify code of function menu_list_draw.
author ulion
date Thu, 20 Dec 2007 02:17:29 +0000
parents 333ba4e7d5e3
children 11cd0fdfcb4a
files libmenu/menu_list.c
diffstat 1 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libmenu/menu_list.c	Wed Dec 19 16:17:26 2007 +0000
+++ b/libmenu/menu_list.c	Thu Dec 20 02:17:29 2007 +0000
@@ -31,6 +31,7 @@
   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 @@
   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 @@
   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 @@
       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 @@
     } 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;
   }
 
 }