diff options
author | ulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-11-10 02:01:41 +0000 |
---|---|---|
committer | ulion <ulion@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-11-10 02:01:41 +0000 |
commit | 4ab4cd3dcdae578409d6be3a8d3bbaaa775f4fc3 (patch) | |
tree | 43badfd2a9b7f28d2843884288bc5bbb75930d97 | |
parent | 2cad693abdaeb95b8fa8728847e129af7da22ba6 (diff) |
Make page up and down with proper page size instead of always 10 rows.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25007 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libmenu/menu_list.c | 26 | ||||
-rw-r--r-- | libmenu/menu_list.h | 2 |
2 files changed, 16 insertions, 12 deletions
diff --git a/libmenu/menu_list.c b/libmenu/menu_list.c index 9da2e8922d..511ca8e912 100644 --- a/libmenu/menu_list.c +++ b/libmenu/menu_list.c @@ -78,30 +78,32 @@ void menu_list_draw(menu_t* menu,mp_image_t* mpi) { need_h = count * (mpriv->vspace + vo_font->height) - mpriv->vspace; if( need_h + th > dh) { int start,end; - int maxl = (dh + mpriv->vspace - th) / (mpriv->vspace + vo_font->height); - if(maxl < 4) { + mpriv->disp_lines = (dh + mpriv->vspace - th) / (mpriv->vspace + vo_font->height); + if(mpriv->disp_lines < 4) { th = 0; - maxl = (dh + mpriv->vspace) / ( vo_font->height + mpriv->vspace); + mpriv->disp_lines = (dh + mpriv->vspace) / ( vo_font->height + mpriv->vspace); } // Too smoll - if(maxl < 1) return; - need_h = maxl*(mpriv->vspace + vo_font->height) - mpriv->vspace; + if(mpriv->disp_lines < 1) return; + need_h = mpriv->disp_lines*(mpriv->vspace + vo_font->height) - mpriv->vspace; - start = sidx - (maxl/2); + start = sidx - (mpriv->disp_lines/2); if(start < 0) start = 0; - end = start + maxl; + end = start + mpriv->disp_lines; if(end > count) { end = count; - if(end - start < maxl) - start = end - maxl < 0 ? 0 : end - maxl; + if(end - start < mpriv->disp_lines) + start = end - mpriv->disp_lines < 0 ? 0 : end - mpriv->disp_lines; } m = mpriv->menu; for(i = 0 ; m->next && i < start ; ) { if(!m->hide) i++; m = m->next; } - } else + } else { m = mpriv->menu; + mpriv->disp_lines = count; + } bg_w = need_w+2*mpriv->minb; if(th > 0) { @@ -219,13 +221,13 @@ void menu_list_read_key(menu_t* menu,int c,int jump_to) { mpriv->current = m; break; case KEY_PAGE_UP: - for(i = 0, m = mpriv->current ; m && m->prev && i < 10 ; m = m->prev, i++) + for(i = 0, m = mpriv->current ; m && m->prev && i < mpriv->disp_lines ; m = m->prev, i++) /**/; if(m) mpriv->current = m; break; case KEY_PAGE_DOWN: - for(i = 0, m = mpriv->current ; m && m->next && i < 10 ; m = m->next, i++) + for(i = 0, m = mpriv->current ; m && m->next && i < mpriv->disp_lines ; m = m->next, i++) /**/; if(m) mpriv->current = m; diff --git a/libmenu/menu_list.h b/libmenu/menu_list.h index 25c4753ccf..566d1b389c 100644 --- a/libmenu/menu_list.h +++ b/libmenu/menu_list.h @@ -28,6 +28,7 @@ typedef struct menu_priv_s { int x,y; int w,h; int vspace, minb; + int disp_lines; char* ptr; int title_bg,title_bg_alpha; int item_bg,item_bg_alpha; @@ -55,6 +56,7 @@ extern const menu_list_priv_t menu_list_priv_dflt; -1,-1, \ 0,0, \ 5, 3, \ + 0, \ NULL, \ 0xFF, 0xFF, \ 0xFF, 0xFF, \ |