Mercurial > mplayer.hg
annotate gui/ui/main.c @ 35544:fd7a5b62326d
Add comment.
author | ib |
---|---|
date | Sun, 09 Dec 2012 14:44:58 +0000 |
parents | 5289e495e70e |
children | d83d2bd5f365 |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
34699
ed0e00db4306
Cosmetic: Move, change and add some comments on GUI windows.
ib
parents:
34697
diff
changeset
|
19 /* main window */ |
ed0e00db4306
Cosmetic: Move, change and add some comments on GUI windows.
ib
parents:
34697
diff
changeset
|
20 |
23077 | 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:
23154
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" |
35528 | 28 #include "ui.h" |
35525 | 29 #include "gui/app/app.h" |
30 #include "gui/app/gui.h" | |
33738 | 31 #include "gui/interface.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
32 #include "gui/skin/font.h" |
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
33 #include "gui/skin/skin.h" |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33739
diff
changeset
|
34 #include "gui/util/list.h" |
33739 | 35 #include "gui/util/mem.h" |
33737 | 36 #include "gui/util/string.h" |
26365
10dfbc523184
Add gui/ prefix to some #include paths so that compilation from the
diego
parents:
26203
diff
changeset
|
37 #include "gui/wm/ws.h" |
23077 | 38 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
39 #include "help_mp.h" |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
34077
diff
changeset
|
40 #include "mp_msg.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
41 #include "libvo/x11_common.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
42 #include "libvo/fastmemcpy.h" |
33531
84ce059fae34
Get non-multimedia X11 key definitions from libvo/wskeys.h.
ib
parents:
33525
diff
changeset
|
43 #include "libvo/wskeys.h" |
23077 | 44 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
45 #include "stream/stream.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
46 #include "stream/url.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
47 #include "mixer.h" |
32467 | 48 #include "sub/sub.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
49 #include "access_mpcontext.h" |
23077 | 50 |
30537
7bebe34b6ad2
Move movie_aspect extern declaration to libmpcodecs/vd.h.
diego
parents:
30516
diff
changeset
|
51 #include "libmpcodecs/vd.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
52 #include "libmpdemux/demuxer.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
53 #include "libmpdemux/stheader.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
54 #include "codec-cfg.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
55 #include "m_option.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
56 #include "m_property.h" |
30516 | 57 #include "mp_core.h" |
32043
f6249bc89c38
Move extern declarations used by both mplayer.c and mencoder.c to mpcommon.h.
diego
parents:
32041
diff
changeset
|
58 #include "mpcommon.h" |
23077 | 59 |
60 #define GUI_REDRAW_WAIT 375 | |
61 | |
33556 | 62 #include "actions.h" |
35529 | 63 #include "gui/dialog/dialog.h" |
23077 | 64 |
28051 | 65 unsigned int GetTimerMS( void ); |
23077 | 66 |
33555 | 67 unsigned char * mainDrawBuffer = NULL; |
35493 | 68 int uiMainRender = True; |
23077 | 69 |
35493 | 70 int uiMainAutoPlay = False; |
23077 | 71 |
35493 | 72 int mainVisible = True; |
23077 | 73 |
35493 | 74 int boxMoved = False; |
23077 | 75 int sx = 0,sy = 0; |
76 int i,pot = 0; | |
77 | |
33556 | 78 #include "render.h" |
23077 | 79 |
33555 | 80 void uiMainDraw( void ) |
23077 | 81 { |
82 | |
33768 | 83 if ( guiApp.mainWindow.State == wsWindowClosed ) mplayer( MPLAYER_EXIT_GUI, EXIT_QUIT, 0 ); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
84 |
33555 | 85 if ( guiApp.mainWindow.Visible == wsWindowNotVisible || |
23077 | 86 !mainVisible ) return; |
33555 | 87 // !guiApp.mainWindow.Mapped ) return; |
23077 | 88 |
33555 | 89 if ( uiMainRender && guiApp.mainWindow.State == wsWindowExpose ) |
23077 | 90 { |
33555 | 91 btnModify( evSetMoviePosition,guiInfo.Position ); |
92 btnModify( evSetVolume,guiInfo.Volume ); | |
23077 | 93 |
33555 | 94 fast_memcpy( mainDrawBuffer,guiApp.main.Bitmap.Image,guiApp.main.Bitmap.ImageSize ); |
95 RenderAll( &guiApp.mainWindow,guiApp.mainItems,guiApp.IndexOfMainItems,mainDrawBuffer ); | |
35493 | 96 uiMainRender=False; |
23077 | 97 } |
33555 | 98 wsPutImage( &guiApp.mainWindow ); |
23077 | 99 // XFlush( wsDisplay ); |
100 } | |
101 | |
35490
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
102 static void MediumPrepare (int type) |
33771
6e774a02d00c
Remove gtkClearStruct code from mplayer() in interface.c.
ib
parents:
33768
diff
changeset
|
103 { |
35490
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
104 switch (type) |
33771
6e774a02d00c
Remove gtkClearStruct code from mplayer() in interface.c.
ib
parents:
33768
diff
changeset
|
105 { |
35490
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
106 case STREAMTYPE_DVD: |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
107 listMgr(PLAYLIST_DELETE, 0); |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
108 break; |
33771
6e774a02d00c
Remove gtkClearStruct code from mplayer() in interface.c.
ib
parents:
33768
diff
changeset
|
109 |
35490
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
110 case STREAMTYPE_CDDA: |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
111 case STREAMTYPE_VCD: |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
112 listMgr(PLAYLIST_DELETE, 0); |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
113 case STREAMTYPE_FILE: |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
114 case STREAMTYPE_STREAM: |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
115 case STREAMTYPE_PLAYLIST: |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
116 guiInfo.AudioStreams = 0; |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
117 guiInfo.Subtitles = 0; |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
118 guiInfo.Chapters = 0; |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
119 guiInfo.Angles = 0; |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
120 break; |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
121 } |
33771
6e774a02d00c
Remove gtkClearStruct code from mplayer() in interface.c.
ib
parents:
33768
diff
changeset
|
122 } |
6e774a02d00c
Remove gtkClearStruct code from mplayer() in interface.c.
ib
parents:
33768
diff
changeset
|
123 |
23077 | 124 static unsigned last_redraw_time = 0; |
125 | |
33555 | 126 void uiEventHandling( int msg,float param ) |
23077 | 127 { |
35543 | 128 int iparam = (int)param, osd; |
33555 | 129 mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext); |
23077 | 130 |
131 switch( msg ) | |
132 { | |
34684 | 133 /* user events */ |
23077 | 134 case evExit: |
33768 | 135 mplayer( MPLAYER_EXIT_GUI, EXIT_QUIT, 0 ); |
23077 | 136 break; |
137 | |
34324 | 138 case evLoadURL: |
34329 | 139 gtkShow( evLoadURL,NULL ); |
23077 | 140 break; |
141 | |
34333 | 142 case ivSetAudio: |
33657 | 143 if ( !mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam ) break; |
34469 | 144 mp_property_do("switch_audio",M_PROPERTY_SET,&iparam,guiInfo.mpcontext); |
145 break; | |
23077 | 146 |
34333 | 147 case ivSetVideo: |
33657 | 148 if ( !mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam ) break; |
34469 | 149 mp_property_do("switch_video",M_PROPERTY_SET,&iparam,guiInfo.mpcontext); |
150 break; | |
23077 | 151 |
34333 | 152 case ivSetSubtitle: |
33555 | 153 mp_property_do("sub",M_PROPERTY_SET,&iparam,guiInfo.mpcontext); |
23077 | 154 break; |
155 | |
34387 | 156 #ifdef CONFIG_CDDA |
157 case ivSetCDTrack: | |
158 guiInfo.Track=iparam; | |
159 case evPlayCD: | |
160 guiInfo.StreamType=STREAMTYPE_CDDA; | |
161 goto play; | |
162 #endif | |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
163 #ifdef CONFIG_VCD |
34333 | 164 case ivSetVCDTrack: |
33555 | 165 guiInfo.Track=iparam; |
23077 | 166 case evPlayVCD: |
33555 | 167 guiInfo.StreamType=STREAMTYPE_VCD; |
23077 | 168 goto play; |
169 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
170 #ifdef CONFIG_DVDREAD |
34417 | 171 case ivSetDVDSubtitle: |
172 dvdsub_id=iparam; | |
34455
00cf27b14c15
Replace goto label by an internal event case expression.
ib
parents:
34454
diff
changeset
|
173 uiEventHandling( ivPlayDVD, 0 ); |
34417 | 174 break; |
175 case ivSetDVDAudio: | |
176 audio_id=iparam; | |
34455
00cf27b14c15
Replace goto label by an internal event case expression.
ib
parents:
34454
diff
changeset
|
177 uiEventHandling( ivPlayDVD, 0 ); |
34417 | 178 break; |
179 case ivSetDVDChapter: | |
180 guiInfo.Chapter=iparam; | |
34455
00cf27b14c15
Replace goto label by an internal event case expression.
ib
parents:
34454
diff
changeset
|
181 uiEventHandling( ivPlayDVD, 0 ); |
34417 | 182 break; |
183 case ivSetDVDTitle: | |
184 guiInfo.Track=iparam; | |
185 guiInfo.Chapter=1; | |
186 guiInfo.Angle=1; | |
34455
00cf27b14c15
Replace goto label by an internal event case expression.
ib
parents:
34454
diff
changeset
|
187 uiEventHandling( ivPlayDVD, 0 ); |
34417 | 188 break; |
23077 | 189 case evPlayDVD: |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
190 guiInfo.Chapter=1; |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
191 guiInfo.Angle=1; |
34455
00cf27b14c15
Replace goto label by an internal event case expression.
ib
parents:
34454
diff
changeset
|
192 case ivPlayDVD: |
33555 | 193 guiInfo.StreamType=STREAMTYPE_DVD; |
23077 | 194 goto play; |
195 #endif | |
196 case evPlay: | |
197 case evPlaySwitchToPause: | |
198 play: | |
199 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
200 if ( ( msg == evPlaySwitchToPause )&&( guiInfo.Playing == GUI_PAUSE ) ) goto NoPause; |
23077 | 201 |
35490
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
202 MediumPrepare( guiInfo.StreamType ); |
a5f5f61a7a35
Replace confusing guiInfoMediumClear() by MediumPrepare().
ib
parents:
35484
diff
changeset
|
203 |
33555 | 204 switch ( guiInfo.StreamType ) |
23077 | 205 { |
34077 | 206 case STREAMTYPE_FILE: |
23077 | 207 case STREAMTYPE_STREAM: |
34859 | 208 case STREAMTYPE_PLAYLIST: |
33898 | 209 if ( !guiInfo.Track ) |
210 guiInfo.Track=1; | |
33890 | 211 guiInfo.NewPlay=GUI_FILE_NEW; |
23077 | 212 break; |
34454 | 213 |
34387 | 214 case STREAMTYPE_CDDA: |
215 if ( guiInfo.Playing != GUI_PAUSE ) | |
216 { | |
217 if ( !guiInfo.Track ) | |
218 guiInfo.Track=1; | |
219 guiInfo.NewPlay=GUI_FILE_SAME; | |
220 } | |
221 break; | |
34454 | 222 |
23077 | 223 case STREAMTYPE_VCD: |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
224 if ( guiInfo.Playing != GUI_PAUSE ) |
23077 | 225 { |
33555 | 226 if ( !guiInfo.Track ) |
33874 | 227 guiInfo.Track=2; |
33890 | 228 guiInfo.NewPlay=GUI_FILE_SAME; |
23077 | 229 } |
230 break; | |
34454 | 231 |
23077 | 232 case STREAMTYPE_DVD: |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
233 if ( guiInfo.Playing != GUI_PAUSE ) |
23077 | 234 { |
35422
696a8a165952
Check and set track for DVDs just as for the other StreamTypes.
ib
parents:
35389
diff
changeset
|
235 if ( !guiInfo.Track ) |
696a8a165952
Check and set track for DVDs just as for the other StreamTypes.
ib
parents:
35389
diff
changeset
|
236 guiInfo.Track=1; |
33890 | 237 guiInfo.NewPlay=GUI_FILE_SAME; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
238 } |
23077 | 239 break; |
240 } | |
33555 | 241 uiPlay(); |
23077 | 242 break; |
243 | |
244 case evPause: | |
245 case evPauseSwitchToPlay: | |
246 NoPause: | |
33555 | 247 uiPause(); |
23077 | 248 break; |
249 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
250 case evStop: |
33614 | 251 guiInfo.Playing=GUI_STOP; |
33555 | 252 uiState(); |
23077 | 253 break; |
254 | |
255 case evLoadPlay: | |
35493 | 256 uiMainAutoPlay=True; |
33555 | 257 // guiInfo.StreamType=STREAMTYPE_FILE; |
23077 | 258 case evLoad: |
259 gtkShow( evLoad,NULL ); | |
260 break; | |
261 case evLoadSubtitle: gtkShow( evLoadSubtitle,NULL ); break; | |
262 case evDropSubtitle: | |
33897 | 263 nfree( guiInfo.SubtitleFilename ); |
33763 | 264 mplayerLoadSubtitle( NULL ); |
23077 | 265 break; |
266 case evLoadAudioFile: gtkShow( evLoadAudioFile,NULL ); break; | |
33555 | 267 case evPrev: uiPrev(); break; |
268 case evNext: uiNext(); break; | |
23077 | 269 |
34321
daebf766dea6
Cosmetic: Synchronize evPlaylist event and message names.
ib
parents:
34174
diff
changeset
|
270 case evPlaylist: gtkShow( evPlaylist,NULL ); break; |
23077 | 271 case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break; |
272 case evAbout: gtkShow( evAbout,NULL ); break; | |
273 case evPreferences: gtkShow( evPreferences,NULL ); break; | |
274 case evEqualizer: gtkShow( evEqualizer,NULL ); break; | |
275 | |
33555 | 276 case evForward10min: uiRelSeek( 600 ); break; |
277 case evBackward10min: uiRelSeek( -600 );break; | |
278 case evForward1min: uiRelSeek( 60 ); break; | |
279 case evBackward1min: uiRelSeek( -60 ); break; | |
280 case evForward10sec: uiRelSeek( 10 ); break; | |
281 case evBackward10sec: uiRelSeek( -10 ); break; | |
282 case evSetMoviePosition: uiAbsSeek( param ); break; | |
23077 | 283 |
284 case evIncVolume: vo_x11_putkey( wsGrayMul ); break; | |
285 case evDecVolume: vo_x11_putkey( wsGrayDiv ); break; | |
286 case evMute: mixer_mute( mixer ); break; | |
287 | |
288 case evSetVolume: | |
33555 | 289 guiInfo.Volume=param; |
23077 | 290 { |
33555 | 291 float l = guiInfo.Volume * ( ( 100.0 - guiInfo.Balance ) / 50.0 ); |
292 float r = guiInfo.Volume * ( ( guiInfo.Balance ) / 50.0 ); | |
293 if ( l > guiInfo.Volume ) l=guiInfo.Volume; | |
294 if ( r > guiInfo.Volume ) r=guiInfo.Volume; | |
295 // printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiInfo.Volume,guiInfo.Balance,l,r ); | |
23077 | 296 mixer_setvolume( mixer,l,r ); |
297 } | |
298 if ( osd_level ) | |
299 { | |
300 osd_visible=(GetTimerMS() + 1000) | 1; | |
301 vo_osd_progbar_type=OSD_VOLUME; | |
33555 | 302 vo_osd_progbar_value=( ( guiInfo.Volume ) * 256.0 ) / 100.0; |
23077 | 303 vo_osd_changed( OSDTYPE_PROGBAR ); |
304 } | |
305 break; | |
306 | |
35539 | 307 case evSetBalance: |
308 guiInfo.Balance=param; | |
35544 | 309 mixer_setbalance( mixer,(guiInfo.Balance - 50.0 ) / 50.0 ); // transform 0..100 to -1..1 |
35543 | 310 osd = osd_level; |
311 osd_level = 0; | |
312 uiEventHandling(evSetVolume, guiInfo.Volume); | |
313 osd_level = osd; | |
35539 | 314 if ( osd_level ) |
315 { | |
316 osd_visible=(GetTimerMS() + 1000) | 1; | |
317 vo_osd_progbar_type=OSD_BALANCE; | |
318 vo_osd_progbar_value=( ( guiInfo.Balance ) * 256.0 ) / 100.0; | |
319 vo_osd_changed( OSDTYPE_PROGBAR ); | |
320 } | |
321 break; | |
23077 | 322 |
34458 | 323 case evMenu: |
34473 | 324 /*if (guiApp.menuIsPresent) NOTE TO MYSELF: Uncomment only after mouse |
325 { pointer and cursor keys work | |
326 gtkShow( ivHidePopUpMenu,NULL ); with this menu from skin as | |
327 uiShowMenu( 0,0 ); they do with normal menus. | |
34458 | 328 } |
329 else*/ gtkShow( ivShowPopUpMenu,NULL ); | |
330 break; | |
331 | |
23077 | 332 case evIconify: |
333 switch ( iparam ) | |
334 { | |
35355 | 335 case 0: wsIconify( &guiApp.mainWindow ); break; |
336 case 1: wsIconify( &guiApp.videoWindow ); break; | |
23077 | 337 } |
338 break; | |
339 case evHalfSize: | |
33947 | 340 if ( guiInfo.VideoWindow && guiInfo.Playing ) |
23077 | 341 { |
34697 | 342 if ( guiApp.videoWindow.isFullScreen ) |
23077 | 343 { |
33555 | 344 uiFullScreen(); |
23077 | 345 } |
34697 | 346 wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2 ); |
347 wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); | |
33950 | 348 btnSet( evFullScreen,btnReleased ); |
23077 | 349 } |
350 break; | |
351 case evDoubleSize: | |
33947 | 352 if ( guiInfo.VideoWindow && guiInfo.Playing ) |
23077 | 353 { |
34697 | 354 if ( guiApp.videoWindow.isFullScreen ) |
23077 | 355 { |
33555 | 356 uiFullScreen(); |
23077 | 357 } |
34697 | 358 wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2 ); |
359 wsMoveWindowWithin( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); | |
33950 | 360 btnSet( evFullScreen,btnReleased ); |
23077 | 361 } |
362 break; | |
363 case evNormalSize: | |
33947 | 364 if ( guiInfo.VideoWindow && guiInfo.Playing ) |
23077 | 365 { |
34697 | 366 if ( guiApp.videoWindow.isFullScreen ) |
23077 | 367 { |
33555 | 368 uiFullScreen(); |
23077 | 369 } |
34697 | 370 wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight ); |
371 wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); | |
33947 | 372 btnSet( evFullScreen,btnReleased ); |
23077 | 373 break; |
34697 | 374 } else if ( !guiApp.videoWindow.isFullScreen ) break; |
23077 | 375 case evFullScreen: |
33947 | 376 if ( guiInfo.VideoWindow && guiInfo.Playing ) |
377 { | |
33950 | 378 uiFullScreen(); |
34697 | 379 if ( !guiApp.videoWindow.isFullScreen ) |
33950 | 380 { |
34697 | 381 wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight ); |
382 wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); | |
33950 | 383 } |
33947 | 384 } |
34697 | 385 if ( guiApp.videoWindow.isFullScreen ) btnSet( evFullScreen,btnPressed ); |
23077 | 386 else btnSet( evFullScreen,btnReleased ); |
387 break; | |
388 | |
389 case evSetAspect: | |
390 switch ( iparam ) | |
391 { | |
392 case 2: movie_aspect=16.0f / 9.0f; break; | |
393 case 3: movie_aspect=4.0f / 3.0f; break; | |
394 case 4: movie_aspect=2.35; break; | |
395 case 1: | |
396 default: movie_aspect=-1; | |
397 } | |
35357
80fe9ad7f318
Pass guiApp's wsTWindow parameters always by reference (if possible).
ib
parents:
35355
diff
changeset
|
398 wsClearWindow( &guiApp.videoWindow ); |
34456 | 399 if ( guiInfo.StreamType == STREAMTYPE_VCD ) uiEventHandling( evPlayVCD, 0 ); |
400 else if ( guiInfo.StreamType == STREAMTYPE_DVD ) uiEventHandling( ivPlayDVD, 0 ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
401 else |
33890 | 402 guiInfo.NewPlay=GUI_FILE_NEW; |
23077 | 403 break; |
404 | |
34684 | 405 /* timer events */ |
34333 | 406 case ivRedraw: |
23077 | 407 { |
408 unsigned now = GetTimerMS(); | |
409 if ((now > last_redraw_time) && | |
410 (now < last_redraw_time + GUI_REDRAW_WAIT) && | |
34035 | 411 !uiPlaybarFade && (iparam == 0)) |
23077 | 412 break; |
413 last_redraw_time = now; | |
414 } | |
35493 | 415 uiMainRender=True; |
33555 | 416 wsPostRedisplay( &guiApp.mainWindow ); |
417 wsPostRedisplay( &guiApp.playbarWindow ); | |
23077 | 418 break; |
34684 | 419 /* system events */ |
23077 | 420 case evNone: |
34416 | 421 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] uiEventHandling: evNone\n" ); |
23077 | 422 break; |
423 default: | |
34416 | 424 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] uiEventHandling: unknown event %d, param %.2f\n", msg, param ); |
23077 | 425 break; |
426 } | |
427 } | |
428 | |
33555 | 429 void uiMainMouseHandle( int Button,int X,int Y,int RX,int RY ) |
23077 | 430 { |
431 static int itemtype = 0; | |
432 int i; | |
433 wItem * item = NULL; | |
434 float value = 0.0f; | |
435 | |
436 static int SelectedItem = -1; | |
437 int currentselected = -1; | |
438 | |
33555 | 439 for ( i=0;i <= guiApp.IndexOfMainItems;i++ ) |
440 if ( ( guiApp.mainItems[i].pressed != btnDisabled )&& | |
441 ( wgIsRect( X,Y,guiApp.mainItems[i].x,guiApp.mainItems[i].y,guiApp.mainItems[i].x+guiApp.mainItems[i].width,guiApp.mainItems[i].y+guiApp.mainItems[i].height ) ) ) | |
23077 | 442 { currentselected=i; break; } |
443 | |
444 switch ( Button ) | |
445 { | |
446 case wsPMMouseButton: | |
34333 | 447 gtkShow( ivHidePopUpMenu,NULL ); |
33555 | 448 uiShowMenu( RX,RY ); |
23077 | 449 itemtype=itPRMButton; |
450 break; | |
451 case wsRMMouseButton: | |
33555 | 452 uiHideMenu( RX,RY,0 ); |
23077 | 453 break; |
454 | |
455 case wsPLMouseButton: | |
34333 | 456 gtkShow( ivHidePopUpMenu,NULL ); |
35493 | 457 sx=X; sy=Y; boxMoved=True; itemtype=itPLMButton; |
23077 | 458 SelectedItem=currentselected; |
459 if ( SelectedItem == -1 ) break; | |
35493 | 460 boxMoved=False; |
33555 | 461 item=&guiApp.mainItems[SelectedItem]; |
23077 | 462 itemtype=item->type; |
463 item->pressed=btnPressed; | |
464 switch( item->type ) | |
465 { | |
466 case itButton: | |
467 if ( ( SelectedItem > -1 ) && | |
32911 | 468 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) || |
469 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) ) | |
23077 | 470 { item->pressed=btnDisabled; } |
471 break; | |
472 } | |
473 break; | |
474 case wsRLMouseButton: | |
35493 | 475 boxMoved=False; |
33107 | 476 if ( SelectedItem != -1 ) // NOTE TO MYSELF: only if itButton, itHPotmeter or itVPotmeter |
477 { | |
33555 | 478 item=&guiApp.mainItems[SelectedItem]; |
33108 | 479 item->pressed=btnReleased; |
33107 | 480 } |
35351 | 481 if ( currentselected == - 1 || SelectedItem == -1 ) { itemtype=0; break; } |
23077 | 482 SelectedItem=-1; |
483 value=0; | |
484 switch( itemtype ) | |
485 { | |
486 case itPotmeter: | |
487 case itHPotmeter: | |
32911 | 488 btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f ); |
33555 | 489 uiEventHandling( item->message,item->value ); |
23077 | 490 value=item->value; |
491 break; | |
492 case itVPotmeter: | |
32911 | 493 btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); |
33555 | 494 uiEventHandling( item->message,item->value ); |
23077 | 495 value=item->value; |
496 break; | |
497 } | |
33555 | 498 uiEventHandling( item->message,value ); |
23077 | 499 itemtype=0; |
500 break; | |
501 | |
502 case wsRRMouseButton: | |
34333 | 503 gtkShow( ivShowPopUpMenu,NULL ); |
23077 | 504 break; |
505 | |
34684 | 506 /* rolled mouse ... de szar :))) */ |
23077 | 507 case wsP5MouseButton: value=-2.5f; goto rollerhandled; |
508 case wsP4MouseButton: value= 2.5f; | |
509 rollerhandled: | |
35365 | 510 if (currentselected != - 1) |
511 { | |
35366 | 512 item=&guiApp.mainItems[currentselected]; |
513 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) | |
514 { | |
515 item->value+=value; | |
516 btnModify( item->message,item->value ); | |
517 uiEventHandling( item->message,item->value ); | |
518 } | |
35365 | 519 } |
23077 | 520 break; |
521 | |
34684 | 522 /* moving */ |
23077 | 523 case wsMoveMouse: |
33555 | 524 item=&guiApp.mainItems[SelectedItem]; |
23077 | 525 switch ( itemtype ) |
526 { | |
527 case itPLMButton: | |
33993 | 528 wsMoveWindow( &guiApp.mainWindow,True,RX - abs( sx ),RY - abs( sy ) ); |
35493 | 529 uiMainRender=False; |
23077 | 530 break; |
531 case itPRMButton: | |
34472 | 532 uiMenuMouseHandle( RX,RY ); |
23077 | 533 break; |
534 case itPotmeter: | |
535 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
536 goto potihandled; | |
537 case itVPotmeter: | |
538 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
539 goto potihandled; | |
540 case itHPotmeter: | |
541 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
542 potihandled: | |
543 if ( item->value > 100.0f ) item->value=100.0f; | |
544 if ( item->value < 0.0f ) item->value=0.0f; | |
33555 | 545 uiEventHandling( item->message,item->value ); |
23077 | 546 break; |
547 } | |
548 break; | |
549 } | |
550 } | |
551 | |
33555 | 552 void uiMainKeyHandle( int KeyCode,int Type,int Key ) |
23077 | 553 { |
554 int msg = evNone; | |
555 | |
556 if ( Type != wsKeyPressed ) return; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
557 |
23077 | 558 if ( !Key ) |
559 { | |
560 switch ( KeyCode ) | |
561 { | |
33524 | 562 // NOTE TO MYSELF: This is only for the Acer AirKey V keyboard. |
33536
fc1402410163
Remove support for Acer AirKey V keyboard multimedia keys.
ib
parents:
33535
diff
changeset
|
563 /*case wsXFMMPrev: msg=evPrev; break; |
23077 | 564 case wsXFMMStop: msg=evStop; break; |
565 case wsXFMMPlay: msg=evPlaySwitchToPause; break; | |
566 case wsXFMMNext: msg=evNext; break; | |
567 case wsXFMMVolUp: msg=evIncVolume; break; | |
568 case wsXFMMVolDown: msg=evDecVolume; break; | |
33536
fc1402410163
Remove support for Acer AirKey V keyboard multimedia keys.
ib
parents:
33535
diff
changeset
|
569 case wsXFMMMute: msg=evMute; break;*/ |
23077 | 570 } |
571 } | |
572 else | |
573 { | |
574 switch ( Key ) | |
575 { | |
576 case wsEnter: msg=evPlay; break; | |
577 case wsXF86LowerVolume: msg=evDecVolume; break; | |
578 case wsXF86RaiseVolume: msg=evIncVolume; break; | |
579 case wsXF86Mute: msg=evMute; break; | |
33525 | 580 case wsXF86Pause: |
23077 | 581 case wsXF86Play: msg=evPlaySwitchToPause; break; |
582 case wsXF86Stop: msg=evStop; break; | |
583 case wsXF86Prev: msg=evPrev; break; | |
584 case wsXF86Next: msg=evNext; break; | |
585 case wsXF86Media: msg=evLoad; break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
586 case wsEscape: |
34697 | 587 if ( guiInfo.VideoWindow && guiInfo.Playing && guiApp.videoWindow.isFullScreen ) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
588 { |
33555 | 589 uiEventHandling( evNormalSize,0 ); |
23077 | 590 return; |
591 } | |
592 default: vo_x11_putkey( Key ); return; | |
593 } | |
594 } | |
33555 | 595 if ( msg != evNone ) uiEventHandling( msg,0 ); |
23077 | 596 } |
597 | |
598 /* this will be used to handle Drag&Drop files */ | |
33555 | 599 void uiDandDHandler(int num,char** files) |
23077 | 600 { |
601 struct stat buf; | |
602 int f = 0; | |
603 | |
604 char* subtitles = NULL; | |
35521 | 605 char* file = NULL; |
35384 | 606 char* s; |
23077 | 607 |
608 if (num <= 0) | |
609 return; | |
610 | |
611 | |
612 /* now fill it with new items */ | |
613 for(f=0; f < num; f++){ | |
614 char* str = strdup( files[f] ); | |
615 plItem* item; | |
616 | |
24086
f5b32d12b691
remove gconvert_uri_to_filename() and use url_unescape_string() instead.
iive
parents:
23457
diff
changeset
|
617 url_unescape_string(str, files[f]); |
23077 | 618 |
619 if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) { | |
620 /* this is not a directory so try to play it */ | |
621 mp_msg( MSGT_GPLAYER,MSGL_V,"Received D&D %s\n",str ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
622 |
23077 | 623 /* check if it is a subtitle file */ |
624 { | |
625 char* ext = strrchr(str,'.'); | |
626 if (ext) { | |
627 static char supported[] = "utf/sub/srt/smi/rt//txt/ssa/aqt/"; | |
628 char* type; | |
629 int len; | |
630 if((len=strlen(++ext)) && (type=strstr(supported,ext)) &&\ | |
631 (type-supported)%4 == 0 && *(type+len) == '/'){ | |
632 /* handle subtitle file */ | |
33739 | 633 nfree(subtitles); |
23077 | 634 subtitles = str; |
635 continue; | |
636 } | |
637 } | |
638 } | |
639 | |
640 /* clear playlist */ | |
35521 | 641 if (file == NULL) { |
642 file = files[f]; | |
34663 | 643 listMgr(PLAYLIST_DELETE,0); |
23077 | 644 } |
645 | |
646 item = calloc(1,sizeof(plItem)); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
647 |
35384 | 648 s = strrchr( str,'/' ); |
649 | |
23077 | 650 /* FIXME: decompose file name ? */ |
651 /* yes -- Pontscho */ | |
35384 | 652 if ( s ) { |
653 *s=0; s++; | |
23077 | 654 item->name = gstrdup( s ); |
655 item->path = gstrdup( str ); | |
656 } else { | |
35385 | 657 // NOTE TO MYSELF: this shouldn't happen, make sure we have a full path |
23077 | 658 item->name = strdup(str); |
35385 | 659 item->path = strdup("."); |
23077 | 660 } |
34681 | 661 listMgr(PLAYLIST_ITEM_APPEND,item); |
23077 | 662 } else { |
663 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotAFile,str ); | |
664 } | |
665 free( str ); | |
666 } | |
667 | |
35521 | 668 if (file) { |
669 uiSetFile( NULL,file,STREAMTYPE_FILE ); | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
670 if ( guiInfo.Playing == GUI_PLAY ) uiEventHandling( evStop,0 ); |
33555 | 671 uiEventHandling( evPlay,0 ); |
23077 | 672 } |
673 if (subtitles) { | |
33897 | 674 nfree(guiInfo.SubtitleFilename); |
675 guiInfo.SubtitleFilename = subtitles; | |
676 mplayerLoadSubtitle(guiInfo.SubtitleFilename); | |
23077 | 677 } |
678 } |