Mercurial > mplayer.hg
annotate gui/ui/actions.c @ 36815:4c44fdd14655
Fix issue with Win32 GUI default preferences.
Don't (mis)use option variables to set defaults (and then don't use
them when actually setting the defaults in the preferences dialog).
Set them directly (and correctly) instead, and use proper symbolic
constants.
author | ib |
---|---|
date | Sun, 23 Feb 2014 19:33:46 +0000 |
parents | 0da6c7ff95d2 |
children | 669e2f7fb150 |
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" | |
48 #include "mp_msg.h" | |
49 #include "mpcommon.h" | |
50 #include "mplayer.h" | |
32881 | 51 #include "input/input.h" |
35431 | 52 #include "libmpdemux/demuxer.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
53 #include "libvo/video_out.h" |
35771 | 54 #include "libvo/wskeys.h" |
55 #include "libvo/x11_common.h" | |
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 { |
96 int iparam = (int)param, osd; | |
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 |
35792 | 202 guiInfo.NewPlay = GUI_FILE_NEW; |
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 |
216 guiInfo.NewPlay = GUI_FILE_SAME; | |
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: | |
309 uiAbsSeek(param); | |
310 break; | |
311 | |
312 case evIncVolume: | |
313 vo_x11_putkey(wsGrayMul); | |
314 break; | |
315 | |
316 case evDecVolume: | |
317 vo_x11_putkey(wsGrayDiv); | |
318 break; | |
319 | |
320 case evMute: | |
321 mixer_mute(mixer); | |
322 break; | |
323 | |
324 case evSetVolume: | |
325 guiInfo.Volume = param; | |
326 { | |
327 float l = guiInfo.Volume * ((100.0 - guiInfo.Balance) / 50.0); | |
328 float r = guiInfo.Volume * ((guiInfo.Balance) / 50.0); | |
329 mixer_setvolume(mixer, FFMIN(l, guiInfo.Volume), FFMIN(r, guiInfo.Volume)); | |
330 } | |
331 | |
332 if (osd_level) { | |
333 osd_visible = (GetTimerMS() + 1000) | 1; | |
334 vo_osd_progbar_type = OSD_VOLUME; | |
335 vo_osd_progbar_value = ((guiInfo.Volume) * 256.0) / 100.0; | |
336 vo_osd_changed(OSDTYPE_PROGBAR); | |
337 } | |
338 | |
339 break; | |
340 | |
341 case evSetBalance: | |
342 guiInfo.Balance = param; | |
343 mixer_setbalance(mixer, (guiInfo.Balance - 50.0) / 50.0); // transform 0..100 to -1..1 | |
344 osd = osd_level; | |
345 osd_level = 0; | |
35773 | 346 uiEvent(evSetVolume, guiInfo.Volume); |
35771 | 347 osd_level = osd; |
348 | |
349 if (osd_level) { | |
350 osd_visible = (GetTimerMS() + 1000) | 1; | |
351 vo_osd_progbar_type = OSD_BALANCE; | |
352 vo_osd_progbar_value = ((guiInfo.Balance) * 256.0) / 100.0; | |
353 vo_osd_changed(OSDTYPE_PROGBAR); | |
354 } | |
355 | |
356 break; | |
357 | |
358 case evMenu: | |
359 /*if (guiApp.menuIsPresent) NOTE TO MYSELF: Uncomment only after mouse | |
360 * { pointer and cursor keys work | |
361 * gtkShow( ivHidePopUpMenu,NULL ); with this menu from skin as | |
362 * uiMenuShow( 0,0 ); they do with normal menus. | |
363 * } | |
364 * else*/gtkShow(ivShowPopUpMenu, NULL); | |
365 break; | |
366 | |
367 case evIconify: | |
368 | |
369 switch (iparam) { | |
370 case 0: | |
371 wsWindowIconify(&guiApp.mainWindow); | |
372 break; | |
373 | |
374 case 1: | |
375 wsWindowIconify(&guiApp.videoWindow); | |
376 break; | |
377 } | |
378 | |
379 break; | |
380 | |
381 case evHalfSize: | |
382 | |
383 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
384 if (guiApp.videoWindow.isFullScreen) { | |
385 uiFullScreen(); | |
386 } | |
387 | |
388 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth / 2, guiInfo.VideoHeight / 2); | |
389 btnSet(evFullScreen, btnReleased); | |
390 } | |
391 | |
392 break; | |
393 | |
394 case evDoubleSize: | |
395 | |
396 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
397 if (guiApp.videoWindow.isFullScreen) { | |
398 uiFullScreen(); | |
399 } | |
400 | |
401 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth * 2, guiInfo.VideoHeight * 2); | |
402 wsWindowMoveWithin(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); | |
403 btnSet(evFullScreen, btnReleased); | |
404 } | |
405 | |
406 break; | |
407 | |
408 case evNormalSize: | |
409 | |
410 if (guiInfo.VideoWindow && guiInfo.Playing) { | |
411 if (guiApp.videoWindow.isFullScreen) { | |
412 uiFullScreen(); | |
413 } | |
414 | |
415 wsWindowResize(&guiApp.videoWindow, guiInfo.VideoWidth, guiInfo.VideoHeight); | |
416 btnSet(evFullScreen, btnReleased); | |
417 break; | |
418 } else if (!guiApp.videoWindow.isFullScreen) | |
419 break; | |
420 | |
421 case evFullScreen: | |
422 | |
423 if (guiInfo.VideoWindow && (guiInfo.Playing || !iparam)) { | |
424 uiFullScreen(); | |
425 | |
426 if (!guiApp.videoWindow.isFullScreen) | |
427 wsWindowResize(&guiApp.videoWindow, iparam ? guiInfo.VideoWidth : guiApp.video.width, iparam ? guiInfo.VideoHeight : guiApp.video.height); | |
428 } | |
429 | |
430 if (guiApp.videoWindow.isFullScreen) | |
431 btnSet(evFullScreen, btnPressed); | |
432 else | |
433 btnSet(evFullScreen, btnReleased); | |
434 | |
435 break; | |
436 | |
437 case evSetAspect: | |
438 | |
439 switch (iparam) { | |
440 case 2: | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
441 aspect = 16.0f / 9.0f; |
35771 | 442 break; |
443 | |
444 case 3: | |
36262
703a51ce08c8
Enable the change of the movie aspect ratio on the fly.
ib
parents:
36032
diff
changeset
|
445 aspect = 4.0f / 3.0f; |
35771 | 446 break; |
447 | |
448 case 4: | |
36276 | 449 aspect = 2.35f; |
35771 | 450 break; |
451 | |
452 case 1: | |
453 default: | |
36272
aa0011dfbfdc
Use again special value -1 to set original aspect ratio.
ib
parents:
36264
diff
changeset
|
454 aspect = -1; |
35771 | 455 } |
456 | |
36274 | 457 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
|
458 mp_input_queue_cmd(mp_input_parse_cmd(cmd)); |
35771 | 459 |
460 break; | |
461 | |
462 /* timer events */ | |
463 case ivRedraw: | |
464 { | |
35775 | 465 unsigned int now = GetTimerMS(); |
35771 | 466 |
467 if ((now > last_redraw_time) && | |
468 (now < last_redraw_time + GUI_REDRAW_WAIT) && | |
469 !uiPlaybarFade && (iparam == 0)) | |
470 break; | |
471 | |
472 last_redraw_time = now; | |
473 } | |
474 uiMainRender = True; | |
475 wsWindowRedraw(&guiApp.mainWindow); | |
476 wsWindowRedraw(&guiApp.playbarWindow); | |
477 break; | |
478 | |
479 /* system events */ | |
480 case evNone: | |
35773 | 481 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: evNone\n"); |
35771 | 482 break; |
483 | |
484 default: | |
35773 | 485 mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[actions] uiEvent: unknown event %d, param %.2f\n", ev, param); |
35771 | 486 break; |
487 } | |
488 } | |
23077 | 489 |
35437 | 490 /** |
491 * @brief Switch video window fullscreen mode. | |
492 * | |
493 * Switch normal video to fullscreen and fullscreen video to normal. | |
494 */ | |
33555 | 495 void uiFullScreen(void) |
23077 | 496 { |
33960 | 497 if (!guiInfo.VideoWindow) |
32881 | 498 return; |
499 | |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
500 wsWindowFullscreen(&guiApp.videoWindow); |
23077 | 501 |
34697 | 502 vo_fs = guiApp.videoWindow.isFullScreen; |
23077 | 503 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
504 wsWindowLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 505 |
33555 | 506 if (guiApp.menuIsPresent) |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
507 wsWindowLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); |
23077 | 508 } |
509 | |
35437 | 510 /** |
511 * @brief Switch to play mode. | |
512 */ | |
33555 | 513 void uiPlay(void) |
23077 | 514 { |
34401
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
515 if (guiInfo.Playing == GUI_PLAY) |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
516 return; |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
517 |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
518 if (guiInfo.StreamType != STREAMTYPE_CDDA && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
519 guiInfo.StreamType != STREAMTYPE_VCD && |
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
520 guiInfo.StreamType != STREAMTYPE_DVD && |
36429 | 521 guiInfo.StreamType != STREAMTYPE_TV && |
522 guiInfo.StreamType != STREAMTYPE_DVB && | |
34401
af8838c2b60b
Allow uiPlay() without guiInfo.Filename for some stream types.
ib
parents:
34400
diff
changeset
|
523 (!guiInfo.Filename || (guiInfo.Filename[0] == 0))) |
32881 | 524 return; |
23077 | 525 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
526 if (guiInfo.Playing == GUI_PAUSE) { |
33555 | 527 uiPause(); |
32881 | 528 return; |
529 } | |
530 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
531 gui(GUI_SET_STATE, (void *)GUI_PLAY); |
23077 | 532 } |
533 | |
35437 | 534 /** |
535 * @brief Switch to pause mode. | |
536 */ | |
33555 | 537 void uiPause(void) |
23077 | 538 { |
33555 | 539 if (!guiInfo.Playing) |
32881 | 540 return; |
541 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
542 if (guiInfo.Playing == GUI_PLAY) { |
32881 | 543 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); |
35433 | 544 |
35432 | 545 if (cmd) { |
35433 | 546 cmd->id = MP_CMD_PAUSE; |
547 cmd->name = strdup("pause"); | |
548 mp_input_queue_cmd(cmd); | |
35432 | 549 } |
32881 | 550 } else |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
551 guiInfo.Playing = GUI_PLAY; |
23077 | 552 } |
553 | |
35437 | 554 /** |
555 * @brief Adjust GUI items to reflect current state (i.e. current playing mode). | |
556 */ | |
33555 | 557 void uiState(void) |
32881 | 558 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
559 if (guiInfo.Playing == GUI_STOP || guiInfo.Playing == GUI_PAUSE) { |
33978 | 560 btnSet(evPlaySwitchToPause, btnReleased); |
561 btnSet(evPauseSwitchToPlay, btnDisabled); | |
32881 | 562 } else { |
35434 | 563 btnSet(evPauseSwitchToPlay, btnReleased); |
33978 | 564 btnSet(evPlaySwitchToPause, btnDisabled); |
32881 | 565 } |
23077 | 566 } |
567 | |
35437 | 568 /** |
569 * @brief Seek new playback position. | |
570 * | |
35438 | 571 * The new position is a relative one. |
35437 | 572 * |
573 * @param sec seconds to seek (either forward (> 0) or backward (< 0)) | |
574 */ | |
33555 | 575 void uiRelSeek(float sec) |
32881 | 576 { |
32971 | 577 rel_seek_secs = sec; |
32881 | 578 abs_seek_pos = 0; |
579 } | |
580 | |
35437 | 581 /** |
582 * @brief Seek new playback position. | |
583 * | |
35438 | 584 * The new position is an absolute one. |
35437 | 585 * |
586 * @param percent percentage of playback time to position to | |
587 */ | |
33555 | 588 void uiAbsSeek(float percent) |
32881 | 589 { |
32971 | 590 rel_seek_secs = percent / 100.0; |
35431 | 591 abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR; |
23077 | 592 } |
593 | |
35437 | 594 /** |
595 * @brief Change to a different skin. | |
596 * | |
597 * @param name name of the skin to change to | |
598 */ | |
33555 | 599 void uiChangeSkin(char *name) |
23077 | 600 { |
35799 | 601 int was_menu, was_playbar; |
32881 | 602 |
35799 | 603 was_menu = guiApp.menuIsPresent; |
604 was_playbar = guiApp.playbarIsPresent; | |
32881 | 605 |
35493 | 606 mainVisible = False; |
32881 | 607 |
32893 | 608 if (skinRead(name) != 0) { |
609 if (skinRead(skinName) != 0) { | |
36694 | 610 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
|
611 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32893 | 612 } |
32881 | 613 } |
614 | |
35800 | 615 /* reload main window (must be first!) */ |
23077 | 616 |
35800 | 617 uiMainDone(); |
618 uiMainInit(); | |
32881 | 619 |
35800 | 620 wsWindowVisibility(&guiApp.mainWindow, wsShowWindow); |
621 mainVisible = True; | |
23077 | 622 |
35805 | 623 /* adjust video window */ |
23077 | 624 |
35805 | 625 if (guiApp.video.Bitmap.Image) { |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
626 wsImageResize(&guiApp.videoWindow, guiApp.video.Bitmap.Width, guiApp.video.Bitmap.Height); |
35805 | 627 wsImageRender(&guiApp.videoWindow, guiApp.video.Bitmap.Image); |
628 } | |
32881 | 629 |
35805 | 630 if (!guiInfo.Playing) { |
631 if (!guiApp.videoWindow.isFullScreen) { | |
35806 | 632 wsWindowResize(&guiApp.videoWindow, guiApp.video.width, guiApp.video.height); |
633 wsWindowMove(&guiApp.videoWindow, False, guiApp.video.x, guiApp.video.y); | |
634 } | |
32881 | 635 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
636 wsWindowRedraw(&guiApp.videoWindow); |
35805 | 637 } |
32881 | 638 |
34684 | 639 /* reload playbar */ |
32881 | 640 |
35799 | 641 if (was_playbar) |
35796
497a1c45a597
Add uiMainDone(), uiVideoDone(), uiPlaybarDone() and uiMenuDone().
ib
parents:
35795
diff
changeset
|
642 uiPlaybarDone(); |
32881 | 643 |
33555 | 644 uiPlaybarInit(); |
23077 | 645 |
35800 | 646 /* reload menu window */ |
647 | |
35804
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
648 if (was_menu) |
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
649 uiMenuDone(); |
32881 | 650 |
35804
25852c740093
Remove code almost identical to uiMenuDone() plus uiMenuInit().
ib
parents:
35801
diff
changeset
|
651 uiMenuInit(); |
35800 | 652 |
653 /* */ | |
32881 | 654 |
33555 | 655 btnModify(evSetVolume, guiInfo.Volume); |
656 btnModify(evSetBalance, guiInfo.Balance); | |
657 btnModify(evSetMoviePosition, guiInfo.Position); | |
34697 | 658 btnSet(evFullScreen, (guiApp.videoWindow.isFullScreen ? btnPressed : btnReleased)); |
23077 | 659 |
35681
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
660 wsWindowLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.videoWindow.isFullScreen); |
80c5c89f77d6
Cosmetic: Rename ws functions for the sake of consistency.
ib
parents:
35658
diff
changeset
|
661 wsWindowLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.videoWindow.isFullScreen); |
32881 | 662 } |
663 | |
35437 | 664 /** |
35452 | 665 * @brief Set the file to be played. |
35437 | 666 * |
667 * @param dir directory (optional, else NULL) | |
668 * @param name filename | |
669 * @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
|
670 * |
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
671 * @note All #guiInfo members associated with the file will be cleared. |
35437 | 672 */ |
35968 | 673 void uiSetFile(const char *dir, const char *name, int type) |
32881 | 674 { |
675 if (!dir) | |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
676 setdup(&guiInfo.Filename, name); |
32881 | 677 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
678 setddup(&guiInfo.Filename, dir, name); |
23077 | 679 |
34064 | 680 filename = guiInfo.Filename; |
34399
f2c03009068d
Don't explicitly set stream type if the type doesn't change.
ib
parents:
34387
diff
changeset
|
681 |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
682 if (type != SAME_STREAMTYPE) { |
34400 | 683 guiInfo.StreamType = type; |
35568 | 684 uiUnsetMedia(False); |
35483
8ac7761bcb7c
Clear information associated with a file when setting a new one.
ib
parents:
35462
diff
changeset
|
685 } |
23077 | 686 } |
687 | |
35437 | 688 /** |
35453 | 689 * @brief Unset the file being played. |
690 */ | |
691 void uiUnsetFile(void) | |
692 { | |
693 uiSetFile(NULL, NULL, STREAMTYPE_DUMMY); | |
694 } | |
695 | |
696 /** | |
35562 | 697 * @brief Unset media information. |
35568 | 698 * |
699 * @param totals whether to unset number of chapters and angles (#True) or | |
700 * just track, chapter and angle (#False) as well | |
35562 | 701 */ |
35568 | 702 void uiUnsetMedia(int totals) |
35562 | 703 { |
704 guiInfo.VideoWidth = 0; | |
705 guiInfo.VideoHeight = 0; | |
706 guiInfo.AudioChannels = 0; | |
707 guiInfo.RunningTime = 0; | |
35568 | 708 |
709 if (totals) { | |
710 guiInfo.Chapters = 0; | |
711 guiInfo.Angles = 0; | |
712 } else { | |
35569 | 713 guiInfo.Track = 0; |
714 guiInfo.Chapter = 0; | |
715 guiInfo.Angle = 0; | |
35568 | 716 } |
35562 | 717 |
718 nfree(guiInfo.CodecName); | |
719 nfree(guiInfo.AudioFilename); | |
720 nfree(guiInfo.SubtitleFilename); | |
721 } | |
722 | |
723 /** | |
35437 | 724 * @brief Set file to be played to current playlist entry. |
725 */ | |
33555 | 726 void uiCurr(void) |
23077 | 727 { |
32881 | 728 plItem *curr; |
23077 | 729 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
730 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 731 return; |
23077 | 732 |
33555 | 733 switch (guiInfo.StreamType) { |
34387 | 734 case STREAMTYPE_CDDA: |
34077 | 735 case STREAMTYPE_VCD: |
736 case STREAMTYPE_DVD: | |
36429 | 737 case STREAMTYPE_TV: |
738 case STREAMTYPE_DVB: | |
35433 | 739 |
32881 | 740 break; |
741 | |
742 default: | |
743 | |
34663 | 744 curr = listMgr(PLAYLIST_ITEM_GET_CURR, 0); |
32881 | 745 |
746 if (curr) { | |
35452 | 747 uiSetFile(curr->path, curr->name, STREAMTYPE_FILE); |
35493 | 748 guiInfo.PlaylistNext = False; |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
749 guiInfo.Track = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, curr); |
32881 | 750 break; |
751 } | |
752 | |
753 return; | |
754 } | |
755 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
756 if (guiInfo.Playing == GUI_PLAY) |
35773 | 757 uiEvent(evPlay, 0); |
23077 | 758 } |
759 | |
35437 | 760 /** |
761 * @brief Switch to previous playback track. | |
762 */ | |
33555 | 763 void uiPrev(void) |
23077 | 764 { |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
765 int stop = False, unset = True; |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
766 plItem *prev = NULL; |
32881 | 767 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
768 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 769 return; |
770 | |
33555 | 771 switch (guiInfo.StreamType) { |
34387 | 772 case STREAMTYPE_CDDA: |
35426 | 773 |
34387 | 774 if (--guiInfo.Track == 0) { |
775 guiInfo.Track = 1; | |
35493 | 776 stop = True; |
34387 | 777 } |
35426 | 778 |
34387 | 779 break; |
780 | |
34077 | 781 case STREAMTYPE_VCD: |
35426 | 782 |
34077 | 783 if (--guiInfo.Track == 1) { |
784 guiInfo.Track = 2; | |
35493 | 785 stop = True; |
34077 | 786 } |
35426 | 787 |
34077 | 788 break; |
789 | |
32881 | 790 case STREAMTYPE_DVD: |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
791 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
792 if (--guiInfo.Chapter == 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
793 guiInfo.Chapter = 1; |
32881 | 794 |
35428 | 795 if (--guiInfo.Track == 0) { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
796 guiInfo.Track = 1; |
35493 | 797 stop = True; |
32881 | 798 } |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
799 } else |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
800 unset = False; |
32881 | 801 |
802 break; | |
803 | |
36429 | 804 case STREAMTYPE_TV: |
805 case STREAMTYPE_DVB: | |
806 | |
807 if (guiInfo.Playing == GUI_PLAY) | |
808 mp_input_queue_cmd(mp_input_parse_cmd("tv_step_channel -1")); | |
809 | |
810 return; | |
811 | |
32881 | 812 default: |
813 | |
34663 | 814 prev = listMgr(PLAYLIST_ITEM_GET_PREV, 0); |
32881 | 815 |
816 if (prev) { | |
35452 | 817 uiSetFile(prev->path, prev->name, STREAMTYPE_FILE); |
35500 | 818 guiInfo.PlaylistNext = !guiInfo.Playing; |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
819 guiInfo.Track = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, prev); |
32881 | 820 break; |
821 } | |
822 | |
823 return; | |
824 } | |
825 | |
826 if (stop) | |
35773 | 827 uiEvent(evStop, 0); |
32881 | 828 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
829 if (guiInfo.Playing == GUI_PLAY) |
35773 | 830 uiEvent(evPlay, 0); |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
831 else if (!stop && !prev && unset) |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
832 uiUnsetMedia(True); |
23077 | 833 } |
834 | |
35437 | 835 /** |
836 * @brief Switch to next playback track. | |
837 */ | |
33555 | 838 void uiNext(void) |
23077 | 839 { |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
840 int stop = False, unset = True; |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
841 plItem *next = NULL; |
23077 | 842 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
843 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 844 return; |
845 | |
33555 | 846 switch (guiInfo.StreamType) { |
34387 | 847 case STREAMTYPE_CDDA: |
35425 | 848 case STREAMTYPE_VCD: |
34387 | 849 |
850 if (++guiInfo.Track > guiInfo.Tracks) { | |
851 guiInfo.Track = guiInfo.Tracks; | |
35493 | 852 stop = True; |
34387 | 853 } |
854 | |
855 break; | |
856 | |
32881 | 857 case STREAMTYPE_DVD: |
858 | |
35570 | 859 if (guiInfo.Chapter++ >= guiInfo.Chapters) { |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
860 guiInfo.Chapter = 1; |
32881 | 861 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
862 if (++guiInfo.Track > guiInfo.Tracks) { |
35561 | 863 guiInfo.Track = guiInfo.Tracks; |
35560
1a2200a93ea8
Make DVD stop if manually advancing beyond last chapter of last track.
ib
parents:
35528
diff
changeset
|
864 guiInfo.Chapter = guiInfo.Chapters; |
35493 | 865 stop = True; |
32881 | 866 } |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
867 } else |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
868 unset = False; |
32881 | 869 |
870 break; | |
871 | |
36429 | 872 case STREAMTYPE_TV: |
873 case STREAMTYPE_DVB: | |
874 | |
875 if (guiInfo.Playing == GUI_PLAY) | |
876 mp_input_queue_cmd(mp_input_parse_cmd("tv_step_channel 1")); | |
877 | |
878 return; | |
879 | |
32881 | 880 default: |
881 | |
34663 | 882 next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0); |
32881 | 883 |
884 if (next) { | |
35452 | 885 uiSetFile(next->path, next->name, STREAMTYPE_FILE); |
35500 | 886 guiInfo.PlaylistNext = !guiInfo.Playing; |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
887 guiInfo.Track = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, next); |
32881 | 888 break; |
889 } | |
890 | |
891 return; | |
892 } | |
893 | |
894 if (stop) | |
35773 | 895 uiEvent(evStop, 0); |
32881 | 896 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
897 if (guiInfo.Playing == GUI_PLAY) |
35773 | 898 uiEvent(evPlay, 0); |
35571
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
899 else if (!stop && !next && unset) |
29761b2b8cb0
Reset media information while changing tracks in stop mode.
ib
parents:
35570
diff
changeset
|
900 uiUnsetMedia(True); |
23077 | 901 } |