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
|
|
10 #include "../app.h"
|
|
11 #include "../skin/font.h"
|
|
12 #include "../skin/skin.h"
|
|
13 #include "../wm/ws.h"
|
|
14
|
|
15 #include "../../config.h"
|
|
16 #include "../../help_mp.h"
|
|
17 #include "../../libvo/x11_common.h"
|
9625
|
18 #include "../../libvo/fastmemcpy.h"
|
8973
|
19
|
|
20 #include "../../libmpdemux/stream.h"
|
|
21 #include "../../mixer.h"
|
|
22 #include "../../libvo/sub.h"
|
|
23 #include "../../mplayer.h"
|
|
24
|
|
25 #include "../../libmpdemux/demuxer.h"
|
|
26 #include "../../libmpdemux/stheader.h"
|
|
27 #include "../../codec-cfg.h"
|
|
28
|
|
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;
|
|
124 case wsPRMouseButton:
|
|
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:
|
8975
|
157 case itVPotmeter:
|
8973
|
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 }
|
|
164 mplEventHandling( item->msg,value );
|
|
165
|
|
166 itemtype=0;
|
|
167 break;
|
|
168 // ---
|
|
169 case wsP5MouseButton: value=-2.5f; goto rollerhandled;
|
|
170 case wsP4MouseButton: value= 2.5f;
|
|
171 rollerhandled:
|
|
172 item=&appMPlayer.barItems[currentselected];
|
|
173 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) )
|
|
174 {
|
|
175 item->value+=value;
|
|
176 btnModify( item->msg,item->value );
|
|
177 mplEventHandling( item->msg,item->value );
|
|
178 }
|
|
179 break;
|
|
180 // ---
|
|
181 case wsMoveMouse:
|
|
182 item=&appMPlayer.barItems[SelectedItem];
|
|
183 switch ( itemtype )
|
|
184 {
|
|
185 case itPRMButton:
|
|
186 mplMenuMouseHandle( X,Y,RX,RY );
|
|
187 break;
|
|
188 case itPotmeter:
|
|
189 item->value=(float)( X - item->x ) / item->width * 100.0f;
|
|
190 goto potihandled;
|
|
191 case itHPotmeter:
|
|
192 item->value=(float)( X - item->x ) / item->width * 100.0f;
|
|
193 potihandled:
|
|
194 if ( item->value > 100.0f ) item->value=100.0f;
|
|
195 if ( item->value < 0.0f ) item->value=0.0f;
|
|
196 mplEventHandling( item->msg,item->value );
|
|
197 break;
|
|
198 }
|
|
199 break;
|
|
200 }
|
|
201 }
|
|
202
|
|
203 void mplPBShow( int x, int y )
|
|
204 {
|
|
205 if ( !appMPlayer.barIsPresent || !gtkEnablePlayBar ) return;
|
|
206 if ( !appMPlayer.subWindow.isFullScreen ) return;
|
|
207
|
|
208 if ( y > appMPlayer.subWindow.Height - appMPlayer.bar.height )
|
|
209 {
|
|
210 if ( !mplPBFade ) wsVisibleWindow( &appMPlayer.barWindow,wsShowWindow );
|
|
211 mplPBFade=1; mplPBVisible=1; wsPostRedisplay( &appMPlayer.barWindow );
|
|
212 }
|
|
213 else if ( !mplPBFade ) mplPBFade=2;
|
|
214 }
|
|
215
|
|
216 void mplPBInit( void )
|
|
217 {
|
|
218 if ( !appMPlayer.barIsPresent ) return;
|
|
219
|
9625
|
220 gfree( (void**)&mplPBDrawBuffer );
|
|
221
|
|
222 if ( ( mplPBDrawBuffer = (unsigned char *)malloc( appMPlayer.bar.Bitmap.ImageSize ) ) == NULL )
|
8973
|
223 {
|
9625
|
224 mp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB );
|
8973
|
225 exit( 0 );
|
|
226 }
|
|
227
|
|
228 appMPlayer.barWindow.Parent=appMPlayer.subWindow.WindowID;
|
|
229 wsCreateWindow( &appMPlayer.barWindow,
|
|
230 appMPlayer.bar.x,appMPlayer.bar.y,appMPlayer.bar.width,appMPlayer.bar.height,
|
|
231 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsHideWindow,"PlayBar" );
|
|
232
|
|
233 wsSetShape( &appMPlayer.barWindow,appMPlayer.bar.Mask.Image );
|
|
234
|
|
235 appMPlayer.barWindow.ReDraw=(void *)mplPBDraw;
|
|
236 appMPlayer.barWindow.MouseHandler=mplPBMouseHandle;
|
|
237 appMPlayer.barWindow.KeyHandler=mplMainKeyHandle;
|
|
238
|
|
239 mplPBLength=appMPlayer.subWindow.Height;
|
|
240 }
|