Mercurial > mplayer.hg
annotate gui/ui/playbar.c @ 33622:27f7a3196e18
tvi_dshow: Adjust mp_msg printf conversion specifier to avoid warnings.
stream/tvi_dshow.c:2807: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'
stream/tvi_dshow.c:2821: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'long unsigned int'i
author | diego |
---|---|
date | Wed, 22 Jun 2011 13:48:51 +0000 |
parents | 520fb0f7544c |
children | 90f7a7266410 |
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 <sys/stat.h> | |
24 #include <unistd.h> | |
23305
22d3d12c6dfb
Include string.h for memcpy, fastmemcpy.h alone is not enough.
reimar
parents:
23077
diff
changeset
|
25 #include <string.h> |
23077 | 26 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
27 #include "config.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
28 #include "gui/app.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
29 #include "gui/skin/font.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
30 #include "gui/skin/skin.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
31 #include "gui/wm/ws.h" |
23077 | 32 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
33 #include "help_mp.h" |
33024 | 34 #include "mp_core.h" |
26382
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" | |
33556 | 47 #include "actions.h" |
23077 | 48 #include "widgets.h" |
33556 | 49 #include "render.h" |
23077 | 50 |
28051 | 51 unsigned int GetTimerMS( void ); |
52 unsigned int GetTimer( void ); | |
23077 | 53 |
33555 | 54 unsigned char * playbarDrawBuffer = NULL; |
55 int playbarVisible = 0; | |
56 int playbarLength = 0; | |
57 int uiPlaybarFade = 0; | |
23077 | 58 |
33555 | 59 static void uiPlaybarDraw( void ) |
23077 | 60 { |
61 int x; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
62 |
33555 | 63 if ( !guiApp.subWindow.isFullScreen ) return; |
64 if ( !playbarVisible || !guiApp.playbarIsPresent ) return; | |
23077 | 65 |
33555 | 66 // guiApp.playbar.x=( guiApp.subWindow.Width - guiApp.playbar.width ) / 2; |
67 switch( guiApp.playbar.x ) | |
23077 | 68 { |
33555 | 69 case -1: x=( guiApp.subWindow.Width - guiApp.playbar.width ) / 2; break; |
70 case -2: x=( guiApp.subWindow.Width - guiApp.playbar.width ); break; | |
71 default: x=guiApp.playbar.x; | |
23077 | 72 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
73 |
33555 | 74 switch ( uiPlaybarFade ) |
23077 | 75 { |
76 case 1: // fade in | |
33555 | 77 playbarLength--; |
78 if ( guiApp.subWindow.Height - guiApp.playbar.height >= playbarLength ) | |
23077 | 79 { |
33555 | 80 playbarLength=guiApp.subWindow.Height - guiApp.playbar.height; |
81 uiPlaybarFade=0; | |
23077 | 82 vo_mouse_autohide=0; |
83 } | |
33555 | 84 wsMoveWindow( &guiApp.playbarWindow,0,x,playbarLength ); |
23077 | 85 break; |
86 case 2: // fade out | |
33555 | 87 playbarLength+=10; |
88 if ( playbarLength > guiApp.subWindow.Height ) | |
23077 | 89 { |
33555 | 90 playbarLength=guiApp.subWindow.Height; |
91 uiPlaybarFade=playbarVisible=0; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
92 vo_mouse_autohide=1; |
33555 | 93 wsVisibleWindow( &guiApp.playbarWindow,wsHideWindow ); |
23077 | 94 return; |
95 } | |
33555 | 96 wsMoveWindow( &guiApp.playbarWindow,0,x,playbarLength ); |
23077 | 97 break; |
98 } | |
99 | |
100 // --- render | |
33555 | 101 if ( guiApp.playbarWindow.State == wsWindowExpose ) |
23077 | 102 { |
33555 | 103 btnModify( evSetMoviePosition,guiInfo.Position ); |
104 btnModify( evSetVolume,guiInfo.Volume ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
105 |
23077 | 106 vo_mouse_autohide=0; |
107 | |
33555 | 108 fast_memcpy( playbarDrawBuffer,guiApp.playbar.Bitmap.Image,guiApp.playbar.Bitmap.ImageSize ); |
109 RenderAll( &guiApp.playbarWindow,guiApp.playbarItems,guiApp.IndexOfPlaybarItems,playbarDrawBuffer ); | |
110 wsConvert( &guiApp.playbarWindow,playbarDrawBuffer ); | |
23077 | 111 } |
33555 | 112 wsPutImage( &guiApp.playbarWindow ); |
23077 | 113 } |
114 | |
33555 | 115 static void uiPlaybarMouseHandle( 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 | |
33555 | 125 for ( i=0;i <= guiApp.IndexOfPlaybarItems;i++ ) |
126 if ( ( guiApp.playbarItems[i].pressed != btnDisabled )&& | |
127 ( wgIsRect( X,Y,guiApp.playbarItems[i].x,guiApp.playbarItems[i].y,guiApp.playbarItems[i].x+guiApp.playbarItems[i].width,guiApp.playbarItems[i].y+guiApp.playbarItems[i].height ) ) ) | |
23077 | 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 ); | |
33555 | 134 uiShowMenu( RX,RY ); |
23077 | 135 break; |
136 case wsRMMouseButton: | |
33555 | 137 uiHideMenu( RX,RY,0 ); |
23077 | 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 | |
33555 | 147 item=&guiApp.playbarItems[SelectedItem]; |
23077 | 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: | |
33107 | 163 if ( SelectedItem != -1 ) // NOTE TO MYSELF: only if itButton, itHPotmeter or itVPotmeter |
164 { | |
33555 | 165 item=&guiApp.playbarItems[SelectedItem]; |
33108 | 166 item->pressed=btnReleased; |
33107 | 167 } |
23077 | 168 SelectedItem=-1; |
169 if ( currentselected == - 1 ) { itemtype=0; break; } | |
170 value=0; | |
171 | |
172 switch( itemtype ) | |
173 { | |
174 case itPotmeter: | |
175 case itHPotmeter: | |
32911 | 176 btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f ); |
33555 | 177 uiEventHandling( item->message,item->value ); |
23077 | 178 value=item->value; |
179 break; | |
180 case itVPotmeter: | |
32911 | 181 btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); |
33555 | 182 uiEventHandling( item->message,item->value ); |
23077 | 183 value=item->value; |
184 break; | |
185 } | |
33555 | 186 uiEventHandling( item->message,value ); |
23077 | 187 |
188 itemtype=0; | |
189 break; | |
190 // --- | |
191 case wsP5MouseButton: value=-2.5f; goto rollerhandled; | |
192 case wsP4MouseButton: value= 2.5f; | |
193 rollerhandled: | |
33555 | 194 item=&guiApp.playbarItems[currentselected]; |
23077 | 195 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) |
196 { | |
197 item->value+=value; | |
32911 | 198 btnModify( item->message,item->value ); |
33555 | 199 uiEventHandling( item->message,item->value ); |
23077 | 200 } |
201 break; | |
202 // --- | |
203 case wsMoveMouse: | |
33555 | 204 item=&guiApp.playbarItems[SelectedItem]; |
23077 | 205 switch ( itemtype ) |
206 { | |
207 case itPRMButton: | |
33555 | 208 uiMenuMouseHandle( X,Y,RX,RY ); |
23077 | 209 break; |
210 case itPotmeter: | |
211 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
212 goto potihandled; | |
213 case itVPotmeter: | |
214 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
215 goto potihandled; | |
216 case itHPotmeter: | |
217 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
218 potihandled: | |
219 if ( item->value > 100.0f ) item->value=100.0f; | |
220 if ( item->value < 0.0f ) item->value=0.0f; | |
33555 | 221 uiEventHandling( item->message,item->value ); |
23077 | 222 break; |
223 } | |
224 break; | |
225 } | |
226 } | |
227 | |
33555 | 228 void uiPlaybarShow( int x, int y ) |
23077 | 229 { |
33555 | 230 if ( !guiApp.playbarIsPresent || !gtkEnablePlayBar ) return; |
231 if ( !guiApp.subWindow.isFullScreen ) return; | |
23077 | 232 |
33555 | 233 if ( y > guiApp.subWindow.Height - guiApp.playbar.height ) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
234 { |
33555 | 235 if ( !uiPlaybarFade ) wsVisibleWindow( &guiApp.playbarWindow,wsShowWindow ); |
236 uiPlaybarFade=1; playbarVisible=1; wsPostRedisplay( &guiApp.playbarWindow ); | |
23077 | 237 } |
33555 | 238 else if ( !uiPlaybarFade ) uiPlaybarFade=2; |
23077 | 239 } |
240 | |
33555 | 241 void uiPlaybarInit( void ) |
23077 | 242 { |
33555 | 243 if ( !guiApp.playbarIsPresent ) return; |
23077 | 244 |
33555 | 245 gfree( (void**)&playbarDrawBuffer ); |
23077 | 246 |
33555 | 247 if ( ( playbarDrawBuffer = malloc( guiApp.playbar.Bitmap.ImageSize ) ) == NULL ) |
23077 | 248 { |
33024 | 249 gmp_msg( MSGT_GPLAYER,MSGL_FATAL,MSGTR_NEMDB ); |
33263 | 250 guiExit( EXIT_ERROR ); |
23077 | 251 } |
252 | |
33555 | 253 guiApp.playbarWindow.Parent=guiApp.subWindow.WindowID; |
254 wsCreateWindow( &guiApp.playbarWindow, | |
255 guiApp.playbar.x,guiApp.playbar.y,guiApp.playbar.width,guiApp.playbar.height, | |
23077 | 256 wsNoBorder,wsShowMouseCursor|wsHandleMouseButton|wsHandleMouseMove,wsHideFrame|wsHideWindow,"PlayBar" ); |
257 | |
33555 | 258 wsSetShape( &guiApp.playbarWindow,guiApp.playbar.Mask.Image ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
259 |
33555 | 260 guiApp.playbarWindow.ReDraw=(void *)uiPlaybarDraw; |
261 guiApp.playbarWindow.MouseHandler=uiPlaybarMouseHandle; | |
262 guiApp.playbarWindow.KeyHandler=uiMainKeyHandle; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
263 |
33555 | 264 playbarLength=guiApp.subWindow.Height; |
23077 | 265 } |