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