diff options
author | George Hazan <george.hazan@gmail.com> | 2016-05-23 13:32:02 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-05-23 13:32:02 +0000 |
commit | c8b51e0745cc481644752d29c1c779e14e3530bb (patch) | |
tree | 4e160962d2c13cccb8dc39f29a897c3f84487f6a /src/mir_app | |
parent | 0c4dc97b703e93e2503c9cabedaa6c42984d0f00 (diff) |
- optimization in cli_SaveStateAndRebuildList applied to all clists (bLockScrollbar);
- boolean variables were made bool;
git-svn-id: http://svn.miranda-ng.org/main/trunk@16863 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/clc.cpp | 30 | ||||
-rw-r--r-- | src/mir_app/src/clcfiledrop.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/clcitems.cpp | 28 | ||||
-rw-r--r-- | src/mir_app/src/clcutils.cpp | 15 |
4 files changed, 42 insertions, 35 deletions
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index b2168711c4..1a02e1f04c 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -270,7 +270,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam dat->infoTipTimeout = db_get_w(NULL, "CLC", "InfoTipHoverTime", 750);
dat->extraColumnSpacing = 20;
dat->list.cl.increment = 30;
- dat->needsResort = 1;
+ dat->bNeedsResort = true;
cli.pfnLoadClcOptions(hwnd, dat, TRUE);
if (!IsWindowVisible(hwnd))
SetTimer(hwnd, TIMERID_REBUILDAFTER, 10, NULL);
@@ -286,7 +286,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam case INTM_SCROLLBARCHANGED:
if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_CONTACTLIST) {
- if (dat->noVScrollbar)
+ if (dat->bNoVScrollbar)
ShowScrollBar(hwnd, SB_VERT, FALSE);
else
cli.pfnRecalcScrollBar(hwnd, dat);
@@ -323,7 +323,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam HBITMAP hBmpMask = CreateBitmap(rc.right, rc.bottom, 1, 1, NULL);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hoBmp = (HBITMAP)SelectObject(hdcMem, hBmp);
- HBRUSH hBrush = CreateSolidBrush(dat->useWindowsColours ? GetSysColor(COLOR_HIGHLIGHT) : dat->selBkColour);
+ HBRUSH hBrush = CreateSolidBrush(dat->bUseWindowsColours ? GetSysColor(COLOR_HIGHLIGHT) : dat->selBkColour);
FillRect(hdcMem, &rc, hBrush);
DeleteObject(hBrush);
@@ -440,7 +440,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam }
else cli.pfnDeleteItemFromTree(hwnd, wParam);
- dat->needsResort = 1;
+ dat->bNeedsResort = true;
SortClcByTimer(hwnd);
}
break;
@@ -470,7 +470,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam nm.flags = 0;
nm.hItem = (HANDLE)wParam;
SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)& nm);
- dat->needsResort = 1;
+ dat->bNeedsResort = true;
}
}
SetTimer(hwnd, TIMERID_REBUILDAFTER, 1, NULL);
@@ -504,7 +504,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam if (contact) {
contact->iImage = (WORD)lParam;
cli.pfnNotifyNewContact(hwnd, wParam);
- dat->needsResort = 1;
+ dat->bNeedsResort = true;
}
}
}
@@ -523,7 +523,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam else
contact->flags &= ~CONTACTF_ONLINE;
}
- dat->needsResort = 1;
+ dat->bNeedsResort = true;
}
if (hSelItem) {
ClcGroup *selgroup;
@@ -541,7 +541,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam break;
mir_tstrncpy(contact->szText, cli.pfnGetContactDisplayName(wParam, 0), _countof(contact->szText));
- dat->needsResort = 1;
+ dat->bNeedsResort = true;
SortClcByTimer(hwnd);
break;
@@ -703,7 +703,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam case VK_RETURN:
cli.pfnDoSelectionDefaultAction(hwnd, dat);
dat->szQuickSearch[0] = 0;
- if (dat->filterSearch)
+ if (dat->bFilterSearch)
cli.pfnSaveStateAndRebuildList(hwnd, dat);
return 0;
case VK_F2: cli.pfnBeginRenameSelection(hwnd, dat); return 0;
@@ -721,7 +721,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam }
}
if (changeGroupExpand) {
- if (!dat->filterSearch)
+ if (!dat->bFilterSearch)
dat->szQuickSearch[0] = 0;
hit = cli.pfnGetRowByIndex(dat, dat->selection, &contact, &group);
if (hit != -1) {
@@ -741,7 +741,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam return 0;
}
if (selMoved) {
- if (!dat->filterSearch)
+ if (!dat->bFilterSearch)
dat->szQuickSearch[0] = 0;
if (dat->selection >= cli.pfnGetGroupContentsCount(&dat->list, 1))
dat->selection = cli.pfnGetGroupContentsCount(&dat->list, 1) - 1;
@@ -794,7 +794,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam mir_tstrcat(dat->szQuickSearch, szNew);
}
- if (dat->filterSearch)
+ if (dat->bFilterSearch)
cli.pfnSaveStateAndRebuildList(hwnd, dat);
if (dat->szQuickSearch[0]) {
@@ -901,7 +901,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam cli.pfnEndRename(hwnd, dat, 1);
dat->ptDragStart.x = (short)LOWORD(lParam);
dat->ptDragStart.y = (short)HIWORD(lParam);
- if (!dat->filterSearch)
+ if (!dat->bFilterSearch)
dat->szQuickSearch[0] = 0;
hit = cli.pfnHitTest(hwnd, dat, (short)LOWORD(lParam), (short)HIWORD(lParam), &contact, &group, &hitFlags);
@@ -1183,7 +1183,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam UpdateWindow(hwnd);
cli.pfnDoSelectionDefaultAction(hwnd, dat);
dat->szQuickSearch[0] = 0;
- if (dat->filterSearch)
+ if (dat->bFilterSearch)
cli.pfnSaveStateAndRebuildList(hwnd, dat);
break;
@@ -1195,7 +1195,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam if (GetFocus() != hwnd)
SetFocus(hwnd);
dat->iHotTrack = -1;
- if (!dat->filterSearch)
+ if (!dat->bFilterSearch)
dat->szQuickSearch[0] = 0;
{
POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
diff --git a/src/mir_app/src/clcfiledrop.cpp b/src/mir_app/src/clcfiledrop.cpp index 4f91d76d17..aadd459d60 100644 --- a/src/mir_app/src/clcfiledrop.cpp +++ b/src/mir_app/src/clcfiledrop.cpp @@ -151,7 +151,7 @@ HRESULT CDropTarget::DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL hwndCurrentDrag = hwnd;
ClcData *dat = (ClcData *) GetWindowLongPtr(hwndCurrentDrag, 0);
originalSelection = dat->selection;
- dat->showSelAlways = 1;
+ dat->bShowSelAlways = true;
}
if (pDropTargetHelper && hwndCurrentDrag)
pDropTargetHelper->DragEnter(hwndCurrentDrag, pDataObj, (POINT*)&pt, *pdwEffect);
@@ -164,7 +164,7 @@ HRESULT CDropTarget::DragLeave(void) if (pDropTargetHelper)
pDropTargetHelper->DragLeave();
ClcData *dat = (ClcData *) GetWindowLongPtr(hwndCurrentDrag, 0);
- dat->showSelAlways = 0;
+ dat->bShowSelAlways = false;
dat->selection = originalSelection;
cli.pfnInvalidateRect(hwndCurrentDrag, NULL, FALSE);
}
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index c679103251..46a288eb56 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -45,7 +45,7 @@ ClcGroup* fnAddGroup(HWND hwnd, ClcData *dat, const TCHAR *szName, DWORD flags, ClcGroup *group = &dat->list; int i, compareResult; - dat->needsResort = 1; + dat->bNeedsResort = true;
if (!(GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_USEGROUPS)) return &dat->list; @@ -175,7 +175,7 @@ int fnAddContactToGroup(ClcData *dat, ClcGroup *group, MCONTACT hContact) { int i, index = -1; - dat->needsResort = 1; + dat->bNeedsResort = true;
for (i = group->cl.count - 1; i >= 0; i--) { if (group->cl.items[i]->hContact == hContact) return i; @@ -222,7 +222,7 @@ void fnAddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int updateTo WORD status = ID_STATUS_OFFLINE; char *szProto = GetContactProto(hContact); - dat->needsResort = 1; + dat->bNeedsResort = true;
if (style & CLS_NOHIDEOFFLINE) checkHideOffline = 0; if (checkHideOffline) @@ -309,7 +309,7 @@ ClcGroup* fnRemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, void fnDeleteItemFromTree(HWND hwnd, MCONTACT hItem) { ClcData *dat = (ClcData*)GetWindowLongPtr(hwnd, 0); - dat->needsResort = 1; + dat->bNeedsResort = true;
ClcGroup *group; ClcContact *contact; @@ -376,7 +376,7 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat) if (group != NULL) { group->totalMembers++; - if (dat->filterSearch && dat->szQuickSearch[0] != '\0') { + if (dat->bFilterSearch && dat->szQuickSearch[0] != '\0') { TCHAR *name = cli.pfnGetContactDisplayName(hContact, 0); TCHAR *lowered_name = CharLowerW(NEWTSTR_ALLOCA(name)); TCHAR *lowered_search = CharLowerW(NEWTSTR_ALLOCA(dat->szQuickSearch)); @@ -544,7 +544,7 @@ void fnSortCLC(HWND hwnd, ClcData *dat, int useInsertionSort) { ClcGroup *group = &dat->list; - if (dat->needsResort) { + if (dat->bNeedsResort) { MCONTACT hSelItem; ClcContact *selcontact; if (cli.pfnGetRowByIndex(dat, dat->selection, &selcontact, NULL) == -1) @@ -576,7 +576,7 @@ void fnSortCLC(HWND hwnd, ClcData *dat, int useInsertionSort) cli.pfnRecalcScrollBar(hwnd, dat); } - dat->needsResort = 0; + dat->bNeedsResort = false; cli.pfnInvalidateRect(hwnd, NULL, FALSE); } @@ -600,7 +600,6 @@ struct SavedInfoState_t void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) { - NMCLISTCONTROL nm; int i, j; ClcGroup *group; ClcContact *contact; @@ -610,11 +609,13 @@ void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) KillTimer(hwnd, TIMERID_RENAME); cli.pfnEndRename(hwnd, dat, 1); + dat->bLockScrollbar = true;
+ OBJLIST<SavedContactState_t> saveContact(10, NumericKeySortT); OBJLIST<SavedGroupState_t> saveGroup(100, NumericKeySortT); OBJLIST<SavedInfoState_t> saveInfo(10, NumericKeySortT); - dat->needsResort = 1; + dat->bNeedsResort = true;
group = &dat->list; group->scanIndex = 0; for (;;) { @@ -627,21 +628,21 @@ void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) group = group->cl.items[group->scanIndex]->group; group->scanIndex = 0; - SavedGroupState_t* p = new SavedGroupState_t; + SavedGroupState_t *p = new SavedGroupState_t; p->groupId = group->groupId; p->expanded = group->expanded; saveGroup.insert(p); continue; } else if (group->cl.items[group->scanIndex]->type == CLCIT_CONTACT) { - SavedContactState_t* p = new SavedContactState_t; + SavedContactState_t *p = new SavedContactState_t; p->hContact = group->cl.items[group->scanIndex]->hContact; memcpy(p->iExtraImage, group->cl.items[group->scanIndex]->iExtraImage, sizeof(p->iExtraImage)); p->checked = group->cl.items[group->scanIndex]->flags & CONTACTF_CHECKED; saveContact.insert(p); } else if (group->cl.items[group->scanIndex]->type == CLCIT_INFO) { - SavedInfoState_t* p = new SavedInfoState_t; + SavedInfoState_t *p = new SavedInfoState_t; p->parentId = (group->parent == NULL) ? -1 : group->groupId; p->contact = *group->cl.items[group->scanIndex]; saveInfo.insert(p); @@ -695,9 +696,12 @@ void fnSaveStateAndRebuildList(HWND hwnd, ClcData *dat) *group->cl.items[j] = saveInfo[i].contact; } + dat->bLockScrollbar = false;
cli.pfnRecalculateGroupCheckboxes(hwnd, dat); cli.pfnRecalcScrollBar(hwnd, dat); + + NMCLISTCONTROL nm; nm.hdr.code = CLN_LISTREBUILT; nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetDlgCtrlID(hwnd); diff --git a/src/mir_app/src/clcutils.cpp b/src/mir_app/src/clcutils.cpp index 1e89d3e202..94dccfc161 100644 --- a/src/mir_app/src/clcutils.cpp +++ b/src/mir_app/src/clcutils.cpp @@ -272,6 +272,9 @@ void fnEnsureVisible(HWND hwnd, ClcData *dat, int iItem, int partialOk) void fnRecalcScrollBar(HWND hwnd, ClcData *dat)
{
+ if (dat->bLockScrollbar)
+ return;
+
RECT clRect;
GetClientRect(hwnd, &clRect);
@@ -284,7 +287,7 @@ void fnRecalcScrollBar(HWND hwnd, ClcData *dat) si.nPos = dat->yScroll;
if (GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_CONTACTLIST) {
- if (dat->noVScrollbar == 0)
+ if (!dat->bNoVScrollbar)
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
}
else SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
@@ -369,7 +372,7 @@ int fnFindRowByText(HWND hwnd, ClcData *dat, const TCHAR *text, int prefixOk) }
if (group->cl.items[group->scanIndex]->type != CLCIT_DIVIDER) {
bool show;
- if (dat->filterSearch) {
+ if (dat->bFilterSearch) {
TCHAR *lowered_szText = CharLowerW(NEWTSTR_ALLOCA(group->cl.items[group->scanIndex]->szText));
TCHAR *lowered_text = CharLowerW(NEWTSTR_ALLOCA(text));
show = _tcsstr(lowered_szText, lowered_text) != NULL;
@@ -725,9 +728,9 @@ void fnLoadClcOptions(HWND hwnd, ClcData *dat, BOOL bFirst) dat->scrollTime = db_get_w(NULL, "CLC", "ScrollTime", CLCDEFAULT_SCROLLTIME);
dat->groupIndent = db_get_b(NULL, "CLC", "GroupIndent", CLCDEFAULT_GROUPINDENT);
dat->gammaCorrection = db_get_b(NULL, "CLC", "GammaCorrect", CLCDEFAULT_GAMMACORRECT);
- dat->showIdle = db_get_b(NULL, "CLC", "ShowIdle", CLCDEFAULT_SHOWIDLE);
- dat->noVScrollbar = db_get_b(NULL, "CLC", "NoVScrollBar", 0);
- dat->filterSearch = db_get_b(NULL, "CLC", "FilterSearch", 1);
+ dat->bShowIdle = db_get_b(NULL, "CLC", "ShowIdle", CLCDEFAULT_SHOWIDLE) != 0;
+ dat->bNoVScrollbar = db_get_b(NULL, "CLC", "NoVScrollBar", false) != 0;
+ dat->bFilterSearch = db_get_b(NULL, "CLC", "FilterSearch", true) != 0;
SendMessage(hwnd, INTM_SCROLLBARCHANGED, 0, 0);
dat->greyoutFlags = db_get_dw(NULL, "CLC", "GreyoutFlags", CLCDEFAULT_GREYOUTFLAGS);
@@ -736,7 +739,7 @@ void fnLoadClcOptions(HWND hwnd, ClcData *dat, BOOL bFirst) dat->selTextColour = db_get_dw(NULL, "CLC", "SelTextColour", CLCDEFAULT_SELTEXTCOLOUR);
dat->hotTextColour = db_get_dw(NULL, "CLC", "HotTextColour", CLCDEFAULT_HOTTEXTCOLOUR);
dat->quickSearchColour = db_get_dw(NULL, "CLC", "QuickSearchColour", CLCDEFAULT_QUICKSEARCHCOLOUR);
- dat->useWindowsColours = db_get_b(NULL, "CLC", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS);
+ dat->bUseWindowsColours = db_get_b(NULL, "CLC", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS) != 0;
if (cli.hwndContactTree != NULL && hwnd != cli.hwndContactTree) {
dat->bkChanged = true; // block custom background
|