2008-04-22 09:33:39 +00:00
|
|
|
/*
|
|
|
|
* main window
|
|
|
|
*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2003-01-17 22:39:43 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
2007-05-16 21:45:46 +00:00
|
|
|
#include <string.h>
|
2003-01-17 22:39:43 +00:00
|
|
|
|
2008-04-12 16:03:07 +00:00
|
|
|
#include "config.h"
|
2008-04-11 16:55:27 +00:00
|
|
|
#include "gui/app.h"
|
|
|
|
#include "gui/skin/font.h"
|
|
|
|
#include "gui/skin/skin.h"
|
|
|
|
#include "gui/wm/ws.h"
|
2005-12-08 22:12:57 +00:00
|
|
|
|
2008-04-12 16:03:07 +00:00
|
|
|
#include "help_mp.h"
|
|
|
|
#include "libvo/x11_common.h"
|
|
|
|
#include "libvo/fastmemcpy.h"
|
2005-12-08 22:12:57 +00:00
|
|
|
|
2008-04-12 16:03:07 +00:00
|
|
|
#include "stream/stream.h"
|
|
|
|
#include "mixer.h"
|
|
|
|
#include "libvo/sub.h"
|
2005-12-08 22:12:57 +00:00
|
|
|
|
2008-04-12 16:03:07 +00:00
|
|
|
#include "libmpdemux/demuxer.h"
|
|
|
|
#include "libmpdemux/stheader.h"
|
|
|
|
#include "codec-cfg.h"
|
2003-01-17 22:39:43 +00:00
|
|
|
|
2006-11-25 18:37:37 +00:00
|
|
|
#include "gmplayer.h"
|
2003-01-17 22:39:43 +00:00
|
|
|
#include "play.h"
|
|
|
|
#include "widgets.h"
|
2008-01-06 16:31:26 +00:00
|
|
|
#include "gui_common.h"
|
2003-01-17 22:39:43 +00:00
|
|
|
|
2008-12-03 23:01:03 +00:00
|
|
|
unsigned int GetTimerMS( void );
|
|
|
|
unsigned int GetTimer( void );
|
2003-01-17 22:39:43 +00:00
|
|
|
|
|
|
|
unsigned char * mplPBDrawBuffer = NULL;
|
|
|
|
int mplPBVisible = 0;
|
|
|
|
int mplPBLength = 0;
|
|
|
|
int mplPBFade = 0;
|
|
|
|
|
|
|
|
void mplPBDraw( void )
|
|
|
|
{
|
2003-01-25 10:04:05 +00:00
|
|
|
int x;
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2003-01-17 22:39:43 +00:00
|
|
|
if ( !appMPlayer.subWindow.isFullScreen ) return;
|
|
|
|
if ( !mplPBVisible || !appMPlayer.barIsPresent ) return;
|
|
|
|
|
2003-01-25 10:04:05 +00:00
|
|
|
// appMPlayer.bar.x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2;
|
|
|
|
switch( appMPlayer.bar.x )
|
|
|
|
{
|
|
|
|
case -1: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2; break;
|
|
|
|
case -2: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ); break;
|
|
|
|
default: x=appMPlayer.bar.x;
|
|
|
|
}
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2003-01-17 22:39:43 +00:00
|
|
|
switch ( mplPBFade )
|
|
|
|
{
|
|
|
|
case 1: // fade in
|
|
|
|
mplPBLength--;
|
|
|
|
if ( appMPlayer.subWindow.Height - appMPlayer.bar.height >= mplPBLength )
|
|
|
|
{
|
|
|
|
mplPBLength=appMPlayer.subWindow.Height - appMPlayer.bar.height;
|
|
|
|
mplPBFade=0;
|
|
|
|
vo_mouse_autohide=0;
|
|
|
|
}
|
2009-05-13 02:58:57 +00:00
|
|
|
wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength );
|
2003-01-17 22:39:43 +00:00
|
|
|
break;
|
|
|
|
case 2: // fade out
|
|
|
|
mplPBLength+=10;
|
|
|
|
if ( mplPBLength > appMPlayer.subWindow.Height )
|
|
|
|
{
|
|
|
|
mplPBLength=appMPlayer.subWindow.Height;
|
|
|
|
mplPBFade=mplPBVisible=0;
|
2009-05-13 02:58:57 +00:00
|
|
|
vo_mouse_autohide=1;
|
|
|
|
wsVisibleWindow( &appMPlayer.barWindow,wsHideWindow );
|
2003-01-17 22:39:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-05-13 02:58:57 +00:00
|
|
|
wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength );
|
2003-01-17 22:39:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- render
|
|
|
|
if ( appMPlayer.barWindow.State == wsWindowExpose )
|
|
|
|
{
|
|
|
|
btnModify( evSetMoviePosition,guiIntfStruct.Position );
|
|
|
|
btnModify( evSetVolume,guiIntfStruct.Volume );
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2003-02-06 22:44:52 +00:00
|
|
|
vo_mouse_autohide=0;
|
2003-01-17 22:39:43 +00:00
|
|
|
|
2007-06-05 14:27:54 +00:00
|
|
|
fast_memcpy( mplPBDrawBuffer,appMPlayer.bar.Bitmap.Image,appMPlayer.bar.Bitmap.ImageSize );
|
2003-01-17 22:39:43 +00:00
|
|
|
Render( &appMPlayer.barWindow,appMPlayer.barItems,appMPlayer.NumberOfBarItems,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
|
2009-05-13 02:58:57 +00:00
|
|
|
wsConvert( &appMPlayer.barWindow,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
|
2003-01-17 22:39:43 +00:00
|
|
|
}
|
|
|
|
wsPutImage( &appMPlayer.barWindow );
|
|
|
|
}
|
|
|
|
|
|
|
|
#define itPLMButton (itNULL - 1)
|
|
|
|
#define itPRMButton (itNULL - 2)
|
|
|
|
|
|
|
|
void mplPBMouseHandle( int Button,int X,int Y,int RX,int RY )
|
|
|
|
{
|
|
|
|
static int itemtype = 0;
|
|
|
|
int i;
|
|
|
|
wItem * item = NULL;
|
|
|
|
float value = 0.0f;
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2003-01-17 22:39:43 +00:00
|
|
|
static int SelectedItem = -1;
|
|
|
|
int currentselected = -1;
|
|
|
|
|
|
|
|
for ( i=0;i < appMPlayer.NumberOfBarItems + 1;i++ )
|
|
|
|
if ( ( appMPlayer.barItems[i].pressed != btnDisabled )&&
|
|
|
|
( wgIsRect( X,Y,appMPlayer.barItems[i].x,appMPlayer.barItems[i].y,appMPlayer.barItems[i].x+appMPlayer.barItems[i].width,appMPlayer.barItems[i].y+appMPlayer.barItems[i].height ) ) )
|
|
|
|
{ currentselected=i; break; }
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2003-01-17 22:39:43 +00:00
|
|
|
switch ( Button )
|
|
|
|
{
|
|
|
|
case wsPMMouseButton:
|
|
|
|
gtkShow( evHidePopUpMenu,NULL );
|
|
|
|
mplShowMenu( RX,RY );
|
|
|
|
break;
|
|
|
|
case wsRMMouseButton:
|
|
|
|
mplHideMenu( RX,RY,0 );
|
|
|
|
break;
|
2005-12-04 15:58:52 +00:00
|
|
|
case wsRRMouseButton:
|
2003-01-17 22:39:43 +00:00
|
|
|
gtkShow( evShowPopUpMenu,NULL );
|
|
|
|
break;
|
|
|
|
// ---
|
|
|
|
case wsPLMouseButton:
|
|
|
|
gtkShow( evHidePopUpMenu,NULL );
|
|
|
|
SelectedItem=currentselected;
|
|
|
|
if ( SelectedItem == -1 ) break; // yeees, i'm move the fucking window
|
|
|
|
item=&appMPlayer.barItems[SelectedItem];
|
|
|
|
itemtype=item->type;
|
|
|
|
item->pressed=btnPressed;
|
|
|
|
|
|
|
|
switch( item->type )
|
|
|
|
{
|
|
|
|
case itButton:
|
|
|
|
if ( ( SelectedItem > -1 ) &&
|
|
|
|
( ( ( item->msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) ||
|
|
|
|
( ( item->msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) )
|
|
|
|
{ item->pressed=btnDisabled; }
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case wsRLMouseButton:
|
|
|
|
item=&appMPlayer.barItems[SelectedItem];
|
|
|
|
item->pressed=btnReleased;
|
|
|
|
SelectedItem=-1;
|
|
|
|
if ( currentselected == - 1 ) { itemtype=0; break; }
|
|
|
|
value=0;
|
|
|
|
|
|
|
|
switch( itemtype )
|
|
|
|
{
|
|
|
|
case itPotmeter:
|
|
|
|
case itHPotmeter:
|
|
|
|
btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f );
|
|
|
|
mplEventHandling( item->msg,item->value );
|
|
|
|
value=item->value;
|
|
|
|
break;
|
2005-12-27 19:21:04 +00:00
|
|
|
case itVPotmeter:
|
|
|
|
btnModify( item->msg, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f );
|
|
|
|
mplEventHandling( item->msg,item->value );
|
|
|
|
value=item->value;
|
|
|
|
break;
|
2003-01-17 22:39:43 +00:00
|
|
|
}
|
|
|
|
mplEventHandling( item->msg,value );
|
|
|
|
|
|
|
|
itemtype=0;
|
|
|
|
break;
|
|
|
|
// ---
|
|
|
|
case wsP5MouseButton: value=-2.5f; goto rollerhandled;
|
|
|
|
case wsP4MouseButton: value= 2.5f;
|
|
|
|
rollerhandled:
|
|
|
|
item=&appMPlayer.barItems[currentselected];
|
|
|
|
if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) )
|
|
|
|
{
|
|
|
|
item->value+=value;
|
|
|
|
btnModify( item->msg,item->value );
|
|
|
|
mplEventHandling( item->msg,item->value );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
// ---
|
|
|
|
case wsMoveMouse:
|
|
|
|
item=&appMPlayer.barItems[SelectedItem];
|
|
|
|
switch ( itemtype )
|
|
|
|
{
|
|
|
|
case itPRMButton:
|
|
|
|
mplMenuMouseHandle( X,Y,RX,RY );
|
|
|
|
break;
|
|
|
|
case itPotmeter:
|
|
|
|
item->value=(float)( X - item->x ) / item->width * 100.0f;
|
|
|
|
goto potihandled;
|
2005-12-27 19:21:04 +00:00
|
|
|
case itVPotmeter:
|
|
|
|
item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f;
|
|
|
|
goto potihandled;
|
2003-01-17 22:39:43 +00:00
|
|
|
case itHPotmeter:
|
|
|
|
item->value=(float)( X - item->x ) / item->width * 100.0f;
|
|
|
|
potihandled:
|
|
|
|
if ( item->value > 100.0f ) item->value=100.0f;
|
|
|
|
if ( item->value < 0.0f ) item->value=0.0f;
|
|
|
|
mplEventHandling( item->msg,item->value );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mplPBShow( int x, int y )
|
|
|
|
{
|
|
|
|
if ( !appMPlayer.barIsPresent || !gtkEnablePlayBar ) return;
|
|
|
|
if ( !appMPlayer.subWindow.isFullScreen ) return;
|
|
|
|
|
2009-05-13 02:58:57 +00:00
|
|
|
if ( y > appMPlayer.subWindow.Height - appMPlayer.bar.height )
|
|
|
|
{
|
2003-01-17 22:39:43 +00:00
|
|
|
if ( !mplPBFade ) wsVisibleWindow( &appMPlayer.barWindow,wsShowWindow );
|
|
|
|
mplPBFade=1; mplPBVisible=1; wsPostRedisplay( &appMPlayer.barWindow );
|
|
|
|
}
|
|
|
|
else if ( !mplPBFade ) mplPBFade=2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mplPBInit( void )
|
|
|
|
{
|
|
|
|
if ( !appMPlayer.barIsPresent ) return;
|
|
|
|
|
2003-03-20 12:42:16 +00:00
|
|
|
gfree( (void**)&mplPBDrawBuffer );
|
|
|
|
|
2006-07-13 16:17:24 +00:00
|
|
|
if ( ( mplPBDrawBuffer = malloc( appMPlayer.bar.Bitmap.ImageSize ) ) == NULL )
|
2003-01-17 22:39:43 +00:00
|
|
|
{
|
2003-03-20 12:42:16 +00:00
|
|
|
mp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB );
|
2003-01-17 22:39:43 +00:00
|
|
|
exit( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
appMPlayer.barWindow.Parent=appMPlayer.subWindow.WindowID;
|
|
|
|
wsCreateWindow( &appMPlayer.barWindow,
|
|
|
|
appMPlayer.bar.x,appMPlayer.bar.y,appMPlayer.bar.width,appMPlayer.bar.height,
|
|
|
|
wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsHideWindow,"PlayBar" );
|
|
|
|
|
|
|
|
wsSetShape( &appMPlayer.barWindow,appMPlayer.bar.Mask.Image );
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2003-01-17 22:39:43 +00:00
|
|
|
appMPlayer.barWindow.ReDraw=(void *)mplPBDraw;
|
|
|
|
appMPlayer.barWindow.MouseHandler=mplPBMouseHandle;
|
|
|
|
appMPlayer.barWindow.KeyHandler=mplMainKeyHandle;
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2003-01-17 22:39:43 +00:00
|
|
|
mplPBLength=appMPlayer.subWindow.Height;
|
|
|
|
}
|