mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 23:00:41 +00:00
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
This commit is contained in:
parent
2cad693abd
commit
4ab4cd3dcd
@ -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;
|
need_h = count * (mpriv->vspace + vo_font->height) - mpriv->vspace;
|
||||||
if( need_h + th > dh) {
|
if( need_h + th > dh) {
|
||||||
int start,end;
|
int start,end;
|
||||||
int maxl = (dh + mpriv->vspace - th) / (mpriv->vspace + vo_font->height);
|
mpriv->disp_lines = (dh + mpriv->vspace - th) / (mpriv->vspace + vo_font->height);
|
||||||
if(maxl < 4) {
|
if(mpriv->disp_lines < 4) {
|
||||||
th = 0;
|
th = 0;
|
||||||
maxl = (dh + mpriv->vspace) / ( vo_font->height + mpriv->vspace);
|
mpriv->disp_lines = (dh + mpriv->vspace) / ( vo_font->height + mpriv->vspace);
|
||||||
}
|
}
|
||||||
// Too smoll
|
// Too smoll
|
||||||
if(maxl < 1) return;
|
if(mpriv->disp_lines < 1) return;
|
||||||
need_h = maxl*(mpriv->vspace + vo_font->height) - mpriv->vspace;
|
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;
|
if(start < 0) start = 0;
|
||||||
end = start + maxl;
|
end = start + mpriv->disp_lines;
|
||||||
if(end > count) {
|
if(end > count) {
|
||||||
end = count;
|
end = count;
|
||||||
if(end - start < maxl)
|
if(end - start < mpriv->disp_lines)
|
||||||
start = end - maxl < 0 ? 0 : end - maxl;
|
start = end - mpriv->disp_lines < 0 ? 0 : end - mpriv->disp_lines;
|
||||||
}
|
}
|
||||||
m = mpriv->menu;
|
m = mpriv->menu;
|
||||||
for(i = 0 ; m->next && i < start ; ) {
|
for(i = 0 ; m->next && i < start ; ) {
|
||||||
if(!m->hide) i++;
|
if(!m->hide) i++;
|
||||||
m = m->next;
|
m = m->next;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
m = mpriv->menu;
|
m = mpriv->menu;
|
||||||
|
mpriv->disp_lines = count;
|
||||||
|
}
|
||||||
|
|
||||||
bg_w = need_w+2*mpriv->minb;
|
bg_w = need_w+2*mpriv->minb;
|
||||||
if(th > 0) {
|
if(th > 0) {
|
||||||
@ -219,13 +221,13 @@ void menu_list_read_key(menu_t* menu,int c,int jump_to) {
|
|||||||
mpriv->current = m;
|
mpriv->current = m;
|
||||||
break;
|
break;
|
||||||
case KEY_PAGE_UP:
|
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)
|
if(m)
|
||||||
mpriv->current = m;
|
mpriv->current = m;
|
||||||
break;
|
break;
|
||||||
case KEY_PAGE_DOWN:
|
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)
|
if(m)
|
||||||
mpriv->current = m;
|
mpriv->current = m;
|
||||||
|
@ -28,6 +28,7 @@ typedef struct menu_priv_s {
|
|||||||
int x,y;
|
int x,y;
|
||||||
int w,h;
|
int w,h;
|
||||||
int vspace, minb;
|
int vspace, minb;
|
||||||
|
int disp_lines;
|
||||||
char* ptr;
|
char* ptr;
|
||||||
int title_bg,title_bg_alpha;
|
int title_bg,title_bg_alpha;
|
||||||
int item_bg,item_bg_alpha;
|
int item_bg,item_bg_alpha;
|
||||||
@ -55,6 +56,7 @@ extern const menu_list_priv_t menu_list_priv_dflt;
|
|||||||
-1,-1, \
|
-1,-1, \
|
||||||
0,0, \
|
0,0, \
|
||||||
5, 3, \
|
5, 3, \
|
||||||
|
0, \
|
||||||
NULL, \
|
NULL, \
|
||||||
0xFF, 0xFF, \
|
0xFF, 0xFF, \
|
||||||
0xFF, 0xFF, \
|
0xFF, 0xFF, \
|
||||||
|
Loading…
Reference in New Issue
Block a user