view_miniinfo.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #include "main.h"
  2. #include "api__ml_local.h"
  3. #include "..\..\General\gen_ml/config.h"
  4. #include "resource.h"
  5. #include "..\..\General\gen_ml/ml_ipc_0313.h"
  6. static int g_displayinfo = TRUE, g_displayinfochanged=FALSE;
  7. static HWND m_media_hwnd = NULL;
  8. static HWND m_info_hwnd = NULL;
  9. static HRGN g_rgnUpdate = NULL;
  10. static int offsetX = 0, offsetY = 0;
  11. #define IDC_WEBINFO 0x1000
  12. static void LayoutWindows(HWND hwnd, BOOL fShowInfo, BOOL fRedraw)
  13. {
  14. RECT rc, ri, rg;
  15. HRGN rgn = NULL;
  16. GetClientRect(hwnd, &rc);
  17. SetRect(&rg, 0, 0, 0, 0);
  18. if (rc.bottom - rc.top < WASABI_API_APP->getScaleY(180)) fShowInfo = FALSE;
  19. if (rc.bottom <= rc.top || rc.right <= rc.left) return;
  20. if (fShowInfo)
  21. {
  22. if (!IsWindow(m_info_hwnd)) // create browser
  23. {
  24. WEBINFOCREATE wic = {0};
  25. wic.hwndParent = hwnd;
  26. wic.uMsgQuery = WM_QUERYFILEINFO;
  27. wic.x = rc.left;
  28. wic.y = rc.bottom - WASABI_API_APP->getScaleY(101);
  29. wic.cx = (rc.right - rc.left) - WASABI_API_APP->getScaleX(3);
  30. wic.cy = WASABI_API_APP->getScaleY(100);
  31. wic.ctrlId = IDC_WEBINFO;
  32. m_info_hwnd = (HWND)SENDMLIPC(plugin.hwndLibraryParent, ML_IPC_CREATEWEBINFO, (WPARAM)&wic);
  33. if (IsWindow(m_info_hwnd))
  34. {
  35. SetWindowPos(m_info_hwnd, HWND_BOTTOM, 0, 0, 0, 0,
  36. SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW | SWP_NOCOPYBITS);
  37. ShowWindow(m_info_hwnd, SW_SHOWNORMAL);
  38. }
  39. }
  40. else
  41. {
  42. SetWindowPos(m_info_hwnd, NULL, rc.left, rc.bottom - WASABI_API_APP->getScaleY(101),
  43. rc.right - WASABI_API_APP->getScaleX(3), WASABI_API_APP->getScaleY(100),
  44. SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOREDRAW);
  45. }
  46. if (IsWindow(m_info_hwnd))
  47. {
  48. rc.bottom -= WASABI_API_APP->getScaleY(104);
  49. SetRect(&rg, rc.left, rc.bottom - WASABI_API_APP->getScaleY(101),
  50. rc.right - WASABI_API_APP->getScaleX(10),
  51. rc.bottom - WASABI_API_APP->getScaleY(1));
  52. }
  53. }
  54. InvalidateRect(hwnd, NULL, TRUE);
  55. if (IsWindow(m_media_hwnd))
  56. {
  57. SetRect(&ri, rc.left, rc.top, rc.right, rc.bottom);
  58. rgn = CreateRectRgn(0, 0, ri.right - ri.left, ri.bottom - ri.top);
  59. SendMessage(m_media_hwnd, WM_USER + 0x201, MAKEWPARAM(offsetX, offsetY), (LPARAM)rgn);
  60. SetWindowPos(m_media_hwnd, NULL, ri.left, ri.top, ri.right - ri.left, ri.bottom - ri.top,
  61. SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOACTIVATE | ((!fRedraw) ? SWP_NOREDRAW : 0));
  62. SendMessage(m_media_hwnd, WM_USER + 0x201, 0, 0L);
  63. if (IsWindowVisible(m_media_hwnd))
  64. {
  65. ValidateRect(hwnd, &ri);
  66. if (GetUpdateRect(m_media_hwnd, NULL, FALSE))
  67. {
  68. GetUpdateRgn(m_media_hwnd, rgn, FALSE);
  69. OffsetRgn(rgn, ri.left, ri.top);
  70. InvalidateRgn(hwnd, rgn, FALSE);
  71. }
  72. }
  73. }
  74. if (fRedraw)
  75. {
  76. UpdateWindow(hwnd);
  77. if (IsWindow(m_media_hwnd)) UpdateWindow(m_media_hwnd);
  78. }
  79. if (g_rgnUpdate)
  80. {
  81. GetUpdateRgn(hwnd, g_rgnUpdate, FALSE);
  82. if (rgn)
  83. {
  84. OffsetRgn(rgn, rc.left, rc.top);
  85. CombineRgn(g_rgnUpdate, g_rgnUpdate, rgn, RGN_OR);
  86. }
  87. }
  88. ValidateRgn(hwnd, NULL);
  89. if (rgn) DeleteObject(rgn);
  90. }
  91. INT_PTR CALLBACK view_miniinfoDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  92. {
  93. BOOL a=dialogSkinner.Handle(hwndDlg,uMsg,wParam,lParam); if (a) return a;
  94. switch(uMsg)
  95. {
  96. case WM_DISPLAYCHANGE:
  97. if (IsWindow(m_media_hwnd)) PostMessageW(m_media_hwnd, WM_DISPLAYCHANGE, wParam, lParam);
  98. if (IsWindow(m_info_hwnd)) PostMessageW(m_info_hwnd, WM_DISPLAYCHANGE, wParam, lParam);
  99. break;
  100. case WM_INITDIALOG:
  101. {
  102. g_displayinfo = g_view_metaconf->ReadInt(L"midivvis", 1);
  103. g_displayinfochanged = FALSE;
  104. m_media_hwnd = (lParam) ? WASABI_API_CREATEDIALOGW(((INT_PTR*)lParam)[1], hwndDlg, (DLGPROC)((INT_PTR*)lParam)[0]) : NULL;
  105. SetWindowPos(m_media_hwnd, NULL, 0,0,0,0, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW | SWP_SHOWWINDOW);
  106. MLSKINWINDOW m = {0};
  107. m.skinType = SKINNEDWND_TYPE_DIALOG;
  108. m.hwndToSkin = hwndDlg;
  109. m.style = SWS_USESKINFONT | SWS_USESKINCOLORS | SWS_USESKINCURSORS;
  110. MLSkinWindow(plugin.hwndLibraryParent, &m);
  111. }
  112. return TRUE;
  113. case WM_WINDOWPOSCHANGED:
  114. if ((SWP_NOSIZE | SWP_NOMOVE) != ((SWP_NOSIZE | SWP_NOMOVE) & ((WINDOWPOS*)lParam)->flags) ||
  115. (SWP_FRAMECHANGED & ((WINDOWPOS*)lParam)->flags))
  116. {
  117. LayoutWindows(hwndDlg, g_displayinfo, !(SWP_NOREDRAW & ((WINDOWPOS*)lParam)->flags));
  118. }
  119. return 0;
  120. case WM_APP+1: //sent by parent for resizing window
  121. if (IsWindow(m_media_hwnd)) return SendMessage(m_media_hwnd,uMsg,wParam,lParam); // forward on
  122. return 0;
  123. case WM_APP+2: //sent by media child to get current query
  124. return SendMessage(GetParent(hwndDlg),uMsg,wParam,lParam); // forward on
  125. case WM_QUERYFILEINFO: if(IsWindow(m_media_hwnd)) PostMessageW(m_media_hwnd, uMsg, wParam, lParam); break;
  126. case WM_SHOWFILEINFO:
  127. if (IsWindow(m_info_hwnd))
  128. {
  129. WEBINFOSHOW wis = {0};
  130. wis.pszFileName = (LPCWSTR)lParam;
  131. wis.fFlags = (TRUE == wParam) ? WISF_FORCE : WISF_NORMAL;
  132. SENDMLIPC(m_info_hwnd, ML_IPC_WEBINFO_SHOWINFO, (WPARAM)&wis);
  133. }
  134. case WM_USER+66:
  135. if (wParam == -1)
  136. {
  137. g_displayinfo = !g_displayinfo;
  138. g_displayinfochanged = !g_displayinfochanged;
  139. if (IsWindow(m_info_hwnd)) ShowWindow(m_info_hwnd, (g_displayinfo) ? SW_SHOWNA : SW_HIDE);
  140. LayoutWindows(hwndDlg, g_displayinfo, TRUE);
  141. }
  142. SetWindowLongPtr(hwndDlg,DWLP_MSGRESULT, (g_displayinfo) ? 0xff : 0xf0);
  143. return TRUE;
  144. case WM_USER + 0x200:
  145. SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, 1); // yes, we support no - redraw resize
  146. return TRUE;
  147. case WM_USER + 0x201:
  148. offsetX = (short)LOWORD(wParam);
  149. offsetY = (short)HIWORD(wParam);
  150. g_rgnUpdate = (HRGN)lParam;
  151. return TRUE;
  152. case WM_PAINT:
  153. {
  154. if (GetDlgItem(hwndDlg, IDC_WEBINFO))
  155. {
  156. static int tab[] = { IDC_WEBINFO | DCW_SUNKENBORDER };
  157. dialogSkinner.Draw(hwndDlg, tab, sizeof(tab) / sizeof(tab[0]));
  158. }
  159. else
  160. dialogSkinner.Draw(hwndDlg, 0, 0);
  161. }
  162. return 0;
  163. case WM_ERASEBKGND:
  164. return 1; //handled by WADlg_DrawChildWindowBorders in WM_PAINT
  165. case WM_DESTROY:
  166. if(g_displayinfochanged) g_view_metaconf->WriteInt(L"midivvis", g_displayinfo);
  167. if (IsWindow(m_info_hwnd)) SENDMLIPC(m_info_hwnd, ML_IPC_WEBINFO_RELEASE, 0);
  168. m_media_hwnd = NULL;
  169. m_info_hwnd = NULL;
  170. break;
  171. }
  172. return FALSE;
  173. }