[MPlayer-cvslog] CVS: main/libmenu menu.c, 1.13, 1.14 menu.h, 1.2, 1.3 menu_list.c, 1.8, 1.9 menu_list.h, 1.2, 1.3 menu_console.c, 1.12, 1.13
Alban Bedel CVS
syncmail at mplayerhq.hu
Thu Mar 30 04:52:57 CEST 2006
- Previous message: [MPlayer-cvslog] CVS: main/libmpdemux asf.h, 1.18, 1.19 asfheader.c, 1.47, 1.48 demux_asf.c, 1.45, 1.46
- Next message: [MPlayer-cvslog] CVS: main/libao2 ao_oss.c, 1.58, 1.59 audio_out.c, 1.53, 1.54
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
CVS change done by Alban Bedel CVS
Update of /cvsroot/mplayer/main/libmenu
In directory mail:/var2/tmp/cvs-serv14318/libmenu
Modified Files:
menu.c menu.h menu_list.c menu_list.h menu_console.c
Log Message:
Add a function to draw flat boxes and use it to make the list
menu and console look much cooler. Idea take from Otvos Atilla's
patches (oattila_At_chello--.--hu).
Index: menu.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- menu.c 25 Mar 2006 17:32:10 -0000 1.13
+++ menu.c 30 Mar 2006 02:52:54 -0000 1.14
@@ -559,3 +559,31 @@
}
return txt;
}
+
+
+void menu_draw_box(mp_image_t* mpi, char grey, char alpha, int x, int y, int w, int h) {
+ draw_alpha_f draw_alpha = get_draw_alpha(mpi->imgfmt);
+
+ if(!draw_alpha) {
+ printf("Unsupported outformat !!!!\n");
+ return;
+ }
+
+ if(x > mpi->w || y > mpi->h) return;
+
+ if(x < 0) w += x, x = 0;
+ if(x+w > mpi->w) w = mpi->w-x;
+ if(y < 0) h += y, y = 0;
+ if(y+h > mpi->h) h = mpi->h-y;
+
+ {
+ int stride = (w+7)&(~7); // round to 8
+ char pic[stride*h],pic_alpha[stride*h];
+ memset(pic,grey,stride*h);
+ memset(pic_alpha,alpha,stride*h);
+ draw_alpha(w,h,pic,pic_alpha,stride,
+ mpi->planes[0] + y * mpi->stride[0] + x * (mpi->bpp>>3),
+ mpi->stride[0]);
+ }
+
+}
Index: menu.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- menu.h 25 Mar 2006 17:32:10 -0000 1.2
+++ menu.h 30 Mar 2006 02:52:54 -0000 1.3
@@ -72,3 +72,5 @@
void menu_draw_text_full(mp_image_t* mpi,char* txt,
int x, int y,int w, int h,
int vspace, int warp, int align, int anchor);
+
+void menu_draw_box(mp_image_t* mpi, char grey, char alpha, int x, int y, int w, int h);
Index: menu_list.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu_list.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- menu_list.c 27 Mar 2006 19:27:42 -0000 1.8
+++ menu_list.c 30 Mar 2006 02:52:54 -0000 1.9
@@ -30,6 +30,7 @@
int dy = 0;
int need_h = 0,need_w = 0,ptr_l,sidx = 0;
int th,count = 0;
+ int bg_w;
list_entry_t* m;
if(mpriv->count < 1)
@@ -102,7 +103,15 @@
} else
m = mpriv->menu;
+ bg_w = need_w+2*mpriv->minb;
if(th > 0) {
+ if(mpriv->title_bg >= 0) {
+ int tw,th2;
+ menu_text_size(mpriv->title,dw,mpriv->vspace,1,&tw,&th2);
+ if(tw+2*mpriv->minb > bg_w) bg_w = tw+2*mpriv->minb;
+ menu_draw_box(mpi,mpriv->title_bg,mpriv->title_bg_alpha,
+ x < 0 ? (mpi->w-bg_w)/2 : x-mpriv->minb,dy+y-mpriv->vspace,bg_w,th);
+ }
menu_draw_text_full(mpi,mpriv->title,
x < 0 ? mpi->w / 2 : x,
dy+y,dw,0,
@@ -114,13 +123,22 @@
for( ; m != NULL && dy + vo_font->height < dh ; m = m->next ) {
if(m->hide) continue;
- if(ptr_l > 0 && m == mpriv->current)
- menu_draw_text_full(mpi,mpriv->ptr,
- x < 0 ? (mpi->w - need_w) / 2 + ptr_l : x,
- 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));
+ 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,
+ bg_w,vo_font->height + mpriv->vspace);
+ if(ptr_l > 0)
+ menu_draw_text_full(mpi,mpriv->ptr,
+ x < 0 ? (mpi->w - need_w) / 2 + ptr_l : x,
+ 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));
+ } 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,
+ bg_w,vo_font->height + mpriv->vspace);
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,
Index: menu_list.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu_list.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- menu_list.h 25 Mar 2006 18:15:37 -0000 1.2
+++ menu_list.h 30 Mar 2006 02:52:54 -0000 1.3
@@ -29,6 +29,9 @@
int w,h;
int vspace, minb;
char* ptr;
+ int title_bg,title_bg_alpha;
+ int item_bg,item_bg_alpha;
+ int ptr_bg,ptr_bg_alpha;
} menu_list_priv_t;
typedef void (*free_entry_t)(list_entry_t* entry);
@@ -52,7 +55,10 @@
-1,-1, \
0,0, \
5, 3, \
- ">" \
+ NULL, \
+ 0x80, 0x80, \
+ 0x40, 0x80, \
+ 0x70, 0x80 \
}
@@ -63,5 +69,15 @@
{ "y", M_ST_OFF(menu_list_priv_t,y), CONF_TYPE_INT, M_OPT_MIN, 0, 0, NULL }, \
{ "w", M_ST_OFF(menu_list_priv_t,w), CONF_TYPE_INT, M_OPT_MIN, 0, 0, NULL }, \
{ "h", M_ST_OFF(menu_list_priv_t,h), CONF_TYPE_INT, M_OPT_MIN, 0, 0, NULL }, \
- { "ptr", M_ST_OFF(menu_list_priv_t,ptr), CONF_TYPE_STRING, 0, 0, 0, NULL }
+ { "ptr", M_ST_OFF(menu_list_priv_t,ptr), CONF_TYPE_STRING, 0, 0, 0, NULL }, \
+ { "title-bg", M_ST_OFF(menu_list_priv_t,title_bg), CONF_TYPE_INT, M_OPT_RANGE, -1, 255, NULL }, \
+ { "title-bg-alpha", M_ST_OFF(menu_list_priv_t,title_bg_alpha), \
+ CONF_TYPE_INT, M_OPT_RANGE, 0, 255, NULL }, \
+ { "item-bg", M_ST_OFF(menu_list_priv_t,item_bg), CONF_TYPE_INT, M_OPT_RANGE, -1, 255, NULL }, \
+ { "item-bg-alpha", M_ST_OFF(menu_list_priv_t,item_bg_alpha), \
+ CONF_TYPE_INT, M_OPT_RANGE, 0, 255, NULL }, \
+ { "ptr-bg", M_ST_OFF(menu_list_priv_t,ptr_bg), CONF_TYPE_INT, M_OPT_RANGE, -1, 255, NULL }, \
+ { "ptr-bg-alpha", M_ST_OFF(menu_list_priv_t,ptr_bg_alpha), \
+ CONF_TYPE_INT, M_OPT_RANGE, 0, 255, NULL } \
+
Index: menu_console.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu_console.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- menu_console.c 26 Oct 2005 00:07:43 -0000 1.12
+++ menu_console.c 30 Mar 2006 02:52:54 -0000 1.13
@@ -55,6 +55,7 @@
int height; // Display size in %
int minb;
int vspace;
+ int bg,bg_alpha;
unsigned int hide_time;
unsigned int show_time;
int history_max;
@@ -81,6 +82,7 @@
33, // %
3,
3,
+ 0x80,0x40,
500,
500,
10,
@@ -96,6 +98,8 @@
{ "height", ST_OFF(height), CONF_TYPE_INT, M_OPT_RANGE, 1, 100, NULL },
{ "minbor", ST_OFF(minb), CONF_TYPE_INT, M_OPT_MIN, 0, 0, NULL },
{ "vspace", ST_OFF(vspace), CONF_TYPE_INT, M_OPT_MIN, 0, 0, NULL },
+ { "bg", ST_OFF(bg), CONF_TYPE_INT, M_OPT_RANGE, -1, 255, NULL },
+ { "bg-alpha", ST_OFF(bg_alpha), CONF_TYPE_INT, M_OPT_RANGE, 0, 255, NULL },
{ "show-time",ST_OFF(show_time), CONF_TYPE_INT, M_OPT_MIN, 0, 0, NULL },
{ "hide-time",ST_OFF(hide_time), CONF_TYPE_INT, M_OPT_MIN, 0, 0, NULL },
{ "history-size",ST_OFF(history_max), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL },
@@ -190,6 +194,9 @@
if(x < 0 || y < 0 || w <= 0 || h <= 0 )
return;
+ if(mpriv->bg >= 0)
+ menu_draw_box(mpi,mpriv->bg,mpriv->bg_alpha,0,0,mpi->w,h);
+
if(!mpriv->child || !mpriv->raw_child){
char input[strlen(mpriv->cur_history->buffer) + strlen(mpriv->prompt) + 1];
sprintf(input,"%s%s",mpriv->prompt,mpriv->cur_history->buffer);
- Previous message: [MPlayer-cvslog] CVS: main/libmpdemux asf.h, 1.18, 1.19 asfheader.c, 1.47, 1.48 demux_asf.c, 1.45, 1.46
- Next message: [MPlayer-cvslog] CVS: main/libao2 ao_oss.c, 1.58, 1.59 audio_out.c, 1.53, 1.54
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list