# HG changeset patch # User ulion # Date 1198134708 0 # Node ID 11cd0fdfcb4a36f3d5fda50150e7f35e515ced53 # Parent 2664bccccb80f5939f29cb368bb4573198247ed0 Add variable bx, dx to simplify code of function menu_draw_list. diff -r 2664bccccb80 -r 11cd0fdfcb4a libmenu/menu_list.c --- 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,