Mercurial > mplayer.hg
annotate gui/win32/gui.c @ 30697:9a49143918aa
Mark stream open filename parameter as const, the filename string is not
modified by these functions.
author | reimar |
---|---|
date | Thu, 25 Feb 2010 22:47:04 +0000 |
parents | dc7ed18ea0df |
children | 13ca93203358 |
rev | line source |
---|---|
23077 | 1 /* |
23079 | 2 * MPlayer GUI for Win32 |
3 * Copyright (C) 2003 Sascha Sommer <saschasommer@freenet.de> | |
4 * Copyright (C) 2006 Erik Augustson <erik_27can@yahoo.com> | |
5 * Copyright (C) 2006 Gianluigi Tiesi <sherpya@netfarm.it> | |
6 * | |
7 * This file is part of MPlayer. | |
8 * | |
9 * MPlayer is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * MPlayer is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
26457 | 19 * You should have received a copy of the GNU General Public License along |
20 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
23079 | 22 */ |
23077 | 23 |
24 #include <stdio.h> | |
25 #include <stdlib.h> | |
26 #include <ctype.h> | |
27 #include <fcntl.h> | |
28 #include <windows.h> | |
29 #include <windowsx.h> | |
30 #include <shlobj.h> | |
23091
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
31 |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
32 #include "version.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
33 #include "mplayer.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
34 #include "mp_fifo.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
35 #include "mp_msg.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
36 #include "help_mp.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
37 #include "input/input.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
38 #include "input/mouse.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
39 #include "osdep/keycodes.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
40 #include "stream/stream.h" |
52488bb09d90
Consistently use quotes instead of angled brackets in #include
diego
parents:
23079
diff
changeset
|
41 #include "libvo/video_out.h" |
30684
dc7ed18ea0df
Include libmpcodecs/vd.h for declaration of "fullscreen".
zuxy
parents:
30558
diff
changeset
|
42 #include "libmpcodecs/vd.h" |
26372
76413880bfad
Update include paths to account for build system changes.
diego
parents:
26193
diff
changeset
|
43 #include "gui/interface.h" |
30558 | 44 #include "gui/mplayer/gmplayer.h" |
23077 | 45 #include "gui.h" |
46 #include "dialogs.h" | |
47 | |
48 // HACK around bug in old mingw | |
49 #undef INVALID_FILE_ATTRIBUTES | |
50 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) | |
51 | |
52 #ifndef WM_XBUTTONDOWN | |
53 # define WM_XBUTTONDOWN 0x020B | |
54 # define WM_XBUTTONUP 0x020C | |
55 # define WM_XBUTTONDBLCLK 0x020D | |
56 #endif | |
57 | |
58 /* Globals / Externs */ | |
28051 | 59 void renderinfobox(skin_t *skin, window_priv_t *priv); |
60 void renderwidget(skin_t *skin, image *dest, widget *item, int state); | |
61 void print_version(void); | |
23077 | 62 float sub_aspect; |
63 | |
64 DWORD oldtime; | |
65 NOTIFYICONDATA nid; | |
66 int console_state = 0; | |
67 play_tree_t *playtree = NULL; | |
68 | |
69 static HBRUSH colorbrush = NULL; //Handle to colorkey brush | |
70 static COLORREF windowcolor = RGB(255,0,255); //Windowcolor == colorkey | |
71 | |
72 void console_toggle(void) | |
73 { | |
74 if (console_state) | |
75 { | |
76 FreeConsole(); | |
77 console = 0; | |
78 console_state = 0; | |
79 } | |
80 else | |
81 { | |
82 /* This code comes from: http://dslweb.nwnexus.com/~ast/dload/guicon.htm */ | |
83 CONSOLE_SCREEN_BUFFER_INFO coninfo; | |
84 FILE *fp; | |
85 HWND hwnd = NULL; | |
86 console = 1; | |
87 AllocConsole(); | |
88 SetConsoleTitle(MP_TITLE); | |
89 | |
90 /* disable the close button for now */ | |
91 while (!hwnd) | |
92 { | |
93 hwnd = FindWindow(NULL, MP_TITLE); | |
94 Sleep(100); | |
95 } | |
96 DeleteMenu(GetSystemMenu(hwnd, 0), SC_CLOSE, MF_BYCOMMAND); | |
97 | |
98 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); | |
99 coninfo.dwSize.Y = 1000; | |
100 SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); | |
101 fp = freopen("con", "w", stdout); | |
102 *stdout = *fp; | |
103 setvbuf(stdout, NULL, _IONBF, 0); | |
104 fp = freopen("con", "r", stdin); | |
105 *stdin = *fp; | |
106 setvbuf(stdin, NULL, _IONBF, 0); | |
107 fp = freopen("con", "w", stdout); | |
108 *stderr = *fp; | |
109 setvbuf(stderr, NULL, _IONBF, 0); | |
110 print_version(); | |
111 console_state = 1; | |
112 } | |
113 } | |
114 | |
115 void capitalize(char *filename) | |
116 { | |
117 unsigned int i; | |
118 BOOL cap = TRUE; | |
119 for (i=0; i < strlen(filename); i++) | |
120 { | |
121 if (cap) | |
122 { | |
123 cap = FALSE; | |
124 filename[i] = toupper(filename[i]); | |
125 } | |
126 else if (filename[i] == ' ') | |
127 cap = TRUE; | |
128 else | |
129 filename[i] = tolower(filename[i]); | |
130 } | |
131 } | |
132 | |
133 static image *get_drawground(HWND hwnd) | |
134 { | |
135 gui_t * gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
136 unsigned int i; | |
137 if(!gui) return NULL; | |
138 for(i=0; i<gui->window_priv_count; i++) | |
139 if(gui->window_priv[i]->hwnd==hwnd) | |
140 return &gui->window_priv[i]->img; | |
141 return NULL; | |
142 } | |
143 | |
144 static HBITMAP get_bitmap(HWND hwnd) | |
145 { | |
146 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
147 unsigned int i; | |
148 if(!gui) return NULL; | |
149 for(i=0; i<gui->window_priv_count; i++) | |
150 if(gui->window_priv[i]->hwnd == hwnd) | |
151 return gui->window_priv[i]->bitmap; | |
152 return NULL; | |
153 } | |
154 | |
155 static int get_windowtype(HWND hwnd) | |
156 { | |
157 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA); | |
158 unsigned int i; | |
159 if(!gui) return -1; | |
160 for(i=0; i<gui->window_priv_count; i++) | |
161 if(gui->window_priv[i]->hwnd == hwnd) | |
162 return gui->window_priv[i]->type; | |
163 return -1; | |
164 } | |
165 | |
166 static void uninit(gui_t *gui) | |
167 { | |
168 if(gui->skin) destroy_window(gui); | |
169 if(gui->playlist) gui->playlist->free_playlist(gui->playlist); | |
170 gui->playlist = NULL; | |
171 } | |
172 | |
173 /* | |
174 the gui message handler | |
175 tries to handle the incoming messages | |
176 and passes them to the player's message handler if it can't handle them | |
177 */ | |
178 static void handlemsg(HWND hWnd, int msg) | |
179 { | |
180 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
181 if(msg == evNone) return; | |
182 | |
183 switch(msg) | |
184 { | |
185 case evLoadPlay: | |
186 case evLoad: | |
187 if(display_openfilewindow(gui, 0) && (msg == evLoadPlay)) | |
188 handlemsg(hWnd, evDropFile); | |
189 return; | |
190 case evLoadSubtitle: | |
191 display_opensubtitlewindow(gui); | |
192 break; | |
193 case evPreferences: | |
194 display_prefswindow(gui); | |
195 return; | |
196 case evPlayList: | |
197 display_playlistwindow(gui); | |
198 return; | |
199 case evSkinBrowser: | |
200 display_skinbrowser(gui); | |
201 break; | |
202 case evEqualizer: | |
203 display_eqwindow(gui); | |
204 break; | |
205 case evAbout: | |
206 MessageBox(hWnd, COPYRIGHT, "About", MB_OK); | |
207 break; | |
208 case evIconify: | |
209 ShowWindow(hWnd, SW_MINIMIZE); | |
210 break; | |
211 case evIncVolume: | |
212 mplayer_put_key(KEY_VOLUME_UP); | |
213 break; | |
214 case evDecVolume: | |
215 mplayer_put_key(KEY_VOLUME_DOWN); | |
216 break; | |
217 default: | |
218 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] received msg %s (%i)\n", gui->skin->geteventname(msg), msg); | |
219 break; | |
220 } | |
221 gui->playercontrol(msg); | |
222 } | |
223 | |
224 static widget *clickedinsidewidget(gui_t *gui, int window, int x, int y) | |
225 { | |
226 unsigned int i; | |
227 widget *item; | |
228 for(i=0; i<gui->skin->widgetcount; i++) | |
229 { | |
230 item = gui->skin->widgets[i]; | |
231 if((item->window == window) && (item->x <= x) && (item->x + item->width >= x) && | |
232 (item->y <= y) && (item->y + item->height >= y)) | |
233 return item; | |
234 } | |
235 return NULL; | |
236 } | |
237 | |
238 /* updates sliders and the display */ | |
239 static void updatedisplay(gui_t *gui, HWND hwnd) | |
240 { | |
241 unsigned int i; | |
242 window_priv_t *priv = NULL; | |
243 DWORD time = timeGetTime(); | |
244 | |
245 if(!hwnd) return; | |
246 | |
247 /* load all potmeters hpotmeters */ | |
248 for(i=0; i<gui->skin->widgetcount; i++) | |
249 { | |
250 if(gui->skin->widgets[i]->type == tyHpotmeter || gui->skin->widgets[i]->type == tyPotmeter) | |
251 { | |
252 if(gui->skin->widgets[i]->msg == evSetVolume) | |
253 gui->skin->widgets[i]->value = guiIntfStruct.Volume; | |
254 else if(gui->skin->widgets[i]->msg == evSetMoviePosition) | |
255 gui->skin->widgets[i]->value = guiIntfStruct.Position; | |
256 else if(gui->skin->widgets[i]->msg == evSetBalance) | |
257 gui->skin->widgets[i]->value = guiIntfStruct.Balance; | |
258 if(gui->skin->widgets[i]->window == get_windowtype(hwnd)) | |
259 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
260 gui->skin->widgets[i]->pressed ? 0 : 1); | |
261 } | |
262 /* update some buttons */ | |
263 if(gui->skin->widgets[i]->type == tyButton && gui->skin->widgets[i]->window == get_windowtype(hwnd)) | |
264 { | |
265 if(gui->skin->widgets[i]->msg == evPlaySwitchToPause) | |
266 { | |
267 gui->skin->widgets[i]->value = guiIntfStruct.Playing; | |
268 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
269 guiIntfStruct.Playing == 1 ? 0 : 1); | |
270 } | |
271 if(gui->skin->widgets[i]->msg == evMute) | |
272 { | |
273 gui->skin->widgets[i]->value = guiIntfStruct.Volume; | |
274 renderwidget(gui->skin, get_drawground(hwnd), gui->skin->widgets[i], | |
275 guiIntfStruct.Volume == 0.0f ? 0 : 1); | |
276 } | |
277 } | |
278 } | |
279 | |
280 /* updating the display once a 100.second is enough imo */ | |
281 if((time - oldtime) < 100) return; | |
282 oldtime=time; | |
283 | |
284 /* suppress directx's fullscreen window when using the sub window */ | |
285 if(sub_window && &video_driver_list[0] && strstr("directx", video_driver_list[0])) | |
286 { | |
287 HWND hWndFS = NULL; //handle to directx's fullscreen window | |
288 if(hWndFS == NULL) | |
289 { | |
290 hWndFS = FindWindow(NULL, "MPlayer Fullscreen"); | |
291 if(hWndFS != NULL) DestroyWindow(hWndFS); //sub window handles fullscreen | |
292 } | |
293 } | |
294 | |
295 for (i=0; i<gui->window_priv_count; i++) | |
296 { | |
297 if(gui->window_priv[i]->hwnd == hwnd) | |
298 priv=gui->window_priv[i]; | |
299 }// Sherpya | |
300 /* display the status msgs */ | |
301 renderinfobox(gui->skin, priv); | |
302 RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE); | |
303 } | |
304 | |
305 static LRESULT CALLBACK SubProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
306 { | |
307 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
308 if (gui && (gui->subwindow != hWnd)) return FALSE; | |
309 | |
310 switch (message) | |
311 { | |
312 case WM_CLOSE: | |
313 handlemsg(hWnd, evExit); | |
314 return 0; | |
315 case WM_DESTROY: | |
316 PostQuitMessage(0); | |
317 return 0; | |
318 case WM_KEYDOWN: | |
319 { | |
320 switch(wParam) | |
321 { | |
322 case VK_LEFT: | |
323 mplayer_put_key(KEY_LEFT); | |
324 break; | |
325 case VK_UP: | |
326 mplayer_put_key(KEY_UP); | |
327 break; | |
328 case VK_RIGHT: | |
329 mplayer_put_key(KEY_RIGHT); | |
330 break; | |
331 case VK_DOWN: | |
332 mplayer_put_key(KEY_DOWN); | |
333 break; | |
334 case VK_TAB: | |
335 mplayer_put_key(KEY_TAB); | |
336 break; | |
337 case VK_BACK: | |
338 mplayer_put_key(KEY_BS); | |
339 break; | |
340 case VK_DELETE: | |
341 mplayer_put_key(KEY_DELETE); | |
342 break; | |
343 case VK_INSERT: | |
344 mplayer_put_key(KEY_INSERT); | |
345 break; | |
346 case VK_HOME: | |
347 mplayer_put_key(KEY_HOME); | |
348 break; | |
349 case VK_END: | |
350 mplayer_put_key(KEY_END); | |
351 break; | |
352 case VK_PRIOR: | |
353 mplayer_put_key(KEY_PAGE_UP); | |
354 break; | |
355 case VK_NEXT: | |
356 mplayer_put_key(KEY_PAGE_DOWN); | |
357 break; | |
358 case VK_ESCAPE: | |
359 mplayer_put_key(KEY_ESC); | |
360 break; | |
361 } | |
362 break; | |
363 } | |
364 case WM_COMMAND: | |
365 { | |
366 switch(LOWORD(wParam)) | |
367 { | |
368 case IDEXIT: | |
369 PostQuitMessage(0); | |
370 handlemsg(hWnd, evExit); | |
371 break; | |
372 case IDFILE_OPEN: | |
373 handlemsg(hWnd, evLoadPlay); | |
374 break; | |
375 case IDURL_OPEN: | |
376 display_openurlwindow(gui, 0); | |
377 break; | |
378 case IDDIR_OPEN: | |
379 { | |
380 static char path[MAX_PATH]; | |
381 BROWSEINFO bi; | |
382 LPITEMIDLIST pidl; | |
383 memset(&bi, 0, sizeof(BROWSEINFO)); | |
384 bi.lpszTitle = "Choose a Directory..."; | |
385 pidl = SHBrowseForFolder(&bi); | |
386 if (SHGetPathFromIDList(pidl, path)) | |
387 { | |
388 gui->playlist->clear_playlist(gui->playlist); | |
389 adddirtoplaylist(gui->playlist, path, TRUE); | |
390 gui->startplay(gui); | |
391 } | |
392 break; | |
393 } | |
394 case ID_PTRACK: | |
395 handlemsg(hWnd, evPrev); | |
396 break; | |
397 case ID_SEEKB: | |
398 handlemsg(hWnd, evBackward10sec); | |
399 break; | |
400 case ID_PLAY: | |
401 handlemsg(hWnd, evPlaySwitchToPause); | |
402 break; | |
403 case ID_STOP: | |
404 handlemsg(hWnd, evStop); | |
405 break; | |
406 case ID_SEEKF: | |
407 handlemsg(hWnd, evForward10sec); | |
408 break; | |
409 case ID_NTRACK: | |
410 handlemsg(hWnd, evNext); | |
411 break; | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27292
diff
changeset
|
412 #ifdef CONFIG_DVDREAD |
23077 | 413 case ID_CHAPTERSEL: |
414 display_chapterselwindow(gui); | |
415 break; | |
416 #endif | |
417 case ID_FULLSCREEN: | |
418 mp_input_queue_cmd(mp_input_parse_cmd("vo_fullscreen")); | |
419 break; | |
420 case ID_MUTE: | |
421 mp_input_queue_cmd(mp_input_parse_cmd("mute")); | |
422 break; | |
423 case ID_ASPECT1: | |
424 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.777777")); | |
425 break; | |
426 case ID_ASPECT2: | |
427 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 1.333333")); | |
428 break; | |
429 case ID_ASPECT3: | |
430 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 2.35")); | |
431 break; | |
432 case ID_ASPECT4: | |
433 mp_input_queue_cmd(mp_input_parse_cmd("switch_ratio 0")); | |
434 break; | |
435 case IDSUB_TOGGLE: | |
436 mp_input_queue_cmd(mp_input_parse_cmd("sub_visibility")); | |
437 break; | |
438 case IDSUB_CYCLE: | |
439 mp_input_queue_cmd(mp_input_parse_cmd("sub_select")); | |
440 break; | |
441 } | |
442 return 0; | |
443 } | |
444 case WM_CHAR: | |
445 mplayer_put_key(wParam); | |
446 break; | |
447 case WM_DROPFILES: | |
448 { | |
449 if(!lParam) | |
450 { | |
451 char file[MAX_PATH]; | |
452 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
453 int i; | |
454 for(i=0; i<filecount; i++) | |
455 { | |
456 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
457 mplSetFileName(NULL, file, STREAMTYPE_FILE); | |
458 if(!parse_filename(file, playtree, mconfig, 1)) | |
459 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
460 } | |
461 DragFinish((HDROP) wParam); | |
462 handlemsg(hWnd, evDropFile); | |
463 } | |
464 else | |
465 { | |
466 gui->playlist->clear_playlist(gui->playlist); | |
467 gui->playlist->add_track(gui->playlist, (const char *) wParam, NULL, NULL, 0); | |
468 handlemsg(hWnd, evDropFile); | |
469 } | |
470 SetForegroundWindow(gui->subwindow); | |
471 return 0; | |
472 } | |
473 case WM_LBUTTONDOWN: | |
474 { | |
475 if(!vo_nomouse_input) | |
476 mplayer_put_key(MOUSE_BTN0); | |
477 break; | |
478 } | |
479 case WM_MBUTTONDOWN: | |
480 { | |
481 if(!vo_nomouse_input) | |
482 mplayer_put_key(MOUSE_BTN1); | |
483 break; | |
484 } | |
485 case WM_RBUTTONDOWN: | |
486 { | |
487 POINT point; | |
488 point.x = GET_X_LPARAM(lParam); | |
489 point.y = GET_Y_LPARAM(lParam); | |
490 ClientToScreen(hWnd, &point); | |
491 if(guiIntfStruct.StreamType == STREAMTYPE_DVD) | |
492 EnableMenuItem(gui->dvdmenu, ID_CHAPTERSEL, MF_BYCOMMAND | MF_ENABLED); | |
493 TrackPopupMenu(gui->submenu, 0, point.x, point.y, 0, hWnd, NULL); | |
494 return 0; | |
495 } | |
496 case WM_LBUTTONDBLCLK: | |
497 { | |
498 if(!vo_nomouse_input) | |
499 mplayer_put_key(MOUSE_BTN0_DBL); | |
500 break; | |
501 } | |
502 case WM_MBUTTONDBLCLK: | |
503 { | |
504 if(!vo_nomouse_input) | |
505 mplayer_put_key(MOUSE_BTN1_DBL); | |
506 break; | |
507 } | |
508 case WM_RBUTTONDBLCLK: | |
509 { | |
510 if(!vo_nomouse_input) | |
511 mplayer_put_key(MOUSE_BTN2_DBL); | |
512 break; | |
513 } | |
514 case WM_MOUSEWHEEL: | |
515 { | |
516 int x = GET_WHEEL_DELTA_WPARAM(wParam); | |
517 if(vo_nomouse_input) | |
518 break; | |
519 if (x > 0) | |
520 mplayer_put_key(MOUSE_BTN3); | |
521 else | |
522 mplayer_put_key(MOUSE_BTN4); | |
523 break; | |
524 } | |
525 case WM_XBUTTONDOWN: | |
526 { | |
527 if(vo_nomouse_input) | |
528 break; | |
529 if(HIWORD(wParam) == 1) | |
530 mplayer_put_key(MOUSE_BTN5); | |
531 else | |
532 mplayer_put_key(MOUSE_BTN6); | |
533 break; | |
534 } | |
535 case WM_XBUTTONDBLCLK: | |
536 { | |
537 if(vo_nomouse_input) | |
538 break; | |
539 if(HIWORD(wParam) == 1) | |
540 mplayer_put_key(MOUSE_BTN5_DBL); | |
541 else | |
542 mplayer_put_key(MOUSE_BTN6_DBL); | |
543 break; | |
544 } | |
545 case WM_TIMER: | |
546 { | |
547 if(fullscreen) while(ShowCursor(FALSE) >= 0){} | |
548 KillTimer(hWnd, ID_TIMER); | |
549 return 0; | |
550 } | |
551 case WM_MOUSEMOVE: | |
552 { | |
553 ShowCursor(TRUE); | |
554 SetTimer(hWnd, ID_TIMER, 3000, (TIMERPROC) NULL); | |
555 break; | |
556 } | |
557 case WM_WINDOWPOSCHANGED: | |
558 { | |
559 int tmpheight=0; | |
560 static uint32_t rect_width; | |
561 static uint32_t rect_height; | |
562 RECT rd; | |
563 POINT pt; | |
564 pt.x = 0; | |
565 pt.y = 0; | |
566 GetClientRect(hWnd, &rd); | |
567 ClientToScreen(hWnd, &pt); | |
568 | |
569 rect_width = rd.right - rd.left; | |
570 rect_height = rd.bottom - rd.top; | |
571 | |
572 /* maintain our aspect ratio */ | |
573 tmpheight = ((float)rect_width/sub_aspect); | |
574 tmpheight += tmpheight % 2; | |
575 if(tmpheight > rect_height) | |
576 { | |
577 rect_width = ((float)rect_height*sub_aspect); | |
578 rect_width += rect_width % 2; | |
579 } | |
580 else rect_height = tmpheight; | |
581 | |
582 rd.right = rd.left + rect_width; | |
583 rd.bottom = rd.top + rect_height; | |
584 | |
585 AdjustWindowRect(&rd, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 0); | |
586 SetWindowPos(hWnd, 0, fullscreen?0:pt.x+rd.left, fullscreen?0:pt.y+rd.top, | |
587 fullscreen?vo_screenwidth:rd.right-rd.left, fullscreen?vo_screenheight:rd.bottom-rd.top, SWP_NOOWNERZORDER); | |
588 SetForegroundWindow(hWnd); | |
589 return 0; | |
590 } | |
591 case WM_SYSCOMMAND: | |
592 { | |
593 switch(wParam) | |
594 { | |
595 case SC_SCREENSAVE: | |
596 case SC_MONITORPOWER: | |
597 mp_msg(MSGT_VO, MSGL_V ,"<vo_directx><INFO>killing screensaver\n" ); | |
598 return 0; | |
599 } | |
600 break; | |
601 } | |
602 case WM_PAINT: | |
603 { | |
604 PAINTSTRUCT ps; | |
605 RECT rect; | |
606 HDC hdc = BeginPaint(hWnd, &ps); | |
607 HDC hMemDC = CreateCompatibleDC(hdc); | |
608 HBRUSH blackbrush = (HBRUSH)GetStockObject(BLACK_BRUSH); | |
609 int width, height; | |
610 GetClientRect(hWnd, &rect); | |
611 width = rect.right - rect.left; | |
612 height = rect.bottom - rect.top; | |
613 if(guiIntfStruct.Playing == 0) | |
614 { | |
615 int i; | |
616 window *desc = NULL; | |
617 | |
618 for (i=0; i<gui->skin->windowcount; i++) | |
619 if(gui->skin->windows[i]->type == wiSub) | |
620 desc = gui->skin->windows[i]; | |
621 | |
622 SelectObject(hMemDC, get_bitmap(hWnd)); | |
623 StretchBlt(hdc, 0, 0, width, height, hMemDC, 0, 0, desc->base->bitmap[0]->width, | |
624 desc->base->bitmap[0]->height, SRCCOPY); | |
625 } else { | |
626 FillRect(GetDC(hWnd), &rect, fullscreen?blackbrush:colorbrush); | |
627 } | |
628 DeleteDC(hMemDC); | |
629 EndPaint(hWnd, &ps); | |
630 return 0; | |
631 } | |
632 } | |
633 return DefWindowProc(hWnd, message, wParam, lParam); | |
634 } | |
635 | |
636 /* Window Proc for the gui Window */ | |
637 static LRESULT CALLBACK EventProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | |
638 { | |
639 gui_t *gui = (gui_t *) GetWindowLongPtr(hWnd, GWLP_USERDATA); | |
640 | |
641 /* Avoid processing when then window doesn't match gui mainwindow */ | |
642 if (gui && (gui->mainwindow != hWnd)) return FALSE; | |
643 | |
644 switch (message) | |
645 { | |
646 case WM_CLOSE: | |
647 handlemsg(hWnd, evExit); | |
648 return 0; | |
649 case WM_DESTROY: | |
650 PostQuitMessage(0); | |
651 return 0; | |
652 case WM_SYSTRAY: | |
653 { | |
654 switch(lParam) | |
655 { | |
656 POINT cursor; | |
657 case WM_RBUTTONDOWN: | |
658 { | |
659 GetCursorPos(&cursor); | |
660 SetForegroundWindow(hWnd); | |
661 TrackPopupMenu(gui->traymenu, 0, cursor.x, cursor.y, 0, hWnd, NULL); | |
662 break; | |
663 } | |
664 case WM_MBUTTONDBLCLK: | |
665 case WM_LBUTTONDBLCLK: | |
666 { | |
667 if(IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); | |
668 else { ShowWindow(hWnd, SW_SHOW); SetForegroundWindow(hWnd); } | |
669 break; | |
670 } | |
671 } | |
672 break; | |
673 } | |
674 case WM_KEYDOWN: | |
675 { | |
676 switch(wParam) | |
677 { | |
678 case VK_LEFT: | |
679 mplayer_put_key(KEY_LEFT); | |
680 break; | |
681 case VK_UP: | |
682 mplayer_put_key(KEY_UP); | |
683 break; | |
684 case VK_RIGHT: | |
685 mplayer_put_key(KEY_RIGHT); | |
686 break; | |
687 case VK_DOWN: | |
688 mplayer_put_key(KEY_DOWN); | |
689 break; | |
690 case VK_TAB: | |
691 mplayer_put_key(KEY_TAB); | |
692 break; | |
693 case VK_BACK: | |
694 mplayer_put_key(KEY_BS); | |
695 break; | |
696 case VK_DELETE: | |
697 mplayer_put_key(KEY_DELETE); | |
698 break; | |
699 case VK_INSERT: | |
700 mplayer_put_key(KEY_INSERT); | |
701 break; | |
702 case VK_HOME: | |
703 mplayer_put_key(KEY_HOME); | |
704 break; | |
705 case VK_END: | |
706 mplayer_put_key(KEY_END); | |
707 break; | |
708 case VK_PRIOR: | |
709 mplayer_put_key(KEY_PAGE_UP); | |
710 break; | |
711 case VK_NEXT: | |
712 mplayer_put_key(KEY_PAGE_DOWN); | |
713 break; | |
714 case VK_ESCAPE: | |
715 mplayer_put_key(KEY_ESC); | |
716 break; | |
717 } | |
718 break; | |
719 } | |
720 case WM_CHAR: | |
721 mplayer_put_key(wParam); | |
722 break; | |
723 case WM_COPYDATA: | |
724 { | |
725 if(lParam) | |
726 { | |
727 PCOPYDATASTRUCT cdData; | |
728 cdData = (PCOPYDATASTRUCT) lParam; | |
729 mplSetFileName(NULL, cdData->lpData, STREAMTYPE_FILE); | |
730 if(!parse_filename(cdData->lpData, playtree, mconfig, 1)) | |
731 gui->playlist->add_track(gui->playlist, cdData->lpData, NULL, NULL, 0); | |
732 gui->startplay(gui); | |
733 } | |
734 break; | |
735 } | |
736 case WM_DROPFILES: | |
737 { | |
738 if(!lParam) | |
739 { | |
740 char file[MAX_PATH]; | |
741 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH); | |
742 int i; | |
743 for(i=0; i<filecount; i++) | |
744 { | |
745 DragQueryFile((HDROP) wParam, i, file, MAX_PATH); | |
746 mplSetFileName(NULL, file, STREAMTYPE_FILE); | |
747 if(!parse_filename(file, playtree, mconfig, 1)) | |
748 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0); | |
749 } | |
750 DragFinish((HDROP) wParam); | |
751 handlemsg(hWnd, evDropFile); | |
752 } | |
753 else | |
754 { | |
755 gui->playlist->clear_playlist(gui->playlist); | |
756 gui->playlist->add_track(gui->playlist, (const char *) wParam, NULL, NULL, 0); | |
757 handlemsg(hWnd, evDropFile); | |
758 } | |
759 SetForegroundWindow(gui->mainwindow); | |
760 return 0; | |
761 } | |
762 case WM_LBUTTONDOWN: | |
763 { | |
764 SetCapture(hWnd); | |
765 gui->mousex = GET_X_LPARAM(lParam); | |
766 gui->mousey = GET_Y_LPARAM(lParam); | |
767 /* inside a widget */ | |
768 gui->activewidget = clickedinsidewidget(gui, get_windowtype(hWnd), gui->mousex, gui->mousey); | |
769 if(gui->activewidget) | |
770 { | |
771 gui->activewidget->pressed = 1; | |
772 gui->mousewx = gui->mousex - gui->activewidget->x; | |
773 gui->mousewy = gui->mousey - gui->activewidget->y; | |
774 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 0); | |
775 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
776 handlemsg(hWnd, gui->activewidget->msg); | |
777 } | |
778 break; | |
779 } | |
780 case WM_CAPTURECHANGED: | |
781 { | |
782 if(gui->activewidget) | |
783 { | |
784 gui->activewidget->pressed = 0; | |
785 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); | |
786 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
787 gui->activewidget = NULL; | |
788 } | |
789 break; | |
790 } | |
791 case WM_LBUTTONUP: | |
792 { | |
793 ReleaseCapture(); | |
794 if(gui->activewidget) | |
795 { | |
796 gui->activewidget->pressed = 0; | |
797 renderwidget(gui->skin, get_drawground(hWnd), gui->activewidget, 1); | |
798 RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE); | |
799 gui->activewidget = NULL; | |
800 } | |
801 break; | |
802 } | |
803 case WM_RBUTTONDOWN: | |
804 { | |
805 POINT point; | |
806 char device[MAX_PATH]; | |
807 char searchpath[MAX_PATH]; | |
808 char searchpath2[MAX_PATH]; | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
809 #ifdef CONFIG_LIBCDIO |
23077 | 810 char searchpath3[MAX_PATH]; |
811 #endif | |
812 int len, pos = 0, cdromdrive = 0; | |
813 UINT errmode; | |
814 point.x = GET_X_LPARAM(lParam); | |
815 point.y = GET_Y_LPARAM(lParam); | |
816 ClientToScreen(hWnd, &point); | |
817 errmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); | |
818 while (GetMenuItemCount(gui->diskmenu) > 0) | |
819 DeleteMenu(gui->diskmenu, 0, MF_BYPOSITION); | |
820 len = GetLogicalDriveStrings(MAX_PATH, device); | |
821 while(pos < len) | |
822 { | |
823 if(GetDriveType(device + pos) == DRIVE_CDROM) | |
824 { | |
825 char volname[MAX_PATH]; | |
826 char menuitem[MAX_PATH]; | |
827 int flags = MF_STRING; | |
828 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] checking %s for CD/VCD/SVCD/DVDs\n", device + pos); | |
829 sprintf(searchpath, "%sVIDEO_TS", device + pos); | |
830 sprintf(searchpath2, "%sMpegav", device + pos); | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
831 #ifdef CONFIG_LIBCDIO |
23077 | 832 sprintf(searchpath3, "%sTrack01.cda", device + pos); |
833 #endif | |
834 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
835 flags |= MF_ENABLED; | |
836 else if(GetFileAttributes(searchpath2) != INVALID_FILE_ATTRIBUTES) | |
837 flags |= MF_ENABLED; | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
838 #ifdef CONFIG_LIBCDIO |
23077 | 839 else if(GetFileAttributes(searchpath3) != INVALID_FILE_ATTRIBUTES) |
840 flags |= MF_ENABLED; | |
841 #endif | |
842 else | |
843 flags |= MF_GRAYED; | |
844 volname[0] = 0; | |
845 strcpy(menuitem, device + pos); | |
846 menuitem[strlen(menuitem) - 1]=0; | |
847 GetVolumeInformation(device + pos, volname, MAX_PATH, NULL, NULL, NULL, NULL, 0); | |
848 if (strlen(volname)) | |
849 { | |
850 capitalize(volname); | |
851 strcat(menuitem, " - "); | |
852 strcat(menuitem, volname); | |
853 } | |
854 AppendMenu(gui->diskmenu, flags, IDPLAYDISK + cdromdrive, menuitem); | |
855 cdromdrive++; | |
856 } | |
857 pos += strlen(device + pos) + 1; | |
858 } | |
859 SetErrorMode(errmode); | |
860 TrackPopupMenu(gui->menu, 0, point.x, point.y, 0, hWnd, NULL); | |
861 return 0; | |
862 } | |
863 case WM_MOUSEMOVE: | |
864 { | |
865 if(wParam & MK_LBUTTON) | |
866 { | |
867 POINT point; | |
868 RECT rect; | |
869 if(gui->activewidget) | |
870 { | |
871 widget *item = gui->activewidget; | |
872 | |
873 if(item->type == tyHpotmeter) | |
874 { | |
875 item->x = GET_X_LPARAM(lParam) - gui->mousewx; | |
876 item->value = (float)((float)((item->x - item->wx) * 100.0f) / (float)(item->wwidth - item->width)); | |
877 } | |
878 if(item->type == tyPotmeter) | |
879 { | |
880 gui->mousewx = GET_X_LPARAM(lParam) - gui->activewidget->x; | |
881 item->value = (float) (gui->mousewx * 100.0f) / (float) item->wwidth; | |
882 } | |
883 | |
884 if((item->type == tyPotmeter) || (item->type == tyHpotmeter) || (item->type == tyVpotmeter)) | |
885 { | |
886 /* Bound checks */ | |
887 if(item->value > 100.0f) | |
888 item->value = 100.0f; | |
889 else if(item->value < 0.0f) | |
890 item->value = 0.0f; | |
891 | |
892 if(item->msg == evSetVolume) | |
893 guiIntfStruct.Volume = (float) item->value; | |
894 else if(item->msg == evSetMoviePosition) | |
895 guiIntfStruct.Position = (float) item->value; | |
896 else if(item->msg == evSetBalance) | |
897 { | |
898 /* make the range for 50% a bit bigger, because the sliders for balance usually suck */ | |
899 if((item->value - 50.0f < 1.5f) && (item->value - 50.0f > -1.5f)) | |
900 item->value = 50.0f; | |
901 guiIntfStruct.Balance = (float) item->value; | |
902 } | |
903 updatedisplay(gui, hWnd); | |
904 handlemsg(hWnd, item->msg); | |
905 } | |
906 break; | |
907 } | |
908 point.x = GET_X_LPARAM(lParam); | |
909 point.y = GET_Y_LPARAM(lParam); | |
910 ClientToScreen(hWnd, &point); | |
911 GetWindowRect(hWnd, &rect); | |
912 MoveWindow(hWnd, point.x - gui->mousex, point.y - gui->mousey, | |
913 rect.right-rect.left,rect.bottom-rect.top,TRUE); | |
914 break; | |
915 } | |
916 break; | |
917 } | |
918 case WM_COMMAND: | |
919 { | |
920 switch(LOWORD(wParam)) | |
921 { | |
922 case IDEXIT: | |
923 PostQuitMessage(0); | |
924 handlemsg(hWnd, evExit); | |
925 break; | |
926 case IDFILE_OPEN: | |
927 handlemsg(hWnd, evLoadPlay); | |
928 break; | |
929 case IDDIR_OPEN: | |
930 { | |
931 static char path[MAX_PATH]; | |
932 BROWSEINFO bi; | |
933 LPITEMIDLIST pidl; | |
934 memset(&bi, 0, sizeof(BROWSEINFO)); | |
935 bi.lpszTitle = "Choose a Directory..."; | |
936 pidl = SHBrowseForFolder(&bi); | |
937 if (SHGetPathFromIDList(pidl, path)) | |
938 { | |
939 gui->playlist->clear_playlist(gui->playlist); | |
940 adddirtoplaylist(gui->playlist, path, TRUE); | |
941 gui->startplay(gui); | |
942 } | |
943 break; | |
944 } | |
945 case ID_SKINBROWSER: | |
946 handlemsg(hWnd, evSkinBrowser); | |
947 break; | |
948 case IDURL_OPEN: | |
949 display_openurlwindow(gui, 0); | |
950 break; | |
951 case ID_MUTE: | |
952 mp_input_queue_cmd(mp_input_parse_cmd("mute")); | |
953 break; | |
954 case IDSUBTITLE_OPEN: | |
955 display_opensubtitlewindow(gui); | |
956 break; | |
957 case ID_PTRACK: | |
958 handlemsg(hWnd, evPrev); | |
959 break; | |
960 case ID_SEEKB: | |
961 handlemsg(hWnd, evBackward10sec); | |
962 break; | |
963 case ID_PLAY: | |
964 handlemsg(hWnd, evPlaySwitchToPause); | |
965 break; | |
966 case ID_STOP: | |
967 handlemsg(hWnd, evStop); | |
968 break; | |
969 case ID_SEEKF: | |
970 handlemsg(hWnd, evForward10sec); | |
971 break; | |
972 case ID_NTRACK: | |
973 handlemsg(hWnd, evNext); | |
974 break; | |
975 case ID_SHOWHIDE: | |
976 { | |
977 if(IsWindowVisible(hWnd)) ShowWindow(hWnd, SW_HIDE); | |
978 else ShowWindow(hWnd, SW_SHOW); | |
979 break; | |
980 } | |
981 case ID_PLAYLIST: | |
982 handlemsg(hWnd, evPlayList); | |
983 break; | |
984 case ID_PREFS: | |
985 handlemsg(hWnd, evPreferences); | |
986 break; | |
987 case ID_CONSOLE: | |
988 console_toggle(); | |
989 break; | |
990 case ID_ONLINEHELP: | |
991 ShellExecute(NULL, "open", ONLINE_HELP_URL, NULL, NULL, SW_SHOWNORMAL); | |
992 break; | |
993 } | |
994 if((IDPLAYDISK <= LOWORD(wParam)) && (LOWORD(wParam) < (IDPLAYDISK + 100))) | |
995 { | |
996 char device[MAX_PATH]; | |
997 char searchpath[MAX_PATH]; | |
998 char filename[MAX_PATH]; | |
999 int len, pos = 0, cdromdrive = 0; | |
1000 len = GetLogicalDriveStrings(MAX_PATH, device); | |
1001 while(pos < len) | |
1002 { | |
1003 if(GetDriveType(device + pos)==DRIVE_CDROM) | |
1004 { | |
1005 if(LOWORD(wParam) - IDPLAYDISK == cdromdrive) | |
1006 { | |
1007 sprintf(searchpath, "%sVIDEO_TS", device + pos); | |
1008 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
1009 { | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27292
diff
changeset
|
1010 #ifdef CONFIG_DVDREAD |
23077 | 1011 if (dvd_device) free(dvd_device); |
1012 dvd_device = strdup(device + pos); | |
1013 dvd_title = dvd_chapter = dvd_angle = 1; | |
1014 handlemsg(hWnd, evPlayDVD); | |
23147
21c35763b178
compilation fix for disabling dvd functionality, patch by <bangbangbear at gmail dot com>, slightly modified by me.
vayne
parents:
23091
diff
changeset
|
1015 #endif |
23077 | 1016 } |
1017 sprintf(searchpath, "%sTrack01.cda", device + pos); | |
1018 if(GetFileAttributes(searchpath) != INVALID_FILE_ATTRIBUTES) | |
1019 { | |
27391
1d2faa1020fb
Rename a bunch of miscellaneous preprocessor directives.
diego
parents:
27341
diff
changeset
|
1020 #ifdef CONFIG_LIBCDIO |
23077 | 1021 if (cdrom_device) free(cdrom_device); |
1022 cdrom_device = strdup(device + pos); | |
1023 /* mplayer doesn't seem to like the trailing \ after the device name */ | |
1024 cdrom_device[2]=0; | |
1025 handlemsg(hWnd, evPlayCD); | |
1026 #endif | |
23147
21c35763b178
compilation fix for disabling dvd functionality, patch by <bangbangbear at gmail dot com>, slightly modified by me.
vayne
parents:
23091
diff
changeset
|
1027 } else { |
23077 | 1028 HANDLE searchhndl; |
1029 WIN32_FIND_DATA finddata; | |
1030 sprintf(searchpath, "%smpegav\\*.dat", device + pos); | |
1031 if((searchhndl=FindFirstFile(searchpath, &finddata)) != INVALID_HANDLE_VALUE) | |
1032 { | |
1033 mp_msg(MSGT_GPLAYER,MSGL_V, "Opening VCD/SVCD\n"); | |
1034 gui->playlist->clear_playlist(gui->playlist); | |
1035 do | |
1036 { | |
1037 sprintf(filename, "%smpegav\\%s", device + pos, finddata.cFileName); | |
1038 gui->playlist->add_track(gui->playlist, filename, NULL, NULL, 0); | |
1039 } | |
1040 while(FindNextFile(searchhndl, &finddata)); | |
1041 FindClose(searchhndl); | |
1042 } | |
1043 gui->startplay(gui); | |
1044 } | |
1045 } | |
1046 cdromdrive++; | |
1047 } | |
1048 pos += strlen(device + pos) + 1; | |
1049 } | |
1050 } | |
1051 break; | |
1052 } | |
1053 case WM_PAINT: | |
1054 { | |
1055 PAINTSTRUCT ps; | |
1056 RECT rd; | |
1057 HDC hdc = BeginPaint(hWnd, &ps); | |
1058 HDC hMemDC = CreateCompatibleDC(hdc); | |
1059 int width, height; | |
1060 GetClientRect(hWnd, &rd); | |
1061 width = rd.right - rd.left; | |
1062 height = rd.bottom - rd.top; | |
1063 SelectObject(hMemDC, get_bitmap(hWnd)); | |
1064 BitBlt(hdc, 0, 0, width, height, hMemDC, 0, 0, SRCCOPY); | |
1065 DeleteDC(hMemDC); | |
1066 EndPaint(hWnd, &ps); | |
1067 return 0; | |
1068 } | |
1069 return 0; | |
1070 } | |
1071 return DefWindowProc(hWnd, message, wParam, lParam); | |
1072 } | |
1073 | |
27292 | 1074 static void startplay(gui_t *gui) |
23077 | 1075 { |
1076 handlemsg(gui->mainwindow, evDropFile); | |
1077 } | |
1078 | |
1079 /* returns the bits per pixel of the desktop */ | |
1080 /* the format is always in BGR byte order */ | |
1081 static int GetDesktopBitsPerPixel(void) | |
1082 { | |
1083 HWND desktop=GetDesktopWindow(); | |
1084 HDC dc=GetDC(desktop); | |
1085 int bpp=GetDeviceCaps(dc, BITSPIXEL); | |
1086 ReleaseDC(desktop, dc); | |
1087 return bpp; | |
1088 } | |
1089 | |
1090 /* unloads a skin and destroys its windows */ | |
28051 | 1091 int destroy_window(gui_t *gui) |
23077 | 1092 { |
1093 RECT rd; | |
1094 unsigned int i; | |
1095 | |
1096 /* Save position: MSDN says don't pass workspace coordinates | |
1097 * to CreateWindow() or SetWindowPos(), as both of which expect | |
1098 * screen coordinates; resulting in the window appearing in the | |
1099 * wrong location. | |
1100 * -Erik | |
1101 */ | |
1102 | |
1103 /* main window position */ | |
1104 if(IsIconic(gui->mainwindow)) | |
1105 ShowWindow(gui->mainwindow, SW_SHOWNORMAL); | |
1106 GetWindowRect(gui->mainwindow, &rd); | |
1107 gui_main_pos_x = rd.left; | |
1108 gui_main_pos_y = rd.top; | |
1109 | |
1110 /* sub window position */ | |
1111 if(IsIconic(gui->subwindow)) | |
1112 ShowWindow(gui->subwindow, SW_SHOWNORMAL); | |
1113 GetWindowRect(gui->subwindow, &rd); | |
1114 gui_sub_pos_x = rd.left; | |
1115 gui_sub_pos_y = rd.top; | |
1116 | |
1117 for(i=0; i<gui->window_priv_count; i++) | |
1118 { | |
1119 if(gui->window_priv[i]->bitmap) | |
1120 DeleteObject(gui->window_priv[i]->bitmap); | |
1121 free(gui->window_priv[i]); | |
1122 } | |
1123 free(gui->window_priv); | |
1124 gui->window_priv = NULL; | |
1125 gui->window_priv_count = 0; | |
1126 | |
1127 /* destroy the main window */ | |
1128 if(gui->mainwindow) | |
1129 DestroyWindow(gui->mainwindow); | |
1130 gui->mainwindow = NULL; | |
1131 | |
1132 /* destroy the sub window */ | |
1133 if(gui->subwindow) | |
1134 DestroyWindow(gui->subwindow); | |
1135 gui->subwindow = NULL; | |
1136 | |
1137 UnregisterClass(gui->classname, 0); | |
1138 DestroyIcon(gui->icon); | |
1139 | |
1140 gui->skin->freeskin(gui->skin); | |
1141 gui->skin = NULL; | |
1142 return 0; | |
1143 } | |
1144 | |
1145 static void create_menu(gui_t *gui) | |
1146 { | |
1147 gui->diskmenu = CreatePopupMenu(); | |
1148 gui->menu=CreatePopupMenu(); | |
1149 gui->trayplaymenu = CreatePopupMenu(); | |
1150 AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); | |
1151 AppendMenu(gui->trayplaymenu, MF_STRING, IDFILE_OPEN, "File..."); | |
1152 AppendMenu(gui->trayplaymenu, MF_STRING, IDURL_OPEN, "Url..."); | |
1153 AppendMenu(gui->trayplaymenu, MF_STRING, IDDIR_OPEN, "Directory..."); | |
1154 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1155 AppendMenu(gui->menu, MF_STRING | MF_POPUP, (UINT) gui->diskmenu, "Play &CD/DVD/VCD/SVCD"); | |
1156 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1157 AppendMenu(gui->menu, MF_STRING, IDSUBTITLE_OPEN, "Open Subtitle"); | |
1158 AppendMenu(gui->menu, MF_STRING, ID_SKINBROWSER, "Skin Browser"); | |
1159 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1160 AppendMenu(gui->menu, MF_STRING, ID_PREFS, "Preferences"); | |
1161 AppendMenu(gui->menu, MF_STRING, ID_CONSOLE, "Debug Console"); | |
1162 AppendMenu(gui->menu, MF_STRING, ID_ONLINEHELP, "Online Help"); | |
1163 AppendMenu(gui->menu, MF_SEPARATOR, 0, 0); | |
1164 AppendMenu(gui->menu, MF_STRING, IDEXIT, "&Exit"); | |
1165 } | |
1166 | |
1167 static void create_traymenu(gui_t *gui) | |
1168 { | |
1169 gui->traymenu = CreatePopupMenu(); | |
1170 gui->trayplaybackmenu = CreatePopupMenu(); | |
1171 AppendMenu(gui->traymenu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); | |
1172 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1173 AppendMenu(gui->traymenu, MF_STRING | MF_POPUP, (UINT) gui->trayplaybackmenu, "Playback"); | |
1174 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_SEEKB, "Seek Backwards"); | |
1175 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_PTRACK, "Previous Track"); | |
1176 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_PLAY, "Play/Pause"); | |
1177 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_STOP, "Stop"); | |
1178 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_NTRACK, "Next Track"); | |
1179 AppendMenu(gui->trayplaybackmenu, MF_STRING, ID_SEEKF, "Seek Forwards"); | |
1180 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1181 AppendMenu(gui->traymenu, MF_STRING, ID_MUTE, "Toggle Mute"); | |
1182 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1183 AppendMenu(gui->traymenu, MF_STRING, IDSUBTITLE_OPEN, "Open Subtitle"); | |
1184 AppendMenu(gui->traymenu, MF_STRING, ID_PLAYLIST, "Playlist"); | |
1185 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1186 AppendMenu(gui->traymenu, MF_STRING, ID_SHOWHIDE, "Show/Hide"); | |
1187 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1188 AppendMenu(gui->traymenu, MF_STRING, ID_PREFS, "Preferences"); | |
1189 AppendMenu(gui->traymenu, MF_STRING, ID_CONSOLE, "Debug Console"); | |
1190 AppendMenu(gui->traymenu, MF_STRING, ID_ONLINEHELP, "Online Help"); | |
1191 AppendMenu(gui->traymenu, MF_SEPARATOR, 0, 0); | |
1192 AppendMenu(gui->traymenu, MF_STRING, IDEXIT, "&Exit"); | |
1193 } | |
1194 | |
1195 static void create_submenu(gui_t *gui) | |
1196 { | |
1197 gui->submenu = CreatePopupMenu(); | |
1198 gui->dvdmenu = CreatePopupMenu(); | |
1199 gui->aspectmenu = CreatePopupMenu(); | |
1200 gui->subtitlemenu = CreatePopupMenu(); | |
1201 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->trayplaymenu, "Open..."); | |
1202 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
1203 AppendMenu(gui->submenu, MF_STRING, ID_SEEKB, "Seek Backwards"); | |
1204 AppendMenu(gui->submenu, MF_STRING, ID_PTRACK, "Previous Track"); | |
1205 AppendMenu(gui->submenu, MF_STRING, ID_PLAY, "Play/Pause"); | |
1206 AppendMenu(gui->submenu, MF_STRING, ID_STOP, "Stop"); | |
1207 AppendMenu(gui->submenu, MF_STRING, ID_NTRACK, "Next Track"); | |
1208 AppendMenu(gui->submenu, MF_STRING, ID_SEEKF, "Seek Forwards"); | |
1209 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
1210 AppendMenu(gui->submenu, MF_STRING, ID_FULLSCREEN, "Toggle Fullscreen"); | |
1211 AppendMenu(gui->submenu, MF_STRING, ID_MUTE, "Toggle Mute"); | |
1212 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
1213 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->aspectmenu, "Aspect Ratio"); | |
1214 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->subtitlemenu, "Subtitle Options"); | |
1215 AppendMenu(gui->submenu, MF_STRING | MF_POPUP, (UINT) gui->dvdmenu, "DVD Options"); | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27292
diff
changeset
|
1216 #ifdef CONFIG_DVDREAD |
23077 | 1217 AppendMenu(gui->dvdmenu, MF_STRING | MF_GRAYED, ID_CHAPTERSEL, "Select Title/Chapter..."); |
1218 #endif | |
1219 AppendMenu(gui->subtitlemenu, MF_STRING, IDSUB_TOGGLE, "Subtitle Visibility On/Off"); | |
1220 AppendMenu(gui->subtitlemenu, MF_STRING, IDSUB_CYCLE, "Cycle Subtitle Languages"); | |
1221 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT1, "Set 16:9"); | |
1222 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT2, "Set 4:3"); | |
1223 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT3, "Set 2.35"); | |
1224 AppendMenu(gui->aspectmenu, MF_SEPARATOR, 0, 0); | |
1225 AppendMenu(gui->aspectmenu, MF_STRING, ID_ASPECT4, "Original Aspect"); | |
1226 AppendMenu(gui->submenu, MF_SEPARATOR, 0, 0); | |
1227 AppendMenu(gui->submenu, MF_STRING, IDEXIT, "&Exit"); | |
1228 } | |
1229 | |
1230 static void maketransparent(HWND hwnd, COLORREF crTransparent) | |
1231 { | |
1232 HDC mdc = GetDC(hwnd); | |
1233 RECT rd; | |
1234 HRGN crRgnres, crRgn, crRgnTmp; | |
1235 int iX = 0, iY = 0, iLeftX = 0; | |
1236 int width, height; | |
1237 GetWindowRect(hwnd, &rd); | |
1238 width = rd.right - rd.left; | |
1239 height = rd.bottom - rd.top; | |
1240 | |
1241 /* create an empty region */ | |
1242 crRgn = CreateRectRgn(0, 0, 0, 0); | |
1243 | |
1244 /* Create a region from a bitmap with transparency colour of Purple */ | |
1245 for (iY = -1; iY < height; iY++) | |
1246 { | |
1247 do | |
1248 { | |
1249 /* skip over transparent pixels at start of lines */ | |
1250 while (iX <= width && GetPixel(mdc,iX, iY) == crTransparent) iX++; | |
1251 | |
1252 /* remember this pixel */ | |
1253 iLeftX = iX; | |
1254 | |
1255 /* now find first non transparent pixel */ | |
1256 while (iX <= width && GetPixel(mdc,iX, iY) != crTransparent) ++iX; | |
1257 | |
1258 /* create a temp region on this info */ | |
1259 crRgnTmp = CreateRectRgn(iLeftX, iY, iX, iY+1); | |
1260 | |
1261 /* combine into main region */ | |
1262 crRgnres = crRgn; | |
1263 CombineRgn(crRgnres, crRgn, crRgnTmp, RGN_OR); | |
1264 crRgn = crRgnres; | |
1265 | |
1266 /* delete the temp region for next pass (otherwise you'll get an ASSERT) */ | |
1267 DeleteObject(crRgnTmp); | |
1268 } while (iX < width); | |
1269 iX = 0; | |
1270 } | |
1271 SetWindowRgn(hwnd, crRgn, TRUE); | |
1272 DeleteObject(crRgn); | |
1273 ReleaseDC(hwnd,mdc); | |
1274 } | |
1275 | |
1276 static int window_render(gui_t *gui, HWND hWnd, HDC hdc, window_priv_t *priv, window *desc, BITMAPINFO binfo) | |
1277 { | |
1278 int i; | |
1279 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui); | |
1280 (gui->window_priv_count)++; | |
1281 gui->window_priv = realloc(gui->window_priv, sizeof(window_priv_t *) * gui->window_priv_count); | |
1282 priv = gui->window_priv[gui->window_priv_count - 1] = calloc(1, sizeof(window_priv_t)); | |
1283 priv->hwnd = hWnd; | |
1284 priv->type = desc->type; | |
1285 priv->background = desc->base->bitmap[0]; | |
1286 memcpy(&priv->img, desc->base->bitmap[0], sizeof(image)); | |
1287 hdc = GetDC(hWnd); | |
1288 binfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | |
1289 binfo.bmiHeader.biWidth = priv->img.width; | |
1290 binfo.bmiHeader.biHeight = -priv->img.height; | |
1291 binfo.bmiHeader.biPlanes = 1; | |
1292 binfo.bmiHeader.biSizeImage = priv->img.width * priv->img.height * (gui->screenbpp / 8); | |
1293 binfo.bmiHeader.biXPelsPerMeter = 0; | |
1294 binfo.bmiHeader.biYPelsPerMeter = 0; | |
1295 binfo.bmiHeader.biClrUsed = 0; | |
1296 binfo.bmiHeader.biClrImportant = 0; | |
1297 binfo.bmiHeader.biBitCount = gui->screenbpp; | |
1298 binfo.bmiHeader.biCompression = BI_RGB; | |
1299 priv->bitmap = CreateDIBSection(hdc, &binfo, DIB_RGB_COLORS, (void **) &priv->img.data, NULL, 0); | |
1300 if(!priv->bitmap) | |
1301 { | |
1302 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] unable to create bitmap for skinned window\n"); | |
1303 return 0; | |
1304 } | |
1305 memcpy(priv->img.data, desc->base->bitmap[0]->data, binfo.bmiHeader.biSizeImage); | |
1306 ReleaseDC(hWnd,hdc); | |
1307 | |
1308 for (i=0; i<gui->skin->widgetcount; i++) | |
1309 if(gui->skin->widgets[i]->window == desc->type) | |
1310 renderwidget(gui->skin, &priv->img, gui->skin->widgets[i], 1); | |
1311 | |
1312 return 0; | |
1313 } | |
1314 | |
1315 /* creates the sub (AKA video) window,*/ | |
28051 | 1316 int create_subwindow(gui_t *gui, char *skindir) |
23077 | 1317 { |
1318 HINSTANCE instance = GetModuleHandle(NULL); | |
1319 WNDCLASS wc; | |
1320 RECT rect; | |
1321 HWND hWnd; | |
1322 DWORD style = 0; | |
1323 HDC hdc = NULL; | |
1324 BITMAPINFO binfo; | |
1325 window_priv_t *priv = NULL; | |
1326 window *desc = NULL; | |
1327 int i, x = -1, y = -1; | |
1328 vo_colorkey = 0xff00ff; | |
1329 | |
1330 for (i=0; i<gui->skin->windowcount; i++) | |
1331 if(gui->skin->windows[i]->type == wiSub) | |
1332 desc = gui->skin->windows[i]; | |
1333 | |
1334 if(!desc) | |
1335 { | |
1336 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] Invalid skin description\n"); | |
1337 return 1; | |
1338 } | |
1339 | |
1340 windowcolor = vo_colorkey; | |
1341 colorbrush = CreateSolidBrush(windowcolor); | |
1342 wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; | |
1343 wc.lpfnWndProc = SubProc; | |
1344 wc.cbClsExtra = 0; | |
1345 wc.cbWndExtra = 0; | |
1346 wc.hInstance = instance; | |
1347 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
1348 wc.hIcon = gui->icon; | |
1349 wc.hbrBackground = NULL; //WM_PAINT will handle background color switching; | |
1350 wc.lpszClassName = "MPlayer Sub for Windows"; | |
1351 wc.lpszMenuName = NULL; | |
1352 RegisterClass(&wc); | |
1353 | |
1354 /* create the sub window menu */ | |
1355 create_submenu(gui); | |
1356 | |
1357 rect.top = rect.left = 100; | |
1358 rect.bottom = rect.top+desc->base->bitmap[0]->height; | |
1359 rect.right = rect.left+desc->base->bitmap[0]->width; | |
1360 | |
1361 /* our window aspect */ | |
1362 sub_aspect = (float)(rect.right-rect.left)/(rect.bottom-rect.top); | |
1363 | |
1364 style = fullscreen?WS_VISIBLE | WS_POPUP:WS_OVERLAPPEDWINDOW | WS_SYSMENU | WS_MINIMIZEBOX; | |
1365 AdjustWindowRect(&rect, style, 0); | |
1366 | |
1367 if (gui_sub_pos_x >= 0) | |
1368 x = gui_sub_pos_x; | |
1369 if (gui_sub_pos_y >= 0) | |
1370 y = gui_sub_pos_y; | |
1371 | |
1372 /* out of bounds check */ | |
1373 if (x <= -1 || (x+(rect.right-rect.left) > GetSystemMetrics(SM_CXSCREEN))) | |
1374 x = CW_USEDEFAULT; | |
1375 if (y <= -1 || (y+(rect.bottom-rect.top) > GetSystemMetrics(SM_CYSCREEN))) | |
1376 y = x; | |
1377 | |
1378 hWnd = CreateWindowEx(0, "MPlayer Sub for Windows", "MPlayer for Windows", style, | |
1379 x, y, rect.right-rect.left, rect.bottom-rect.top, | |
1380 gui->subwindow, NULL, instance, NULL); | |
1381 | |
1382 /* load all the window images */ | |
1383 window_render(gui, hWnd, hdc, priv, desc, binfo); | |
1384 | |
1385 /* enable drag and drop support */ | |
1386 DragAcceptFiles(hWnd, TRUE); | |
1387 | |
1388 gui->subwindow = hWnd; | |
1389 if(sub_window) | |
1390 WinID = gui->subwindow; | |
1391 ShowWindow(gui->subwindow, SW_SHOW); | |
1392 UpdateWindow(gui->subwindow); | |
1393 return 0; | |
1394 } | |
1395 | |
1396 /* loads/updates a skin and creates windows for it */ | |
28051 | 1397 int create_window(gui_t *gui, char *skindir) |
23077 | 1398 { |
1399 HINSTANCE instance = GetModuleHandle(NULL); | |
1400 WNDCLASS wc; | |
1401 RECT rect; | |
1402 DWORD style = 0; | |
1403 HWND hwnd; | |
1404 HDC hdc = NULL; | |
1405 BITMAPINFO binfo; | |
1406 window_priv_t *priv = NULL; | |
1407 window *desc = NULL; | |
1408 char dir[MAX_PATH]; | |
1409 unsigned int i; | |
1410 int x = -1, y = -1; | |
1411 | |
1412 /* destroy the current main window */ | |
1413 if(gui->skin) destroy_window(gui); | |
1414 | |
1415 /* get screenproperties */ | |
1416 gui->screenbpp = GetDesktopBitsPerPixel(); | |
1417 gui->screenw = GetSystemMetrics(SM_CXSCREEN); | |
1418 gui->screenh = GetSystemMetrics(SM_CYSCREEN); | |
1419 | |
1420 /* load the new skin */ | |
1421 gui->skin = loadskin(skindir, gui->screenbpp); | |
1422 if(!gui->skin) | |
1423 { | |
1424 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] fatal error during skinload\n"); | |
1425 /* Set default Skin */ | |
1426 if (skinName) free(skinName); | |
1427 skinName = strdup("Blue"); | |
1428 /* then force write conf */ | |
1429 cfg_write(); | |
1430 return 1; | |
1431 } | |
1432 | |
1433 /* find the description of the mainwindow */ | |
1434 for (i=0; i<gui->skin->windowcount; i++) | |
1435 if(gui->skin->windows[i]->type == wiMain) | |
1436 desc = gui->skin->windows[i]; | |
1437 | |
1438 if(!desc) | |
1439 { | |
1440 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "[GUI] Invalid skin description\n"); | |
1441 return 1; | |
1442 } | |
1443 | |
1444 /* load the icon from the executable */ | |
1445 GetModuleFileName(NULL, dir, MAX_PATH); | |
1446 gui->icon = ExtractIcon(instance, dir, 0); | |
1447 | |
1448 /* create the window class */ | |
1449 wc.style = CS_HREDRAW | CS_VREDRAW; | |
1450 wc.lpfnWndProc = EventProc; | |
1451 wc.cbClsExtra = 0; | |
1452 wc.cbWndExtra = 0; | |
1453 wc.hInstance = instance; | |
1454 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
1455 wc.hIcon = gui->icon; | |
1456 wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); | |
1457 wc.lpszClassName = gui->classname = "MPlayer GUI for Windows"; | |
1458 wc.lpszMenuName = NULL; | |
1459 RegisterClass(&wc); | |
1460 | |
1461 /* create a context menu */ | |
1462 create_menu(gui); | |
1463 /* create the systray menu */ | |
1464 create_traymenu(gui); | |
1465 | |
1466 /* create the mainwindow */ | |
1467 /* TODO implement aligning as described in skin.html */ | |
1468 rect.top = rect.left = 100; | |
1469 rect.bottom = rect.top+desc->base->bitmap[0]->height; | |
1470 rect.right = rect.left+desc->base->bitmap[0]->width; | |
1471 if(desc->decoration) style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; | |
1472 else style = WS_POPUP | WS_SYSMENU; | |
1473 | |
1474 AdjustWindowRect(&rect, style, 0); | |
1475 | |
1476 /* Check if out of screen */ | |
1477 if (gui_main_pos_x >= 0) | |
1478 x = gui_main_pos_x; | |
1479 if (gui_main_pos_y >= 0) | |
1480 y = gui_main_pos_y; | |
1481 | |
1482 if (x <= -1 || (x+(rect.right-rect.left) > GetSystemMetrics(SM_CXFULLSCREEN))) | |
1483 { | |
1484 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - ((rect.right-rect.left) / 2); | |
1485 gui_main_pos_x = x; | |
1486 } | |
1487 if (y <= -1 || (y+(rect.bottom-rect.top) > GetSystemMetrics(SM_CYFULLSCREEN))) | |
1488 { | |
1489 y = ((GetSystemMetrics(SM_CYSCREEN)-40) - (rect.bottom-rect.top)); | |
1490 gui_main_pos_y = y; | |
1491 } | |
1492 | |
1493 hwnd = CreateWindowEx(0, gui->classname, "MPlayer for Windows", style, | |
1494 x, y, rect.right-rect.left, rect.bottom-rect.top, | |
1495 gui->mainwindow, NULL, instance, NULL); | |
1496 | |
1497 /* set the systray icon properties */ | |
1498 nid.cbSize = sizeof(NOTIFYICONDATA); | |
1499 nid.hWnd = hwnd; | |
1500 nid.uID = 1; | |
1501 nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; | |
1502 nid.uCallbackMessage = WM_SYSTRAY; | |
1503 nid.hIcon = gui->icon; | |
1504 strcpy(nid.szTip, "MPlayer for Windows"); | |
1505 | |
1506 /* register the systray icon */ | |
1507 Shell_NotifyIcon(NIM_ADD, &nid); | |
1508 | |
1509 /* load all the window images */ | |
1510 window_render(gui, hwnd, hdc, priv, desc, binfo); | |
1511 | |
1512 /* enable drag and drop support */ | |
1513 DragAcceptFiles(hwnd, TRUE); | |
1514 | |
1515 updatedisplay(gui, hwnd); | |
1516 gui->mainwindow = hwnd; | |
1517 | |
1518 /* display */ | |
1519 ShowWindow(gui->mainwindow, SW_SHOW); | |
1520 UpdateWindow(gui->mainwindow); | |
1521 maketransparent(gui->mainwindow, RGB(255, 0, 255)); | |
1522 return 0; | |
1523 } | |
1524 | |
1525 gui_t *create_gui(char *skindir, char *skinName, void (*playercontrol)(int event)) | |
1526 { | |
1527 gui_t *gui = calloc(1, sizeof(gui_t)); | |
1528 char temp[MAX_PATH]; | |
1529 HWND runningmplayer = FindWindow("MPlayer GUI for Windows", "MPlayer for Windows"); | |
1530 | |
1531 if(runningmplayer) | |
1532 { | |
1533 free(gui); | |
1534 return NULL; | |
1535 } | |
1536 | |
1537 gui->startplay = startplay; | |
1538 gui->playercontrol = playercontrol; | |
1539 gui->uninit = uninit; | |
1540 gui->updatedisplay = updatedisplay; | |
1541 | |
1542 /* create playlist */ | |
1543 gui->playlist = create_playlist(); | |
1544 | |
1545 if(!skinName) skinName = strdup("Blue"); | |
1546 sprintf(temp, "%s\\%s", skindir, skinName); | |
1547 if(create_window(gui, temp)) return NULL; | |
1548 if(create_subwindow(gui, temp)) return NULL; | |
1549 if(console) console_toggle(); | |
1550 return gui; | |
1551 } |