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