Mercurial > mplayer.hg
annotate Gui/mplayer/pb.c @ 22297:3340e52ad814
Move some related variables together & add a comment
author | uau |
---|---|
date | Thu, 22 Feb 2007 20:44:48 +0000 |
parents | 308495b6d611 |
children |
rev | line source |
---|---|
8973 | 1 |
2 // main window | |
3 | |
4 #include <stdlib.h> | |
5 #include <stdio.h> | |
6 #include <inttypes.h> | |
7 #include <sys/stat.h> | |
8 #include <unistd.h> | |
9 | |
17144 | 10 #include "app.h" |
11 #include "skin/font.h" | |
12 #include "skin/skin.h" | |
13 #include "wm/ws.h" | |
8973 | 14 |
17144 | 15 #include "../config.h" |
16 #include "../help_mp.h" | |
17 #include "../libvo/x11_common.h" | |
18 #include "../libvo/fastmemcpy.h" | |
8973 | 19 |
19271
64d82a45a05d
introduce new 'stream' directory for all stream layer related components and split them from libmpdemux
ben
parents:
19061
diff
changeset
|
20 #include "../stream/stream.h" |
17144 | 21 #include "../mixer.h" |
22 #include "../libvo/sub.h" | |
8973 | 23 |
17144 | 24 #include "../libmpdemux/demuxer.h" |
25 #include "../libmpdemux/stheader.h" | |
26 #include "../codec-cfg.h" | |
8973 | 27 |
21227
308495b6d611
Rename Gui/mplayer/mplayer.h to gmplayer.h, another file named mplayer.h
diego
parents:
19271
diff
changeset
|
28 #include "gmplayer.h" |
8973 | 29 #include "play.h" |
30 #include "widgets.h" | |
31 #include "common.h" | |
32 | |
33 extern unsigned int GetTimerMS( void ); | |
34 extern unsigned int GetTimer( void ); | |
35 | |
36 unsigned char * mplPBDrawBuffer = NULL; | |
37 int mplPBVisible = 0; | |
38 int mplPBLength = 0; | |
39 int mplPBFade = 0; | |
40 | |
41 void mplPBDraw( void ) | |
42 { | |
9088 | 43 int x; |
44 | |
8973 | 45 if ( !appMPlayer.subWindow.isFullScreen ) return; |
46 if ( !mplPBVisible || !appMPlayer.barIsPresent ) return; | |
47 | |
9088 | 48 // appMPlayer.bar.x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2; |
49 switch( appMPlayer.bar.x ) | |
50 { | |
51 case -1: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2; break; | |
52 case -2: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ); break; | |
53 default: x=appMPlayer.bar.x; | |
54 } | |
55 | |
8973 | 56 switch ( mplPBFade ) |
57 { | |
58 case 1: // fade in | |
59 mplPBLength--; | |
60 if ( appMPlayer.subWindow.Height - appMPlayer.bar.height >= mplPBLength ) | |
61 { | |
62 mplPBLength=appMPlayer.subWindow.Height - appMPlayer.bar.height; | |
63 mplPBFade=0; | |
64 vo_mouse_autohide=0; | |
65 } | |
9088 | 66 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength ); |
8973 | 67 break; |
68 case 2: // fade out | |
69 mplPBLength+=10; | |
70 if ( mplPBLength > appMPlayer.subWindow.Height ) | |
71 { | |
72 mplPBLength=appMPlayer.subWindow.Height; | |
73 mplPBFade=mplPBVisible=0; | |
74 vo_mouse_autohide=1; | |
75 wsVisibleWindow( &appMPlayer.barWindow,wsHideWindow ); | |
76 return; | |
77 } | |
9088 | 78 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength ); |
8973 | 79 break; |
80 } | |
81 | |
82 // --- render | |
83 if ( appMPlayer.barWindow.State == wsWindowExpose ) | |
84 { | |
85 btnModify( evSetMoviePosition,guiIntfStruct.Position ); | |
86 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
9305 | 87 |
88 vo_mouse_autohide=0; | |
8973 | 89 |
90 memcpy( mplPBDrawBuffer,appMPlayer.bar.Bitmap.Image,appMPlayer.bar.Bitmap.ImageSize ); | |
91 Render( &appMPlayer.barWindow,appMPlayer.barItems,appMPlayer.NumberOfBarItems,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize ); | |
92 wsConvert( &appMPlayer.barWindow,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize ); | |
93 } | |
94 wsPutImage( &appMPlayer.barWindow ); | |
95 } | |
96 | |
97 #define itPLMButton (itNULL - 1) | |
98 #define itPRMButton (itNULL - 2) | |
99 | |
100 void mplPBMouseHandle( int Button,int X,int Y,int RX,int RY ) | |
101 { | |
102 static int itemtype = 0; | |
103 int i; | |
104 wItem * item = NULL; | |
105 float value = 0.0f; | |
106 | |
107 static int SelectedItem = -1; | |
108 int currentselected = -1; | |
109 | |
110 for ( i=0;i < appMPlayer.NumberOfBarItems + 1;i++ ) | |
111 if ( ( appMPlayer.barItems[i].pressed != btnDisabled )&& | |
112 ( 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 ) ) ) | |
113 { currentselected=i; break; } | |
114 | |
115 switch ( Button ) | |
116 { | |
117 case wsPMMouseButton: | |
118 gtkShow( evHidePopUpMenu,NULL ); | |
119 mplShowMenu( RX,RY ); | |
120 break; | |
121 case wsRMMouseButton: | |
122 mplHideMenu( RX,RY,0 ); | |
123 break; | |
17087
4a56f15dee5f
Fix popup menu problems: GTK cannot get a grab while the button is down,
reimar
parents:
9625
diff
changeset
|
124 case wsRRMouseButton: |
8973 | 125 gtkShow( evShowPopUpMenu,NULL ); |
126 break; | |
127 // --- | |
128 case wsPLMouseButton: | |
129 gtkShow( evHidePopUpMenu,NULL ); | |
130 SelectedItem=currentselected; | |
131 if ( SelectedItem == -1 ) break; // yeees, i'm move the fucking window | |
132 item=&appMPlayer.barItems[SelectedItem]; | |
133 itemtype=item->type; | |
134 item->pressed=btnPressed; | |
135 | |
136 switch( item->type ) | |
137 { | |
138 case itButton: | |
139 if ( ( SelectedItem > -1 ) && | |
140 ( ( ( item->msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) || | |
141 ( ( item->msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) ) | |
142 { item->pressed=btnDisabled; } | |
143 break; | |
144 } | |
145 | |
146 break; | |
147 case wsRLMouseButton: | |
148 item=&appMPlayer.barItems[SelectedItem]; | |
149 item->pressed=btnReleased; | |
150 SelectedItem=-1; | |
151 if ( currentselected == - 1 ) { itemtype=0; break; } | |
152 value=0; | |
153 | |
154 switch( itemtype ) | |
155 { | |
156 case itPotmeter: | |
157 case itHPotmeter: | |
158 btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f ); | |
159 mplEventHandling( item->msg,item->value ); | |
160 value=item->value; | |
161 break; | |
17254 | 162 case itVPotmeter: |
163 btnModify( item->msg, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); | |
164 mplEventHandling( item->msg,item->value ); | |
165 value=item->value; | |
166 break; | |
8973 | 167 } |
168 mplEventHandling( item->msg,value ); | |
169 | |
170 itemtype=0; | |
171 break; | |
172 // --- | |
173 case wsP5MouseButton: value=-2.5f; goto rollerhandled; | |
174 case wsP4MouseButton: value= 2.5f; | |
175 rollerhandled: | |
176 item=&appMPlayer.barItems[currentselected]; | |
177 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) | |
178 { | |
179 item->value+=value; | |
180 btnModify( item->msg,item->value ); | |
181 mplEventHandling( item->msg,item->value ); | |
182 } | |
183 break; | |
184 // --- | |
185 case wsMoveMouse: | |
186 item=&appMPlayer.barItems[SelectedItem]; | |
187 switch ( itemtype ) | |
188 { | |
189 case itPRMButton: | |
190 mplMenuMouseHandle( X,Y,RX,RY ); | |
191 break; | |
192 case itPotmeter: | |
193 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
194 goto potihandled; | |
17254 | 195 case itVPotmeter: |
196 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
197 goto potihandled; | |
8973 | 198 case itHPotmeter: |
199 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
200 potihandled: | |
201 if ( item->value > 100.0f ) item->value=100.0f; | |
202 if ( item->value < 0.0f ) item->value=0.0f; | |
203 mplEventHandling( item->msg,item->value ); | |
204 break; | |
205 } | |
206 break; | |
207 } | |
208 } | |
209 | |
210 void mplPBShow( int x, int y ) | |
211 { | |
212 if ( !appMPlayer.barIsPresent || !gtkEnablePlayBar ) return; | |
213 if ( !appMPlayer.subWindow.isFullScreen ) return; | |
214 | |
215 if ( y > appMPlayer.subWindow.Height - appMPlayer.bar.height ) | |
216 { | |
217 if ( !mplPBFade ) wsVisibleWindow( &appMPlayer.barWindow,wsShowWindow ); | |
218 mplPBFade=1; mplPBVisible=1; wsPostRedisplay( &appMPlayer.barWindow ); | |
219 } | |
220 else if ( !mplPBFade ) mplPBFade=2; | |
221 } | |
222 | |
223 void mplPBInit( void ) | |
224 { | |
225 if ( !appMPlayer.barIsPresent ) return; | |
226 | |
9625 | 227 gfree( (void**)&mplPBDrawBuffer ); |
228 | |
19061
86350b4b8203
drops casts from void * on malloc/calloc from the gui code
reynaldo
parents:
17254
diff
changeset
|
229 if ( ( mplPBDrawBuffer = malloc( appMPlayer.bar.Bitmap.ImageSize ) ) == NULL ) |
8973 | 230 { |
9625 | 231 mp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB ); |
8973 | 232 exit( 0 ); |
233 } | |
234 | |
235 appMPlayer.barWindow.Parent=appMPlayer.subWindow.WindowID; | |
236 wsCreateWindow( &appMPlayer.barWindow, | |
237 appMPlayer.bar.x,appMPlayer.bar.y,appMPlayer.bar.width,appMPlayer.bar.height, | |
238 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsHideWindow,"PlayBar" ); | |
239 | |
240 wsSetShape( &appMPlayer.barWindow,appMPlayer.bar.Mask.Image ); | |
241 | |
242 appMPlayer.barWindow.ReDraw=(void *)mplPBDraw; | |
243 appMPlayer.barWindow.MouseHandler=mplPBMouseHandle; | |
244 appMPlayer.barWindow.KeyHandler=mplMainKeyHandle; | |
245 | |
246 mplPBLength=appMPlayer.subWindow.Height; | |
247 } |