Mercurial > mplayer.hg
annotate gui/ui/main.c @ 35541:ded4a8c2aa70
Cosmetic: Add some blank lines.
author | ib |
---|---|
date | Sun, 09 Dec 2012 13:19:42 +0000 |
parents | 9bc02a829c48 |
children | 5289e495e70e |
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 { |
128 int iparam = (int)param; | |
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; | |
309 mixer_setbalance( mixer,(guiInfo.Balance - 50.0 ) / 50.0 ); | |
310 if ( osd_level ) | |
311 { | |
312 osd_visible=(GetTimerMS() + 1000) | 1; | |
313 vo_osd_progbar_type=OSD_BALANCE; | |
314 vo_osd_progbar_value=( ( guiInfo.Balance ) * 256.0 ) / 100.0; | |
315 vo_osd_changed( OSDTYPE_PROGBAR ); | |
316 } | |
317 break; | |
23077 | 318 |
34458 | 319 case evMenu: |
34473 | 320 /*if (guiApp.menuIsPresent) NOTE TO MYSELF: Uncomment only after mouse |
321 { pointer and cursor keys work | |
322 gtkShow( ivHidePopUpMenu,NULL ); with this menu from skin as | |
323 uiShowMenu( 0,0 ); they do with normal menus. | |
34458 | 324 } |
325 else*/ gtkShow( ivShowPopUpMenu,NULL ); | |
326 break; | |
327 | |
23077 | 328 case evIconify: |
329 switch ( iparam ) | |
330 { | |
35355 | 331 case 0: wsIconify( &guiApp.mainWindow ); break; |
332 case 1: wsIconify( &guiApp.videoWindow ); break; | |
23077 | 333 } |
334 break; | |
335 case evHalfSize: | |
33947 | 336 if ( guiInfo.VideoWindow && guiInfo.Playing ) |
23077 | 337 { |
34697 | 338 if ( guiApp.videoWindow.isFullScreen ) |
23077 | 339 { |
33555 | 340 uiFullScreen(); |
23077 | 341 } |
34697 | 342 wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2 ); |
343 wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); | |
33950 | 344 btnSet( evFullScreen,btnReleased ); |
23077 | 345 } |
346 break; | |
347 case evDoubleSize: | |
33947 | 348 if ( guiInfo.VideoWindow && guiInfo.Playing ) |
23077 | 349 { |
34697 | 350 if ( guiApp.videoWindow.isFullScreen ) |
23077 | 351 { |
33555 | 352 uiFullScreen(); |
23077 | 353 } |
34697 | 354 wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2 ); |
355 wsMoveWindowWithin( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); | |
33950 | 356 btnSet( evFullScreen,btnReleased ); |
23077 | 357 } |
358 break; | |
359 case evNormalSize: | |
33947 | 360 if ( guiInfo.VideoWindow && guiInfo.Playing ) |
23077 | 361 { |
34697 | 362 if ( guiApp.videoWindow.isFullScreen ) |
23077 | 363 { |
33555 | 364 uiFullScreen(); |
23077 | 365 } |
34697 | 366 wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight ); |
367 wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); | |
33947 | 368 btnSet( evFullScreen,btnReleased ); |
23077 | 369 break; |
34697 | 370 } else if ( !guiApp.videoWindow.isFullScreen ) break; |
23077 | 371 case evFullScreen: |
33947 | 372 if ( guiInfo.VideoWindow && guiInfo.Playing ) |
373 { | |
33950 | 374 uiFullScreen(); |
34697 | 375 if ( !guiApp.videoWindow.isFullScreen ) |
33950 | 376 { |
34697 | 377 wsResizeWindow( &guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight ); |
378 wsMoveWindow( &guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y ); | |
33950 | 379 } |
33947 | 380 } |
34697 | 381 if ( guiApp.videoWindow.isFullScreen ) btnSet( evFullScreen,btnPressed ); |
23077 | 382 else btnSet( evFullScreen,btnReleased ); |
383 break; | |
384 | |
385 case evSetAspect: | |
386 switch ( iparam ) | |
387 { | |
388 case 2: movie_aspect=16.0f / 9.0f; break; | |
389 case 3: movie_aspect=4.0f / 3.0f; break; | |
390 case 4: movie_aspect=2.35; break; | |
391 case 1: | |
392 default: movie_aspect=-1; | |
393 } | |
35357
80fe9ad7f318
Pass guiApp's wsTWindow parameters always by reference (if possible).
ib
parents:
35355
diff
changeset
|
394 wsClearWindow( &guiApp.videoWindow ); |
34456 | 395 if ( guiInfo.StreamType == STREAMTYPE_VCD ) uiEventHandling( evPlayVCD, 0 ); |
396 else if ( guiInfo.StreamType == STREAMTYPE_DVD ) uiEventHandling( ivPlayDVD, 0 ); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
397 else |
33890 | 398 guiInfo.NewPlay=GUI_FILE_NEW; |
23077 | 399 break; |
400 | |
34684 | 401 /* timer events */ |
34333 | 402 case ivRedraw: |
23077 | 403 { |
404 unsigned now = GetTimerMS(); | |
405 if ((now > last_redraw_time) && | |
406 (now < last_redraw_time + GUI_REDRAW_WAIT) && | |
34035 | 407 !uiPlaybarFade && (iparam == 0)) |
23077 | 408 break; |
409 last_redraw_time = now; | |
410 } | |
35493 | 411 uiMainRender=True; |
33555 | 412 wsPostRedisplay( &guiApp.mainWindow ); |
413 wsPostRedisplay( &guiApp.playbarWindow ); | |
23077 | 414 break; |
34684 | 415 /* system events */ |
23077 | 416 case evNone: |
34416 | 417 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] uiEventHandling: evNone\n" ); |
23077 | 418 break; |
419 default: | |
34416 | 420 mp_msg( MSGT_GPLAYER,MSGL_DBG2,"[main] uiEventHandling: unknown event %d, param %.2f\n", msg, param ); |
23077 | 421 break; |
422 } | |
423 } | |
424 | |
33555 | 425 void uiMainMouseHandle( int Button,int X,int Y,int RX,int RY ) |
23077 | 426 { |
427 static int itemtype = 0; | |
428 int i; | |
429 wItem * item = NULL; | |
430 float value = 0.0f; | |
431 | |
432 static int SelectedItem = -1; | |
433 int currentselected = -1; | |
434 | |
33555 | 435 for ( i=0;i <= guiApp.IndexOfMainItems;i++ ) |
436 if ( ( guiApp.mainItems[i].pressed != btnDisabled )&& | |
437 ( 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 | 438 { currentselected=i; break; } |
439 | |
440 switch ( Button ) | |
441 { | |
442 case wsPMMouseButton: | |
34333 | 443 gtkShow( ivHidePopUpMenu,NULL ); |
33555 | 444 uiShowMenu( RX,RY ); |
23077 | 445 itemtype=itPRMButton; |
446 break; | |
447 case wsRMMouseButton: | |
33555 | 448 uiHideMenu( RX,RY,0 ); |
23077 | 449 break; |
450 | |
451 case wsPLMouseButton: | |
34333 | 452 gtkShow( ivHidePopUpMenu,NULL ); |
35493 | 453 sx=X; sy=Y; boxMoved=True; itemtype=itPLMButton; |
23077 | 454 SelectedItem=currentselected; |
455 if ( SelectedItem == -1 ) break; | |
35493 | 456 boxMoved=False; |
33555 | 457 item=&guiApp.mainItems[SelectedItem]; |
23077 | 458 itemtype=item->type; |
459 item->pressed=btnPressed; | |
460 switch( item->type ) | |
461 { | |
462 case itButton: | |
463 if ( ( SelectedItem > -1 ) && | |
32911 | 464 ( ( ( item->message == evPlaySwitchToPause && item->message == evPauseSwitchToPlay ) ) || |
465 ( ( item->message == evPauseSwitchToPlay && item->message == evPlaySwitchToPause ) ) ) ) | |
23077 | 466 { item->pressed=btnDisabled; } |
467 break; | |
468 } | |
469 break; | |
470 case wsRLMouseButton: | |
35493 | 471 boxMoved=False; |
33107 | 472 if ( SelectedItem != -1 ) // NOTE TO MYSELF: only if itButton, itHPotmeter or itVPotmeter |
473 { | |
33555 | 474 item=&guiApp.mainItems[SelectedItem]; |
33108 | 475 item->pressed=btnReleased; |
33107 | 476 } |
35351 | 477 if ( currentselected == - 1 || SelectedItem == -1 ) { itemtype=0; break; } |
23077 | 478 SelectedItem=-1; |
479 value=0; | |
480 switch( itemtype ) | |
481 { | |
482 case itPotmeter: | |
483 case itHPotmeter: | |
32911 | 484 btnModify( item->message,(float)( X - item->x ) / item->width * 100.0f ); |
33555 | 485 uiEventHandling( item->message,item->value ); |
23077 | 486 value=item->value; |
487 break; | |
488 case itVPotmeter: | |
32911 | 489 btnModify( item->message, ( 1. - (float)( Y - item->y ) / item->height) * 100.0f ); |
33555 | 490 uiEventHandling( item->message,item->value ); |
23077 | 491 value=item->value; |
492 break; | |
493 } | |
33555 | 494 uiEventHandling( item->message,value ); |
23077 | 495 itemtype=0; |
496 break; | |
497 | |
498 case wsRRMouseButton: | |
34333 | 499 gtkShow( ivShowPopUpMenu,NULL ); |
23077 | 500 break; |
501 | |
34684 | 502 /* rolled mouse ... de szar :))) */ |
23077 | 503 case wsP5MouseButton: value=-2.5f; goto rollerhandled; |
504 case wsP4MouseButton: value= 2.5f; | |
505 rollerhandled: | |
35365 | 506 if (currentselected != - 1) |
507 { | |
35366 | 508 item=&guiApp.mainItems[currentselected]; |
509 if ( ( item->type == itHPotmeter )||( item->type == itVPotmeter )||( item->type == itPotmeter ) ) | |
510 { | |
511 item->value+=value; | |
512 btnModify( item->message,item->value ); | |
513 uiEventHandling( item->message,item->value ); | |
514 } | |
35365 | 515 } |
23077 | 516 break; |
517 | |
34684 | 518 /* moving */ |
23077 | 519 case wsMoveMouse: |
33555 | 520 item=&guiApp.mainItems[SelectedItem]; |
23077 | 521 switch ( itemtype ) |
522 { | |
523 case itPLMButton: | |
33993 | 524 wsMoveWindow( &guiApp.mainWindow,True,RX - abs( sx ),RY - abs( sy ) ); |
35493 | 525 uiMainRender=False; |
23077 | 526 break; |
527 case itPRMButton: | |
34472 | 528 uiMenuMouseHandle( RX,RY ); |
23077 | 529 break; |
530 case itPotmeter: | |
531 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
532 goto potihandled; | |
533 case itVPotmeter: | |
534 item->value=(1. - (float)( Y - item->y ) / item->height) * 100.0f; | |
535 goto potihandled; | |
536 case itHPotmeter: | |
537 item->value=(float)( X - item->x ) / item->width * 100.0f; | |
538 potihandled: | |
539 if ( item->value > 100.0f ) item->value=100.0f; | |
540 if ( item->value < 0.0f ) item->value=0.0f; | |
33555 | 541 uiEventHandling( item->message,item->value ); |
23077 | 542 break; |
543 } | |
544 break; | |
545 } | |
546 } | |
547 | |
33555 | 548 void uiMainKeyHandle( int KeyCode,int Type,int Key ) |
23077 | 549 { |
550 int msg = evNone; | |
551 | |
552 if ( Type != wsKeyPressed ) return; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
553 |
23077 | 554 if ( !Key ) |
555 { | |
556 switch ( KeyCode ) | |
557 { | |
33524 | 558 // 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
|
559 /*case wsXFMMPrev: msg=evPrev; break; |
23077 | 560 case wsXFMMStop: msg=evStop; break; |
561 case wsXFMMPlay: msg=evPlaySwitchToPause; break; | |
562 case wsXFMMNext: msg=evNext; break; | |
563 case wsXFMMVolUp: msg=evIncVolume; break; | |
564 case wsXFMMVolDown: msg=evDecVolume; break; | |
33536
fc1402410163
Remove support for Acer AirKey V keyboard multimedia keys.
ib
parents:
33535
diff
changeset
|
565 case wsXFMMMute: msg=evMute; break;*/ |
23077 | 566 } |
567 } | |
568 else | |
569 { | |
570 switch ( Key ) | |
571 { | |
572 case wsEnter: msg=evPlay; break; | |
573 case wsXF86LowerVolume: msg=evDecVolume; break; | |
574 case wsXF86RaiseVolume: msg=evIncVolume; break; | |
575 case wsXF86Mute: msg=evMute; break; | |
33525 | 576 case wsXF86Pause: |
23077 | 577 case wsXF86Play: msg=evPlaySwitchToPause; break; |
578 case wsXF86Stop: msg=evStop; break; | |
579 case wsXF86Prev: msg=evPrev; break; | |
580 case wsXF86Next: msg=evNext; break; | |
581 case wsXF86Media: msg=evLoad; break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
582 case wsEscape: |
34697 | 583 if ( guiInfo.VideoWindow && guiInfo.Playing && guiApp.videoWindow.isFullScreen ) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
584 { |
33555 | 585 uiEventHandling( evNormalSize,0 ); |
23077 | 586 return; |
587 } | |
588 default: vo_x11_putkey( Key ); return; | |
589 } | |
590 } | |
33555 | 591 if ( msg != evNone ) uiEventHandling( msg,0 ); |
23077 | 592 } |
593 | |
594 /* this will be used to handle Drag&Drop files */ | |
33555 | 595 void uiDandDHandler(int num,char** files) |
23077 | 596 { |
597 struct stat buf; | |
598 int f = 0; | |
599 | |
600 char* subtitles = NULL; | |
35521 | 601 char* file = NULL; |
35384 | 602 char* s; |
23077 | 603 |
604 if (num <= 0) | |
605 return; | |
606 | |
607 | |
608 /* now fill it with new items */ | |
609 for(f=0; f < num; f++){ | |
610 char* str = strdup( files[f] ); | |
611 plItem* item; | |
612 | |
24086
f5b32d12b691
remove gconvert_uri_to_filename() and use url_unescape_string() instead.
iive
parents:
23457
diff
changeset
|
613 url_unescape_string(str, files[f]); |
23077 | 614 |
615 if(stat(str,&buf) == 0 && S_ISDIR(buf.st_mode) == 0) { | |
616 /* this is not a directory so try to play it */ | |
617 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
|
618 |
23077 | 619 /* check if it is a subtitle file */ |
620 { | |
621 char* ext = strrchr(str,'.'); | |
622 if (ext) { | |
623 static char supported[] = "utf/sub/srt/smi/rt//txt/ssa/aqt/"; | |
624 char* type; | |
625 int len; | |
626 if((len=strlen(++ext)) && (type=strstr(supported,ext)) &&\ | |
627 (type-supported)%4 == 0 && *(type+len) == '/'){ | |
628 /* handle subtitle file */ | |
33739 | 629 nfree(subtitles); |
23077 | 630 subtitles = str; |
631 continue; | |
632 } | |
633 } | |
634 } | |
635 | |
636 /* clear playlist */ | |
35521 | 637 if (file == NULL) { |
638 file = files[f]; | |
34663 | 639 listMgr(PLAYLIST_DELETE,0); |
23077 | 640 } |
641 | |
642 item = calloc(1,sizeof(plItem)); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28051
diff
changeset
|
643 |
35384 | 644 s = strrchr( str,'/' ); |
645 | |
23077 | 646 /* FIXME: decompose file name ? */ |
647 /* yes -- Pontscho */ | |
35384 | 648 if ( s ) { |
649 *s=0; s++; | |
23077 | 650 item->name = gstrdup( s ); |
651 item->path = gstrdup( str ); | |
652 } else { | |
35385 | 653 // NOTE TO MYSELF: this shouldn't happen, make sure we have a full path |
23077 | 654 item->name = strdup(str); |
35385 | 655 item->path = strdup("."); |
23077 | 656 } |
34681 | 657 listMgr(PLAYLIST_ITEM_APPEND,item); |
23077 | 658 } else { |
659 mp_msg( MSGT_GPLAYER,MSGL_WARN,MSGTR_NotAFile,str ); | |
660 } | |
661 free( str ); | |
662 } | |
663 | |
35521 | 664 if (file) { |
665 uiSetFile( NULL,file,STREAMTYPE_FILE ); | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
666 if ( guiInfo.Playing == GUI_PLAY ) uiEventHandling( evStop,0 ); |
33555 | 667 uiEventHandling( evPlay,0 ); |
23077 | 668 } |
669 if (subtitles) { | |
33897 | 670 nfree(guiInfo.SubtitleFilename); |
671 guiInfo.SubtitleFilename = subtitles; | |
672 mplayerLoadSubtitle(guiInfo.SubtitleFilename); | |
23077 | 673 } |
674 } |