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