Mercurial > mplayer.hg
annotate gui/mplayer/pb.c @ 32931:03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
Since the NumberOfMainItems, NumberOfBarItems and NumberOfMenuItems members
actually hold the last index used rather than the number of items, rename
them 'IndexOf' to avoid further confusion. Besides, change their loop
conditions to meet the new name.
author | ib |
---|---|
date | Thu, 03 Mar 2011 14:37:47 +0000 |
parents | 933e784fb598 |
children | 21e0de9c355f |
rev | line source |
---|---|
26458 | 1 /* |
2 * main window | |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
23077 | 20 |
21 #include <stdlib.h> | |
22 #include <stdio.h> | |
23 #include <inttypes.h> | |
24 #include <sys/stat.h> | |
25 #include <unistd.h> | |
23305
22d3d12c6dfb
Include string.h for memcpy, fastmemcpy.h alone is not enough.
reimar
parents:
23077
diff
changeset
|
26 #include <string.h> |
23077 | 27 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
28 #include "config.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
29 #include "gui/app.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
30 #include "gui/skin/font.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
31 #include "gui/skin/skin.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
32 #include "gui/wm/ws.h" |
23077 | 33 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
34 #include "help_mp.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "libvo/x11_common.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
36 #include "libvo/fastmemcpy.h" |
23077 | 37 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
38 #include "stream/stream.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
39 #include "mixer.h" |
32467 | 40 #include "sub/sub.h" |
23077 | 41 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
42 #include "libmpdemux/demuxer.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
43 #include "libmpdemux/stheader.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
44 #include "codec-cfg.h" |
23077 | 45 |
46 #include "gmplayer.h" | |
47 #include "play.h" | |
48 #include "widgets.h" | |
25603
01754b23193e
Rename common.[ch], there are too many files by that name.
diego
parents:
23457
diff
changeset
|
49 #include "gui_common.h" |
23077 | 50 |
28051 | 51 unsigned int GetTimerMS( void ); |
52 unsigned int GetTimer( void ); | |
23077 | 53 |
54 unsigned char * mplPBDrawBuffer = NULL; | |
55 int mplPBVisible = 0; | |
56 int mplPBLength = 0; | |
57 int mplPBFade = 0; | |
58 | |
30535
016e5fc1dead
GUI: Mark functions that are not used outside their files as static.
diego
parents:
29263
diff
changeset
|
59 static void mplPBDraw( void ) |
23077 | 60 { |
61 int x; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
62 |
23077 | 63 if ( !appMPlayer.subWindow.isFullScreen ) return; |
64 if ( !mplPBVisible || !appMPlayer.barIsPresent ) return; | |
65 | |
66 // appMPlayer.bar.x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2; | |
67 switch( appMPlayer.bar.x ) | |
68 { | |
69 case -1: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ) / 2; break; | |
70 case -2: x=( appMPlayer.subWindow.Width - appMPlayer.bar.width ); break; | |
71 default: x=appMPlayer.bar.x; | |
72 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
73 |
23077 | 74 switch ( mplPBFade ) |
75 { | |
76 case 1: // fade in | |
77 mplPBLength--; | |
78 if ( appMPlayer.subWindow.Height - appMPlayer.bar.height >= mplPBLength ) | |
79 { | |
80 mplPBLength=appMPlayer.subWindow.Height - appMPlayer.bar.height; | |
81 mplPBFade=0; | |
82 vo_mouse_autohide=0; | |
83 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
84 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength ); |
23077 | 85 break; |
86 case 2: // fade out | |
87 mplPBLength+=10; | |
88 if ( mplPBLength > appMPlayer.subWindow.Height ) | |
89 { | |
90 mplPBLength=appMPlayer.subWindow.Height; | |
91 mplPBFade=mplPBVisible=0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
92 vo_mouse_autohide=1; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
93 wsVisibleWindow( &appMPlayer.barWindow,wsHideWindow ); |
23077 | 94 return; |
95 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
96 wsMoveWindow( &appMPlayer.barWindow,0,x,mplPBLength ); |
23077 | 97 break; |
98 } | |
99 | |
100 // --- render | |
101 if ( appMPlayer.barWindow.State == wsWindowExpose ) | |
102 { | |
103 btnModify( evSetMoviePosition,guiIntfStruct.Position ); | |
104 btnModify( evSetVolume,guiIntfStruct.Volume ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
105 |
23077 | 106 vo_mouse_autohide=0; |
107 | |
23457
a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents:
23305
diff
changeset
|
108 fast_memcpy( mplPBDrawBuffer,appMPlayer.bar.Bitmap.Image,appMPlayer.bar.Bitmap.ImageSize ); |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32919
diff
changeset
|
109 Render( &appMPlayer.barWindow,appMPlayer.barItems,appMPlayer.IndexOfBarItems,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
110 wsConvert( &appMPlayer.barWindow,mplPBDrawBuffer,appMPlayer.bar.Bitmap.ImageSize ); |
23077 | 111 } |
112 wsPutImage( &appMPlayer.barWindow ); | |
113 } | |
114 | |
30535
016e5fc1dead
GUI: Mark functions that are not used outside their files as static.
diego
parents:
29263
diff
changeset
|
115 static void mplPBMouseHandle( int Button, int X, int Y, int RX, int RY ) |
23077 | 116 { |
117 static int itemtype = 0; | |
118 int i; | |
119 wItem * item = NULL; | |
120 float value = 0.0f; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
121 |
23077 | 122 static int SelectedItem = -1; |
123 int currentselected = -1; | |
124 | |
32931
03b1051bed5c
Rename the 'NumberOf' members of the listItems structure.
ib
parents:
32919
diff
changeset
|
125 for ( i=0;i <= appMPlayer.IndexOfBarItems;i++ ) |
23077 | 126 if ( ( appMPlayer.barItems[i].pressed != btnDisabled )&& |
127 ( 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 ) ) ) | |
128 { currentselected=i; break; } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
129 |
23077 | 130 switch ( Button ) |
131 { | |
132 case wsPMMouseButton: | |
133 gtkShow( evHidePopUpMenu,NULL ); | |
134 mplShowMenu( RX,RY ); | |
135 break; | |
136 case wsRMMouseButton: | |
137 mplHideMenu( RX,RY,0 ); | |
138 break; | |
139 case wsRRMouseButton: | |
140 gtkShow( evShowPopUpMenu,NULL ); | |
141 break; | |
142 // --- | |
143 case wsPLMouseButton: | |
144 gtkShow( evHidePopUpMenu,NULL ); | |
145 SelectedItem=currentselected; | |
146 if ( SelectedItem == -1 ) break; // yeees, i'm move the fucking window | |
147 item=&appMPlayer.barItems[SelectedItem]; | |
148 itemtype=item->type; | |
149 item->pressed=btnPressed; | |
150 | |
151 switch( item->type ) | |
152 { | |
153 case itButton: | |
154 if ( ( SelectedItem > -1 ) && | |
32911 | 155 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) || |
156 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) ) | |
23077 | 157 { item->pressed=btnDisabled; } |
158 break; | |
159 } | |
160 | |
161 break; | |
162 case wsRLMouseButton: | |
163 item=&appMPlayer.barItems[SelectedItem]; | |
164 item->pressed=btnReleased; | |
165 SelectedItem=-1; | |
166 if ( currentselected == - 1 ) { itemtype=0; break; } | |
167 value=0; | |
168 | |
169 switch( itemtype ) | |
170 { | |
171 case itPotmeter: | |
172 case itHPotmeter: | |
32911 | 173 btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f ); |
174 mplEventHandling( item->message,item->value ); | |
23077 | 175 value=item->value; |
176 break; | |
177 case itVPotmeter: | |
32911 | 178 btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); |
179 mplEventHandling( item->message,item->value ); | |
23077 | 180 value=item->value; |
181 break; | |
182 } | |
32911 | 183 mplEventHandling( item->message,value ); |
23077 | 184 |
185 itemtype=0; | |
186 break; | |
187 // --- | |
188 case wsP5MouseButton: value=-2.5f; goto rollerhandled; | |
189 case wsP4MouseButton: value= 2.5f; | |
190 rollerhandled: | |
191 item=&appMPlayer.barItems[currentselected]; | |
192 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) | |
193 { | |
194 item->value+=value; | |
32911 | 195 btnModify( item->message,item->value ); |
196 mplEventHandling( item->message,item->value ); | |
23077 | 197 } |
198 break; | |
199 // --- | |
200 case wsMoveMouse: | |
201 item=&appMPlayer.barItems[SelectedItem]; | |
202 switch ( itemtype ) | |
203 { | |
204 case itPRMButton: | |
205 mplMenuMouseHandle( X,Y,RX,RY ); | |
206 break; | |
207 case itPotmeter: | |
208 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
209 goto potihandled; | |
210 case itVPotmeter: | |
211 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
212 goto potihandled; | |
213 case itHPotmeter: | |
214 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
215 potihandled: | |
216 if ( item->value > 100.0f ) item->value=100.0f; | |
217 if ( item->value < 0.0f ) item->value=0.0f; | |
32911 | 218 mplEventHandling( item->message,item->value ); |
23077 | 219 break; |
220 } | |
221 break; | |
222 } | |
223 } | |
224 | |
225 void mplPBShow( int x, int y ) | |
226 { | |
227 if ( !appMPlayer.barIsPresent || !gtkEnablePlayBar ) return; | |
228 if ( !appMPlayer.subWindow.isFullScreen ) return; | |
229 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
230 if ( y > appMPlayer.subWindow.Height - appMPlayer.bar.height ) |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
231 { |
23077 | 232 if ( !mplPBFade ) wsVisibleWindow( &appMPlayer.barWindow,wsShowWindow ); |
233 mplPBFade=1; mplPBVisible=1; wsPostRedisplay( &appMPlayer.barWindow ); | |
234 } | |
235 else if ( !mplPBFade ) mplPBFade=2; | |
236 } | |
237 | |
238 void mplPBInit( void ) | |
239 { | |
240 if ( !appMPlayer.barIsPresent ) return; | |
241 | |
242 gfree( (void**)&mplPBDrawBuffer ); | |
243 | |
244 if ( ( mplPBDrawBuffer = malloc( appMPlayer.bar.Bitmap.ImageSize ) ) == NULL ) | |
245 { | |
246 mp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB ); | |
247 exit( 0 ); | |
248 } | |
249 | |
250 appMPlayer.barWindow.Parent=appMPlayer.subWindow.WindowID; | |
251 wsCreateWindow( &appMPlayer.barWindow, | |
252 appMPlayer.bar.x,appMPlayer.bar.y,appMPlayer.bar.width,appMPlayer.bar.height, | |
253 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsHideWindow,"PlayBar" ); | |
254 | |
255 wsSetShape( &appMPlayer.barWindow,appMPlayer.bar.Mask.Image ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
256 |
23077 | 257 appMPlayer.barWindow.ReDraw=(void *)mplPBDraw; |
258 appMPlayer.barWindow.MouseHandler=mplPBMouseHandle; | |
259 appMPlayer.barWindow.KeyHandler=mplMainKeyHandle; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
260 |
23077 | 261 mplPBLength=appMPlayer.subWindow.Height; |
262 } |