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