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