Mercurial > mplayer.hg
annotate gui/mplayer/menu.c @ 29968:4e0ff9be2b1e
Avoid '&>' bashism for redirecting both stdout and stderr.
author | diego |
---|---|
date | Sun, 13 Dec 2009 23:48:20 +0000 |
parents | b0a7b35b78d2 |
children | 704903d34069 |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
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. | |
8 * | |
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. | |
13 * | |
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. | |
17 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <stdio.h> | |
21 #include <inttypes.h> | |
22 | |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
23 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
24 #include "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
25 #include "mp_msg.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
26 #include "gui/app.h" |
23154
e564b9cd7290
Fix several implicit declarations of functions warnings.
diego
parents:
23077
diff
changeset
|
27 #include "gmplayer.h" |
23077 | 28 |
29 #include "widgets.h" | |
30 | |
31 unsigned char * mplMenuDrawBuffer = NULL; | |
32 int mplMenuRender = 1; | |
33 int mplMenuItem = -1; | |
34 int mplOldMenuItem = -1; | |
35 int mplMenuX,mplMenuY; | |
36 static int mplMenuIsInitialized = 0; | |
37 | |
38 void mplMenuDraw( void ) | |
39 { | |
40 uint32_t * buf = NULL; | |
41 uint32_t * drw = NULL; | |
42 int x,y,tmp; | |
43 | |
44 if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return; | |
45 if ( !mplMenuRender && !appMPlayer.menuWindow.Visible ) return; | |
46 | |
47 if ( mplMenuRender || mplMenuItem != mplOldMenuItem ) | |
48 { | |
49 memcpy( mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.Image,appMPlayer.menuBase.Bitmap.ImageSize ); | |
50 // --- | |
51 if ( mplMenuItem != -1 ) | |
52 { | |
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++ ) | |
57 { | |
58 tmp=drw[ y * appMPlayer.menuSelected.width + x ]; | |
59 if ( tmp != 0x00ff00ff ) buf[ y * appMPlayer.menuBase.width + x ]=tmp; | |
60 } | |
61 } | |
62 mplOldMenuItem=mplMenuItem; | |
63 // --- | |
64 wsConvert( &appMPlayer.menuWindow,mplMenuDrawBuffer,appMPlayer.menuBase.Bitmap.ImageSize ); | |
65 mplMenuRender=0; | |
66 } | |
67 wsPutImage( &appMPlayer.menuWindow ); | |
68 } | |
69 | |
70 void mplMenuMouseHandle( int X,int Y,int RX,int RY ) | |
71 { | |
72 int x,y,i; | |
73 | |
74 if ( !appMPlayer.menuBase.Bitmap.Image ) return; | |
75 | |
76 mplMenuItem=-1; | |
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 ) ) | |
80 { | |
81 wsPostRedisplay( &appMPlayer.menuWindow ); | |
82 return; | |
83 } | |
84 | |
85 for( i=0;i<=appMPlayer.NumberOfMenuItems;i++ ) | |
86 { | |
87 if ( wgIsRect( x,y, | |
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; } | |
90 } | |
91 wsPostRedisplay( &appMPlayer.menuWindow ); | |
92 } | |
93 | |
94 void mplShowMenu( int mx,int my ) | |
95 { | |
96 int x,y; | |
97 | |
98 if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return; | |
99 | |
100 x=mx; | |
101 if ( x + appMPlayer.menuWindow.Width > wsMaxX ) x=wsMaxX - appMPlayer.menuWindow.Width - 1 + wsOrgX; | |
102 y=my; | |
103 if ( y + appMPlayer.menuWindow.Height > wsMaxY ) y=wsMaxY - appMPlayer.menuWindow.Height - 1 + wsOrgY; | |
104 | |
105 mplMenuX=x; mplMenuY=y; | |
106 | |
107 mplMenuItem = 0; | |
108 | |
109 wsMoveWindow( &appMPlayer.menuWindow,False,x,y ); | |
110 wsMoveTopWindow( wsDisplay,appMPlayer.menuWindow.WindowID ); | |
111 wsSetLayer( wsDisplay,appMPlayer.menuWindow.WindowID,1 ); | |
112 mplMenuRender=1; | |
113 wsVisibleWindow( &appMPlayer.menuWindow,wsShowWindow ); | |
114 wsPostRedisplay( &appMPlayer.menuWindow ); | |
115 } | |
116 | |
117 void mplHideMenu( int mx,int my,int w ) | |
118 { | |
119 int x,y,i=mplMenuItem; | |
120 | |
121 if ( !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return; | |
122 | |
123 x=mx-mplMenuX; | |
124 y=my-mplMenuY; | |
125 // x=RX - appMPlayer.menuWindow.X; | |
126 // y=RY - appMPlayer.menuWindow.Y; | |
127 | |
128 wsVisibleWindow( &appMPlayer.menuWindow,wsHideWindow ); | |
129 | |
130 if ( ( x < 0 ) || ( y < 0 ) ) return; | |
131 | |
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 ); | |
134 if ( wgIsRect( x,y, | |
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 ) ) | |
138 { | |
139 mplEventHandling( appMPlayer.MenuItems[i].msg,(float)w ); | |
140 } | |
141 } | |
142 | |
143 void mplMenuInit( void ) | |
144 { | |
145 | |
146 if ( mplMenuIsInitialized || !appMPlayer.menuIsPresent || !appMPlayer.menuBase.Bitmap.Image ) return; | |
147 | |
148 appMPlayer.menuBase.x=0; | |
149 appMPlayer.menuBase.y=0; | |
150 | |
151 if ( ( mplMenuDrawBuffer = calloc( 1,appMPlayer.menuBase.Bitmap.ImageSize ) ) == NULL ) | |
152 { | |
153 #ifdef DEBUG | |
154 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] %s",MSGTR_NEMFMR ); | |
155 #endif | |
156 gtkMessageBox( GTK_MB_FATAL,MSGTR_NEMFMR ); | |
157 return; | |
158 } | |
159 | |
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" ); | |
163 | |
164 wsSetShape( &appMPlayer.menuWindow,appMPlayer.menuBase.Mask.Image ); | |
165 | |
166 #ifdef DEBUG | |
167 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[menu.h] menu: 0x%x\n",(int)appMPlayer.menuWindow.WindowID ); | |
168 #endif | |
169 | |
170 mplMenuIsInitialized=1; | |
171 appMPlayer.menuWindow.ReDraw=mplMenuDraw; | |
172 // appMPlayer.menuWindow.MouseHandler=mplMenuMouseHandle; | |
173 // appMPlayer.menuWindow.KeyHandler=mplMainKeyHandle; | |
174 mplMenuRender=1; wsPostRedisplay( &appMPlayer.menuWindow ); | |
175 } |