Mercurial > mplayer.hg
annotate gui/ui/actions.c @ 36957:975c482d1afc
Remove pointless btnModify() calls.
These will be performed in the windows' draw handler
prior to rendering anyway.
author | ib |
---|---|
date | Mon, 24 Mar 2014 10:18:55 +0000 |
parents | 7dacd58cd2bb |
children | f11488e801a9 |
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 |
35437 | 19 /** |
20 * @file | |
21 * @brief User interface actions | |
22 */ | |
23 | |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
24 #include <stdint.h> |
23077 | 25 #include <stdlib.h> |
26 #include <string.h> | |
27 | |
33556 | 28 #include "actions.h" |
35528 | 29 #include "ui.h" |
36032 | 30 #include "gui/interface.h" |
35525 | 31 #include "gui/app/app.h" |
35771 | 32 #include "gui/app/cfg.h" |
35525 | 33 #include "gui/app/gui.h" |
35771 | 34 #include "gui/dialog/dialog.h" |
32881 | 35 #include "gui/skin/skin.h" |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
36 #include "gui/util/list.h" |
33739 | 37 #include "gui/util/mem.h" |
33737 | 38 #include "gui/util/string.h" |
35435 | 39 #include "gui/wm/ws.h" |
32881 | 40 #include "gui/wm/wsxdnd.h" |
23077 | 41 |
35771 | 42 #include "access_mpcontext.h" |
43 #include "config.h" | |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
44 #include "help_mp.h" |
36032 | 45 #include "m_property.h" |
46 #include "mixer.h" | |
47 #include "mp_core.h" | |
36894
669e2f7fb150
Directly call mplayer_put_key() instead of vo_x11_putkey().
ib
parents:
36772
diff
changeset
|
48 #include "mp_fifo.h" |
36032 | 49 #include "mp_msg.h" |
50 #include "mpcommon.h" | |
51 #include "mplayer.h" | |
32881 | 52 #include "input/input.h" |
35431 | 53 #include "libmpdemux/demuxer.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
54 #include "libvo/video_out.h" |
36894
669e2f7fb150
Directly call mplayer_put_key() instead of vo_x11_putkey().
ib
parents:
36772
diff
changeset
|
55 #include "osdep/keycodes.h" |
35771 | 56 #include "osdep/timer.h" |
57 #include "stream/stream.h" | |
58 #include "sub/sub.h" | |
59 | |
35776 | 60 #define GUI_REDRAW_WAIT 375 // in milliseconds |
35771 | 61 |
35777 | 62 int uiLoadPlay; |
63 | |
35775 | 64 static unsigned int last_redraw_time; |
35771 | 65 |
35776 | 66 /** |
67 * @brief Clear information not used for this @a type of stream. | |
68 * | |
69 * @param type stream type | |
70 */ | |
35771 | 71 static void MediumPrepare(int type) |
72 { | |
73 switch (type) { | |
74 case STREAMTYPE_DVD: | |
75 listMgr(PLAYLIST_DELETE, 0); | |
76 break; | |
77 | |
78 case STREAMTYPE_CDDA: | |
79 case STREAMTYPE_VCD: | |
36429 | 80 case STREAMTYPE_TV: |
81 case STREAMTYPE_DVB: | |
35771 | 82 listMgr(PLAYLIST_DELETE, 0); |
83 case STREAMTYPE_FILE: | |
84 case STREAMTYPE_STREAM: | |
85 case STREAMTYPE_PLAYLIST: | |
86 guiInfo.AudioStreams = 0; | |
87 guiInfo.Subtitles = 0; | |
88 guiInfo.Chapters = 0; | |
89 guiInfo.Angles = 0; | |
90 break; | |
91 } | |
92 } | |
93 | |
35773 | 94 void uiEvent(int ev, float param) |
35771 | 95 { |
36935 | 96 int iparam = (int)param; |
35771 | 97 mixer_t *mixer = mpctx_get_mixer(guiInfo.mpcontext); |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
98 float aspect; |
36274 | 99 char cmd[40]; |
35771 | 100 |
35773 | 101 switch (ev) { |
35771 | 102 /* user events */ |
103 case evExit: | |
104 mplayer(MPLAYER_EXIT_GUI, EXIT_QUIT, 0); | |
105 break; | |
106 | |
107 case evLoadURL: | |
108 gtkShow(evLoadURL, NULL); | |
109 break; | |
110 | |
111 case ivSetAudio: | |
112 | |
113 if (!mpctx_get_demuxer(guiInfo.mpcontext) || audio_id == iparam) | |
114 break; | |
115 | |
116 mp_property_do("switch_audio", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); | |
117 break; | |
118 | |
119 case ivSetVideo: | |
120 | |
121 if (!mpctx_get_demuxer(guiInfo.mpcontext) || video_id == iparam) | |
122 break; | |
123 | |
124 mp_property_do("switch_video", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); | |
125 break; | |
126 | |
127 case ivSetSubtitle: | |
128 mp_property_do("sub", M_PROPERTY_SET, &iparam, guiInfo.mpcontext); | |
129 break; | |
130 | |
131 #ifdef CONFIG_CDDA | |
132 case ivSetCDTrack: | |
133 guiInfo.Track = iparam; | |
134 | |
135 case evPlayCD: | |
136 guiInfo.StreamType = STREAMTYPE_CDDA; | |
137 goto play; | |
138 | |
139 #endif | |
140 #ifdef CONFIG_VCD | |
141 case ivSetVCDTrack: | |
142 guiInfo.Track = iparam; | |
143 | |
144 case evPlayVCD: | |
145 guiInfo.StreamType = STREAMTYPE_VCD; | |
146 goto play; | |
147 | |
148 #endif | |
149 #ifdef CONFIG_DVDREAD | |
150 case ivSetDVDSubtitle: | |
151 dvdsub_id = iparam; | |
35773 | 152 uiEvent(ivPlayDVD, 0); |
35771 | 153 break; |
154 | |
155 case ivSetDVDAudio: | |
156 audio_id = iparam; | |
35773 | 157 uiEvent(ivPlayDVD, 0); |
35771 | 158 break; |
159 | |
160 case ivSetDVDChapter: | |
161 guiInfo.Chapter = iparam; | |
35773 | 162 uiEvent(ivPlayDVD, 0); |
35771 | 163 break; |
164 | |
165 case ivSetDVDTitle: | |
166 guiInfo.Track = iparam; | |
167 guiInfo.Chapter = 1; | |
168 guiInfo.Angle = 1; | |
35773 | 169 uiEvent(ivPlayDVD, 0); |
35771 | 170 break; |
171 | |
172 case evPlayDVD: | |
173 guiInfo.Chapter = 1; | |
174 guiInfo.Angle = 1; | |
175 | |
176 case ivPlayDVD: | |
177 guiInfo.StreamType = STREAMTYPE_DVD; | |
178 goto play; | |
179 | |
180 #endif | |
36429 | 181 #ifdef CONFIG_TV |
182 case evPlayTV: | |
183 guiInfo.StreamType = guiTV[gui_tv_digital].StreamType; | |
184 goto play; | |
185 | |
186 #endif | |
35771 | 187 case evPlay: |
188 case evPlaySwitchToPause: | |
189 play: | |
190 | |
35791 | 191 if (guiInfo.Playing != GUI_PAUSE) { |
35792 | 192 MediumPrepare(guiInfo.StreamType); |
35771 | 193 |
35792 | 194 switch (guiInfo.StreamType) { |
195 case STREAMTYPE_FILE: | |
196 case STREAMTYPE_STREAM: | |
197 case STREAMTYPE_PLAYLIST: | |
35771 | 198 |
35792 | 199 if (!guiInfo.Track) |
200 guiInfo.Track = 1; | |
35771 | 201 |
36937
ad939f49bb28
Cosmetic: Rename guiInfo member NewPlay MediumChanged.
ib
parents:
36936
diff
changeset
|
202 guiInfo.MediumChanged = GUI_MEDIUM_NEW; |
36938 | 203 guiInfo.PlaylistNext = !guiInfo.Playing; |
35791 | 204 |
35792 | 205 break; |
35771 | 206 |
35792 | 207 case STREAMTYPE_CDDA: |
208 case STREAMTYPE_VCD: | |
209 case STREAMTYPE_DVD: | |
36429 | 210 case STREAMTYPE_TV: |
211 case STREAMTYPE_DVB: | |
35771 | 212 |
213 if (!guiInfo.Track) | |
35793 | 214 guiInfo.Track = (guiInfo.StreamType == STREAMTYPE_VCD ? 2 : 1); |
35771 | 215 |
36937
ad939f49bb28
Cosmetic: Rename guiInfo member NewPlay MediumChanged.
ib
parents:
36936
diff
changeset
|
216 guiInfo.MediumChanged = GUI_MEDIUM_SAME; |
35771 | 217 |
35792 | 218 break; |
219 } | |
35791 | 220 } |
35771 | 221 |
222 uiPlay(); | |
223 break; | |
224 | |
225 case evPause: | |
226 case evPauseSwitchToPlay: | |
227 uiPause(); | |
228 break; | |
229 | |
230 case evStop: | |
231 guiInfo.Playing = GUI_STOP; | |
232 uiState(); | |
233 break; | |
234 | |
235 case evLoadPlay: | |
236 uiLoadPlay = True; | |
237 | |
238 // guiInfo.StreamType=STREAMTYPE_FILE; | |
239 case evLoad: | |
240 gtkShow(evLoad, NULL); | |
241 break; | |
242 | |
243 case evLoadSubtitle: | |
244 gtkShow(evLoadSubtitle, NULL); | |
245 break; | |
246 | |
247 case evDropSubtitle: | |
248 nfree(guiInfo.SubtitleFilename); | |
249 mplayerLoadSubtitle(NULL); | |
250 break; | |
251 | |
252 case evLoadAudioFile: | |
253 gtkShow(evLoadAudioFile, NULL); | |
254 break; | |
255 | |
256 case evPrev: | |
257 uiPrev(); | |
258 break; | |
259 | |
260 case evNext: | |
261 uiNext(); | |
262 break; | |
263 | |
264 case evPlaylist: | |
265 gtkShow(evPlaylist, NULL); | |
266 break; | |
267 | |
268 case evSkinBrowser: | |
269 gtkShow(evSkinBrowser, skinName); | |
270 break; | |
271 | |
272 case evAbout: | |
273 gtkShow(evAbout, NULL); | |
274 break; | |
275 | |
276 case evPreferences: | |
277 gtkShow(evPreferences, NULL); | |
278 break; | |
279 | |
280 case evEqualizer: | |
281 gtkShow(evEqualizer, NULL); | |
282 break; | |
283 | |
284 case evForward10min: | |
285 uiRelSeek(600); | |
286 break; | |
287 | |
288 case evBackward10min: | |
289 uiRelSeek(-600); | |
290 break; | |
291 | |
292 case evForward1min: | |
293 uiRelSeek(60); | |
294 break; | |
295 | |
296 case evBackward1min: | |
297 uiRelSeek(-60); | |
298 break; | |
299 | |
300 case evForward10sec: | |
301 uiRelSeek(10); | |
302 break; | |
303 | |
304 case evBackward10sec: | |
305 uiRelSeek(-10); | |
306 break; | |
307 | |
308 case evSetMoviePosition: | |
36931 | 309 guiInfo.Position = param; |
310 uiAbsSeek(guiInfo.Position); | |
35771 | 311 break; |
312 | |
313 case evIncVolume: | |
36894
669e2f7fb150
Directly call mplayer_put_key() instead of vo_x11_putkey().
ib
parents:
36772
diff
changeset
|
314 mplayer_put_key(KEY_VOLUME_UP); |
35771 | 315 break; |
316 | |
317 case evDecVolume: | |
36894
669e2f7fb150
Directly call mplayer_put_key() instead of vo_x11_putkey().
ib
parents:
36772
diff
changeset
|
318 mplayer_put_key(KEY_VOLUME_DOWN); |
35771 | 319 break; |
320 | |
321 case evMute: | |
322 mixer_mute(mixer); | |
323 break; | |
324 | |
325 case evSetVolume: | |
36933 | 326 case ivSetVolume: |
35771 | 327 guiInfo.Volume = param; |
328 { | |
36902 | 329 float l = guiInfo.Volume * (100.0 - guiInfo.Balance) / 50.0; |
330 float r = guiInfo.Volume * guiInfo.Balance / 50.0; | |
35771 | 331 mixer_setvolume(mixer, FFMIN(l, guiInfo.Volume), FFMIN(r, guiInfo.Volume)); |
332 } | |
333 | |
36956 | 334 if (ev == ivSetVolume) |
36933 | 335 break; |
336 | |
35771 | 337 if (osd_level) { |
338 osd_visible = (GetTimerMS() + 1000) | 1; | |
339 vo_osd_progbar_type = OSD_VOLUME; | |
36902 | 340 vo_osd_progbar_value = guiInfo.Volume * 256.0 / 100.0; |
35771 | 341 vo_osd_changed(OSDTYPE_PROGBAR); |
342 } | |
343 | |
344 break; | |
345 | |
346 case evSetBalance: | |
347 guiInfo.Balance = param; | |
348 mixer_setbalance(mixer, (guiInfo.Balance - 50.0) / 50.0); // transform 0..100 to -1..1 | |
36935 | 349 uiEvent(ivSetVolume, guiInfo.Volume); |
35771 | 350 |
351 if (osd_level) { | |
352 osd_visible = (GetTimerMS() + 1000) | 1; | |
353 vo_osd_progbar_type = OSD_BALANCE; | |
36902 | 354 vo_osd_progbar_value = guiInfo.Balance * 256.0 / 100.0; |
35771 | 355 vo_osd_changed(OSDTYPE_PROGBAR); |
356 } | |
357 | |
358 break; | |
359 | |
360 case evMenu: | |
361 /*if (guiApp.menuIsPresent) NOTE TO MYSELF: Uncomment only after mouse | |
362 * { pointer and cursor keys work | |
363 * gtkShow( ivHidePopUpMenu,NULL ); with this menu from skin as | |
364 * uiMenuShow( 0,0 ); they do with normal menus. | |
365 * } | |
366 * else*/gtkShow(ivShowPopUpMenu, NULL); | |
367 break; | |
368 | |
369 case evIconify: | |
370 | |
371 switch (iparam) { | |
372 case 0: | |
373 wsWindowIconify(&guiApp.mainWindow); | |
374 break; | |
375 | |
376 case 1: | |
377 wsWindowIconify(&guiApp.videoWindow); | |
378 break; | |
379 } | |
380 | |
381 break; | |
382 | |
383 case evHalfSize: | |
384 | |
385 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
386 if (guiApp.videoWindow.isFullScreen) { | |
387 uiFullScreen(); | |
388 } | |
389 | |
390 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2); | |
391 btnSet(evFullScreen, btnReleased); | |
392 } | |
393 | |
394 break; | |
395 | |
396 case evDoubleSize: | |
397 | |
398 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
399 if (guiApp.videoWindow.isFullScreen) { | |
400 uiFullScreen(); | |
401 } | |
402 | |
403 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2); | |
404 wsWindowMoveWithin(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); | |
405 btnSet(evFullScreen, btnReleased); | |
406 } | |
407 | |
408 break; | |
409 | |
410 case evNormalSize: | |
411 | |
412 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
413 if (guiApp.videoWindow.isFullScreen) { | |
414 uiFullScreen(); | |
415 } | |
416 | |
417 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight); | |
418 btnSet(evFullScreen, btnReleased); | |
419 break; | |
420 } else if (!guiApp.videoWindow.isFullScreen) | |
421 break; | |
422 | |
423 case evFullScreen: | |
424 | |
425 if (guiInfo.VideoWindow && (guiInfo.Playing || !iparam)) { | |
426 uiFullScreen(); | |
427 | |
428 if (!guiApp.videoWindow.isFullScreen) | |
429 wsWindowResize(&guiApp.videoWindow, iparam ? guiInfo.VideoWidth : guiApp.video.width, iparam ? guiInfo.VideoHeight : guiApp.video.height); | |
430 } | |
431 | |
432 if (guiApp.videoWindow.isFullScreen) | |
433 btnSet(evFullScreen, btnPressed); | |
434 else | |
435 btnSet(evFullScreen, btnReleased); | |
436 | |
437 break; | |
438 | |
439 case evSetAspect: | |
440 | |
441 switch (iparam) { | |
442 case 2: | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
443 aspect = 16.0f / 9.0f; |
35771 | 444 break; |
445 | |
446 case 3: | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
447 aspect = 4.0f / 3.0f; |
35771 | 448 break; |
449 | |
450 case 4: | |
36276 | 451 aspect = 2.35f; |
35771 | 452 break; |
453 | |
454 case 1: | |
455 default: | |
36272
aa0011dfbfdc
Use again special value -1 to set original aspect ratio.
ib
parents:
36264
diff
changeset
|
456 aspect = -1; |
35771 | 457 } |
458 | |
36274 | 459 snprintf(cmd, sizeof(cmd), "pausing_keep switch_ratio %f", aspect); |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
460 mp_input_queue_cmd(mp_input_parse_cmd(cmd)); |
35771 | 461 |
462 break; | |
463 | |
464 /* timer events */ | |
465 case ivRedraw: | |
466 { | |
35775 | 467 unsigned int now = GetTimerMS(); |
35771 | 468 |
469 if ((now > last_redraw_time) && | |
470 (now < last_redraw_time + GUI_REDRAW_WAIT) && | |
471 !uiPlaybarFade && (iparam == 0)) | |
472 break; | |
473 | |
474 last_redraw_time = now; | |
475 } | |
476 uiMainRender = True; | |
477 wsWindowRedraw(&guiApp.mainWindow); | |
478 wsWindowRedraw(&guiApp.playbarWindow); | |
479 break; | |
480 | |
481 /* system events */ | |
482 case evNone: | |
35773 | 483 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: evNone\n"); |
35771 | 484 break; |
485 | |
486 default: | |
35773 | 487 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: unknown event %d, param %.2f\n", ev, param); |
35771 | 488 break; |
489 } | |
490 } | |
23077 | 491 |
35437 | 492 /** |
493 * @brief Switch video window fullscreen mode. | |
494 * | |
495 * Switch normal video to fullscreen and fullscreen video to normal. | |
496 */ | |
33555 | 497 void uiFullScreen(void) |
23077 | 498 { |
33960 | 499 if (!guiInfo.VideoWindow) |
32881 | 500 return; |
501 | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
502 wsWindowFullscreen(&guiApp.videoWindow); |
23077 | 503 |
34697 | 504 vo_fs = guiApp.videoWindow.isFullScreen; |
23077 | 505 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
506 wsWindowLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 507 |
33555 | 508 if (guiApp.menuIsPresent) |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
509 wsWindowLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); |
23077 | 510 } |
511 | |
35437 | 512 /** |
513 * @brief Switch to play mode. | |
514 */ | |
33555 | 515 void uiPlay(void) |
23077 | 516 { |
34401
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
517 if (guiInfo.Playing == GUI_PLAY) |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
518 return; |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
519 |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
520 if (guiInfo.StreamType != STREAMTYPE_CDDA && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
521 guiInfo.StreamType != STREAMTYPE_VCD && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
522 guiInfo.StreamType != STREAMTYPE_DVD && |
36429 | 523 guiInfo.StreamType != STREAMTYPE_TV && |
524 guiInfo.StreamType != STREAMTYPE_DVB && | |
34401
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
525 (!guiInfo.Filename || (guiInfo.Filename[0] == 0))) |
32881 | 526 return; |
23077 | 527 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
528 if (guiInfo.Playing == GUI_PAUSE) { |
33555 | 529 uiPause(); |
32881 | 530 return; |
531 } | |
532 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
533 gui(GUI_SET_STATE, (void *)GUI_PLAY); |
23077 | 534 } |
535 | |
35437 | 536 /** |
537 * @brief Switch to pause mode. | |
538 */ | |
33555 | 539 void uiPause(void) |
23077 | 540 { |
33555 | 541 if (!guiInfo.Playing) |
32881 | 542 return; |
543 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
544 if (guiInfo.Playing == GUI_PLAY) { |
32881 | 545 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); |
35433 | 546 |
35432 | 547 if (cmd) { |
35433 | 548 cmd->id = MP_CMD_PAUSE; |
549 cmd->name = strdup("pause"); | |
550 mp_input_queue_cmd(cmd); | |
35432 | 551 } |
32881 | 552 } else |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
553 guiInfo.Playing = GUI_PLAY; |
23077 | 554 } |
555 | |
35437 | 556 /** |
557 * @brief Adjust GUI items to reflect current state (i.e. current playing mode). | |
558 */ | |
33555 | 559 void uiState(void) |
32881 | 560 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
561 if (guiInfo.Playing == GUI_STOP || guiInfo.Playing == GUI_PAUSE) { |
33978 | 562 btnSet(evPlaySwitchToPause, btnReleased); |
563 btnSet(evPauseSwitchToPlay, btnDisabled); | |
32881 | 564 } else { |
35434 | 565 btnSet(evPauseSwitchToPlay, btnReleased); |
33978 | 566 btnSet(evPlaySwitchToPause, btnDisabled); |
32881 | 567 } |
23077 | 568 } |
569 | |
35437 | 570 /** |
571 * @brief Seek new playback position. | |
572 * | |
35438 | 573 * The new position is a relative one. |
35437 | 574 * |
575 * @param sec seconds to seek (either forward (> 0) or backward (< 0)) | |
576 */ | |
33555 | 577 void uiRelSeek(float sec) |
32881 | 578 { |
32971 | 579 rel_seek_secs = sec; |
32881 | 580 abs_seek_pos = 0; |
581 } | |
582 | |
35437 | 583 /** |
584 * @brief Seek new playback position. | |
585 * | |
35438 | 586 * The new position is an absolute one. |
35437 | 587 * |
588 * @param percent percentage of playback time to position to | |
589 */ | |
33555 | 590 void uiAbsSeek(float percent) |
32881 | 591 { |
32971 | 592 rel_seek_secs = percent / 100.0; |
35431 | 593 abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR; |
23077 | 594 } |
595 | |
35437 | 596 /** |
597 * @brief Change to a different skin. | |
598 * | |
599 * @param name name of the skin to change to | |
600 */ | |
33555 | 601 void uiChangeSkin(char *name) |
23077 | 602 { |
35799 | 603 int was_menu, was_playbar; |
32881 | 604 |
35799 | 605 was_menu = guiApp.menuIsPresent; |
606 was_playbar = guiApp.playbarIsPresent; | |
32881 | 607 |
35493 | 608 mainVisible = False; |
32881 | 609 |
32893 | 610 if (skinRead(name) != 0) { |
611 if (skinRead(skinName) != 0) { | |
36694 | 612 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_GUI_MSG_SkinCfgError, skinName); |
35801
98693cc5df48
Exit GUI if we can't return to the skin we started with.
ib
parents:
35800
diff
changeset
|
613 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32893 | 614 } |
32881 | 615 } |
616 | |
35800 | 617 /* reload main window (must be first!) */ |
23077 | 618 |
35800 | 619 uiMainDone(); |
620 uiMainInit(); | |
32881 | 621 |
35800 | 622 wsWindowVisibility(&guiApp.mainWindow, wsShowWindow); |
623 mainVisible = True; | |
23077 | 624 |
35805 | 625 /* adjust video window */ |
23077 | 626 |
35805 | 627 if (guiApp.video.Bitmap.Image) { |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
628 wsImageResize(&guiApp.videoWindow, guiApp.video.Bitmap.Width, guiApp.video.Bitmap.Height); |
35805 | 629 wsImageRender(&guiApp.videoWindow, guiApp.video.Bitmap.Image); |
630 } | |
32881 | 631 |
35805 | 632 if (!guiInfo.Playing) { |
633 if (!guiApp.videoWindow.isFullScreen) { | |
35806 | 634 wsWindowResize(&guiApp.videoWindow, guiApp.video.width, guiApp.video.height); |
635 wsWindowMove(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); | |
636 } | |
32881 | 637 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
638 wsWindowRedraw(&guiApp.videoWindow); |
35805 | 639 } |
32881 | 640 |
34684 | 641 /* reload playbar */ |
32881 | 642 |
35799 | 643 if (was_playbar) |
35796
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35795
diff
changeset
|
644 uiPlaybarDone(); |
32881 | 645 |
33555 | 646 uiPlaybarInit(); |
23077 | 647 |
35800 | 648 /* reload menu window */ |
649 | |
35804
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
650 if (was_menu) |
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
651 uiMenuDone(); |
32881 | 652 |
35804
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
653 uiMenuInit(); |
35800 | 654 |
655 /* */ | |
32881 | 656 |
34697 | 657 btnSet(evFullScreen, (guiApp.videoWindow.isFullScreen ? btnPressed : btnReleased)); |
23077 | 658 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
659 wsWindowLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
660 wsWindowLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 661 } |
662 | |
35437 | 663 /** |
35452 | 664 * @brief Set the file to be played. |
35437 | 665 * |
666 * @param dir directory (optional, else NULL) | |
667 * @param name filename | |
668 * @param type stream type of the file | |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
669 * |
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
670 * @note All #guiInfo members associated with the file will be cleared. |
35437 | 671 */ |
35968 | 672 void uiSetFile(const char *dir, const char *name, int type) |
32881 | 673 { |
674 if (!dir) | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
675 setdup(&guiInfo.Filename, name); |
32881 | 676 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
677 setddup(&guiInfo.Filename, dir, name); |
23077 | 678 |
34064 | 679 filename = guiInfo.Filename; |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34387
diff
changeset
|
680 |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
681 if (type != SAME_STREAMTYPE) { |
34400 | 682 guiInfo.StreamType = type; |
35568 | 683 uiUnsetMedia(False); |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
684 } |
23077 | 685 } |
686 | |
35437 | 687 /** |
35453 | 688 * @brief Unset the file being played. |
689 */ | |
690 void uiUnsetFile(void) | |
691 { | |
692 uiSetFile(NULL, NULL, STREAMTYPE_DUMMY); | |
693 } | |
694 | |
695 /** | |
35562 | 696 * @brief Unset media information. |
35568 | 697 * |
698 * @param totals whether to unset number of chapters and angles (#True) or | |
699 * just track, chapter and angle (#False) as well | |
35562 | 700 */ |
35568 | 701 void uiUnsetMedia(int totals) |
35562 | 702 { |
703 guiInfo.VideoWidth = 0; | |
704 guiInfo.VideoHeight = 0; | |
705 guiInfo.AudioChannels = 0; | |
706 guiInfo.RunningTime = 0; | |
35568 | 707 |
708 if (totals) { | |
709 guiInfo.Chapters = 0; | |
710 guiInfo.Angles = 0; | |
711 } else { | |
35569 | 712 guiInfo.Track = 0; |
713 guiInfo.Chapter = 0; | |
714 guiInfo.Angle = 0; | |
35568 | 715 } |
35562 | 716 |
717 nfree(guiInfo.CodecName); | |
718 nfree(guiInfo.AudioFilename); | |
719 nfree(guiInfo.SubtitleFilename); | |
720 } | |
721 | |
722 /** | |
35437 | 723 * @brief Set file to be played to current playlist entry. |
724 */ | |
33555 | 725 void uiCurr(void) |
23077 | 726 { |
32881 | 727 plItem *curr; |
23077 | 728 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
729 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 730 return; |
23077 | 731 |
33555 | 732 switch (guiInfo.StreamType) { |
34387 | 733 case STREAMTYPE_CDDA: |
34077 | 734 case STREAMTYPE_VCD: |
735 case STREAMTYPE_DVD: | |
36429 | 736 case STREAMTYPE_TV: |
737 case STREAMTYPE_DVB: | |
35433 | 738 |
32881 | 739 break; |
740 | |
741 default: | |
742 | |
34663 | 743 curr = listMgr(PLAYLIST_ITEM_GET_CURR, 0); |
32881 | 744 |
745 if (curr) { | |
35452 | 746 uiSetFile(curr->path, curr->name, STREAMTYPE_FILE); |
35493 | 747 guiInfo.PlaylistNext = False; |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
748 guiInfo.Track = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, curr); |
32881 | 749 break; |
750 } | |
751 | |
752 return; | |
753 } | |
754 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
755 if (guiInfo.Playing == GUI_PLAY) |
35773 | 756 uiEvent(evPlay, 0); |
23077 | 757 } |
758 | |
35437 | 759 /** |
760 * @brief Switch to previous playback track. | |
761 */ | |
33555 | 762 void uiPrev(void) |
23077 | 763 { |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
764 int stop = False, unset = True; |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
765 plItem *prev = NULL; |
32881 | 766 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
767 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 768 return; |
769 | |
33555 | 770 switch (guiInfo.StreamType) { |
34387 | 771 case STREAMTYPE_CDDA: |
35426 | 772 |
34387 | 773 if (--guiInfo.Track == 0) { |
774 guiInfo.Track = 1; | |
35493 | 775 stop = True; |
34387 | 776 } |
35426 | 777 |
34387 | 778 break; |
779 | |
34077 | 780 case STREAMTYPE_VCD: |
35426 | 781 |
34077 | 782 if (--guiInfo.Track == 1) { |
783 guiInfo.Track = 2; | |
35493 | 784 stop = True; |
34077 | 785 } |
35426 | 786 |
34077 | 787 break; |
788 | |
32881 | 789 case STREAMTYPE_DVD: |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
790 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
791 if (--guiInfo.Chapter == 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
792 guiInfo.Chapter = 1; |
32881 | 793 |
35428 | 794 if (--guiInfo.Track == 0) { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
795 guiInfo.Track = 1; |
35493 | 796 stop = True; |
32881 | 797 } |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
798 } else |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
799 unset = False; |
32881 | 800 |
801 break; | |
802 | |
36429 | 803 case STREAMTYPE_TV: |
804 case STREAMTYPE_DVB: | |
805 | |
806 if (guiInfo.Playing == GUI_PLAY) | |
807 mp_input_queue_cmd(mp_input_parse_cmd("tv_step_channel -1")); | |
808 | |
809 return; | |
810 | |
32881 | 811 default: |
812 | |
34663 | 813 prev = listMgr(PLAYLIST_ITEM_GET_PREV, 0); |
32881 | 814 |
815 if (prev) { | |
35452 | 816 uiSetFile(prev->path, prev->name, STREAMTYPE_FILE); |
35500 | 817 guiInfo.PlaylistNext = !guiInfo.Playing; |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
818 guiInfo.Track = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, prev); |
32881 | 819 break; |
820 } | |
821 | |
822 return; | |
823 } | |
824 | |
825 if (stop) | |
35773 | 826 uiEvent(evStop, 0); |
32881 | 827 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
828 if (guiInfo.Playing == GUI_PLAY) |
35773 | 829 uiEvent(evPlay, 0); |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
830 else if (!stop && !prev && unset) |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
831 uiUnsetMedia(True); |
23077 | 832 } |
833 | |
35437 | 834 /** |
835 * @brief Switch to next playback track. | |
836 */ | |
33555 | 837 void uiNext(void) |
23077 | 838 { |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
839 int stop = False, unset = True; |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
840 plItem *next = NULL; |
23077 | 841 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
842 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 843 return; |
844 | |
33555 | 845 switch (guiInfo.StreamType) { |
34387 | 846 case STREAMTYPE_CDDA: |
35425 | 847 case STREAMTYPE_VCD: |
34387 | 848 |
849 if (++guiInfo.Track > guiInfo.Tracks) { | |
850 guiInfo.Track = guiInfo.Tracks; | |
35493 | 851 stop = True; |
34387 | 852 } |
853 | |
854 break; | |
855 | |
32881 | 856 case STREAMTYPE_DVD: |
857 | |
35570 | 858 if (guiInfo.Chapter++ >= guiInfo.Chapters) { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
859 guiInfo.Chapter = 1; |
32881 | 860 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
861 if (++guiInfo.Track > guiInfo.Tracks) { |
35561 | 862 guiInfo.Track = guiInfo.Tracks; |
35560
1a2200a93ea8
Make DVD stop if manually advancing beyond last chapter of last track.
ib
parents:
35528
diff
changeset
|
863 guiInfo.Chapter = guiInfo.Chapters; |
35493 | 864 stop = True; |
32881 | 865 } |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
866 } else |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
867 unset = False; |
32881 | 868 |
869 break; | |
870 | |
36429 | 871 case STREAMTYPE_TV: |
872 case STREAMTYPE_DVB: | |
873 | |
874 if (guiInfo.Playing == GUI_PLAY) | |
875 mp_input_queue_cmd(mp_input_parse_cmd("tv_step_channel 1")); | |
876 | |
877 return; | |
878 | |
32881 | 879 default: |
880 | |
34663 | 881 next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0); |
32881 | 882 |
883 if (next) { | |
35452 | 884 uiSetFile(next->path, next->name, STREAMTYPE_FILE); |
35500 | 885 guiInfo.PlaylistNext = !guiInfo.Playing; |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
886 guiInfo.Track = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, next); |
32881 | 887 break; |
888 } | |
889 | |
890 return; | |
891 } | |
892 | |
893 if (stop) | |
35773 | 894 uiEvent(evStop, 0); |
32881 | 895 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
896 if (guiInfo.Playing == GUI_PLAY) |
35773 | 897 uiEvent(evPlay, 0); |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
898 else if (!stop && !next && unset) |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
899 uiUnsetMedia(True); |
23077 | 900 } |