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