Mercurial > mplayer.hg
annotate gui/mplayer/pb.c @ 25984:7df9448678d2
synced with r26015
author | Gabrov |
---|---|
date | Sun, 17 Feb 2008 11:31:28 +0000 |
parents | 01754b23193e |
children | 0d255d03016f |
rev | line source |
---|---|
23077 | 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> | |
23305
22d3d12c6dfb
Include string.h for memcpy, fastmemcpy.h alone is not enough.
reimar
parents:
23077
diff
changeset
|
9 #include <string.h> |
23077 | 10 |
11 #include "app.h" | |
12 #include "skin/font.h" | |
13 #include "skin/skin.h" | |
14 #include "wm/ws.h" | |
15 | |
16 #include "../config.h" | |
17 #include "../help_mp.h" | |
18 #include "../libvo/x11_common.h" | |
19 #include "../libvo/fastmemcpy.h" | |
20 | |
21 #include "../stream/stream.h" | |
22 #include "../mixer.h" | |
23 #include "../libvo/sub.h" | |
24 | |
25 #include "../libmpdemux/demuxer.h" | |
26 #include "../libmpdemux/stheader.h" | |
27 #include "../codec-cfg.h" | |
28 | |
29 #include "gmplayer.h" | |
30 #include "play.h" | |
31 #include "widgets.h" | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
23457
diff
changeset
|
32 #include "gui_common.h" |
23077 | 33 |
34 extern unsigned int GetTimerMS( void ); | |
35 extern unsigned int GetTimer( void ); | |
36 | |
37 unsigned char * mplPBDrawBuffer = NULL; | |
38 int mplPBVisible = 0; | |
39 int mplPBLength = 0; | |
40 int mplPBFade = 0; | |
41 | |
42 void mplPBDraw( void ) | |
43 { | |
44 int x; | |
45 | |
46 if ( !appMPlayer.subWindow.isFullScreen ) return; | |
47 if ( !mplPBVisible || !appMPlayer.barIsPresent ) return; | |
48 | |
49 // appMPlayer.bar.x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2; | |
50 switch( appMPlayer.bar.x ) | |
51 { | |
52 case -1: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2; break; | |
53 case -2: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ); break; | |
54 default: x=appMPlayer.bar.x; | |
55 } | |
56 | |
57 switch ( mplPBFade ) | |
58 { | |
59 case 1: // fade in | |
60 mplPBLength--; | |
61 if ( appMPlayer.subWindow.Height - appMPlayer.bar.height >= mplPBLength ) | |
62 { | |
63 mplPBLength=appMPlayer.subWindow.Height - appMPlayer.bar.height; | |
64 mplPBFade=0; | |
65 vo_mouse_autohide=0; | |
66 } | |
67 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength ); | |
68 break; | |
69 case 2: // fade out | |
70 mplPBLength+=10; | |
71 if ( mplPBLength > appMPlayer.subWindow.Height ) | |
72 { | |
73 mplPBLength=appMPlayer.subWindow.Height; | |
74 mplPBFade=mplPBVisible=0; | |
75 vo_mouse_autohide=1; | |
76 wsVisibleWindow( &appMPlayer.barWindow,wsHideWindow ); | |
77 return; | |
78 } | |
79 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength ); | |
80 break; | |
81 } | |
82 | |
83 // --- render | |
84 if ( appMPlayer.barWindow.State == wsWindowExpose ) | |
85 { | |
86 btnModify( evSetMoviePosition,guiIntfStruct.Position ); | |
87 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
88 | |
89 vo_mouse_autohide=0; | |
90 | |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23305
diff
changeset
|
91 fast_memcpy( mplPBDrawBuffer,appMPlayer.bar.Bitmap.Image,appMPlayer.bar.Bitmap.ImageSize ); |
23077 | 92 Render( &appMPlayer.barWindow,appMPlayer.barItems,appMPlayer.NumberOfBarItems,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize ); |
93 wsConvert( &appMPlayer.barWindow,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize ); | |
94 } | |
95 wsPutImage( &appMPlayer.barWindow ); | |
96 } | |
97 | |
98 #define itPLMButton (itNULL - 1) | |
99 #define itPRMButton (itNULL - 2) | |
100 | |
101 void mplPBMouseHandle( int Button,int X,int Y,int RX,int RY ) | |
102 { | |
103 static int itemtype = 0; | |
104 int i; | |
105 wItem * item = NULL; | |
106 float value = 0.0f; | |
107 | |
108 static int SelectedItem = -1; | |
109 int currentselected = -1; | |
110 | |
111 for ( i=0;i < appMPlayer.NumberOfBarItems + 1;i++ ) | |
112 if ( ( appMPlayer.barItems[i].pressed != btnDisabled )&& | |
113 ( 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 ) ) ) | |
114 { currentselected=i; break; } | |
115 | |
116 switch ( Button ) | |
117 { | |
118 case wsPMMouseButton: | |
119 gtkShow( evHidePopUpMenu,NULL ); | |
120 mplShowMenu( RX,RY ); | |
121 break; | |
122 case wsRMMouseButton: | |
123 mplHideMenu( RX,RY,0 ); | |
124 break; | |
125 case wsRRMouseButton: | |
126 gtkShow( evShowPopUpMenu,NULL ); | |
127 break; | |
128 // --- | |
129 case wsPLMouseButton: | |
130 gtkShow( evHidePopUpMenu,NULL ); | |
131 SelectedItem=currentselected; | |
132 if ( SelectedItem == -1 ) break; // yeees, i'm move the fucking window | |
133 item=&appMPlayer.barItems[SelectedItem]; | |
134 itemtype=item->type; | |
135 item->pressed=btnPressed; | |
136 | |
137 switch( item->type ) | |
138 { | |
139 case itButton: | |
140 if ( ( SelectedItem > -1 ) && | |
141 ( ( ( item->msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) || | |
142 ( ( item->msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) ) | |
143 { item->pressed=btnDisabled; } | |
144 break; | |
145 } | |
146 | |
147 break; | |
148 case wsRLMouseButton: | |
149 item=&appMPlayer.barItems[SelectedItem]; | |
150 item->pressed=btnReleased; | |
151 SelectedItem=-1; | |
152 if ( currentselected == - 1 ) { itemtype=0; break; } | |
153 value=0; | |
154 | |
155 switch( itemtype ) | |
156 { | |
157 case itPotmeter: | |
158 case itHPotmeter: | |
159 btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f ); | |
160 mplEventHandling( item->msg,item->value ); | |
161 value=item->value; | |
162 break; | |
163 case itVPotmeter: | |
164 btnModify( item->msg, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); | |
165 mplEventHandling( item->msg,item->value ); | |
166 value=item->value; | |
167 break; | |
168 } | |
169 mplEventHandling( item->msg,value ); | |
170 | |
171 itemtype=0; | |
172 break; | |
173 // --- | |
174 case wsP5MouseButton: value=-2.5f; goto rollerhandled; | |
175 case wsP4MouseButton: value= 2.5f; | |
176 rollerhandled: | |
177 item=&appMPlayer.barItems[currentselected]; | |
178 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) | |
179 { | |
180 item->value+=value; | |
181 btnModify( item->msg,item->value ); | |
182 mplEventHandling( item->msg,item->value ); | |
183 } | |
184 break; | |
185 // --- | |
186 case wsMoveMouse: | |
187 item=&appMPlayer.barItems[SelectedItem]; | |
188 switch ( itemtype ) | |
189 { | |
190 case itPRMButton: | |
191 mplMenuMouseHandle( X,Y,RX,RY ); | |
192 break; | |
193 case itPotmeter: | |
194 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
195 goto potihandled; | |
196 case itVPotmeter: | |
197 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
198 goto potihandled; | |
199 case itHPotmeter: | |
200 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
201 potihandled: | |
202 if ( item->value > 100.0f ) item->value=100.0f; | |
203 if ( item->value < 0.0f ) item->value=0.0f; | |
204 mplEventHandling( item->msg,item->value ); | |
205 break; | |
206 } | |
207 break; | |
208 } | |
209 } | |
210 | |
211 void mplPBShow( int x, int y ) | |
212 { | |
213 if ( !appMPlayer.barIsPresent || !gtkEnablePlayBar ) return; | |
214 if ( !appMPlayer.subWindow.isFullScreen ) return; | |
215 | |
216 if ( y > appMPlayer.subWindow.Height - appMPlayer.bar.height ) | |
217 { | |
218 if ( !mplPBFade ) wsVisibleWindow( &appMPlayer.barWindow,wsShowWindow ); | |
219 mplPBFade=1; mplPBVisible=1; wsPostRedisplay( &appMPlayer.barWindow ); | |
220 } | |
221 else if ( !mplPBFade ) mplPBFade=2; | |
222 } | |
223 | |
224 void mplPBInit( void ) | |
225 { | |
226 if ( !appMPlayer.barIsPresent ) return; | |
227 | |
228 gfree( (void**)&mplPBDrawBuffer ); | |
229 | |
230 if ( ( mplPBDrawBuffer = malloc( appMPlayer.bar.Bitmap.ImageSize ) ) == NULL ) | |
231 { | |
232 mp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB ); | |
233 exit( 0 ); | |
234 } | |
235 | |
236 appMPlayer.barWindow.Parent=appMPlayer.subWindow.WindowID; | |
237 wsCreateWindow( &appMPlayer.barWindow, | |
238 appMPlayer.bar.x,appMPlayer.bar.y,appMPlayer.bar.width,appMPlayer.bar.height, | |
239 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsHideWindow,"PlayBar" ); | |
240 | |
241 wsSetShape( &appMPlayer.barWindow,appMPlayer.bar.Mask.Image ); | |
242 | |
243 appMPlayer.barWindow.ReDraw=(void *)mplPBDraw; | |
244 appMPlayer.barWindow.MouseHandler=mplPBMouseHandle; | |
245 appMPlayer.barWindow.KeyHandler=mplMainKeyHandle; | |
246 | |
247 mplPBLength=appMPlayer.subWindow.Height; | |
248 } |