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"
|
|
18
|
|
19 #include "../../libmpdemux/stream.h"
|
|
20 #include "../../mixer.h"
|
|
21 #include "../../libvo/sub.h"
|
|
22 #include "../../mplayer.h"
|
|
23
|
|
24 #include "../../libmpdemux/demuxer.h"
|
|
25 #include "../../libmpdemux/stheader.h"
|
|
26 #include "../../codec-cfg.h"
|
|
27
|
|
28 #include "play.h"
|
|
29 #include "widgets.h"
|
|
30 #include "common.h"
|
|
31
|
|
32 extern unsigned int GetTimerMS( void );
|
|
33 extern unsigned int GetTimer( void );
|
|
34
|
|
35 unsigned char * mplPBDrawBuffer = NULL;
|
|
36 int mplPBVisible = 0;
|
|
37 int mplPBLength = 0;
|
|
38 int mplPBFade = 0;
|
|
39
|
|
40 void mplPBDraw( void )
|
|
41 {
|
9088
|
42 int x;
|
|
43
|
8973
|
44 if ( !appMPlayer.subWindow.isFullScreen ) return;
|
|
45 if ( !mplPBVisible || !appMPlayer.barIsPresent ) return;
|
|
46
|
9088
|
47 // appMPlayer.bar.x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2;
|
|
48 switch( appMPlayer.bar.x )
|
|
49 {
|
|
50 case -1: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2; break;
|
|
51 case -2: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ); break;
|
|
52 default: x=appMPlayer.bar.x;
|
|
53 }
|
|
54
|
8973
|
55 switch ( mplPBFade )
|
|
56 {
|
|
57 case 1: // fade in
|
|
58 mplPBLength--;
|
|
59 if ( appMPlayer.subWindow.Height - appMPlayer.bar.height >= mplPBLength )
|
|
60 {
|
|
61 mplPBLength=appMPlayer.subWindow.Height - appMPlayer.bar.height;
|
|
62 mplPBFade=0;
|
|
63 vo_mouse_autohide=0;
|
|
64 }
|
9088
|
65 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength );
|
8973
|
66 break;
|
|
67 case 2: // fade out
|
|
68 mplPBLength+=10;
|
|
69 if ( mplPBLength > appMPlayer.subWindow.Height )
|
|
70 {
|
|
71 mplPBLength=appMPlayer.subWindow.Height;
|
|
72 mplPBFade=mplPBVisible=0;
|
|
73 vo_mouse_autohide=1;
|
|
74 wsVisibleWindow( &appMPlayer.barWindow,wsHideWindow );
|
|
75 return;
|
|
76 }
|
9088
|
77 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength );
|
8973
|
78 break;
|
|
79 }
|
|
80
|
|
81 // --- render
|
|
82 if ( appMPlayer.barWindow.State == wsWindowExpose )
|
|
83 {
|
|
84 btnModify( evSetMoviePosition,guiIntfStruct.Position );
|
|
85 btnModify( evSetVolume,guiIntfStruct.Volume );
|
9305
|
86
|
|
87 vo_mouse_autohide=0;
|
8973
|
88
|
|
89 memcpy( mplPBDrawBuffer,appMPlayer.bar.Bitmap.Image,appMPlayer.bar.Bitmap.ImageSize );
|
|
90 Render( &appMPlayer.barWindow,appMPlayer.barItems,appMPlayer.NumberOfBarItems,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
|
|
91 wsConvert( &appMPlayer.barWindow,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
|
|
92 }
|
|
93 wsPutImage( &appMPlayer.barWindow );
|
|
94 }
|
|
95
|
|
96 #define itPLMButton (itNULL - 1)
|
|
97 #define itPRMButton (itNULL - 2)
|
|
98
|
|
99 void mplPBMouseHandle( int Button,int X,int Y,int RX,int RY )
|
|
100 {
|
|
101 static int itemtype = 0;
|
|
102 int i;
|
|
103 wItem * item = NULL;
|
|
104 float value = 0.0f;
|
|
105
|
|
106 static int SelectedItem = -1;
|
|
107 int currentselected = -1;
|
|
108
|
|
109 for ( i=0;i < appMPlayer.NumberOfBarItems + 1;i++ )
|
|
110 if ( ( appMPlayer.barItems[i].pressed != btnDisabled )&&
|
|
111 ( 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 ) ) )
|
|
112 { currentselected=i; break; }
|
|
113
|
|
114 switch ( Button )
|
|
115 {
|
|
116 case wsPMMouseButton:
|
|
117 gtkShow( evHidePopUpMenu,NULL );
|
|
118 mplShowMenu( RX,RY );
|
|
119 break;
|
|
120 case wsRMMouseButton:
|
|
121 mplHideMenu( RX,RY,0 );
|
|
122 break;
|
|
123 case wsPRMouseButton:
|
|
124 gtkShow( evShowPopUpMenu,NULL );
|
|
125 break;
|
|
126 // ---
|
|
127 case wsPLMouseButton:
|
|
128 gtkShow( evHidePopUpMenu,NULL );
|
|
129 SelectedItem=currentselected;
|
|
130 if ( SelectedItem == -1 ) break; // yeees, i'm move the fucking window
|
|
131 item=&appMPlayer.barItems[SelectedItem];
|
|
132 itemtype=item->type;
|
|
133 item->pressed=btnPressed;
|
|
134
|
|
135 switch( item->type )
|
|
136 {
|
|
137 case itButton:
|
|
138 if ( ( SelectedItem > -1 ) &&
|
|
139 ( ( ( item->msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) ||
|
|
140 ( ( item->msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) )
|
|
141 { item->pressed=btnDisabled; }
|
|
142 break;
|
|
143 }
|
|
144
|
|
145 break;
|
|
146 case wsRLMouseButton:
|
|
147 item=&appMPlayer.barItems[SelectedItem];
|
|
148 item->pressed=btnReleased;
|
|
149 SelectedItem=-1;
|
|
150 if ( currentselected == - 1 ) { itemtype=0; break; }
|
|
151 value=0;
|
|
152
|
|
153 switch( itemtype )
|
|
154 {
|
|
155 case itPotmeter:
|
8975
|
156 case itVPotmeter:
|
8973
|
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;
|
|
162 }
|
|
163 mplEventHandling( item->msg,value );
|
|
164
|
|
165 itemtype=0;
|
|
166 break;
|
|
167 // ---
|
|
168 case wsP5MouseButton: value=-2.5f; goto rollerhandled;
|
|
169 case wsP4MouseButton: value= 2.5f;
|
|
170 rollerhandled:
|
|
171 item=&appMPlayer.barItems[currentselected];
|
|
172 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) )
|
|
173 {
|
|
174 item->value+=value;
|
|
175 btnModify( item->msg,item->value );
|
|
176 mplEventHandling( item->msg,item->value );
|
|
177 }
|
|
178 break;
|
|
179 // ---
|
|
180 case wsMoveMouse:
|
|
181 item=&appMPlayer.barItems[SelectedItem];
|
|
182 switch ( itemtype )
|
|
183 {
|
|
184 case itPRMButton:
|
|
185 mplMenuMouseHandle( X,Y,RX,RY );
|
|
186 break;
|
|
187 case itPotmeter:
|
|
188 item->value=(float)( X - item->x ) / item->width * 100.0f;
|
|
189 goto potihandled;
|
|
190 case itHPotmeter:
|
|
191 item->value=(float)( X - item->x ) / item->width * 100.0f;
|
|
192 potihandled:
|
|
193 if ( item->value > 100.0f ) item->value=100.0f;
|
|
194 if ( item->value < 0.0f ) item->value=0.0f;
|
|
195 mplEventHandling( item->msg,item->value );
|
|
196 break;
|
|
197 }
|
|
198 break;
|
|
199 }
|
|
200 }
|
|
201
|
|
202 void mplPBShow( int x, int y )
|
|
203 {
|
|
204 if ( !appMPlayer.barIsPresent || !gtkEnablePlayBar ) return;
|
|
205 if ( !appMPlayer.subWindow.isFullScreen ) return;
|
|
206
|
|
207 if ( y > appMPlayer.subWindow.Height - appMPlayer.bar.height )
|
|
208 {
|
|
209 if ( !mplPBFade ) wsVisibleWindow( &appMPlayer.barWindow,wsShowWindow );
|
|
210 mplPBFade=1; mplPBVisible=1; wsPostRedisplay( &appMPlayer.barWindow );
|
|
211 }
|
|
212 else if ( !mplPBFade ) mplPBFade=2;
|
|
213 }
|
|
214
|
|
215 void mplPBInit( void )
|
|
216 {
|
|
217 gfree( (void**)&mplPBDrawBuffer );
|
|
218
|
|
219 if ( !appMPlayer.barIsPresent ) return;
|
|
220
|
|
221 if ( ( mplPBDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.bar.Bitmap.ImageSize ) ) == NULL )
|
|
222 {
|
|
223 fprintf( stderr,MSGTR_NEMDB );
|
|
224 exit( 0 );
|
|
225 }
|
|
226
|
|
227 appMPlayer.barWindow.Parent=appMPlayer.subWindow.WindowID;
|
|
228 wsCreateWindow( &appMPlayer.barWindow,
|
|
229 appMPlayer.bar.x,appMPlayer.bar.y,appMPlayer.bar.width,appMPlayer.bar.height,
|
|
230 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsHideWindow,"PlayBar" );
|
|
231
|
|
232 wsSetShape( &appMPlayer.barWindow,appMPlayer.bar.Mask.Image );
|
|
233
|
|
234 appMPlayer.barWindow.ReDraw=(void *)mplPBDraw;
|
|
235 appMPlayer.barWindow.MouseHandler=mplPBMouseHandle;
|
|
236 appMPlayer.barWindow.KeyHandler=mplMainKeyHandle;
|
|
237
|
|
238 mplPBLength=appMPlayer.subWindow.Height;
|
|
239 }
|