From 2f28ea7818c8b9285b505231642247803a69f07e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Sep 2017 19:51:25 +0300 Subject: Clist Modern: more code cleaning --- plugins/Clist_modern/src/cluiframes.cpp | 486 ++++++++++----------- plugins/Clist_modern/src/modern_clc.cpp | 2 - plugins/Clist_modern/src/modern_clcopts.cpp | 6 +- plugins/Clist_modern/src/modern_clcutils.cpp | 6 +- plugins/Clist_modern/src/modern_clistmod.cpp | 2 +- plugins/Clist_modern/src/modern_clui.cpp | 71 ++- plugins/Clist_modern/src/modern_global_structure.h | 21 +- plugins/Clist_modern/src/version.h | 2 +- 8 files changed, 292 insertions(+), 304 deletions(-) (limited to 'plugins/Clist_modern') diff --git a/plugins/Clist_modern/src/cluiframes.cpp b/plugins/Clist_modern/src/cluiframes.cpp index ceb4d094c6..5064a5353c 100644 --- a/plugins/Clist_modern/src/cluiframes.cpp +++ b/plugins/Clist_modern/src/cluiframes.cpp @@ -42,7 +42,8 @@ int g_nTitleBarHeight = DEFAULT_TITLEBAR_HEIGHT; // STATIC -enum { +enum +{ frame_menu_lock = 1, frame_menu_visible, frame_menu_showtitlebar, @@ -900,7 +901,7 @@ static int CLUIFramesModifyMainMenuItems(WPARAM wParam, LPARAM) int pos = id2pos(wParam); if (pos >= 0 && pos < g_nFramesCount) { FRAMEWND &p = g_pfwFrames[pos]; - + Menu_ModifyItem(p.MenuHandles.MIVisible, p.TitleBar.tbname ? p.TitleBar.tbname : p.name); Menu_SetChecked(p.MenuHandles.MIVisible, p.visible); Menu_SetChecked(p.MenuHandles.MILock, p.Locked); @@ -917,7 +918,7 @@ static int CLUIFramesModifyMainMenuItems(WPARAM wParam, LPARAM) Menu_EnableItem(p.MenuHandles.MIAlignBottom, (p.align & alClient) == 0); Menu_SetChecked(p.MenuHandles.MIAlignBottom, (p.align & alBottom) != 0); Menu_SetChecked(p.MenuHandles.MIAlignClient, (p.align & alClient) != 0); - + Menu_SetChecked(p.MenuHandles.MIColl, p.collapsed); Menu_EnableItem(p.MenuHandles.MIColl, p.visible && !p.Locked && pos != CLUIFramesGetalClientFrame()); } @@ -1071,7 +1072,7 @@ static int _us_DoSetFrameOptions(WPARAM wParam, LPARAM lParam) case FO_TBTIPNAME: if (lParam == 0) return -1; - + if (fw.TitleBar.tooltip != nullptr) mir_free_and_nil(fw.TitleBar.tooltip); if (bUnicodeText) @@ -1443,7 +1444,7 @@ static int _us_DoCollapseFrame(WPARAM wParam, LPARAM lParam) sumheight += (F.height) + (g_nTitleBarHeight*btoint(F.TitleBar.ShowTitleBar)) + 2; return FALSE; } - if (sumheight>_nContactListHeight - 0 - 2) + if (sumheight > _nContactListHeight - 0 - 2) g_pfwFrames[FrameId].height = (_nContactListHeight - 0 - 2) - sumheight; } } @@ -1821,7 +1822,7 @@ static BOOL CLUIFramesFitInSize(void) FRAMEWND &F = g_pfwFrames[i]; if ((F.align != alClient) && (!F.floating) && (F.visible) && (!F.needhide)) { sumheight += (F.height) + (g_nTitleBarHeight*btoint(F.TitleBar.ShowTitleBar)) + 2/*+btoint(Frames[i].UseBorder)*2*/; - if (sumheight>_nContactListHeight - tbh - 2) { + if (sumheight > _nContactListHeight - tbh - 2) { if (!g_CluiData.fDocked && g_CluiData.fAutoSize) return TRUE; //Can be required to enlarge @@ -1947,7 +1948,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) drawitems = g_nFramesCount; - while (sumheight>(newheight - tbh) && drawitems > 0) { + while (sumheight > (newheight - tbh) && drawitems > 0) { sumheight = 0; drawitems = 0; for (i = 0; i < g_nFramesCount; i++) { @@ -1955,7 +1956,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) if (((F.align != alClient)) && (!F.floating) && (F.visible) && (!F.needhide)) { drawitems++; curfrmtbh = (g_nTitleBarHeight + g_CluiData.nGapBetweenTitlebar)*btoint(F.TitleBar.ShowTitleBar); - sumheight += (F.height) + curfrmtbh + (i > 0 ? sepw : 0) + ((F.UseBorder && !g_CluiData.fLayered) ? 2 : 0); + sumheight += (F.height) + curfrmtbh + (i > 0 ? sepw : 0) + ((F.UseBorder && !g_CluiData.fLayered) ? 2 : 0); if (sumheight > newheight - tbh) { sumheight -= (F.height) + curfrmtbh + (i > 0 ? sepw : 0); F.needhide = !g_CluiData.fDocked && g_CluiData.fAutoSize ? FALSE : TRUE; @@ -1975,7 +1976,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) if ((!F.needhide) && (!F.floating) && (F.visible) && (F.align == alTop)) { curfrmtbh = (g_nTitleBarHeight + g_CluiData.nGapBetweenTitlebar)*btoint(F.TitleBar.ShowTitleBar); F.wndSize.top = prevframebottomline + (i > 0 ? sepw : 0) + (curfrmtbh); - F.wndSize.bottom = F.height + F.wndSize.top + ((F.UseBorder && !g_CluiData.fLayered) ? 2 : 0); + F.wndSize.bottom = F.height + F.wndSize.top + ((F.UseBorder && !g_CluiData.fLayered) ? 2 : 0); F.prevvisframe = prevframe; prevframe = i; prevframebottomline = F.wndSize.bottom; @@ -2021,7 +2022,7 @@ static int CLUIFramesResizeFrames(const RECT newsize) curfrmtbh = (g_nTitleBarHeight + g_CluiData.nGapBetweenTitlebar)*btoint(F.TitleBar.ShowTitleBar); F.wndSize.bottom = prevframebottomline - (j > 0 ? sepw : 0); - F.wndSize.top = F.wndSize.bottom - F.height - ((F.UseBorder && !g_CluiData.fLayered) ? 2 : 0); + F.wndSize.top = F.wndSize.bottom - F.height - ((F.UseBorder && !g_CluiData.fLayered) ? 2 : 0); F.prevvisframe = prevframe; prevframe = i; prevframebottomline = F.wndSize.top/*-1*/ - curfrmtbh; @@ -2355,7 +2356,7 @@ int OnFrameTitleBarBackgroundChange(WPARAM, LPARAM) sttBkColour = cliGetColor("FrameTitleBar", "BkColour", CLCDEFAULT_BKCOLOUR); sttBkUseWinColours = db_get_b(0, "FrameTitleBar", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS); sttSelBkColour = cliGetColor("FrameTitleBar", "TextColour", CLCDEFAULT_TEXTCOLOUR); - + if (sttBmpBackground) { DeleteObject(sttBmpBackground); sttBmpBackground = nullptr; @@ -2640,32 +2641,32 @@ static LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam break; case WM_RBUTTONDOWN: - { - HMENU hmenu; - POINT pt; - GetCursorPos(&pt); + { + HMENU hmenu; + POINT pt; + GetCursorPos(&pt); - if (ServiceExists(MS_CLIST_MENUBUILDFRAMECONTEXT)) - hmenu = (HMENU)CallService(MS_CLIST_MENUBUILDFRAMECONTEXT, Frameid, 0); - else { - //legacy menu support - int framepos = id2pos(Frameid); + if (ServiceExists(MS_CLIST_MENUBUILDFRAMECONTEXT)) + hmenu = (HMENU)CallService(MS_CLIST_MENUBUILDFRAMECONTEXT, Frameid, 0); + else { + //legacy menu support + int framepos = id2pos(Frameid); + + if (framepos == -1) { break; }; + hmenu = CreatePopupMenu(); + // Frames[Frameid].TitleBar.hmenu = hmenu; + AppendMenu(hmenu, MF_STRING | MF_DISABLED | MF_GRAYED, 15, g_pfwFrames[framepos].name); + AppendMenu(hmenu, MF_SEPARATOR, 16, L""); + AppendMenu(hmenu, g_pfwFrames[framepos].Locked ? (MF_STRING | MF_CHECKED) : MF_STRING, frame_menu_lock, TranslateT("Lock frame")); + AppendMenu(hmenu, g_pfwFrames[framepos].visible ? (MF_STRING | MF_CHECKED) : MF_STRING, frame_menu_visible, TranslateT("Visible")); + AppendMenu(hmenu, g_pfwFrames[framepos].TitleBar.ShowTitleBar ? (MF_STRING | MF_CHECKED) : MF_STRING, frame_menu_showtitlebar, TranslateT("Show title bar")); + AppendMenu(hmenu, g_pfwFrames[framepos].floating ? (MF_STRING | MF_CHECKED) : MF_STRING, frame_menu_floating, TranslateT("Floating")); + } - if (framepos == -1) { break; }; - hmenu = CreatePopupMenu(); - // Frames[Frameid].TitleBar.hmenu = hmenu; - AppendMenu(hmenu, MF_STRING | MF_DISABLED | MF_GRAYED, 15, g_pfwFrames[framepos].name); - AppendMenu(hmenu, MF_SEPARATOR, 16, L""); - AppendMenu(hmenu, g_pfwFrames[framepos].Locked ? (MF_STRING | MF_CHECKED) : MF_STRING, frame_menu_lock, TranslateT("Lock frame")); - AppendMenu(hmenu, g_pfwFrames[framepos].visible ? (MF_STRING | MF_CHECKED) : MF_STRING, frame_menu_visible, TranslateT("Visible")); - AppendMenu(hmenu, g_pfwFrames[framepos].TitleBar.ShowTitleBar ? (MF_STRING | MF_CHECKED) : MF_STRING, frame_menu_showtitlebar, TranslateT("Show title bar")); - AppendMenu(hmenu, g_pfwFrames[framepos].floating ? (MF_STRING | MF_CHECKED) : MF_STRING, frame_menu_floating, TranslateT("Floating")); + TrackPopupMenu(hmenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hwnd, 0); + DestroyMenu(hmenu); } - - TrackPopupMenu(hmenu, TPM_LEFTALIGN, pt.x, pt.y, 0, hwnd, 0); - DestroyMenu(hmenu); - } - break; + break; case WM_LBUTTONDBLCLK: Framemod = -1; @@ -2675,272 +2676,271 @@ static LRESULT CALLBACK CLUIFrameTitleBarProc(HWND hwnd, UINT msg, WPARAM wParam break; case WM_LBUTTONUP: - { - if (GetCapture() != hwnd) { break; }; + if (GetCapture() != hwnd) + break; s_nCurDragBar = -1; s_nLastByPos = -1; s_nOldFrameHeight = -1; ReleaseCapture(); break; - }; - case WM_LBUTTONDOWN: - { - - int framepos = id2pos(Frameid); - if (framepos == -1) { break; }; + case WM_LBUTTONDOWN: { - if (g_pfwFrames[framepos].floating) { - POINT pt; - GetCursorPos(&pt); - g_pfwFrames[framepos].TitleBar.oldpos = pt; - } - } + int framepos = id2pos(Frameid); - //ScreenToClient(Frames[framepos].ContainerWnd,&Frames[framepos].TitleBar.oldpos); + if (framepos == -1) { break; }; + { + if (g_pfwFrames[framepos].floating) { - if ((!(wParam&MK_CONTROL)) && g_pfwFrames[framepos].Locked && (!(g_pfwFrames[framepos].floating))) { - if (db_get_b(0, "CLUI", "ClientAreaDrag", SETTING_CLIENTDRAG_DEFAULT)) { - POINT pt; - int res; - //pt = nm->pt; - GetCursorPos(&pt); - res = SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); - return res; + POINT pt; + GetCursorPos(&pt); + g_pfwFrames[framepos].TitleBar.oldpos = pt; + } } - }; - if (g_pfwFrames[framepos].floating) { - RECT rc; - GetCursorPos(&ptOld); - //ClientToScreen(hwnd,&ptOld); - GetWindowRect(hwnd, &rc); + //ScreenToClient(Frames[framepos].ContainerWnd,&Frames[framepos].TitleBar.oldpos); - nLeft = (short)rc.left; - nTop = (short)rc.top; - }; + if ((!(wParam&MK_CONTROL)) && g_pfwFrames[framepos].Locked && (!(g_pfwFrames[framepos].floating))) { + if (db_get_b(0, "CLUI", "ClientAreaDrag", SETTING_CLIENTDRAG_DEFAULT)) { + POINT pt; + int res; + //pt = nm->pt; + GetCursorPos(&pt); + res = SendMessage(GetParent(hwnd), WM_SYSCOMMAND, SC_MOVE | HTCAPTION, MAKELPARAM(pt.x, pt.y)); + return res; + } + }; - SetCapture(hwnd); + if (g_pfwFrames[framepos].floating) { + RECT rc; + GetCursorPos(&ptOld); + //ClientToScreen(hwnd,&ptOld); + GetWindowRect(hwnd, &rc); + nLeft = (short)rc.left; + nTop = (short)rc.top; + }; + SetCapture(hwnd); + } break; - }; + case WM_MOUSEMOVE: - { - POINT pt, pt2; - RECT wndr; - int pos; - //tbinfo { - wchar_t TBcapt[255]; - pos = id2pos(Frameid); - if (pos != -1) { - int oldflags; - - mir_snwprintf(TBcapt, L"%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d", - g_pfwFrames[pos].name, g_pfwFrames[pos].height, g_pfwFrames[pos].visible, g_pfwFrames[pos].floating, - g_pfwFrames[pos].FloatingPos.x, g_pfwFrames[pos].FloatingPos.y, - g_pfwFrames[pos].FloatingSize.x, g_pfwFrames[pos].FloatingSize.y, - g_pfwFrames[pos].order); - - oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, g_pfwFrames[pos].id), 0); - if (!(oldflags&F_SHOWTBTIP)) { - oldflags |= F_SHOWTBTIP; - //CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,Frames[pos].id),(LPARAM)oldflags); + POINT pt, pt2; + RECT wndr; + int pos; + //tbinfo + { + wchar_t TBcapt[255]; + pos = id2pos(Frameid); + if (pos != -1) { + int oldflags; + + mir_snwprintf(TBcapt, L"%s - h:%d, vis:%d, fl:%d, fl:(%d,%d,%d,%d),or: %d", + g_pfwFrames[pos].name, g_pfwFrames[pos].height, g_pfwFrames[pos].visible, g_pfwFrames[pos].floating, + g_pfwFrames[pos].FloatingPos.x, g_pfwFrames[pos].FloatingPos.y, + g_pfwFrames[pos].FloatingSize.x, g_pfwFrames[pos].FloatingSize.y, + g_pfwFrames[pos].order); + + oldflags = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLAGS, g_pfwFrames[pos].id), 0); + if (!(oldflags&F_SHOWTBTIP)) { + oldflags |= F_SHOWTBTIP; + //CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,Frames[pos].id),(LPARAM)oldflags); + }; + //CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBTIPNAME,Frames[pos].id),(LPARAM)TBcapt); }; - //CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBTIPNAME,Frames[pos].id),(LPARAM)TBcapt); - }; - - } - // - if ((wParam&MK_LBUTTON)/* && (wParam&MK_CONTROL)*/) { - RECT rcMiranda; - RECT rcwnd, rcOverlap; - POINT newpt, ofspt, curpt, newpos; - //if (GetCapture() != hwnd){break;}; - //curdragbar = -1;lbypos = -1;oldframeheight = -1;ReleaseCapture(); - - pos = id2pos(Frameid); - if (g_pfwFrames[pos].floating) { - GetCursorPos(&curpt); - rcwnd.bottom = curpt.y + 5; - rcwnd.top = curpt.y; - rcwnd.left = curpt.x; - rcwnd.right = curpt.x + 5; - - GetWindowRect(pcli->hwndContactList, &rcMiranda); - //GetWindowRect( Frames[pos].ContainerWnd, &rcwnd ); - //IntersectRect( &rcOverlap, &rcwnd, &rcMiranda ) - if (IsWindowVisible(pcli->hwndContactList) && IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) { - int id = g_pfwFrames[pos].id; + } + // + if ((wParam&MK_LBUTTON)/* && (wParam&MK_CONTROL)*/) { + RECT rcMiranda; + RECT rcwnd, rcOverlap; + POINT newpt, ofspt, curpt, newpos; + //if (GetCapture() != hwnd){break;}; + //curdragbar = -1;lbypos = -1;oldframeheight = -1;ReleaseCapture(); + pos = id2pos(Frameid); + if (g_pfwFrames[pos].floating) { + GetCursorPos(&curpt); + rcwnd.bottom = curpt.y + 5; + rcwnd.top = curpt.y; + rcwnd.left = curpt.x; + rcwnd.right = curpt.x + 5; + GetWindowRect(pcli->hwndContactList, &rcMiranda); + //GetWindowRect( Frames[pos].ContainerWnd, &rcwnd ); + //IntersectRect( &rcOverlap, &rcwnd, &rcMiranda ) + if (IsWindowVisible(pcli->hwndContactList) && IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) { + int id = g_pfwFrames[pos].id; - ofspt.x = 0; ofspt.y = 0; - ClientToScreen(g_pfwFrames[pos].TitleBar.hwnd, &ofspt); - ofspt.x = curpt.x - ofspt.x; ofspt.y = curpt.y - ofspt.y; - CLUIFrames_SetFrameFloat(id, 0); - newpt.x = 0; newpt.y = 0; - ClientToScreen(g_pfwFrames[pos].TitleBar.hwnd, &newpt); - SetCursorPos(newpt.x + ofspt.x, newpt.y + ofspt.y); - GetCursorPos(&curpt); - g_pfwFrames[pos].TitleBar.oldpos = curpt; - return 0; - }; + ofspt.x = 0; ofspt.y = 0; + ClientToScreen(g_pfwFrames[pos].TitleBar.hwnd, &ofspt); + ofspt.x = curpt.x - ofspt.x; ofspt.y = curpt.y - ofspt.y; - } - else { - int id = g_pfwFrames[pos].id; + CLUIFrames_SetFrameFloat(id, 0); + newpt.x = 0; newpt.y = 0; + ClientToScreen(g_pfwFrames[pos].TitleBar.hwnd, &newpt); + SetCursorPos(newpt.x + ofspt.x, newpt.y + ofspt.y); + GetCursorPos(&curpt); - GetCursorPos(&curpt); - rcwnd.bottom = curpt.y + 5; - rcwnd.top = curpt.y; - rcwnd.left = curpt.x; - rcwnd.right = curpt.x + 5; + g_pfwFrames[pos].TitleBar.oldpos = curpt; - GetWindowRect(pcli->hwndContactList, &rcMiranda); - //GetWindowRect( Frames[pos].ContainerWnd, &rcwnd ); - //IntersectRect( &rcOverlap, &rcwnd, &rcMiranda ) + return 0; + }; + } + else { + int id = g_pfwFrames[pos].id; - if (!IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) { - GetCursorPos(&curpt); - GetWindowRect(g_pfwFrames[pos].hWnd, &rcwnd); - rcwnd.left = rcwnd.right - rcwnd.left; - rcwnd.top = rcwnd.bottom - rcwnd.top; - newpos.x = curpt.x; newpos.y = curpt.y; - if (curpt.x >= (rcMiranda.right - 1)) { newpos.x = curpt.x + 5; }; - if (curpt.x <= (rcMiranda.left + 1)) { newpos.x = curpt.x - (rcwnd.left) - 5; }; - if (curpt.y >= (rcMiranda.bottom - 1)) { newpos.y = curpt.y + 5; }; - if (curpt.y <= (rcMiranda.top + 1)) { newpos.y = curpt.y - (rcwnd.top) - 5; }; - ofspt.x = 0; ofspt.y = 0; - //ClientToScreen(Frames[pos].TitleBar.hwnd,&ofspt); - GetWindowRect(g_pfwFrames[pos].TitleBar.hwnd, &rcwnd); - ofspt.x = curpt.x - ofspt.x; ofspt.y = curpt.y - ofspt.y; - - g_pfwFrames[pos].FloatingPos.x = newpos.x; - g_pfwFrames[pos].FloatingPos.y = newpos.y; - CLUIFrames_SetFrameFloat(id, 0); - //SetWindowPos(Frames[pos].ContainerWnd, 0, newpos.x,newpos.y, 0, 0, SWP_NOSIZE); - - - newpt.x = 0; newpt.y = 0; - ClientToScreen(g_pfwFrames[pos].TitleBar.hwnd, &newpt); - - GetWindowRect(g_pfwFrames[pos].hWnd, &rcwnd); - SetCursorPos(newpt.x + (rcwnd.right - rcwnd.left) / 2, newpt.y + (rcwnd.bottom - rcwnd.top) / 2); GetCursorPos(&curpt); - - g_pfwFrames[pos].TitleBar.oldpos = curpt; - return 0; + rcwnd.bottom = curpt.y + 5; + rcwnd.top = curpt.y; + rcwnd.left = curpt.x; + rcwnd.right = curpt.x + 5; + + GetWindowRect(pcli->hwndContactList, &rcMiranda); + //GetWindowRect( Frames[pos].ContainerWnd, &rcwnd ); + //IntersectRect( &rcOverlap, &rcwnd, &rcMiranda ) + + + if (!IntersectRect(&rcOverlap, &rcwnd, &rcMiranda)) { + GetCursorPos(&curpt); + GetWindowRect(g_pfwFrames[pos].hWnd, &rcwnd); + rcwnd.left = rcwnd.right - rcwnd.left; + rcwnd.top = rcwnd.bottom - rcwnd.top; + newpos.x = curpt.x; newpos.y = curpt.y; + if (curpt.x >= (rcMiranda.right - 1)) { newpos.x = curpt.x + 5; }; + if (curpt.x <= (rcMiranda.left + 1)) { newpos.x = curpt.x - (rcwnd.left) - 5; }; + if (curpt.y >= (rcMiranda.bottom - 1)) { newpos.y = curpt.y + 5; }; + if (curpt.y <= (rcMiranda.top + 1)) { newpos.y = curpt.y - (rcwnd.top) - 5; }; + ofspt.x = 0; ofspt.y = 0; + //ClientToScreen(Frames[pos].TitleBar.hwnd,&ofspt); + GetWindowRect(g_pfwFrames[pos].TitleBar.hwnd, &rcwnd); + ofspt.x = curpt.x - ofspt.x; ofspt.y = curpt.y - ofspt.y; + + g_pfwFrames[pos].FloatingPos.x = newpos.x; + g_pfwFrames[pos].FloatingPos.y = newpos.y; + CLUIFrames_SetFrameFloat(id, 0); + //SetWindowPos(Frames[pos].ContainerWnd, 0, newpos.x,newpos.y, 0, 0, SWP_NOSIZE); + + + newpt.x = 0; newpt.y = 0; + ClientToScreen(g_pfwFrames[pos].TitleBar.hwnd, &newpt); + + GetWindowRect(g_pfwFrames[pos].hWnd, &rcwnd); + SetCursorPos(newpt.x + (rcwnd.right - rcwnd.left) / 2, newpt.y + (rcwnd.bottom - rcwnd.top) / 2); + GetCursorPos(&curpt); + + g_pfwFrames[pos].TitleBar.oldpos = curpt; + return 0; + } } } - } - if (wParam & MK_LBUTTON) { - int newh = -1, prevold; + if (wParam & MK_LBUTTON) { + int newh = -1, prevold; - if (GetCapture() != hwnd) { break; }; + if (GetCapture() != hwnd) { break; }; - pos = id2pos(Frameid); + pos = id2pos(Frameid); - if (g_pfwFrames[pos].floating) { - GetCursorPos(&pt); - if ((g_pfwFrames[pos].TitleBar.oldpos.x != pt.x) || (g_pfwFrames[pos].TitleBar.oldpos.y != pt.y)) { + if (g_pfwFrames[pos].floating) { + GetCursorPos(&pt); + if ((g_pfwFrames[pos].TitleBar.oldpos.x != pt.x) || (g_pfwFrames[pos].TitleBar.oldpos.y != pt.y)) { - pt2 = pt; - ScreenToClient(hwnd, &pt2); - GetWindowRect(g_pfwFrames[pos].ContainerWnd, &wndr); - { - int dX, dY; - POINT ptNew; + pt2 = pt; + ScreenToClient(hwnd, &pt2); + GetWindowRect(g_pfwFrames[pos].ContainerWnd, &wndr); + { + int dX, dY; + POINT ptNew; - ptNew.x = pt.x; - ptNew.y = pt.y; - //ClientToScreen( hwnd, &ptNew ); + ptNew.x = pt.x; + ptNew.y = pt.y; + //ClientToScreen( hwnd, &ptNew ); - dX = ptNew.x - ptOld.x; - dY = ptNew.y - ptOld.y; + dX = ptNew.x - ptOld.x; + dY = ptNew.y - ptOld.y; - nLeft += (short)dX; - nTop += (short)dY; + nLeft += (short)dX; + nTop += (short)dY; - if (!(wParam&MK_CONTROL)) - PositionThumb(&g_pfwFrames[pos], nLeft, nTop); - else - SetWindowPos(g_pfwFrames[pos].ContainerWnd, - HWND_TOPMOST, - nLeft, - nTop, - 0, - 0, - SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER); + if (!(wParam&MK_CONTROL)) + PositionThumb(&g_pfwFrames[pos], nLeft, nTop); + else + SetWindowPos(g_pfwFrames[pos].ContainerWnd, + HWND_TOPMOST, + nLeft, + nTop, + 0, + 0, + SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER); - ptOld = ptNew; - } + ptOld = ptNew; + } - pt.x = nLeft; - pt.y = nTop; - g_pfwFrames[pos].TitleBar.oldpos = pt; - }; + pt.x = nLeft; + pt.y = nTop; + g_pfwFrames[pos].TitleBar.oldpos = pt; + }; - //break; - return 0; - } + //break; + return 0; + } - if (g_pfwFrames[pos].prevvisframe != -1) { - GetCursorPos(&pt); + if (g_pfwFrames[pos].prevvisframe != -1) { + GetCursorPos(&pt); - if ((g_pfwFrames[pos].TitleBar.oldpos.x == pt.x) && (g_pfwFrames[pos].TitleBar.oldpos.y == pt.y)) - break; + if ((g_pfwFrames[pos].TitleBar.oldpos.x == pt.x) && (g_pfwFrames[pos].TitleBar.oldpos.y == pt.y)) + break; - ypos = rect.top + pt.y; xpos = rect.left + pt.x; - Framemod = -1; + ypos = rect.top + pt.y; xpos = rect.left + pt.x; + Framemod = -1; - if (g_pfwFrames[pos].align == alBottom) { - direction = -1; - Framemod = pos; - } - else { - direction = 1; - Framemod = g_pfwFrames[pos].prevvisframe; - } - if (g_pfwFrames[Framemod].Locked) break; - if (s_nCurDragBar != -1 && s_nCurDragBar != pos) break; - - if (s_nLastByPos == -1) { - s_nCurDragBar = pos; - s_nLastByPos = ypos; - s_nOldFrameHeight = g_pfwFrames[Framemod].height; - SetCapture(hwnd); - break; - } + if (g_pfwFrames[pos].align == alBottom) { + direction = -1; + Framemod = pos; + } + else { + direction = 1; + Framemod = g_pfwFrames[pos].prevvisframe; + } + if (g_pfwFrames[Framemod].Locked) break; + if (s_nCurDragBar != -1 && s_nCurDragBar != pos) break; + + if (s_nLastByPos == -1) { + s_nCurDragBar = pos; + s_nLastByPos = ypos; + s_nOldFrameHeight = g_pfwFrames[Framemod].height; + SetCapture(hwnd); + break; + } - newh = s_nOldFrameHeight + direction*(ypos - s_nLastByPos); - if (newh > 0) { - prevold = g_pfwFrames[Framemod].height; - g_pfwFrames[Framemod].height = newh; - if (!CLUIFramesFitInSize()) { g_pfwFrames[Framemod].height = prevold; return TRUE; } - g_pfwFrames[Framemod].height = newh; - if (newh > 3) g_pfwFrames[Framemod].collapsed = TRUE; + newh = s_nOldFrameHeight + direction*(ypos - s_nLastByPos); + if (newh > 0) { + prevold = g_pfwFrames[Framemod].height; + g_pfwFrames[Framemod].height = newh; + if (!CLUIFramesFitInSize()) { g_pfwFrames[Framemod].height = prevold; return TRUE; } + g_pfwFrames[Framemod].height = newh; + if (newh > 3) g_pfwFrames[Framemod].collapsed = TRUE; + } + g_pfwFrames[pos].TitleBar.oldpos = pt; } - g_pfwFrames[pos].TitleBar.oldpos = pt; - } - if (newh > 0) - CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); - break; + if (newh > 0) + CLUIFramesOnClistResize((WPARAM)pcli->hwndContactList, 0); + break; + } + s_nCurDragBar = -1; s_nLastByPos = -1; s_nOldFrameHeight = -1; ReleaseCapture(); } - s_nCurDragBar = -1; s_nLastByPos = -1; s_nOldFrameHeight = -1; ReleaseCapture(); - } - break; + break; case WM_PRINT: case WM_PRINTCLIENT: diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index 52f6ae07ce..14aa6ef3be 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1543,8 +1543,6 @@ static int clcHookModulesLoaded(WPARAM, LPARAM) if (MirandaExiting()) return 0; - g_CluiData.bAvsPresent = ServiceExists(MS_AV_GETAVATARBITMAP) != 0; - HookEvent(ME_AV_AVATARCHANGED, clcHookAvatarChanged); HookEvent(ME_FOLDERS_PATH_CHANGED, ReloadSkinFolder); diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index b06bccc39c..9a05de36c4 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -1158,7 +1158,7 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP if (IsWindow(hProgMan)) { SetParent(pcli->hwndContactList, hProgMan); Sync(CLUIFrames_SetParentForContainers, (HWND)hProgMan); - g_CluiData.fOnDesktop = 1; + g_CluiData.fOnDesktop = true; } } else { @@ -1166,11 +1166,11 @@ static INT_PTR CALLBACK DlgProcClistWindowOpts(HWND hwndDlg, UINT msg, WPARAM wP SetParent(pcli->hwndContactList, nullptr); Sync(CLUIFrames_SetParentForContainers, (HWND)nullptr); } - g_CluiData.fOnDesktop = 0; + g_CluiData.fOnDesktop = false; } AniAva_UpdateParent(); db_set_b(0, "CLUI", "FadeInOut", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FADEINOUT)); - g_CluiData.fSmoothAnimation = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FADEINOUT); + g_CluiData.fSmoothAnimation = IsDlgButtonChecked(hwndDlg, IDC_FADEINOUT) != 0; { int i1 = SendDlgItemMessage(hwndDlg, IDC_FRAMESSPIN, UDM_GETPOS, 0, 0); int i2 = SendDlgItemMessage(hwndDlg, IDC_CAPTIONSSPIN, UDM_GETPOS, 0, 0); diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index b37ab12ffd..405ecd5d4d 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -450,14 +450,14 @@ void LoadCLCFonts(HWND hwnd, ClcData *dat) void cli_LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) { - g_CluiData.fDisableSkinEngine = db_get_b(0, "ModernData", "DisableEngine", SETTING_DISABLESKIN_DEFAULT); + g_CluiData.fDisableSkinEngine = db_get_b(0, "ModernData", "DisableEngine", SETTING_DISABLESKIN_DEFAULT) != 0; LoadCLCFonts(hwnd, dat); g_CluiData.bSortByOrder[0] = db_get_b(0, "CList", "SortBy1", SETTING_SORTBY1_DEFAULT); g_CluiData.bSortByOrder[1] = db_get_b(0, "CList", "SortBy2", SETTING_SORTBY2_DEFAULT); g_CluiData.bSortByOrder[2] = db_get_b(0, "CList", "SortBy3", SETTING_SORTBY3_DEFAULT); - g_CluiData.fSortNoOfflineBottom = db_get_b(0, "CList", "NoOfflineBottom", SETTING_NOOFFLINEBOTTOM_DEFAULT); + g_CluiData.fSortNoOfflineBottom = db_get_b(0, "CList", "NoOfflineBottom", SETTING_NOOFFLINEBOTTOM_DEFAULT) != 0; // Row dat->row_min_heigh = db_get_w(0, "CList", "MinRowHeight", CLCDEFAULT_ROWHEIGHT); @@ -487,7 +487,7 @@ void cli_LoadCLCOptions(HWND hwnd, ClcData *dat, BOOL bFirst) // Avatar if (pcli->hwndContactTree == hwnd || pcli->hwndContactTree == nullptr) { - dat->avatars_show = g_CluiData.bAvsPresent && db_get_b(0, "CList", "AvatarsShow", SETTINGS_SHOWAVATARS_DEFAULT); + dat->avatars_show = ServiceExists(MS_AV_GETAVATARBITMAP) && db_get_b(0, "CList", "AvatarsShow", SETTINGS_SHOWAVATARS_DEFAULT); dat->avatars_draw_border = db_get_b(0, "CList", "AvatarsDrawBorders", SETTINGS_AVATARDRAWBORDER_DEFAULT); dat->avatars_border_color = (COLORREF)db_get_dw(0, "CList", "AvatarsBorderColor", SETTINGS_AVATARBORDERCOLOR_DEFAULT); dat->avatars_round_corners = db_get_b(0, "CList", "AvatarsRoundCorners", SETTINGS_AVATARROUNDCORNERS_DEFAULT); diff --git a/plugins/Clist_modern/src/modern_clistmod.cpp b/plugins/Clist_modern/src/modern_clistmod.cpp index e9d6901940..c3197d3810 100644 --- a/plugins/Clist_modern/src/modern_clistmod.cpp +++ b/plugins/Clist_modern/src/modern_clistmod.cpp @@ -142,7 +142,7 @@ int CListMod_ContactListShutdownProc(WPARAM, LPARAM) HRESULT PreLoadContactListModule() { /* Global data initialization */ - g_CluiData.fOnDesktop = FALSE; + g_CluiData.fOnDesktop = false; g_CluiData.dwKeyColor = RGB(255, 0, 255); g_CluiData.bCurrentAlpha = 255; diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 7d4926d9f4..d9ea40e650 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -302,7 +302,7 @@ CLUI::~CLUI() HRESULT CLUI::LoadDllsRuntime() { g_CluiData.fLayered = !db_get_b(0, "ModernData", "DisableEngine", SETTING_DISABLESKIN_DEFAULT); - g_CluiData.fSmoothAnimation = db_get_b(0, "CLUI", "FadeInOut", SETTING_FADEIN_DEFAULT); + g_CluiData.fSmoothAnimation = db_get_b(0, "CLUI", "FadeInOut", SETTING_FADEIN_DEFAULT) != 0; g_CluiData.fLayered = (g_CluiData.fLayered*db_get_b(0, "ModernData", "EnableLayering", g_CluiData.fLayered)) && !db_get_b(0, "ModernData", "DisableEngine", SETTING_DISABLESKIN_DEFAULT); if (IsWinVerVistaPlus() && !IsWinVer8Plus()) { @@ -500,33 +500,27 @@ BOOL CLUI_CheckOwnedByClui(HWND hWnd) int CLUI_ShowWindowMod(HWND hWnd, int nCmd) { - if (hWnd == pcli->hwndContactList && (nCmd == SW_HIDE || nCmd == SW_MINIMIZE)) { - AniAva_InvalidateAvatarPositions(0); - AniAva_RemoveInvalidatedAvatars(); - } + if (hWnd == pcli->hwndContactList) { + if (nCmd == SW_HIDE || nCmd == SW_MINIMIZE) { + AniAva_InvalidateAvatarPositions(0); + AniAva_RemoveInvalidatedAvatars(); + } - if (hWnd == pcli->hwndContactList && - !g_mutex_bChangingMode && - nCmd == SW_HIDE && - !g_CluiData.fLayered && - db_get_b(0, "CList", "WindowShadow", SETTING_WINDOWSHADOW_DEFAULT)) - { - ShowWindow(hWnd, SW_MINIMIZE); // removing of shadow - return ShowWindow(hWnd, nCmd); - } - if (hWnd == pcli->hwndContactList && - !g_mutex_bChangingMode && - nCmd == SW_RESTORE && - !g_CluiData.fLayered && - g_CluiData.fSmoothAnimation && - !g_bTransparentFlag) - { - if (db_get_b(0, "CList", "WindowShadow", SETTING_WINDOWSHADOW_DEFAULT)) - CLUI_SmoothAlphaTransition(hWnd, 255, 1); - else { - int ret = ShowWindow(hWnd, nCmd); - CLUI_SmoothAlphaTransition(hWnd, 255, 1); - return ret; + if (!g_mutex_bChangingMode && !g_CluiData.fLayered) { + if (nCmd == SW_HIDE && db_get_b(0, "CList", "WindowShadow", SETTING_WINDOWSHADOW_DEFAULT)) { + ShowWindow(hWnd, SW_MINIMIZE); // removing of shadow + return ShowWindow(hWnd, nCmd); + } + + if (nCmd == SW_RESTORE && g_CluiData.fSmoothAnimation && !g_bTransparentFlag) { + if (db_get_b(0, "CList", "WindowShadow", SETTING_WINDOWSHADOW_DEFAULT)) + CLUI_SmoothAlphaTransition(hWnd, 255, 1); + else { + int ret = ShowWindow(hWnd, nCmd); + CLUI_SmoothAlphaTransition(hWnd, 255, 1); + return ret; + } + } } } return ShowWindow(hWnd, nCmd); @@ -537,9 +531,7 @@ static BOOL CLUI_WaitThreadsCompletion() static BYTE bEntersCount = 0; static const BYTE bcMAX_AWAITING_RETRY = 10; // repeat awaiting only 10 times TRACE("CLUI_WaitThreadsCompletion Enter"); - if (bEntersCount < bcMAX_AWAITING_RETRY && - (g_CluiData.mutexPaintLock || g_hAwayMsgThread || g_hGetTextAsyncThread || g_hSmoothAnimationThread) && !Miranda_IsTerminated()) - { + if (bEntersCount < bcMAX_AWAITING_RETRY && (g_CluiData.mutexPaintLock || g_hAwayMsgThread || g_hGetTextAsyncThread || g_hSmoothAnimationThread) && !Miranda_IsTerminated()) { TRACE("Waiting threads"); TRACEVAR("g_CluiData.mutexPaintLock: %x", g_CluiData.mutexPaintLock); TRACEVAR("g_hAwayMsgThread: %x", g_hAwayMsgThread); @@ -556,10 +548,9 @@ static BOOL CLUI_WaitThreadsCompletion() void CLUI_UpdateLayeredMode() { - g_CluiData.fDisableSkinEngine = db_get_b(0, "ModernData", "DisableEngine", SETTING_DISABLESKIN_DEFAULT); - BOOL tLayeredFlag = TRUE; - tLayeredFlag &= (db_get_b(0, "ModernData", "EnableLayering", tLayeredFlag) && !g_CluiData.fDisableSkinEngine); - + g_CluiData.fDisableSkinEngine = db_get_b(0, "ModernData", "DisableEngine", SETTING_DISABLESKIN_DEFAULT) != 0; + + bool tLayeredFlag = db_get_b(0, "ModernData", "EnableLayering", SETTING_ENABLELAYERING_DEFAULT) != 0 && !g_CluiData.fDisableSkinEngine; if (g_CluiData.fLayered != tLayeredFlag) { BOOL fWasVisible = IsWindowVisible(pcli->hwndContactList); if (fWasVisible) @@ -585,7 +576,7 @@ void CLUI_UpdateLayeredMode() void CLUI_UpdateAeroGlass() { - BOOL tAeroGlass = db_get_b(0, "ModernData", "AeroGlass", SETTING_AEROGLASS_DEFAULT) && (g_CluiData.fLayered); + bool tAeroGlass = db_get_b(0, "ModernData", "AeroGlass", SETTING_AEROGLASS_DEFAULT) && g_CluiData.fLayered; if (g_proc_DWMEnableBlurBehindWindow && (tAeroGlass != g_CluiData.fAeroGlass)) { if (g_CluiData.hAeroGlassRgn) { DeleteObject(g_CluiData.hAeroGlassRgn); @@ -621,7 +612,7 @@ void CLUI_ChangeWindowMode() g_mutex_bChangingMode = TRUE; g_bTransparentFlag = db_get_b(0, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT); - g_CluiData.fSmoothAnimation = db_get_b(0, "CLUI", "FadeInOut", SETTING_FADEIN_DEFAULT); + g_CluiData.fSmoothAnimation = db_get_b(0, "CLUI", "FadeInOut", SETTING_FADEIN_DEFAULT) != 0; if (g_bTransparentFlag == 0 && g_CluiData.bCurrentAlpha != 0) g_CluiData.bCurrentAlpha = 255; @@ -674,7 +665,7 @@ void CLUI_ChangeWindowMode() SetParent(pcli->hwndContactList, nullptr); Sync(CLUIFrames_SetParentForContainers, (HWND)nullptr); UpdateWindow(pcli->hwndContactList); - g_CluiData.fOnDesktop = 0; + g_CluiData.fOnDesktop = false; } // 5 - TODO Apply Style @@ -710,13 +701,13 @@ void CLUI_ChangeWindowMode() if (IsWindow(hProgMan)) { SetParent(pcli->hwndContactList, hProgMan); Sync(CLUIFrames_SetParentForContainers, (HWND)hProgMan); - g_CluiData.fOnDesktop = 1; + g_CluiData.fOnDesktop = true; } } else { SetParent(pcli->hwndContactList, nullptr); Sync(CLUIFrames_SetParentForContainers, (HWND)nullptr); - g_CluiData.fOnDesktop = 0; + g_CluiData.fOnDesktop = false; } // 7 - if it was visible - show @@ -1035,7 +1026,7 @@ int CLUI_ReloadCLUIOptions() wBehindEdgeHideDelay = db_get_w(0, "ModernData", "HideDelay", SETTING_HIDEDELAY_DEFAULT); wBehindEdgeBorderSize = db_get_w(0, "ModernData", "HideBehindBorderSize", SETTING_HIDEBEHINDBORDERSIZE_DEFAULT); - g_CluiData.fAutoSize = db_get_b(0, "CLUI", "AutoSize", SETTING_AUTOSIZE_DEFAULT); + g_CluiData.fAutoSize = db_get_b(0, "CLUI", "AutoSize", SETTING_AUTOSIZE_DEFAULT) != 0; g_CluiData.bInternalAwayMsgDiscovery = db_get_b(0, "ModernData", "InternalAwayMsgDiscovery", SETTING_INTERNALAWAYMSGREQUEST_DEFAULT); g_CluiData.bRemoveAwayMessageForOffline = db_get_b(0, "ModernData", "RemoveAwayMessageForOffline", SETTING_REMOVEAWAYMSGFOROFFLINE_DEFAULT); diff --git a/plugins/Clist_modern/src/modern_global_structure.h b/plugins/Clist_modern/src/modern_global_structure.h index c29f3ea5b1..03d45eef0c 100644 --- a/plugins/Clist_modern/src/modern_global_structure.h +++ b/plugins/Clist_modern/src/modern_global_structure.h @@ -32,23 +32,22 @@ typedef struct tagCLUIDATA DWORD t_now; // Modern Global Variables - bool bAvsPresent; - bool bEventAreaEnabled; - bool bNotifyActive; - BOOL fDisableSkinEngine; - BOOL fOnDesktop; - BOOL fSmoothAnimation; - BOOL fLayered; - BOOL fDocked; - BOOL fSortNoOfflineBottom; - BOOL fAutoSize; - BOOL fAeroGlass; + int fDocked; HRGN hAeroGlassRgn; BOOL mutexPreventDockMoving; BOOL mutexOnEdgeSizing; BOOL mutexPaintLock; + bool bEventAreaEnabled; + bool bNotifyActive; + bool fDisableSkinEngine; + bool fOnDesktop; + bool fSmoothAnimation; + bool fLayered; + bool fSortNoOfflineBottom; + bool fAutoSize; + bool fAeroGlass; BYTE bCurrentAlpha; BYTE bSTATE; BYTE bBehindEdgeSettings; diff --git a/plugins/Clist_modern/src/version.h b/plugins/Clist_modern/src/version.h index 8ce13d08d1..afd5203779 100644 --- a/plugins/Clist_modern/src/version.h +++ b/plugins/Clist_modern/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 9 #define __RELEASE_NUM 1 -#define __BUILD_NUM 6 +#define __BUILD_NUM 7 #include -- cgit v1.2.3