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