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