changeset 25438:11cd0fdfcb4a

Add variable bx, dx to simplify code of function menu_draw_list.
author ulion
date Thu, 20 Dec 2007 07:11:48 +0000
parents 2664bccccb80
children 17098467fc9b
files libmenu/menu_list.c
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libmenu/menu_list.c	Thu Dec 20 02:17:29 2007 +0000
+++ b/libmenu/menu_list.c	Thu Dec 20 07:11:48 2007 +0000
@@ -27,7 +27,7 @@
   int h = mpriv->h;
   int w = mpriv->w;
   int dh = 0,dw =  0;
-  int dy = 0;
+  int bx, dx, dy = 0;
   int need_h = 0,need_w = 0,ptr_l,sidx = 0;
   int th,count = 0;
   int bg_w;
@@ -125,26 +125,28 @@
     dy += th;
   }
   
+  dx = x < 0 ? (mpi->w - need_w) / 2 : x;
+  bx = x < 0 ? (mpi->w - bg_w) / 2 : x - mpriv->minb;
   for( ; m != NULL && dy + vo_font->height < dh ; m = m->next ) {
     if(m->hide) continue;
     if(m == mpriv->current) {
       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,
+                      bx, dy + y - mpriv->vspace / 2,
                       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,
+                            dx,
                             dy+y,dw,dh - dy,
                             mpriv->vspace,0,
-                            MENU_TEXT_TOP|(x < 0 ? MENU_TEXT_RIGHT :MENU_TEXT_LEFT) ,
-                            MENU_TEXT_TOP|(x < 0 ? MENU_TEXT_RIGHT :MENU_TEXT_LEFT));
+                            MENU_TEXT_TOP|MENU_TEXT_LEFT,
+                            MENU_TEXT_TOP|MENU_TEXT_LEFT);
     } 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,
+                    bx, dy + y - mpriv->vspace / 2,
                     bg_w, line_h);
     menu_draw_text_full(mpi,m->txt,
-			x < 0 ? (mpi->w - need_w) / 2  + ptr_l : x + ptr_l,
+			dx + ptr_l,
 			dy+y,dw-ptr_l,dh - dy,
 			mpriv->vspace,0,
 			MENU_TEXT_TOP|MENU_TEXT_LEFT,