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