comparison Gui/mplayer/pb.c @ 8973:0a665389cf2b

- add playbar - add vpotmeter - fix gtk menu's pixel bug - fix some critical (10l) bug
author pontscho
date Fri, 17 Jan 2003 22:39:43 +0000
parents
children e0a3139a4dea
comparison
equal deleted inserted replaced
8972:2ed9b2143f94 8973:0a665389cf2b
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 {
42 if ( !appMPlayer.subWindow.isFullScreen ) return;
43 if ( !mplPBVisible || !appMPlayer.barIsPresent ) return;
44
45 appMPlayer.bar.x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2;
46
47 switch ( mplPBFade )
48 {
49 case 1: // fade in
50 mplPBLength--;
51 if ( appMPlayer.subWindow.Height - appMPlayer.bar.height >= mplPBLength )
52 {
53 mplPBLength=appMPlayer.subWindow.Height - appMPlayer.bar.height;
54 mplPBFade=0;
55 vo_mouse_autohide=0;
56 }
57 wsMoveWindow( &appMPlayer.barWindow,0,appMPlayer.bar.x,mplPBLength );
58 break;
59 case 2: // fade out
60 mplPBLength+=10;
61 if ( mplPBLength > appMPlayer.subWindow.Height )
62 {
63 mplPBLength=appMPlayer.subWindow.Height;
64 mplPBFade=mplPBVisible=0;
65 vo_mouse_autohide=1;
66 wsVisibleWindow( &appMPlayer.barWindow,wsHideWindow );
67 return;
68 }
69 wsMoveWindow( &appMPlayer.barWindow,0,appMPlayer.bar.x,mplPBLength );
70 break;
71 }
72
73 // --- render
74 if ( appMPlayer.barWindow.State == wsWindowExpose )
75 {
76 btnModify( evSetMoviePosition,guiIntfStruct.Position );
77 btnModify( evSetVolume,guiIntfStruct.Volume );
78
79 memcpy( mplPBDrawBuffer,appMPlayer.bar.Bitmap.Image,appMPlayer.bar.Bitmap.ImageSize );
80 Render( &appMPlayer.barWindow,appMPlayer.barItems,appMPlayer.NumberOfBarItems,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
81 wsConvert( &appMPlayer.barWindow,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize );
82 }
83 wsPutImage( &appMPlayer.barWindow );
84 }
85
86 #define itPLMButton (itNULL - 1)
87 #define itPRMButton (itNULL - 2)
88
89 void mplPBMouseHandle( int Button,int X,int Y,int RX,int RY )
90 {
91 static int itemtype = 0;
92 int i;
93 wItem * item = NULL;
94 float value = 0.0f;
95
96 static int SelectedItem = -1;
97 int currentselected = -1;
98
99 for ( i=0;i < appMPlayer.NumberOfBarItems + 1;i++ )
100 if ( ( appMPlayer.barItems[i].pressed != btnDisabled )&&
101 ( 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 ) ) )
102 { currentselected=i; break; }
103
104 switch ( Button )
105 {
106 case wsPMMouseButton:
107 gtkShow( evHidePopUpMenu,NULL );
108 mplShowMenu( RX,RY );
109 break;
110 case wsRMMouseButton:
111 mplHideMenu( RX,RY,0 );
112 break;
113 case wsPRMouseButton:
114 gtkShow( evShowPopUpMenu,NULL );
115 break;
116 // ---
117 case wsPLMouseButton:
118 gtkShow( evHidePopUpMenu,NULL );
119 SelectedItem=currentselected;
120 if ( SelectedItem == -1 ) break; // yeees, i'm move the fucking window
121 item=&appMPlayer.barItems[SelectedItem];
122 itemtype=item->type;
123 item->pressed=btnPressed;
124
125 switch( item->type )
126 {
127 case itButton:
128 if ( ( SelectedItem > -1 ) &&
129 ( ( ( item->msg == evPlaySwitchToPause && item->msg == evPauseSwitchToPlay ) ) ||
130 ( ( item->msg == evPauseSwitchToPlay && item->msg == evPlaySwitchToPause ) ) ) )
131 { item->pressed=btnDisabled; }
132 break;
133 }
134
135 break;
136 case wsRLMouseButton:
137 item=&appMPlayer.barItems[SelectedItem];
138 item->pressed=btnReleased;
139 SelectedItem=-1;
140 if ( currentselected == - 1 ) { itemtype=0; break; }
141 value=0;
142
143 switch( itemtype )
144 {
145 case itPotmeter:
146 case itHPotmeter:
147 btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f );
148 mplEventHandling( item->msg,item->value );
149 value=item->value;
150 break;
151 }
152 mplEventHandling( item->msg,value );
153
154 itemtype=0;
155 break;
156 // ---
157 case wsP5MouseButton: value=-2.5f; goto rollerhandled;
158 case wsP4MouseButton: value= 2.5f;
159 rollerhandled:
160 item=&appMPlayer.barItems[currentselected];
161 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) )
162 {
163 item->value+=value;
164 btnModify( item->msg,item->value );
165 mplEventHandling( item->msg,item->value );
166 }
167 break;
168 // ---
169 case wsMoveMouse:
170 item=&appMPlayer.barItems[SelectedItem];
171 switch ( itemtype )
172 {
173 case itPRMButton:
174 mplMenuMouseHandle( X,Y,RX,RY );
175 break;
176 case itPotmeter:
177 item->value=(float)( X - item->x ) / item->width * 100.0f;
178 goto potihandled;
179 case itHPotmeter:
180 item->value=(float)( X - item->x ) / item->width * 100.0f;
181 potihandled:
182 if ( item->value > 100.0f ) item->value=100.0f;
183 if ( item->value < 0.0f ) item->value=0.0f;
184 mplEventHandling( item->msg,item->value );
185 break;
186 }
187 break;
188 }
189 }
190
191 void mplPBShow( int x, int y )
192 {
193 if ( !appMPlayer.barIsPresent || !gtkEnablePlayBar ) return;
194 if ( !appMPlayer.subWindow.isFullScreen ) return;
195
196 if ( y > appMPlayer.subWindow.Height - appMPlayer.bar.height )
197 {
198 if ( !mplPBFade ) wsVisibleWindow( &appMPlayer.barWindow,wsShowWindow );
199 mplPBFade=1; mplPBVisible=1; wsPostRedisplay( &appMPlayer.barWindow );
200 }
201 else if ( !mplPBFade ) mplPBFade=2;
202 }
203
204 void mplPBInit( void )
205 {
206 gfree( (void**)&mplPBDrawBuffer );
207
208 if ( !appMPlayer.barIsPresent ) return;
209
210 if ( ( mplPBDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.bar.Bitmap.ImageSize ) ) == NULL )
211 {
212 fprintf( stderr,MSGTR_NEMDB );
213 exit( 0 );
214 }
215
216 appMPlayer.barWindow.Parent=appMPlayer.subWindow.WindowID;
217 wsCreateWindow( &appMPlayer.barWindow,
218 appMPlayer.bar.x,appMPlayer.bar.y,appMPlayer.bar.width,appMPlayer.bar.height,
219 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsHideWindow,"PlayBar" );
220
221 wsSetShape( &appMPlayer.barWindow,appMPlayer.bar.Mask.Image );
222
223 appMPlayer.barWindow.ReDraw=(void *)mplPBDraw;
224 appMPlayer.barWindow.MouseHandler=mplPBMouseHandle;
225 appMPlayer.barWindow.KeyHandler=mplMainKeyHandle;
226
227 mplPBLength=appMPlayer.subWindow.Height;
228 }