2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
unsigned char * mplMenuDrawBuffer = NULL;
|
|
|
|
int mplMenuRender = 1;
|
|
|
|
int mplMenuItem = -1;
|
|
|
|
int mplOldMenuItem = -1;
|
|
|
|
int mplMenuX,mplMenuY;
|
|
|
|
|
2002-05-01 09:29:06 +00:00
|
|
|
void mplHideMenu( int mx,int my,int w );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
void mplMenuDraw( wsParamDisplay )
|
|
|
|
{
|
2002-05-23 14:46:08 +00:00
|
|
|
uint32_t * buf = NULL;
|
|
|
|
uint32_t * drw = NULL;
|
2002-02-01 16:34:22 +00:00
|
|
|
int x,y,tmp;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
2001-12-12 22:42:38 +00:00
|
|
|
if ( !mplMenuRender && !appMPlayer.menuWindow.Visible ) return;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
if ( mplMenuRender || mplMenuItem != mplOldMenuItem )
|
|
|
|
{
|
|
|
|
memcpy( mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.Image,appMPlayer.menuBase.Bitmap.ImageSize );
|
|
|
|
// ---
|
|
|
|
if ( mplMenuItem != -1 )
|
|
|
|
{
|
2002-05-23 14:46:08 +00:00
|
|
|
buf=(uint32_t *)mplMenuDrawBuffer;
|
|
|
|
drw=(uint32_t *)appMPlayer.menuSelected.Bitmap.Image;
|
2001-08-25 21:04:29 +00:00
|
|
|
for ( y=appMPlayer.MenuItems[ mplMenuItem ].y; y < appMPlayer.MenuItems[ mplMenuItem ].y + appMPlayer.MenuItems[ mplMenuItem ].height; y++ )
|
|
|
|
for ( x=appMPlayer.MenuItems[ mplMenuItem ].x; x < appMPlayer.MenuItems[ mplMenuItem ].x + appMPlayer.MenuItems[ mplMenuItem ].width; x++ )
|
|
|
|
{
|
|
|
|
tmp=drw[ y * appMPlayer.menuSelected.width + x ];
|
|
|
|
if ( tmp != 0x00ff00ff ) buf[ y * appMPlayer.menuBase.width + x ]=tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mplOldMenuItem=mplMenuItem;
|
|
|
|
// ---
|
|
|
|
wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.ImageSize );
|
|
|
|
mplMenuRender=0;
|
|
|
|
}
|
|
|
|
wsPutImage( &appMPlayer.menuWindow );
|
|
|
|
}
|
|
|
|
|
|
|
|
void mplMenuMouseHandle( int X,int Y,int RX,int RY )
|
|
|
|
{
|
|
|
|
int x,y,i;
|
|
|
|
|
|
|
|
if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
|
|
|
|
|
|
|
mplMenuItem=-1;
|
|
|
|
x=RX - appMPlayer.menuWindow.X;
|
|
|
|
y=RY - appMPlayer.menuWindow.Y;
|
|
|
|
if ( ( x < 0 ) || ( y < 0 ) || ( x > appMPlayer.menuBase.width ) || ( y > appMPlayer.menuBase.height ) )
|
|
|
|
{
|
|
|
|
wsPostRedisplay( &appMPlayer.menuWindow );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-09-01 17:53:07 +00:00
|
|
|
for( i=0;i<=appMPlayer.NumberOfMenuItems;i++ )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
|
|
|
if ( wgIsRect( x,y,
|
|
|
|
appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
|
2001-09-01 17:53:07 +00:00
|
|
|
appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) { mplMenuItem=i; break; }
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
wsPostRedisplay( &appMPlayer.menuWindow );
|
|
|
|
}
|
|
|
|
|
|
|
|
void mplShowMenu( int mx,int my )
|
|
|
|
{
|
|
|
|
int x,y;
|
|
|
|
|
|
|
|
if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
|
|
|
|
|
|
|
x=mx;
|
|
|
|
if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1;
|
|
|
|
y=my;
|
|
|
|
if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1;
|
|
|
|
|
|
|
|
mplMenuX=x; mplMenuY=y;
|
|
|
|
|
|
|
|
mplMenuItem = 0;
|
|
|
|
|
2001-11-12 15:16:13 +00:00
|
|
|
wsMoveWindow( &appMPlayer.menuWindow,False,x,y );
|
2002-05-20 13:56:16 +00:00
|
|
|
wsMoveTopWindow( wsDisplay,appMPlayer.menuWindow.WindowID );
|
2002-05-28 14:12:33 +00:00
|
|
|
wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,1 );
|
2001-12-12 22:42:38 +00:00
|
|
|
mplMenuRender=1;
|
|
|
|
wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow );
|
|
|
|
wsPostRedisplay( &appMPlayer.menuWindow );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
|
2002-05-01 09:29:06 +00:00
|
|
|
void mplHideMenu( int mx,int my,int w )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
|
|
|
int x,y,i=mplMenuItem;
|
|
|
|
|
|
|
|
if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
|
|
|
|
|
|
|
x=mx-mplMenuX;
|
|
|
|
y=my-mplMenuY;
|
2001-09-01 17:53:07 +00:00
|
|
|
// x=RX - appMPlayer.menuWindow.X;
|
|
|
|
// y=RY - appMPlayer.menuWindow.Y;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow );
|
|
|
|
|
|
|
|
if ( ( x < 0 ) || ( y < 0 ) ) return;
|
|
|
|
|
2002-02-23 15:12:55 +00:00
|
|
|
// printf( "---------> %d %d,%d\n",i,x,y );
|
2001-12-12 22:42:38 +00:00
|
|
|
// printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].height );
|
2001-08-25 21:04:29 +00:00
|
|
|
if ( wgIsRect( x,y,
|
|
|
|
appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,
|
|
|
|
appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,
|
|
|
|
appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) )
|
|
|
|
{
|
2002-05-01 09:29:06 +00:00
|
|
|
mplEventHandling( appMPlayer.MenuItems[i].msg,(float)w );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mplMenuInit( void )
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( !appMPlayer.menuBase.Bitmap.Image ) return;
|
|
|
|
|
|
|
|
appMPlayer.menuBase.x=0;
|
|
|
|
appMPlayer.menuBase.y=0;
|
|
|
|
|
|
|
|
if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] %s",MSGTR_NEMFMR );
|
2001-08-25 21:04:29 +00:00
|
|
|
#endif
|
2001-09-17 21:16:00 +00:00
|
|
|
gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR );
|
2001-08-25 21:04:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wsCreateWindow( &appMPlayer.menuWindow,
|
|
|
|
appMPlayer.menuBase.x,appMPlayer.menuBase.y,appMPlayer.menuBase.width,appMPlayer.menuBase.height,
|
2002-01-29 20:39:48 +00:00
|
|
|
wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" );
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-05-28 14:12:33 +00:00
|
|
|
wsSetShape( &appMPlayer.menuWindow,appMPlayer.menuBase.Mask.Image );
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
#ifdef DEBUG
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] menu: 0x%x\n",(int)appMPlayer.menuWindow.WindowID );
|
2001-08-25 21:04:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
appMPlayer.menuWindow.ReDraw=mplMenuDraw;
|
|
|
|
// appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle;
|
|
|
|
// appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle;
|
2001-12-12 22:42:38 +00:00
|
|
|
mplMenuRender=1; wsPostRedisplay( &appMPlayer.menuWindow );
|
2001-08-25 21:04:29 +00:00
|
|
|
}
|