2001-08-25 21:04:29 +00:00
|
|
|
|
2002-11-02 20:10:18 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
2005-12-08 22:12:57 +00:00
|
|
|
#include "app.h"
|
2007-04-29 12:44:34 +00:00
|
|
|
#include "gmplayer.h"
|
2005-12-08 22:12:57 +00:00
|
|
|
#include "../config.h"
|
|
|
|
#include "../help_mp.h"
|
|
|
|
#include "../mp_msg.h"
|
2002-11-02 20:10:18 +00:00
|
|
|
|
|
|
|
#include "widgets.h"
|
|
|
|
|
2001-08-25 21:04:29 +00:00
|
|
|
unsigned char * mplMenuDrawBuffer = NULL;
|
|
|
|
int mplMenuRender = 1;
|
|
|
|
int mplMenuItem = -1;
|
|
|
|
int mplOldMenuItem = -1;
|
|
|
|
int mplMenuX,mplMenuY;
|
2003-01-13 23:38:49 +00:00
|
|
|
static int mplMenuIsInitialized = 0;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2002-11-02 20:10:18 +00:00
|
|
|
void mplMenuDraw( void )
|
2001-08-25 21:04:29 +00:00
|
|
|
{
|
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
|
|
|
|
2003-01-13 23:38:49 +00:00
|
|
|
if ( !appMPlayer.menuIsPresent || !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;
|
|
|
|
|
2003-01-13 23:38:49 +00:00
|
|
|
if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
x=mx;
|
2003-05-26 08:45:43 +00:00
|
|
|
if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1 + wsOrgX;
|
2001-08-25 21:04:29 +00:00
|
|
|
y=my;
|
2003-05-26 08:45:43 +00:00
|
|
|
if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1 + wsOrgY;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2003-01-13 23:38:49 +00:00
|
|
|
if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
|
2003-01-13 23:38:49 +00:00
|
|
|
if ( mplMenuIsInitialized || !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return;
|
2001-08-25 21:04:29 +00:00
|
|
|
|
|
|
|
appMPlayer.menuBase.x=0;
|
|
|
|
appMPlayer.menuBase.y=0;
|
|
|
|
|
|
|
|
if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL )
|
|
|
|
{
|
2006-09-29 09:21:53 +00:00
|
|
|
#ifdef DEBUG
|
2002-02-23 15:12:55 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] %s",MSGTR_NEMFMR );
|
2006-09-29 09:21:53 +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 );
|
|
|
|
|
2006-09-29 09:21:53 +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 );
|
2006-09-29 09:21:53 +00:00
|
|
|
#endif
|
2001-08-25 21:04:29 +00:00
|
|
|
|
2003-01-13 23:38:49 +00:00
|
|
|
mplMenuIsInitialized=1;
|
2001-08-25 21:04:29 +00:00
|
|
|
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
|
|
|
}
|