Mercurial > mplayer.hg
annotate Gui/mplayer/menu.h @ 5837:7e082f42497a
- Fix for big apple architectures by Rogerio Brito, reworked by me to use bswap.h macros.
- Fix with audio only files.
author | atmos4 |
---|---|
date | Fri, 26 Apr 2002 13:07:03 +0000 |
parents | 3473ca9ef158 |
children | 60cf2bca993f |
rev | line source |
---|---|
1693 | 1 |
2 unsigned char * mplMenuDrawBuffer = NULL; | |
3 int mplMenuRender = 1; | |
4 int mplMenuItem = -1; | |
5 int mplOldMenuItem = -1; | |
6 int mplMenuX,mplMenuY; | |
7 | |
8 void mplHideMenu( int mx,int my ); | |
9 | |
10 void mplMenuDraw( wsParamDisplay ) | |
11 { | |
12 unsigned long * buf = NULL; | |
13 unsigned long * drw = NULL; | |
4465 | 14 int x,y,tmp; |
1693 | 15 |
16 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
3476 | 17 if ( !mplMenuRender && !appMPlayer.menuWindow.Visible ) return; |
1693 | 18 |
19 if ( mplMenuRender || mplMenuItem != mplOldMenuItem ) | |
20 { | |
21 memcpy( mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.Image,appMPlayer.menuBase.Bitmap.ImageSize ); | |
22 // --- | |
23 if ( mplMenuItem != -1 ) | |
24 { | |
25 buf=(unsigned long *)mplMenuDrawBuffer; | |
26 drw=(unsigned long *)appMPlayer.menuSelected.Bitmap.Image; | |
27 for ( y=appMPlayer.MenuItems[ mplMenuItem ].y; y < appMPlayer.MenuItems[ mplMenuItem ].y + appMPlayer.MenuItems[ mplMenuItem ].height; y++ ) | |
28 for ( x=appMPlayer.MenuItems[ mplMenuItem ].x; x < appMPlayer.MenuItems[ mplMenuItem ].x + appMPlayer.MenuItems[ mplMenuItem ].width; x++ ) | |
29 { | |
30 tmp=drw[ y * appMPlayer.menuSelected.width + x ]; | |
31 if ( tmp != 0x00ff00ff ) buf[ y * appMPlayer.menuBase.width + x ]=tmp; | |
32 } | |
33 } | |
34 mplOldMenuItem=mplMenuItem; | |
35 // --- | |
36 wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.ImageSize ); | |
37 mplMenuRender=0; | |
38 } | |
39 wsPutImage( &appMPlayer.menuWindow ); | |
40 } | |
41 | |
42 void mplMenuMouseHandle( int X,int Y,int RX,int RY ) | |
43 { | |
44 int x,y,i; | |
45 | |
46 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
47 | |
48 mplMenuItem=-1; | |
49 x=RX - appMPlayer.menuWindow.X; | |
50 y=RY - appMPlayer.menuWindow.Y; | |
51 if ( ( x < 0 ) || ( y < 0 ) || ( x > appMPlayer.menuBase.width ) || ( y > appMPlayer.menuBase.height ) ) | |
52 { | |
53 wsPostRedisplay( &appMPlayer.menuWindow ); | |
54 return; | |
55 } | |
56 | |
1823 | 57 for( i=0;i<=appMPlayer.NumberOfMenuItems;i++ ) |
1693 | 58 { |
59 if ( wgIsRect( x,y, | |
60 appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y, | |
1823 | 61 appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) { mplMenuItem=i; break; } |
1693 | 62 } |
63 wsPostRedisplay( &appMPlayer.menuWindow ); | |
64 } | |
65 | |
66 void mplShowMenu( int mx,int my ) | |
67 { | |
68 int x,y; | |
69 | |
70 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
71 | |
72 x=mx; | |
73 if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1; | |
74 y=my; | |
75 if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1; | |
76 | |
77 mplMenuX=x; mplMenuY=y; | |
78 | |
79 mplMenuItem = 0; | |
80 | |
2854 | 81 wsMoveWindow( &appMPlayer.menuWindow,False,x,y ); |
3476 | 82 wsMoveTopWindow( &appMPlayer.menuWindow ); |
83 mplMenuRender=1; | |
1693 | 84 wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow ); |
3476 | 85 wsPostRedisplay( &appMPlayer.menuWindow ); |
1693 | 86 } |
87 | |
88 void mplHideMenu( int mx,int my ) | |
89 { | |
90 int x,y,i=mplMenuItem; | |
91 | |
92 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
93 | |
94 x=mx-mplMenuX; | |
95 y=my-mplMenuY; | |
1823 | 96 // x=RX - appMPlayer.menuWindow.X; |
97 // y=RY - appMPlayer.menuWindow.Y; | |
1693 | 98 |
99 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow ); | |
100 | |
101 if ( ( x < 0 ) || ( y < 0 ) ) return; | |
102 | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4465
diff
changeset
|
103 // printf( "---------> %d %d,%d\n",i,x,y ); |
3476 | 104 // printf( "--------> mi: %d,%d %dx%d\n",appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y,appMPlayer.MenuItems[i].width,appMPlayer.MenuItems[i].height ); |
1693 | 105 if ( wgIsRect( x,y, |
106 appMPlayer.MenuItems[i].x,appMPlayer.MenuItems[i].y, | |
107 appMPlayer.MenuItems[i].x+appMPlayer.MenuItems[i].width, | |
108 appMPlayer.MenuItems[i].y+appMPlayer.MenuItems[i].height ) ) | |
109 { | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4465
diff
changeset
|
110 mplEventHandling( appMPlayer.MenuItems[i].msg,0 ); |
1693 | 111 } |
112 } | |
113 | |
114 void mplMenuInit( void ) | |
115 { | |
116 | |
117 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
118 | |
119 appMPlayer.menuBase.x=0; | |
120 appMPlayer.menuBase.y=0; | |
121 | |
122 if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL ) | |
123 { | |
124 #ifdef DEBUG | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4465
diff
changeset
|
125 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] %s",MSGTR_NEMFMR ); |
1693 | 126 #endif |
1907 | 127 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR ); |
1693 | 128 return; |
129 } | |
130 | |
131 wsCreateWindow( &appMPlayer.menuWindow, | |
132 appMPlayer.menuBase.x,appMPlayer.menuBase.y,appMPlayer.menuBase.width,appMPlayer.menuBase.height, | |
4411 | 133 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsOverredirect|wsHideFrame|wsMaxSize|wsMinSize|wsHideWindow,"MPlayer menu" ); |
1693 | 134 |
135 #ifdef DEBUG | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4465
diff
changeset
|
136 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] menu: 0x%x\n",(int)appMPlayer.menuWindow.WindowID ); |
1693 | 137 #endif |
138 | |
139 appMPlayer.menuWindow.ReDraw=mplMenuDraw; | |
140 // appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle; | |
141 // appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle; | |
3476 | 142 mplMenuRender=1; wsPostRedisplay( &appMPlayer.menuWindow ); |
1693 | 143 } |