Mercurial > mplayer.hg
annotate gui/ui/actions.c @ 34314:b2c01a543421
ffmjpeg does not incorrectly output BGR32 anymore for ljpeg.
author | cehoyos |
---|---|
date | Thu, 08 Dec 2011 02:44:19 +0000 |
parents | deff81b57903 |
children | 0ba85cad4c7e |
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 |
19 #include <stdlib.h> | |
20 #include <string.h> | |
21 | |
33556 | 22 #include "actions.h" |
32881 | 23 #include "gmplayer.h" |
24 #include "gui/app.h" | |
25 #include "gui/interface.h" | |
26 #include "gui/skin/font.h" | |
27 #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
|
28 #include "gui/util/list.h" |
33739 | 29 #include "gui/util/mem.h" |
33737 | 30 #include "gui/util/string.h" |
32881 | 31 #include "gui/wm/wsxdnd.h" |
32 #include "widgets.h" | |
23077 | 33 |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
34 #include "config.h" |
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
35 #include "help_mp.h" |
32881 | 36 #include "input/input.h" |
30653
3d23e24c5c60
Declare externally used variables from vd.c as extern in vd.h.
diego
parents:
29263
diff
changeset
|
37 #include "libmpcodecs/vd.h" |
26382
b2f4abcf20ed
Make include paths consistent; do not use ../ in them.
diego
parents:
26365
diff
changeset
|
38 #include "libvo/video_out.h" |
32881 | 39 #include "mp_core.h" |
23077 | 40 #include "stream/stream.h" |
41 | |
33555 | 42 int uiGotoTheNext = 1; |
23077 | 43 |
33555 | 44 void uiFullScreen(void) |
23077 | 45 { |
33960 | 46 if (!guiInfo.VideoWindow) |
32881 | 47 return; |
48 | |
33960 | 49 wsFullScreen(&guiApp.subWindow); |
23077 | 50 |
33960 | 51 vo_fs = guiApp.subWindow.isFullScreen; |
23077 | 52 |
33555 | 53 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.subWindow.isFullScreen); |
32881 | 54 |
33555 | 55 if (guiApp.menuIsPresent) |
56 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.subWindow.isFullScreen); | |
32881 | 57 |
33555 | 58 if (guiInfo.Playing) |
59 wsSetBackgroundRGB(&guiApp.subWindow, 0, 0, 0); | |
32881 | 60 else |
33555 | 61 wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); |
23077 | 62 } |
63 | |
33555 | 64 void uiPlay(void) |
23077 | 65 { |
33555 | 66 if (!guiInfo.Filename || |
67 (guiInfo.Filename[0] == 0) || | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
68 (guiInfo.Playing == GUI_PLAY)) |
32881 | 69 return; |
23077 | 70 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
71 if (guiInfo.Playing == GUI_PAUSE) { |
33555 | 72 uiPause(); |
32881 | 73 return; |
74 } | |
75 | |
33731
81f71d910333
Cosmetic: Change prefix for symbolic constants from GMP to GUI.
ib
parents:
33725
diff
changeset
|
76 gui(GUI_SET_STATE, (void *)GUI_PLAY); |
33555 | 77 uiSubRender = 0; |
78 wsSetBackgroundRGB(&guiApp.subWindow, 0, 0, 0); | |
79 wsClearWindow(guiApp.subWindow); | |
23077 | 80 } |
81 | |
33555 | 82 void uiPause(void) |
23077 | 83 { |
33555 | 84 if (!guiInfo.Playing) |
32881 | 85 return; |
86 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
87 if (guiInfo.Playing == GUI_PLAY) { |
32881 | 88 mp_cmd_t *cmd = calloc(1, sizeof(*cmd)); |
89 cmd->id = MP_CMD_PAUSE; | |
90 cmd->name = strdup("pause"); | |
91 mp_input_queue_cmd(cmd); | |
92 } else | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
93 guiInfo.Playing = GUI_PLAY; |
23077 | 94 } |
95 | |
33555 | 96 void uiState(void) |
32881 | 97 { |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
98 if (guiInfo.Playing == GUI_STOP || guiInfo.Playing == GUI_PAUSE) { |
33978 | 99 btnSet(evPlaySwitchToPause, btnReleased); |
100 btnSet(evPauseSwitchToPlay, btnDisabled); | |
32881 | 101 } else { |
33978 | 102 btnSet(evPlaySwitchToPause, btnDisabled); |
103 btnSet(evPauseSwitchToPlay, btnReleased); | |
32881 | 104 } |
23077 | 105 } |
106 | |
33555 | 107 void uiRelSeek(float sec) |
32881 | 108 { |
32971 | 109 rel_seek_secs = sec; |
32881 | 110 abs_seek_pos = 0; |
111 } | |
112 | |
33555 | 113 void uiAbsSeek(float percent) |
32881 | 114 { |
32971 | 115 rel_seek_secs = percent / 100.0; |
32881 | 116 abs_seek_pos = 3; |
23077 | 117 } |
118 | |
33555 | 119 void uiChangeSkin(char *name) |
23077 | 120 { |
32893 | 121 int prev, bprev; |
32881 | 122 |
33555 | 123 prev = guiApp.menuIsPresent; |
124 bprev = guiApp.playbarIsPresent; | |
32881 | 125 |
126 mainVisible = 0; | |
127 | |
32893 | 128 if (skinRead(name) != 0) { |
129 if (skinRead(skinName) != 0) { | |
32894 | 130 mainVisible = 1; |
131 return; | |
32893 | 132 } |
32881 | 133 } |
134 | |
135 // reload menu window | |
23077 | 136 |
33555 | 137 if (prev && guiApp.menuIsPresent) { |
138 free(menuDrawBuffer); | |
139 menuDrawBuffer = calloc(1, guiApp.menu.Bitmap.ImageSize); | |
32881 | 140 |
33555 | 141 if (!menuDrawBuffer) { |
33530 | 142 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
33768 | 143 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32881 | 144 } |
23077 | 145 |
33555 | 146 wsResizeWindow(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); |
147 wsResizeImage(&guiApp.menuWindow, guiApp.menu.width, guiApp.menu.height); | |
148 wsSetShape(&guiApp.menuWindow, guiApp.menu.Mask.Image); | |
149 wsVisibleWindow(&guiApp.menuWindow, wsHideWindow); | |
32881 | 150 } else |
33555 | 151 uiMenuInit(); |
32881 | 152 |
153 // reload sub window | |
23077 | 154 |
33555 | 155 if (guiApp.sub.Bitmap.Image) |
156 wsResizeImage(&guiApp.subWindow, guiApp.sub.Bitmap.Width, guiApp.sub.Bitmap.Height); | |
32881 | 157 |
33555 | 158 if (!guiApp.subWindow.isFullScreen && !guiInfo.Playing) { |
159 wsResizeWindow(&guiApp.subWindow, guiApp.sub.width, guiApp.sub.height); | |
33993 | 160 wsMoveWindow(&guiApp.subWindow, False, guiApp.sub.x, guiApp.sub.y); |
32881 | 161 } |
162 | |
33555 | 163 if (guiApp.sub.Bitmap.Image) |
164 wsConvert(&guiApp.subWindow, guiApp.sub.Bitmap.Image); | |
23077 | 165 |
33555 | 166 if (!guiInfo.Playing) { |
167 uiSubRender = 1; | |
168 wsSetBackgroundRGB(&guiApp.subWindow, guiApp.sub.R, guiApp.sub.G, guiApp.sub.B); | |
169 wsClearWindow(guiApp.subWindow); | |
170 wsPostRedisplay(&guiApp.subWindow); | |
32881 | 171 } |
172 | |
33555 | 173 // reload playbar |
32881 | 174 |
175 if (bprev) | |
33555 | 176 wsDestroyWindow(&guiApp.playbarWindow); |
32881 | 177 |
33555 | 178 uiPlaybarInit(); |
23077 | 179 |
32881 | 180 // reload main window |
181 | |
33555 | 182 free(mainDrawBuffer); |
183 mainDrawBuffer = calloc(1, guiApp.main.Bitmap.ImageSize); | |
23077 | 184 |
33555 | 185 if (!mainDrawBuffer) { |
33530 | 186 gmp_msg(MSGT_GPLAYER, MSGL_FATAL, MSGTR_NEMDB); |
33768 | 187 mplayer(MPLAYER_EXIT_GUI, EXIT_ERROR, 0); |
32881 | 188 } |
23077 | 189 |
33555 | 190 wsDestroyWindow(&guiApp.mainWindow); |
32881 | 191 |
33555 | 192 wsCreateWindow(&guiApp.mainWindow, guiApp.main.x, guiApp.main.y, guiApp.main.width, guiApp.main.height, wsNoBorder, wsShowMouseCursor | wsHandleMouseButton | wsHandleMouseMove, wsShowFrame | wsMaxSize | wsHideWindow, "MPlayer"); |
193 wsCreateImage(&guiApp.mainWindow, guiApp.main.Bitmap.Width, guiApp.main.Bitmap.Height); | |
194 wsSetShape(&guiApp.mainWindow, guiApp.main.Mask.Image); | |
195 wsSetIcon(wsDisplay, guiApp.mainWindow.WindowID, &guiIcon); | |
23077 | 196 |
33555 | 197 guiApp.mainWindow.ReDraw = (void *)uiMainDraw; |
198 guiApp.mainWindow.MouseHandler = uiMainMouseHandle; | |
199 guiApp.mainWindow.KeyHandler = uiMainKeyHandle; | |
200 guiApp.mainWindow.DandDHandler = uiDandDHandler; | |
32881 | 201 |
33555 | 202 wsXDNDMakeAwareness(&guiApp.mainWindow); |
23077 | 203 |
33555 | 204 if (!guiApp.mainDecoration) |
205 wsWindowDecoration(&guiApp.mainWindow, 0); | |
32881 | 206 |
33555 | 207 wsVisibleWindow(&guiApp.mainWindow, wsShowWindow); |
32881 | 208 mainVisible = 1; |
209 | |
33555 | 210 btnModify(evSetVolume, guiInfo.Volume); |
211 btnModify(evSetBalance, guiInfo.Balance); | |
212 btnModify(evSetMoviePosition, guiInfo.Position); | |
33978 | 213 btnSet(evFullScreen, (guiApp.subWindow.isFullScreen ? btnPressed : btnReleased)); |
23077 | 214 |
33555 | 215 wsSetLayer(wsDisplay, guiApp.mainWindow.WindowID, guiApp.subWindow.isFullScreen); |
216 wsSetLayer(wsDisplay, guiApp.menuWindow.WindowID, guiApp.subWindow.isFullScreen); | |
32881 | 217 } |
218 | |
33555 | 219 void uiSetFileName(char *dir, char *name, int type) |
32881 | 220 { |
221 if (!name) | |
222 return; | |
23077 | 223 |
32881 | 224 if (!dir) |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
225 setdup(&guiInfo.Filename, name); |
32881 | 226 else |
33740
2c02269701bd
Remove macros guiSetFilename() and guiSetDF() from interface.h.
ib
parents:
33739
diff
changeset
|
227 setddup(&guiInfo.Filename, dir, name); |
23077 | 228 |
34064 | 229 filename = guiInfo.Filename; |
33555 | 230 guiInfo.StreamType = type; |
34064 | 231 |
33897 | 232 nfree(guiInfo.AudioFilename); |
233 nfree(guiInfo.SubtitleFilename); | |
23077 | 234 } |
235 | |
33555 | 236 void uiCurr(void) |
23077 | 237 { |
32881 | 238 plItem *curr; |
239 int stop = 0; | |
23077 | 240 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
241 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 242 return; |
23077 | 243 |
33555 | 244 switch (guiInfo.StreamType) { |
34077 | 245 #ifdef CONFIG_VCD |
246 case STREAMTYPE_VCD: | |
32881 | 247 break; |
32953 | 248 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
249 |
34077 | 250 #ifdef CONFIG_DVDREAD |
251 case STREAMTYPE_DVD: | |
32881 | 252 break; |
32953 | 253 #endif |
32881 | 254 |
255 default: | |
256 | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
257 curr = listSet(gtkGetCurrPlItem, NULL); |
32881 | 258 |
259 if (curr) { | |
33555 | 260 uiSetFileName(curr->path, curr->name, STREAMTYPE_FILE); |
261 uiGotoTheNext = 0; | |
32881 | 262 break; |
263 } | |
264 | |
265 return; | |
266 } | |
267 | |
268 if (stop) | |
33555 | 269 uiEventHandling(evStop, 0); |
32881 | 270 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
271 if (guiInfo.Playing == GUI_PLAY) |
33555 | 272 uiEventHandling(evPlay, 0); |
23077 | 273 } |
274 | |
33555 | 275 void uiPrev(void) |
23077 | 276 { |
32881 | 277 plItem *prev; |
278 int stop = 0; | |
279 | |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
280 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 281 return; |
282 | |
33555 | 283 switch (guiInfo.StreamType) { |
34077 | 284 #ifdef CONFIG_VCD |
285 case STREAMTYPE_VCD: | |
286 if (--guiInfo.Track == 1) { | |
287 guiInfo.Track = 2; | |
288 stop = 1; | |
289 } | |
290 break; | |
291 #endif | |
292 | |
32881 | 293 #ifdef CONFIG_DVDREAD |
294 case STREAMTYPE_DVD: | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
27370
diff
changeset
|
295 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
296 if (--guiInfo.Chapter == 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
297 guiInfo.Chapter = 1; |
32881 | 298 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
299 if (--guiInfo.Track <= 0) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
300 guiInfo.Track = 1; |
32881 | 301 stop = 1; |
302 } | |
303 } | |
304 | |
305 break; | |
32953 | 306 #endif |
32881 | 307 |
308 default: | |
309 | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
310 prev = listSet(gtkGetPrevPlItem, NULL); |
32881 | 311 |
312 if (prev) { | |
33555 | 313 uiSetFileName(prev->path, prev->name, STREAMTYPE_FILE); |
314 uiGotoTheNext = 0; | |
33898 | 315 guiInfo.Track--; |
32881 | 316 break; |
317 } | |
318 | |
319 return; | |
320 } | |
321 | |
322 if (stop) | |
33555 | 323 uiEventHandling(evStop, 0); |
32881 | 324 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
325 if (guiInfo.Playing == GUI_PLAY) |
33555 | 326 uiEventHandling(evPlay, 0); |
23077 | 327 } |
328 | |
33555 | 329 void uiNext(void) |
23077 | 330 { |
32881 | 331 int stop = 0; |
332 plItem *next; | |
23077 | 333 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
334 if (guiInfo.Playing == GUI_PAUSE) |
32881 | 335 return; |
336 | |
33555 | 337 switch (guiInfo.StreamType) { |
34077 | 338 #ifdef CONFIG_VCD |
339 case STREAMTYPE_VCD: | |
340 | |
341 if (++guiInfo.Track >= guiInfo.Tracks) { | |
342 stop = (guiInfo.Track > guiInfo.Tracks); | |
343 guiInfo.Track = FFMAX(2, guiInfo.Tracks); | |
344 } | |
345 | |
346 break; | |
347 #endif | |
348 | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
26458
diff
changeset
|
349 #ifdef CONFIG_DVDREAD |
32881 | 350 case STREAMTYPE_DVD: |
351 | |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
352 if (guiInfo.Chapter++ == guiInfo.Chapters) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
353 guiInfo.Chapter = 1; |
32881 | 354 |
33876
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
355 if (++guiInfo.Track > guiInfo.Tracks) { |
4789b8eed97e
Get rid of a bunch of needless or redundant guiInfo members.
ib
parents:
33874
diff
changeset
|
356 guiInfo.Track = guiInfo.Tracks; |
32881 | 357 stop = 1; |
358 } | |
359 } | |
360 | |
361 break; | |
32953 | 362 #endif |
32881 | 363 |
364 default: | |
365 | |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
366 next = listSet(gtkGetNextPlItem, NULL); |
32881 | 367 |
368 if (next) { | |
33555 | 369 uiSetFileName(next->path, next->name, STREAMTYPE_FILE); |
370 uiGotoTheNext = 0; | |
33898 | 371 guiInfo.Track++; |
32881 | 372 break; |
373 } | |
374 | |
375 return; | |
376 } | |
377 | |
378 if (stop) | |
33555 | 379 uiEventHandling(evStop, 0); |
32881 | 380 |
33615
1f9a31d4f114
Replace all playback integer constants by their symbolic constants.
ib
parents:
33614
diff
changeset
|
381 if (guiInfo.Playing == GUI_PLAY) |
33555 | 382 uiEventHandling(evPlay, 0); |
23077 | 383 } |