2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31 unsigned char * mplMenuDrawBuffer
= NULL
;
32 int mplMenuRender
= 1;
34 int mplOldMenuItem
= -1;
35 int mplMenuX
,mplMenuY
;
36 static int mplMenuIsInitialized
= 0;
38 void mplMenuDraw( void )
40 uint32_t * buf
= NULL
;
41 uint32_t * drw
= NULL
;
44 if ( !appMPlayer
.menuIsPresent
|| !appMPlayer
.menuBase
.Bitmap
.Image
) return;
45 if ( !mplMenuRender
&& !appMPlayer
.menuWindow
.Visible
) return;
47 if ( mplMenuRender
|| mplMenuItem
!= mplOldMenuItem
)
49 memcpy( mplMenuDrawBuffer
,appMPlayer
.menuBase
.Bitmap
.Image
,appMPlayer
.menuBase
.Bitmap
.ImageSize
);
51 if ( mplMenuItem
!= -1 )
53 buf
=(uint32_t *)mplMenuDrawBuffer
;
54 drw
=(uint32_t *)appMPlayer
.menuSelected
.Bitmap
.Image
;
55 for ( y
=appMPlayer
.MenuItems
[ mplMenuItem
].y
; y
< appMPlayer
.MenuItems
[ mplMenuItem
].y
+ appMPlayer
.MenuItems
[ mplMenuItem
].height
; y
++ )
56 for ( x
=appMPlayer
.MenuItems
[ mplMenuItem
].x
; x
< appMPlayer
.MenuItems
[ mplMenuItem
].x
+ appMPlayer
.MenuItems
[ mplMenuItem
].width
; x
++ )
58 tmp
=drw
[ y
* appMPlayer
.menuSelected
.width
+ x
];
59 if ( tmp
!= 0x00ff00ff ) buf
[ y
* appMPlayer
.menuBase
.width
+ x
]=tmp
;
62 mplOldMenuItem
=mplMenuItem
;
64 wsConvert( &appMPlayer
.menuWindow
,mplMenuDrawBuffer
,appMPlayer
.menuBase
.Bitmap
.ImageSize
);
67 wsPutImage( &appMPlayer
.menuWindow
);
70 void mplMenuMouseHandle( int X
,int Y
,int RX
,int RY
)
74 if ( !appMPlayer
.menuBase
.Bitmap
.Image
) return;
77 x
=RX
- appMPlayer
.menuWindow
.X
;
78 y
=RY
- appMPlayer
.menuWindow
.Y
;
79 if ( ( x
< 0 ) || ( y
< 0 ) || ( x
> appMPlayer
.menuBase
.width
) || ( y
> appMPlayer
.menuBase
.height
) )
81 wsPostRedisplay( &appMPlayer
.menuWindow
);
85 for( i
=0;i
<=appMPlayer
.NumberOfMenuItems
;i
++ )
88 appMPlayer
.MenuItems
[i
].x
,appMPlayer
.MenuItems
[i
].y
,
89 appMPlayer
.MenuItems
[i
].x
+appMPlayer
.MenuItems
[i
].width
,appMPlayer
.MenuItems
[i
].y
+appMPlayer
.MenuItems
[i
].height
) ) { mplMenuItem
=i
; break; }
91 wsPostRedisplay( &appMPlayer
.menuWindow
);
94 void mplShowMenu( int mx
,int my
)
98 if ( !appMPlayer
.menuIsPresent
|| !appMPlayer
.menuBase
.Bitmap
.Image
) return;
101 if ( x
+ appMPlayer
.menuWindow
.Width
> wsMaxX
) x
=wsMaxX
- appMPlayer
.menuWindow
.Width
- 1 + wsOrgX
;
103 if ( y
+ appMPlayer
.menuWindow
.Height
> wsMaxY
) y
=wsMaxY
- appMPlayer
.menuWindow
.Height
- 1 + wsOrgY
;
105 mplMenuX
=x
; mplMenuY
=y
;
109 wsMoveWindow( &appMPlayer
.menuWindow
,False
,x
,y
);
110 wsMoveTopWindow( wsDisplay
,appMPlayer
.menuWindow
.WindowID
);
111 wsSetLayer( wsDisplay
,appMPlayer
.menuWindow
.WindowID
,1 );
113 wsVisibleWindow( &appMPlayer
.menuWindow
,wsShowWindow
);
114 wsPostRedisplay( &appMPlayer
.menuWindow
);
117 void mplHideMenu( int mx
,int my
,int w
)
119 int x
,y
,i
=mplMenuItem
;
121 if ( !appMPlayer
.menuIsPresent
|| !appMPlayer
.menuBase
.Bitmap
.Image
) return;
125 // x=RX - appMPlayer.menuWindow.X;
126 // y=RY - appMPlayer.menuWindow.Y;
128 wsVisibleWindow( &appMPlayer
.menuWindow
,wsHideWindow
);
130 if ( ( x
< 0 ) || ( y
< 0 ) ) return;
132 // printf( "---------> %d %d,%d\n",i,x,y );
133 // printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].height );
135 appMPlayer
.MenuItems
[i
].x
,appMPlayer
.MenuItems
[i
].y
,
136 appMPlayer
.MenuItems
[i
].x
+appMPlayer
.MenuItems
[i
].width
,
137 appMPlayer
.MenuItems
[i
].y
+appMPlayer
.MenuItems
[i
].height
) )
139 mplEventHandling( appMPlayer
.MenuItems
[i
].msg
,(float)w
);
143 void mplMenuInit( void )
146 if ( mplMenuIsInitialized
|| !appMPlayer
.menuIsPresent
|| !appMPlayer
.menuBase
.Bitmap
.Image
) return;
148 appMPlayer
.menuBase
.x
=0;
149 appMPlayer
.menuBase
.y
=0;
151 if ( ( mplMenuDrawBuffer
= calloc( 1,appMPlayer
.menuBase
.Bitmap
.ImageSize
) ) == NULL
)
154 mp_msg( MSGT_GPLAYER
,MSGL_DBG2
,"[menu.h] %s",MSGTR_NEMFMR
);
156 gtkMessageBox( GTK_MB_FATAL
,MSGTR_NEMFMR
);
160 wsCreateWindow( &appMPlayer
.menuWindow
,
161 appMPlayer
.menuBase
.x
,appMPlayer
.menuBase
.y
,appMPlayer
.menuBase
.width
,appMPlayer
.menuBase
.height
,
162 wsNoBorder
,wsShowMouseCursor
|wsHandleMouseButton
|wsHandleMouseMove
,wsOverredirect
|wsHideFrame
|wsMaxSize
|wsMinSize
|wsHideWindow
,"MPlayer menu" );
164 wsSetShape( &appMPlayer
.menuWindow
,appMPlayer
.menuBase
.Mask
.Image
);
167 mp_msg( MSGT_GPLAYER
,MSGL_DBG2
,"[menu.h] menu: 0x%x\n",(int)appMPlayer
.menuWindow
.WindowID
);
170 mplMenuIsInitialized
=1;
171 appMPlayer
.menuWindow
.ReDraw
=mplMenuDraw
;
172 // appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle;
173 // appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle;
174 mplMenuRender
=1; wsPostRedisplay( &appMPlayer
.menuWindow
);