1
mirror of https://github.com/mpv-player/mpv synced 2025-03-11 04:44:32 +01:00

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

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25465 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
ulion 2007-12-20 02:17:29 +00:00
parent 50c286342e
commit bfe3186801

@ -31,6 +31,7 @@ void menu_list_draw(menu_t* menu,mp_image_t* mpi) {
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_image_t* mpi) {
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_image_t* mpi) {
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_image_t* mpi) {
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_image_t* mpi) {
} 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;
}
}