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