1
0

options_video.cpp 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /** (c) Nullsoft, Inc. C O N F I D E N T I A L
  2. ** Filename:
  3. ** Project:
  4. ** Description:
  5. ** Author:
  6. ** Created:
  7. **/
  8. #include "Main.h"
  9. #include "WinampAttributes.h"
  10. #include "Options.h"
  11. #include "resource.h"
  12. #include "video.h"
  13. void hideShowVideoOptions(HWND hwndDlg)
  14. {
  15. int ids[] = {IDC_VIDEO_GROUP1, IDC_PREFS_VIDEO_AUTOOPEN, IDC_PREFS_VIDEO_AUTOCLOSE, IDC_PREFS_VIDEO_STOPCLOSE,
  16. IDC_PREFS_VIDEO_UPDSIZE, IDC_PREFS_VIDEO_NOSS, IDC_PREFS_VIDEO_LOGO, IDC_VIDEO_GROUP2, IDC_PREFS_VIDEO_AUTO_FS_ON_START,
  17. IDC_PREFS_VIDEO_REMOVE_FS_ON_STOP, IDC_PREFS_VIDEO_OSD, IDC_VIDEO_GROUP3, IDC_PREFS_VIDEO_FLIPRGB,
  18. IDC_PREFS_VIDEO_ADJASP, IDC_USE_SCREENSHAPE, IDC_SCREENSHAPE1, IDC_STATIC1, IDC_SCREENSHAPE2,
  19. IDC_STATIC2, IDC_PREFS_VIDEO_VSYNC};
  20. for (int i = 0; i < ARRAYSIZE(ids); i++)
  21. {
  22. ShowWindow(GetDlgItem(hwndDlg, ids[i]), !g_no_video_loaded);
  23. }
  24. ShowWindow(GetDlgItem(hwndDlg, IDC_VIDEO_RESTART), !g_no_video_loaded != IsDlgButtonChecked(hwndDlg, IDC_PREFS_VIDEO_ENABLE));
  25. if (g_no_video_loaded) ShowWindow(GetDlgItem(hwndDlg, IDC_PREFS_VIDEO_HIDE_PREFS), SW_SHOW);
  26. }
  27. void hideShowOverlayItems(HWND hwndDlg)
  28. {
  29. int enabled = IsDlgButtonChecked(hwndDlg, IDC_PREFS_VIDEO_OVERLAYS);
  30. EnableWindow(GetDlgItem(hwndDlg, IDC_PREFS_VIDEO_YV12), enabled);
  31. }
  32. void hideShowAspectRatioItems(HWND hwndDlg)
  33. {
  34. int enabled = IsDlgButtonChecked(hwndDlg, IDC_PREFS_VIDEO_ADJASP);
  35. int subenabled = IsDlgButtonChecked(hwndDlg, IDC_USE_SCREENSHAPE);
  36. EnableWindow(GetDlgItem(hwndDlg, IDC_USE_SCREENSHAPE), enabled);
  37. int ids[] = {IDC_SCREENSHAPE1, IDC_SCREENSHAPE2, IDC_STATIC1, IDC_STATIC2};
  38. for (int i = 0; i < ARRAYSIZE(ids); i++)
  39. {
  40. EnableWindow(GetDlgItem(hwndDlg, ids[i]), enabled && subenabled);
  41. }
  42. }
  43. // video tab procedure
  44. INT_PTR CALLBACK VideoProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  45. {
  46. hi helpinfo[]={
  47. {IDC_PREFS_VIDEO_ENABLE,IDS_P_O_VIDEO_ENABLE},
  48. {IDC_PREFS_VIDEO_HIDE_PREFS,IDS_P_O_VIDEO_HIDE_PREFS},
  49. {IDC_PREFS_VIDEO_VSYNC,IDS_P_O_VIDEO_VSYNC},
  50. {IDC_PREFS_VIDEO_ADJASP,IDS_P_O_VIDEO_ADJASP},
  51. {IDC_PREFS_VIDEO_OVERLAYS,IDS_P_O_VIDEO_OVERLAYS},
  52. {IDC_PREFS_VIDEO_UPDSIZE,IDS_P_O_VIDEO_UPDSIZE},
  53. {IDC_PREFS_VIDEO_AUTOCLOSE,IDS_P_O_VIDEO_AUTOCLOSE},
  54. {IDC_PREFS_VIDEO_NOSS,IDS_P_O_VIDEO_NOSS},
  55. {IDC_PREFS_VIDEO_OSD,IDS_P_O_VIDEO_OSD},
  56. {IDC_PREFS_VIDEO_YV12,IDS_P_O_VIDEO_YV12},
  57. {IDC_PREFS_VIDEO_STOPCLOSE,IDS_P_O_VIDEO_STOPCLOSE},
  58. {IDC_PREFS_VIDEO_AUTO_FS_ON_START,IDS_P_O_VIDEO_AUTO_FS_ON_START},
  59. {IDC_PREFS_VIDEO_REMOVE_FS_ON_STOP,IDS_P_O_VIDEO_REMOVE_FS_ON_STOP},
  60. {IDC_PREFS_VIDEO_AUTOOPEN,IDS_P_O_VIDEO_AUTOOPEN},
  61. {IDC_PREFS_VIDEO_FLIPRGB,IDS_P_O_VIDEO_FLIPRGB},
  62. };
  63. DO_HELP();
  64. if (uMsg == WM_INITDIALOG)
  65. {
  66. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_ENABLE,!_r_i("no_video", 0));
  67. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_HIDE_PREFS,_r_i("no_video", 0) == 2);
  68. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_VSYNC,config_video_vsync2);
  69. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_ADJASP,config_video_aspectadj);
  70. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_OVERLAYS,config_video_overlays);
  71. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_UPDSIZE,config_video_updsize);
  72. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_AUTOOPEN,config_video_autoopen);
  73. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_AUTOCLOSE,config_video_autoclose);
  74. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_NOSS,!!config_video_noss);
  75. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_LOGO,!!config_video_logo);
  76. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_OSD,config_video_osd);
  77. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_YV12,config_video_yv12);
  78. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_STOPCLOSE,config_video_stopclose);
  79. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_AUTO_FS_ON_START,config_video_auto_fs);
  80. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_REMOVE_FS_ON_STOP,config_video_remove_fs_on_stop);
  81. CheckDlgButton(hwndDlg,IDC_PREFS_VIDEO_FLIPRGB,config_video_fliprgb);
  82. //EnableWindow(GetDlgItem(hwndDlg,IDC_PREFS_VIDEO_YV12),config_video_overlays);
  83. if (config_video_useratio) CheckDlgButton(hwndDlg,IDC_USE_SCREENSHAPE,BST_CHECKED);
  84. SetDlgItemInt(hwndDlg,IDC_SCREENSHAPE1,config_video_ratio1,FALSE);
  85. SetDlgItemInt(hwndDlg,IDC_SCREENSHAPE2,config_video_ratio2,FALSE);
  86. #ifdef EXPERIMENTAL_CONTRAST
  87. SendDlgItemMessage(hwndDlg,IDC_PREFS_VIDEO_CONTRAST,TBM_SETRANGE,TRUE,MAKELONG(0,255));
  88. SendDlgItemMessage(hwndDlg,IDC_PREFS_VIDEO_CONTRAST,TBM_SETPOS,TRUE,config_video_contrast);
  89. SendDlgItemMessage(hwndDlg,IDC_PREFS_VIDEO_BRIGHTNESS,TBM_SETRANGE,TRUE,MAKELONG(0,255));
  90. SendDlgItemMessage(hwndDlg,IDC_PREFS_VIDEO_BRIGHTNESS,TBM_SETPOS,TRUE,config_video_brightness);
  91. #endif
  92. hideShowAspectRatioItems(hwndDlg);
  93. hideShowOverlayItems(hwndDlg);
  94. hideShowVideoOptions(hwndDlg);
  95. }
  96. #ifdef EXPERIMENTAL_CONTRAST
  97. if (uMsg == WM_HSCROLL)
  98. {
  99. HWND swnd = (HWND) lParam;
  100. if (swnd == GetDlgItem(hwndDlg, IDC_PREFS_VIDEO_CONTRAST))
  101. {
  102. config_video_contrast = (unsigned char) SendMessageW(GetDlgItem(hwndDlg,IDC_PREFS_VIDEO_CONTRAST),TBM_GETPOS,0,0);
  103. }
  104. if (swnd == GetDlgItem(hwndDlg, IDC_PREFS_VIDEO_BRIGHTNESS))
  105. {
  106. config_video_brightness = (unsigned char) SendMessageW(GetDlgItem(hwndDlg,IDC_PREFS_VIDEO_BRIGHTNESS),TBM_GETPOS,0,0);
  107. }
  108. }
  109. #endif
  110. if (uMsg == WM_COMMAND) switch (LOWORD(wParam))
  111. {
  112. case IDC_PREFS_VIDEO_ENABLE:
  113. {
  114. int val = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_ENABLE)?1:0;
  115. if (val == _r_i("no_video", 0))
  116. {
  117. _w_i("no_video", !val);
  118. if (val == g_no_video_loaded &&
  119. LPMessageBox(hwndDlg, IDS_P_VIDEO_CHANGE_MSG, IDS_P_VIDEO_CHANGE, MB_YESNO | MB_ICONQUESTION) == IDYES)
  120. {
  121. PostMessageW(hMainWindow,WM_USER,0,IPC_RESTARTWINAMP);
  122. }
  123. ShowWindow(GetDlgItem(hwndDlg, IDC_VIDEO_RESTART), !g_no_video_loaded != IsDlgButtonChecked(hwndDlg, IDC_PREFS_VIDEO_ENABLE));
  124. }
  125. }
  126. break;
  127. case IDC_PREFS_VIDEO_HIDE_PREFS:
  128. {
  129. _w_i("no_video", IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_HIDE_PREFS)?2:1);
  130. prefsDlgRec t = {0};
  131. t._id = 24;
  132. prefs_liveDlgRemove(&t);
  133. prefs_last_page = 0;
  134. prefs_dialog(1);
  135. }
  136. break;
  137. case IDC_PREFS_VIDEO_VSYNC: config_video_vsync2 = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_VSYNC)?1:0; break;
  138. case IDC_PREFS_VIDEO_ADJASP: config_video_aspectadj = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_ADJASP)?1:0; hideShowAspectRatioItems(hwndDlg); videoReinit(); break;
  139. case IDC_PREFS_VIDEO_OVERLAYS: config_video_overlays = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_OVERLAYS)?1:0; hideShowOverlayItems(hwndDlg); videoReinit(); break;
  140. case IDC_PREFS_VIDEO_UPDSIZE: config_video_updsize = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_UPDSIZE)?1:0; break;
  141. case IDC_PREFS_VIDEO_AUTOOPEN: config_video_autoopen = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_AUTOOPEN)?1:0; break;
  142. case IDC_PREFS_VIDEO_AUTOCLOSE: config_video_autoclose = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_AUTOCLOSE)?1:0; break;
  143. case IDC_PREFS_VIDEO_NOSS: config_video_noss = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_NOSS)?1:0; break;
  144. case IDC_PREFS_VIDEO_LOGO:
  145. {
  146. config_video_logo = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_LOGO)?1:0;
  147. if (IsWindow(hVideoWindow))
  148. {
  149. RedrawWindow(hVideoWindow, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASENOW | RDW_ALLCHILDREN);
  150. }
  151. break;
  152. }
  153. case IDC_PREFS_VIDEO_OSD: config_video_osd = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_OSD)?1:0; break;
  154. case IDC_PREFS_VIDEO_YV12: config_video_yv12 = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_YV12)?1:0; break;
  155. case IDC_PREFS_VIDEO_STOPCLOSE: config_video_stopclose = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_STOPCLOSE)?1:0; break;
  156. case IDC_PREFS_VIDEO_AUTO_FS_ON_START: config_video_auto_fs = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_AUTO_FS_ON_START)?1:0; break;
  157. case IDC_PREFS_VIDEO_REMOVE_FS_ON_STOP: config_video_remove_fs_on_stop = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_REMOVE_FS_ON_STOP)?1:0; break;
  158. case IDC_PREFS_VIDEO_FLIPRGB:
  159. {
  160. int new_fliprgb = IsDlgButtonChecked(hwndDlg,IDC_PREFS_VIDEO_FLIPRGB)?1:0;
  161. config_video_fliprgb = 0;
  162. videoSetFlip(new_fliprgb);
  163. config_video_fliprgb = new_fliprgb;
  164. }
  165. break;
  166. case IDC_USE_SCREENSHAPE:
  167. config_video_useratio=!!IsDlgButtonChecked(hwndDlg,IDC_USE_SCREENSHAPE);
  168. hideShowAspectRatioItems(hwndDlg);
  169. videoReinit();
  170. break;
  171. case IDC_SCREENSHAPE1:
  172. {
  173. BOOL t;
  174. config_video_ratio1 = GetDlgItemInt(hwndDlg,IDC_SCREENSHAPE1,&t,FALSE);
  175. if (!t || !config_video_ratio1) config_video_ratio1=4;
  176. if (config_video_useratio) videoReinit();
  177. }
  178. break;
  179. case IDC_SCREENSHAPE2:
  180. {
  181. BOOL t;
  182. config_video_ratio2 = GetDlgItemInt(hwndDlg,IDC_SCREENSHAPE2,&t,FALSE);
  183. if (!t || !config_video_ratio2) config_video_ratio2=3;
  184. if (config_video_useratio) videoReinit();
  185. }
  186. break;
  187. }
  188. return FALSE;
  189. } //video