summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-07-23 21:08:23 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-07-23 21:08:23 +0300
commit97846e5e80ca89b0307d740e71cd488895ac42c6 (patch)
treefc48e0f23fa9062a29fff6414210e21f6077dac9
parent17b316e3e7bce8ca2f51efdc8824451c4be89b8f (diff)
let boolean variables inside ClcGroup be boolean
-rw-r--r--include/m_clist.h6
-rw-r--r--include/m_clistint.h5
-rw-r--r--libs/win32/mir_app.libbin263386 -> 264370 bytes
-rw-r--r--libs/win64/mir_app.libbin262438 -> 263400 bytes
-rw-r--r--plugins/Clist_modern/src/groupmenu.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp18
-rw-r--r--plugins/Clist_modern/src/modern_clcidents.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_clcitems.cpp6
-rw-r--r--plugins/Clist_modern/src/modern_clcmsgs.cpp2
-rw-r--r--plugins/Clist_modern/src/modern_clcpaint.cpp30
-rw-r--r--plugins/Clist_modern/src/modern_clcutils.cpp8
-rw-r--r--plugins/Clist_modern/src/modern_rowheight_funcs.cpp6
-rw-r--r--plugins/Clist_modern/src/modern_viewmodebar.cpp34
-rw-r--r--plugins/Clist_nicer/src/clc.cpp4
-rw-r--r--plugins/Clist_nicer/src/clc.h1
-rw-r--r--plugins/Clist_nicer/src/clcpaint.cpp8
-rw-r--r--plugins/Clist_nicer/src/clcutils.cpp40
-rw-r--r--plugins/Clist_nicer/src/rowheight_funcs.cpp2
-rw-r--r--src/core/stdclist/src/clcpaint.cpp4
-rw-r--r--src/mir_app/src/clc.cpp12
-rw-r--r--src/mir_app/src/clc.h1
-rw-r--r--src/mir_app/src/clcidents.cpp14
-rw-r--r--src/mir_app/src/clcitems.cpp28
-rw-r--r--src/mir_app/src/clcmsgs.cpp22
-rw-r--r--src/mir_app/src/clcutils.cpp37
-rw-r--r--src/mir_app/src/clistcore.cpp1
-rw-r--r--src/mir_app/src/clistgroups.cpp26
-rw-r--r--src/mir_app/src/menu_groups.cpp2
-rw-r--r--src/mir_app/src/mir_app.def3
-rw-r--r--src/mir_app/src/mir_app64.def3
30 files changed, 166 insertions, 163 deletions
diff --git a/include/m_clist.h b/include/m_clist.h
index 3eb05692cc..33ea474b98 100644
--- a/include/m_clist.h
+++ b/include/m_clist.h
@@ -420,6 +420,12 @@ EXTERN_C MIR_APP_DLL(wchar_t*) Clist_GroupGetName(MGROUP hGroup, uint32_t *pdwFl
EXTERN_C MIR_APP_DLL(int) Clist_GroupSetExpanded(MGROUP hGroup, int iNewState);
/////////////////////////////////////////////////////////////////////////////////////////
+// saves & restores the state flag for all groups
+
+EXTERN_C MIR_APP_DLL(void) Clist_GroupSaveExpanded();
+EXTERN_C MIR_APP_DLL(void) Clist_GroupRestoreExpanded();
+
+/////////////////////////////////////////////////////////////////////////////////////////
// changes the flags for a group
// iNewFlags = MAKELPARAM(flags, flagsMask)
// returns 0 on success, nonzero on failure
diff --git a/include/m_clistint.h b/include/m_clistint.h
index 7877eb7934..f3aa749140 100644
--- a/include/m_clistint.h
+++ b/include/m_clistint.h
@@ -84,7 +84,8 @@ struct ClcGroup : public MZeroedObject
{}
LIST<ClcContact> cl;
- int expanded, hideOffline, groupId;
+ int groupId;
+ bool bExpanded, bHideOffline;
ClcGroup *parent;
int scanIndex;
int totalMembers;
@@ -278,6 +279,7 @@ MIR_APP_DLL(int) Clist_RemoveEvent(MCONTACT hContact, MEVENT hDbEvent);
MIR_APP_DLL(ClcGroup*) Clist_RemoveItemFromGroup(HWND hwnd, ClcGroup *group, ClcContact *contact, int updateTotalCount);
MIR_APP_DLL(void) Clist_SaveStateAndRebuildList(HWND hwnd, ClcData *dat);
MIR_APP_DLL(void) Clist_SetGroupChildCheckboxes(ClcGroup *group, int checked);
+MIR_APP_DLL(void) Clist_SetGroupExpand(HWND hwnd, ClcData *dat, ClcGroup *group, int newState);
MIR_APP_DLL(int) Clist_TrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int status);
MIR_APP_DLL(int) Clist_TrayIconDestroy(HWND hwnd);
@@ -350,7 +352,6 @@ struct CLIST_INTERFACE
int (*pfnHitTest)(HWND hwnd, ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, uint32_t * flags);
void (*pfnScrollTo)(HWND hwnd, ClcData *dat, int desty, int noSmooth);
void (*pfnRecalcScrollBar)(HWND hwnd, ClcData *dat);
- void (*pfnSetGroupExpand)(HWND hwnd, ClcData *dat, ClcGroup *group, int newState);
int (*pfnFindRowByText)(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk);
void (*pfnBeginRenameSelection)(HWND hwnd, ClcData *dat);
void (*pfnGetDefaultFontSetting)(int i, LOGFONT *lf, COLORREF *colour);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 77490f8a8c..a9289b8d58 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 3e9b392024..df86862301 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Clist_modern/src/groupmenu.cpp b/plugins/Clist_modern/src/groupmenu.cpp
index c3d6d99d0b..d91e63214b 100644
--- a/plugins/Clist_modern/src/groupmenu.cpp
+++ b/plugins/Clist_modern/src/groupmenu.cpp
@@ -118,7 +118,7 @@ static int OnBuildSubGroupMenu(WPARAM wParam, LPARAM)
return 0;
bool showOfflineinGroup = CLCItems_IsShowOfflineGroup(group);
- bool gray2 = group->hideOffline == 0;
+ bool gray2 = !group->bHideOffline;
Menu_EnableItem(hShowOfflineUsersHereMenuItem, gray2);
Menu_SetChecked(hShowOfflineUsersHereMenuItem, showOfflineinGroup && gray2);
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index 2749972689..ce1facd553 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -239,7 +239,7 @@ static int clcSearchNextContact(HWND hwnd, ClcData *dat, int index, const wchar_
int contactScanIndex = group->scanIndex;
int foundindex;
for (; group; group = group->parent)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, group, 1);
+ Clist_SetGroupExpand(hwnd, dat, group, 1);
foundindex = g_clistApi.pfnGetRowsPriorTo(&dat->list, contactGroup, contactScanIndex);
if (fReturnAsFound)
return foundindex;
@@ -253,7 +253,7 @@ static int clcSearchNextContact(HWND hwnd, ClcData *dat, int index, const wchar_
group->scanIndex = contactScanIndex;
}
if (cc->type == CLCIT_GROUP) {
- if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || cc->group->expanded) {
+ if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
continue;
@@ -278,7 +278,7 @@ static bool clcItemNotHiddenOffline(ClcGroup *group, ClcContact *contact)
if (!group)
return false;
- if (group->hideOffline)
+ if (group->bHideOffline)
return false;
if (CLCItems_IsShowOfflineGroup(group))
@@ -556,14 +556,14 @@ static LRESULT clcOnKeyDown(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPARAM
}
else if (contact->type == CLCIT_GROUP) {
if (changeGroupExpand == 1) {
- if (!contact->group->expanded) {
+ if (!contact->group->bExpanded) {
dat->selection--;
selMoved = 1;
}
- else g_clistApi.pfnSetGroupExpand(hwnd, dat, contact->group, 0);
+ else Clist_SetGroupExpand(hwnd, dat, contact->group, 0);
}
else if (changeGroupExpand == 2) {
- g_clistApi.pfnSetGroupExpand(hwnd, dat, contact->group, 1);
+ Clist_SetGroupExpand(hwnd, dat, contact->group, 1);
dat->selection++;
selMoved = 1;
}
@@ -755,7 +755,7 @@ static LRESULT clcOnLButtonDown(ClcData *dat, HWND hwnd, UINT, WPARAM, LPARAM lP
ClcGroup *selgroup;
ClcContact *selcontact;
dat->selection = cliGetRowByIndex(dat, dat->selection, &selcontact, &selgroup);
- g_clistApi.pfnSetGroupExpand(hwnd, dat, contact->group, -1);
+ Clist_SetGroupExpand(hwnd, dat, contact->group, -1);
if (dat->selection != -1) {
dat->selection = cliGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact));
if (dat->selection == -1)
@@ -1374,10 +1374,10 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT, WPARAM wParam
if (contact && contact->iImage == lParam)
return 0;
- if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline) && clcItemNotHiddenOffline(group, contact))
+ if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->bHideOffline) && clcItemNotHiddenOffline(group, contact))
shouldShow = TRUE;
- if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && ((style & CLS_HIDEOFFLINE) || group->hideOffline)) { // CLVM changed
+ if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && ((style & CLS_HIDEOFFLINE) || group->bHideOffline)) { // CLVM changed
if (dat->selection >= 0 && g_clistApi.pfnGetRowByIndex(dat, dat->selection, &selcontact, nullptr) != -1)
hSelItem = Clist_ContactToHItem(selcontact);
Clist_RemoveItemFromGroup(hwnd, group, contact, (style & CLS_CONTACTLIST) == 0);
diff --git a/plugins/Clist_modern/src/modern_clcidents.cpp b/plugins/Clist_modern/src/modern_clcidents.cpp
index 29be4b6442..7ed304fed8 100644
--- a/plugins/Clist_modern/src/modern_clcidents.cpp
+++ b/plugins/Clist_modern/src/modern_clcidents.cpp
@@ -45,7 +45,7 @@ int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex)
if (cc->group == subgroup && contactIndex == -1)
return count - 1;
- if (cc->group->expanded) {
+ if (cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
subcontactscount = 0;
@@ -122,7 +122,7 @@ int cliGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup
}
index++;
- if (cc->type == CLCIT_GROUP && cc->group->expanded) {
+ if (cc->type == CLCIT_GROUP && cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
continue;
diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp
index 19540468c0..8ee400d56b 100644
--- a/plugins/Clist_modern/src/modern_clcitems.cpp
+++ b/plugins/Clist_modern/src/modern_clcitems.cpp
@@ -196,7 +196,7 @@ void cli_AddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int update
bool CLCItems_IsShowOfflineGroup(ClcGroup *group)
{
if (!group) return false;
- if (group->hideOffline) return false;
+ if (group->bHideOffline) return false;
uint32_t groupFlags = 0;
Clist_GroupGetName(group->groupId, &groupFlags);
@@ -296,7 +296,7 @@ int GetNewSelection(ClcGroup *group, int selection, int direction)
return lastcount;
ClcContact *cc = group->cl[group->scanIndex];
- if (cc->type == CLCIT_GROUP && (cc->group->expanded)) {
+ if (cc->type == CLCIT_GROUP && cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
continue;
@@ -376,7 +376,7 @@ int cliGetGroupContentsCount(ClcGroup *group, int visibleOnly)
}
ClcContact *cc = group->cl[group->scanIndex];
- if (cc->type == CLCIT_GROUP && (!(visibleOnly & 0x01) || cc->group->expanded)) {
+ if (cc->type == CLCIT_GROUP && (!(visibleOnly & 0x01) || cc->group->bExpanded)) {
group = cc->group;
group->scanIndex = 0;
count += group->cl.getCount();
diff --git a/plugins/Clist_modern/src/modern_clcmsgs.cpp b/plugins/Clist_modern/src/modern_clcmsgs.cpp
index 663872a25c..3c65f72c37 100644
--- a/plugins/Clist_modern/src/modern_clcmsgs.cpp
+++ b/plugins/Clist_modern/src/modern_clcmsgs.cpp
@@ -188,7 +188,7 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP
if (!Clist_FindItem(hwnd, dat, wParam, &contact, &group))
break;
for (tgroup = group; tgroup; tgroup = tgroup->parent)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, tgroup, 1);
+ Clist_SetGroupExpand(hwnd, dat, tgroup, 1);
if (!contact->iSubNumber) {
index = group->cl.indexOf(contact);
diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp
index aeb4dd1ade..099a27e63e 100644
--- a/plugins/Clist_modern/src/modern_clcpaint.cpp
+++ b/plugins/Clist_modern/src/modern_clcpaint.cpp
@@ -147,7 +147,7 @@ int CLCPaint::GetBasicFontID(ClcContact *contact)
{
switch (contact->type) {
case CLCIT_GROUP:
- return (contact->group->expanded) ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS;
+ return (contact->group->bExpanded) ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS;
case CLCIT_INFO:
return (contact->flags & CLCIIF_GROUPFONT) ? FONTID_OPENGROUPS : FONTID_CONTACTS;
@@ -489,7 +489,7 @@ MODERNMASK* CLCPaint::_GetCLCContactRowBackModernMask(ClcGroup *group, ClcContac
case CLCIT_GROUP:
_AddParamShort(mpModernMask, hi_Type, hi_Group);
if (Drawing->group) {
- _AddParamShort(mpModernMask, hi_Open, Drawing->group->expanded ? hi_True : hi_False);
+ _AddParamShort(mpModernMask, hi_Open, Drawing->group->bExpanded ? hi_True : hi_False);
_AddParamShort(mpModernMask, hi_IsEmpty, (Drawing->group->cl.getCount() == 0) ? hi_True : hi_False);
}
break;
@@ -617,7 +617,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R
int iImage = -1;
// Get image
if (Drawing->type == CLCIT_GROUP) {
- iImage = Drawing->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
+ iImage = Drawing->group->bExpanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
}
else if (Drawing->type == CLCIT_CONTACT)
iImage = Drawing->iImage;
@@ -726,7 +726,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R
// Has to draw the count?
if (szCounts && mir_wstrlen(szCounts) > 0) {
// calc width and height
- ChangeToFont(hdcMem, dat, Drawing->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
+ ChangeToFont(hdcMem, dat, Drawing->group->bExpanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
ske_DrawText(hdcMem, L" ", 1, &count_rc, DT_CALCRECT | DT_NOPREFIX);
count_size.cx = count_rc.right - count_rc.left;
space_width = count_size.cx;
@@ -740,7 +740,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R
{
SIZE grp_size = { 0 };
int wid = fr_rc.right - fr_rc.left;
- ChangeToFont(hdcMem, dat, Drawing->group->expanded ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS, nullptr);
+ ChangeToFont(hdcMem, dat, Drawing->group->bExpanded ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS, nullptr);
GetTextSize(&grp_size, hdcMem, fr_rc, Drawing->szText, Drawing->ssText.plText, 0, dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight);
if (wid - count_size.cx > grp_size.cx) {
@@ -768,7 +768,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R
}
uTextFormat |= DT_VCENTER;
- ChangeToFont(hdcMem, dat, Drawing->group->expanded ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS, nullptr);
+ ChangeToFont(hdcMem, dat, Drawing->group->bExpanded ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS, nullptr);
if (selected)
SetTextColor(hdcMem, dat->selTextColour);
else if (hottrack)
@@ -782,7 +782,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R
}
if (szCounts && mir_wstrlen(szCounts) > 0) {
- ChangeToFont(hdcMem, dat, Drawing->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
+ ChangeToFont(hdcMem, dat, Drawing->group->bExpanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
if (selected)
SetTextColor(hdcMem, dat->selTextColour);
else if (hottrack)
@@ -809,7 +809,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R
space_size.cx = space_rc.right - space_rc.left;
space_size.cy = min(space_rc.bottom - space_rc.top, fr_rc.bottom - fr_rc.top);
- ChangeToFont(hdcMem, dat, Drawing->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
+ ChangeToFont(hdcMem, dat, Drawing->group->bExpanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
DrawText(hdcMem, szCounts, (int)mir_wstrlen(szCounts), &counts_rc, DT_CALCRECT);
counts_size.cx = counts_rc.right - counts_rc.left;
@@ -854,7 +854,7 @@ void CLCPaint::_PaintRowItemsEx(HDC hdcMem, ClcData *dat, ClcContact *Drawing, R
_DrawTextSmiley(hdcMem, &text_rect, &text_size, Drawing->szText, idx, (int)mir_wstrlen(dat->szQuickSearch), Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys);
}
if (Drawing->type == CLCIT_GROUP && szCounts && szCounts[0] && counts_rc.right - counts_rc.left > 0) {
- ChangeToFont(hdcMem, dat, Drawing->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
+ ChangeToFont(hdcMem, dat, Drawing->group->bExpanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
if (dat->text_rtl != 0) _RTLRect(&counts_rc, free_row_rc.right);
ske_DrawText(hdcMem, szCounts, (int)mir_wstrlen(szCounts), &counts_rc, uTextFormat);
if (dat->text_rtl == 0)
@@ -1295,7 +1295,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT *rcPaint,
}
if (cc && subindex == -1) {
- if (cc->type == CLCIT_GROUP && cc->group->expanded) {
+ if (cc->type == CLCIT_GROUP && cc->group->bExpanded) {
group = cc->group;
indent++;
group->scanIndex = 0;
@@ -1577,7 +1577,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT
// Get image
iImage = -1;
if (Drawing->type == CLCIT_GROUP && !dat->row_hide_group_icon)
- iImage = Drawing->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
+ iImage = Drawing->group->bExpanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
else if (Drawing->type == CLCIT_CONTACT)
iImage = Drawing->iImage;
@@ -1702,7 +1702,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT
space_size.cx = space_rc.right - space_rc.left;
space_size.cy = min(space_rc.bottom - space_rc.top, free_height);
- ChangeToFont(hdcMem, dat, Drawing->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
+ ChangeToFont(hdcMem, dat, Drawing->group->bExpanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
DrawText(hdcMem, szCounts, (int)mir_wstrlen(szCounts), &counts_rc, DT_CALCRECT);
counts_size.cx = counts_rc.right - counts_rc.left;
@@ -1734,7 +1734,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT
selection_text_rc = text_rc;
full_text_width = text_width;
- ChangeToFont(hdcMem, dat, Drawing->group->expanded ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS, nullptr);
+ ChangeToFont(hdcMem, dat, Drawing->group->bExpanded ? FONTID_OPENGROUPS : FONTID_CLOSEDGROUPS, nullptr);
}
if (dat->row_align_group_mode == 1) { // center
@@ -2113,7 +2113,7 @@ void CLCPaint::_DrawContactIcon(HDC hdcMem, ClcData *dat, ClcContact *Drawing, i
int iImage = -1;
// Get image
if (Drawing->type == CLCIT_GROUP) {
- if (!dat->row_hide_group_icon) iImage = Drawing->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
+ if (!dat->row_hide_group_icon) iImage = Drawing->group->bExpanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
else iImage = -1;
}
else if (Drawing->type == CLCIT_CONTACT)
@@ -2176,7 +2176,7 @@ void CLCPaint::_DrawContactSubText(HDC hdcMem, ClcData *dat, ClcContact *Drawing
// Has to draw the count?
if (szCounts && szCounts[0]) {
- ChangeToFont(hdcMem, dat, Drawing->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
+ ChangeToFont(hdcMem, dat, Drawing->group->bExpanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
if (selected)
SetTextColor(hdcMem, dat->selTextColour);
else if (hottrack)
diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp
index 8de0df74a2..ef9d199730 100644
--- a/plugins/Clist_modern/src/modern_clcutils.cpp
+++ b/plugins/Clist_modern/src/modern_clcutils.cpp
@@ -342,7 +342,7 @@ int GetDropTargetInformation(HWND hwnd, ClcData *dat, POINT pt)
ok = 1;
}
else if ((pt.y + dat->yScroll >= cliGetRowTopY(dat, hit + 1) - dat->insertionMarkHitHeight)
- || (contact->type == CLCIT_GROUP && contact->group->expanded && contact->group->cl.getCount() > 0)) {
+ || (contact->type == CLCIT_GROUP && contact->group->bExpanded && contact->group->cl.getCount() > 0)) {
//could be insertion mark (below)
topItem = hit; bottomItem = hit + 1;
topcontact = contact; topgroup = group;
@@ -648,12 +648,12 @@ int cliFindRowByText(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk)
ClcGroup *ccGroup = group;
int ccScanIndex = group->scanIndex;
for (; group; group = group->parent)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, group, 1);
+ Clist_SetGroupExpand(hwnd, dat, group, 1);
return g_clistApi.pfnGetRowsPriorTo(&dat->list, ccGroup, ccScanIndex + SubCount);
}
if (cc->type == CLCIT_GROUP) {
- if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || cc->group->expanded) {
+ if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
SubCount = 0;
@@ -679,7 +679,7 @@ int cliFindRowByText(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk)
ClcGroup *ccGroup = group;
int ccScanIndex = group->scanIndex;
for (; group; group = group->parent)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, group, 1);
+ Clist_SetGroupExpand(hwnd, dat, group, 1);
if (!cc->bSubExpanded)
ExpandMetaContact(hwnd, cc, dat);
return g_clistApi.pfnGetRowsPriorTo(&dat->list, ccGroup, ccScanIndex + SubCount + i + 1);
diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
index bd54fbd582..4049d6df0a 100644
--- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
+++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
@@ -62,7 +62,7 @@ int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item)
wchar_t *szCounts = Clist_GetGroupCountsText(dat, contact);
// Has the count?
if (szCounts && szCounts[0])
- tmp = max(tmp, dat->fontModernInfo[contact->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS].fontHeight);
+ tmp = max(tmp, dat->fontModernInfo[contact->group->bExpanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS].fontHeight);
}
tmp = max(tmp, ICON_HEIGHT);
tmp = max(tmp, dat->row_min_heigh);
@@ -101,7 +101,7 @@ int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item)
if (szCounts && mir_wstrlen(szCounts) > 0) {
RECT count_rc = { 0 };
// calc width and height
- g_clcPainter.ChangeToFont(hdc, dat, contact->group->expanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
+ g_clcPainter.ChangeToFont(hdc, dat, contact->group->bExpanded ? FONTID_OPENGROUPCOUNTS : FONTID_CLOSEDGROUPCOUNTS, nullptr);
ske_DrawText(hdc, L" ", 1, &count_rc, DT_CALCRECT | DT_NOPREFIX);
size.cx += count_rc.right - count_rc.left;
count_rc.right = 0;
@@ -441,7 +441,7 @@ void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd)
}
if (subindex == -1) {
- if (group->cl[group->scanIndex]->type == CLCIT_GROUP && group->cl[group->scanIndex]->group->expanded) {
+ if (group->cl[group->scanIndex]->type == CLCIT_GROUP && group->cl[group->scanIndex]->group->bExpanded) {
group = group->cl[group->scanIndex]->group;
indent++;
group->scanIndex = 0;
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp
index 6e6ea22632..a6239a2a5a 100644
--- a/plugins/Clist_modern/src/modern_viewmodebar.cpp
+++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp
@@ -1255,8 +1255,10 @@ void ApplyViewMode(const char *szName)
g_clistApi.pfnSetHideOffline(g_CluiData.bOldHideOffline);
if (g_CluiData.bOldHideEmptyGroups != -1)
SendMessage(g_clistApi.hwndContactTree, CLM_SETHIDEEMPTYGROUPS, g_CluiData.bOldHideEmptyGroups, 0);
- if (g_CluiData.bOldFoldGroups != -1)
- SendMessage(g_clistApi.hwndContactTree, CLM_EXPAND, 0, g_CluiData.bOldFoldGroups ? CLE_COLLAPSE : CLE_EXPAND);
+ if (g_CluiData.bOldFoldGroups != -1) {
+ Clist_GroupRestoreExpanded();
+ SendMessage(g_clistApi.hwndContactTree, CLM_EXPAND, 0, -1);
+ }
g_CluiData.bOldUseGroups = -1;
g_CluiData.bOldHideOffline = -1;
@@ -1347,19 +1349,7 @@ void ApplyViewMode(const char *szName)
g_CluiData.bOldHideOffline = -1;
}
- int iValue = (g_CluiData.filterFlags & CLVM_FOLDGROUPS) ? 1 : ((g_CluiData.filterFlags & CLVM_UNFOLDGROUPS) ? 0 : -1);
- if (iValue != -1) {
- if (g_CluiData.bOldFoldGroups == -1)
- g_CluiData.bOldFoldGroups = !Clist::UseGroups;
-
- SendMessage(g_clistApi.hwndContactTree, CLM_EXPAND, 0, iValue ? CLE_COLLAPSE : CLE_EXPAND);
- }
- else if (g_CluiData.bOldFoldGroups != -1) {
- SendMessage(g_clistApi.hwndContactTree, CLM_EXPAND, 0, g_CluiData.bOldFoldGroups ? CLE_COLLAPSE : CLE_EXPAND);
- g_CluiData.bOldFoldGroups = -1;
- }
-
- iValue = (g_CluiData.filterFlags & CLVM_USEGROUPS) ? 1 : ((g_CluiData.filterFlags & CLVM_DONOTUSEGROUPS) ? 0 : -1);
+ int iValue = (g_CluiData.filterFlags & CLVM_USEGROUPS) ? 1 : ((g_CluiData.filterFlags & CLVM_DONOTUSEGROUPS) ? 0 : -1);
if (iValue != -1) {
if (g_CluiData.bOldUseGroups == -1)
g_CluiData.bOldUseGroups = Clist::UseGroups;
@@ -1383,6 +1373,20 @@ void ApplyViewMode(const char *szName)
g_CluiData.bOldHideEmptyGroups = -1;
}
+ iValue = (g_CluiData.filterFlags & CLVM_FOLDGROUPS) ? 1 : ((g_CluiData.filterFlags & CLVM_UNFOLDGROUPS) ? 0 : -1);
+ if (iValue != -1) {
+ if (g_CluiData.bOldFoldGroups == -1)
+ Clist_GroupSaveExpanded();
+
+ SendMessage(g_clistApi.hwndContactTree, CLM_EXPAND, 0, iValue ? CLE_COLLAPSE : CLE_EXPAND);
+ g_CluiData.bOldFoldGroups = 1;
+ }
+ else if (g_CluiData.bOldFoldGroups != -1) {
+ Clist_GroupRestoreExpanded();
+ SendMessage(g_clistApi.hwndContactTree, CLM_EXPAND, 0, -1);
+ g_CluiData.bOldFoldGroups = -1;
+ }
+
SetWindowText(hwndSelector, ptrW(mir_utf8decodeW((szName[0] == 13) ? szName + 1 : szName)));
}
diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp
index 4924dccd16..86d9a7fe68 100644
--- a/plugins/Clist_nicer/src/clc.cpp
+++ b/plugins/Clist_nicer/src/clc.cpp
@@ -340,7 +340,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
uint32_t style = GetWindowLongPtr(hwnd, GWL_STYLE);
if (contact->iImage == (uint16_t)lParam)
break;
- if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline || cfg::dat.bFilterEffective)) { // CLVM changed
+ if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->bHideOffline || cfg::dat.bFilterEffective)) { // CLVM changed
if (dat->selection >= 0 && g_clistApi.pfnGetRowByIndex(dat, dat->selection, &selcontact, nullptr) != -1)
hSelItem = Clist_ContactToHItem(selcontact);
Clist_RemoveItemFromGroup(hwnd, group, contact, 0);
@@ -665,7 +665,7 @@ LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
hMenu = Menu_BuildSubGroupMenu(contact->group);
ClientToScreen(hwnd, &pt);
TrackPopupMenu(hMenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, g_clistApi.hwndContactList, nullptr);
- CheckMenuItem(hMenu, POPUP_GROUPHIDEOFFLINE, contact->group->hideOffline ? MF_CHECKED : MF_UNCHECKED);
+ CheckMenuItem(hMenu, POPUP_GROUPHIDEOFFLINE, contact->group->bHideOffline ? MF_CHECKED : MF_UNCHECKED);
DestroyMenu(hMenu);
return 0;
}
diff --git a/plugins/Clist_nicer/src/clc.h b/plugins/Clist_nicer/src/clc.h
index 8e138f374b..8df56f8ede 100644
--- a/plugins/Clist_nicer/src/clc.h
+++ b/plugins/Clist_nicer/src/clc.h
@@ -373,7 +373,6 @@ uint32_t INTSORT_GetLastMsgTime(MCONTACT hContact);
LRESULT ProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPARAM wParam, LPARAM lParam);
// clcutils.c
-void SetGroupExpand(HWND hwnd, struct ClcData *dat, ClcGroup *group, int newState);
void BeginRenameSelection(HWND hwnd, struct ClcData *dat);
int HitTest(HWND hwnd, struct ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, uint32_t *flags);
void ScrollTo(HWND hwnd, struct ClcData *dat, int desty, int noSmooth);
diff --git a/plugins/Clist_nicer/src/clcpaint.cpp b/plugins/Clist_nicer/src/clcpaint.cpp
index e7f49f900c..71d811fe6c 100644
--- a/plugins/Clist_nicer/src/clcpaint.cpp
+++ b/plugins/Clist_nicer/src/clcpaint.cpp
@@ -718,7 +718,7 @@ set_bg_l:
oldGroupColor = SetTextColor(hdcMem, sempty->TEXTCOLOR);
}
}
- else if (contact->group->expanded) {
+ else if (contact->group->bExpanded) {
if (!sexpanded->IGNORED) {
rc.left = sexpanded->MARGIN_LEFT + bg_indent_l;
rc.top = y + sexpanded->MARGIN_TOP;
@@ -815,7 +815,7 @@ bgskipped:
int iImage;
if (type == CLCIT_GROUP)
- iImage = (contact->group->expanded) ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
+ iImage = (contact->group->bExpanded) ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
else if (type == CLCIT_CONTACT)
iImage = contact->iImage;
else
@@ -1374,7 +1374,7 @@ bgdone:
if (cc->cFlags & ECF_AVATAR)
g_list_avatars++;
- if (cc->type == CLCIT_GROUP && (cc->group->expanded)) {
+ if (cc->type == CLCIT_GROUP && cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
continue;
@@ -1409,7 +1409,7 @@ bgdone:
}
index++;
y += dat->row_heights[line_num];
- if (cc->type == CLCIT_GROUP && (cc->group->expanded)) {
+ if (cc->type == CLCIT_GROUP && cc->group->bExpanded) {
group = cc->group;
indent++;
group->scanIndex = 0;
diff --git a/plugins/Clist_nicer/src/clcutils.cpp b/plugins/Clist_nicer/src/clcutils.cpp
index 1ea0c9f1e2..d26133a099 100644
--- a/plugins/Clist_nicer/src/clcutils.cpp
+++ b/plugins/Clist_nicer/src/clcutils.cpp
@@ -375,46 +375,6 @@ void RecalcScrollBar(HWND hwnd, struct ClcData *dat)
SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)& nm);
}
-void SetGroupExpand(HWND hwnd, struct ClcData *dat, ClcGroup *group, int newState)
-{
- int contentCount;
- int groupy;
- int newy;
- int posy;
- RECT clRect;
- NMCLISTCONTROL nm;
-
- if (newState == -1)
- group->expanded ^= 1;
- else {
- if (group->expanded == (newState != 0))
- return;
- group->expanded = newState != 0;
- }
- InvalidateRect(hwnd, nullptr, FALSE);
- contentCount = g_clistApi.pfnGetGroupContentsCount(group, 1);
-
- groupy = g_clistApi.pfnGetRowsPriorTo(&dat->list, group, -1);
- if (dat->selection > groupy && dat->selection < groupy + contentCount) dat->selection = groupy;
- g_clistApi.pfnRecalcScrollBar(hwnd, dat);
-
- GetClientRect(hwnd, &clRect);
- newy = dat->yScroll;
- posy = RowHeight::getItemBottomY(dat, groupy + contentCount);
- if (posy >= newy + clRect.bottom)
- newy = posy - clRect.bottom;
- posy = RowHeight::getItemTopY(dat, groupy);
- if (newy > posy) newy = posy;
- ScrollTo(hwnd, dat, newy, 0);
-
- nm.hdr.code = CLN_EXPANDED;
- nm.hdr.hwndFrom = hwnd;
- nm.hdr.idFrom = GetDlgCtrlID(hwnd);
- nm.hItem = (HANDLE)group->groupId;
- nm.action = (group->expanded);
- SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm);
-}
-
static LRESULT CALLBACK RenameEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
diff --git a/plugins/Clist_nicer/src/rowheight_funcs.cpp b/plugins/Clist_nicer/src/rowheight_funcs.cpp
index 6a44596915..865c7f30cf 100644
--- a/plugins/Clist_nicer/src/rowheight_funcs.cpp
+++ b/plugins/Clist_nicer/src/rowheight_funcs.cpp
@@ -152,7 +152,7 @@ void RowHeight::calcRowHeights(ClcData *dat, HWND hwnd)
// Calc row height
getRowHeight(dat, cc, line_num, dwStyle);
- if (cc->type == CLCIT_GROUP && (cc->group->expanded & 0x0000ffff)) {
+ if (cc->type == CLCIT_GROUP && cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
continue;
diff --git a/src/core/stdclist/src/clcpaint.cpp b/src/core/stdclist/src/clcpaint.cpp
index d2e59b1878..f6cbfbd5a1 100644
--- a/src/core/stdclist/src/clcpaint.cpp
+++ b/src/core/stdclist/src/clcpaint.cpp
@@ -312,7 +312,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint)
// icon
if (cc->type == CLCIT_GROUP)
- iImage = cc->group->expanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
+ iImage = cc->group->bExpanded ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
else if (cc->type == CLCIT_CONTACT)
iImage = cc->iImage;
@@ -423,7 +423,7 @@ void PaintClc(HWND hwnd, struct ClcData *dat, HDC hdc, RECT * rcPaint)
index++;
y += dat->rowHeight;
- if (cc->type == CLCIT_GROUP && cc->group->expanded) {
+ if (cc->type == CLCIT_GROUP && cc->group->bExpanded) {
group = cc->group;
indent++;
group->scanIndex = 0;
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp
index 0266b7bcf3..ecc1409a75 100644
--- a/src/mir_app/src/clc.cpp
+++ b/src/mir_app/src/clc.cpp
@@ -391,7 +391,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam
else
eq = !mir_wstrcmp(szFullName, ptrW(mir_utf8decodeW(dbcws->value.pszVal + 1)));
- if (eq && (contact->group->hideOffline != 0) == ((dbcws->value.pszVal[0] & GROUPF_HIDEOFFLINE) != 0))
+ if (eq && contact->group->bHideOffline == ((dbcws->value.pszVal[0] & GROUPF_HIDEOFFLINE) != 0))
break; //only expanded has changed: no action reqd
}
}
@@ -498,7 +498,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam
else { // item in list already
if (contact->iImage == (uint16_t)lParam)
break;
- if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
+ if (!shouldShow && !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->bHideOffline)) {
if (dat->selection >= 0 && g_clistApi.pfnGetRowByIndex(dat, dat->selection, &selcontact, nullptr) != -1)
hSelItem = Clist_ContactToHItem(selcontact);
Clist_RemoveItemFromGroup(hwnd, group, contact, (style & CLS_CONTACTLIST) == 0);
@@ -709,7 +709,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam
if (changeGroupExpand == 1) {
switch (contact->type) {
case CLCIT_GROUP:
- if (contact->group->expanded)
+ if (contact->group->bExpanded)
break;
__fallthrough;
case CLCIT_CONTACT:
@@ -721,7 +721,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam
}
if (contact->type == CLCIT_GROUP)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, contact->group, changeGroupExpand == 2);
+ Clist_SetGroupExpand(hwnd, dat, contact->group, changeGroupExpand == 2);
return 0;
}
@@ -904,7 +904,7 @@ LBL_MoveSelection:
ClcGroup *selgroup;
ClcContact *selcontact;
dat->selection = g_clistApi.pfnGetRowByIndex(dat, dat->selection, &selcontact, &selgroup);
- g_clistApi.pfnSetGroupExpand(hwnd, dat, contact->group, -1);
+ Clist_SetGroupExpand(hwnd, dat, contact->group, -1);
if (dat->selection != -1) {
dat->selection =
g_clistApi.pfnGetRowsPriorTo(&dat->list, selgroup, selgroup->cl.indexOf(selcontact));
@@ -1245,7 +1245,7 @@ LBL_MoveSelection:
Clist_GroupDelete(contact->groupId);
break;
case POPUP_GROUPHIDEOFFLINE:
- Clist_GroupSetFlags(contact->groupId, MAKELPARAM(contact->group->hideOffline ? 0 : GROUPF_HIDEOFFLINE, GROUPF_HIDEOFFLINE));
+ Clist_GroupSetFlags(contact->groupId, MAKELPARAM(contact->group->bHideOffline ? 0 : GROUPF_HIDEOFFLINE, GROUPF_HIDEOFFLINE));
break;
}
diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h
index f5ebfc5e87..8f792d958a 100644
--- a/src/mir_app/src/clc.h
+++ b/src/mir_app/src/clc.h
@@ -76,7 +76,6 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar
int fnHitTest(HWND hwnd, ClcData *dat, int testx, int testy, ClcContact **contact, ClcGroup **group, uint32_t * flags);
void fnScrollTo(HWND hwnd, ClcData *dat, int desty, int noSmooth);
void fnRecalcScrollBar(HWND hwnd, ClcData *dat);
-void fnSetGroupExpand(HWND hwnd, ClcData *dat, ClcGroup *group, int newState);
int fnFindRowByText(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk);
void fnBeginRenameSelection(HWND hwnd, ClcData *dat);
diff --git a/src/mir_app/src/clcidents.cpp b/src/mir_app/src/clcidents.cpp
index 83497cf50d..8359e596b7 100644
--- a/src/mir_app/src/clcidents.cpp
+++ b/src/mir_app/src/clcidents.cpp
@@ -62,7 +62,7 @@ int fnGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex)
if (cc->type == CLCIT_GROUP) {
if (cc->group == subgroup && contactIndex == -1)
return count - 1;
- if (cc->group->expanded) {
+ if (cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
continue;
@@ -90,7 +90,7 @@ ClcContact* fnFindItem(uint32_t dwItem, ClcContact *cc)
MIR_APP_DLL(bool) Clist_FindItem(HWND hwnd, ClcData *dat, uint32_t dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible)
{
int index = 0;
- int nowVisible = 1;
+ bool nowVisible = true;
ClcGroup *group = &dat->list;
group->scanIndex = 0;
@@ -99,10 +99,10 @@ MIR_APP_DLL(bool) Clist_FindItem(HWND hwnd, ClcData *dat, uint32_t dwItem, ClcCo
if ((group = group->parent) == nullptr)
break;
- nowVisible = 1;
+ nowVisible = true;
for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent)
- if (!group->expanded) {
- nowVisible = 0;
+ if (!group->bExpanded) {
+ nowVisible = false;
break;
}
group->scanIndex++;
@@ -142,7 +142,7 @@ MIR_APP_DLL(bool) Clist_FindItem(HWND hwnd, ClcData *dat, uint32_t dwItem, ClcCo
if (cc->type == CLCIT_GROUP) {
group = cc->group;
group->scanIndex = 0;
- nowVisible &= group->expanded;
+ nowVisible &= group->bExpanded;
continue;
}
group->scanIndex++;
@@ -180,7 +180,7 @@ int fnGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup
return index;
}
index++;
- if (cc->type == CLCIT_GROUP && cc->group->expanded) {
+ if (cc->type == CLCIT_GROUP && cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
continue;
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp
index eef6b57d56..d786fe5599 100644
--- a/src/mir_app/src/clcitems.cpp
+++ b/src/mir_app/src/clcitems.cpp
@@ -70,8 +70,8 @@ ClcGroup* fnAddGroup(HWND hwnd, ClcData *dat, const wchar_t *szName, uint32_t fl
if (pNextField == nullptr && flags != (uint32_t)-1) {
cc->groupId = (uint16_t)groupId;
group = cc->group;
- group->expanded = (flags & GROUPF_EXPANDED) != 0;
- group->hideOffline = (flags & GROUPF_HIDEOFFLINE) != 0;
+ group->bExpanded = (flags & GROUPF_EXPANDED) != 0;
+ group->bHideOffline = (flags & GROUPF_HIDEOFFLINE) != 0;
group->groupId = groupId;
}
else group = cc->group;
@@ -96,12 +96,11 @@ ClcGroup* fnAddGroup(HWND hwnd, ClcData *dat, const wchar_t *szName, uint32_t fl
group = cc->group;
if (flags == (uint32_t)-1 || pNextField != nullptr) {
- group->expanded = 0;
- group->hideOffline = 0;
+ group->bExpanded = group->bHideOffline = false;
}
else {
- group->expanded = (flags & GROUPF_EXPANDED) != 0;
- group->hideOffline = (flags & GROUPF_HIDEOFFLINE) != 0;
+ group->bExpanded = (flags & GROUPF_EXPANDED) != 0;
+ group->bHideOffline = (flags & GROUPF_HIDEOFFLINE) != 0;
}
group->groupId = pNextField ? 0 : groupId;
group->totalMembers = 0;
@@ -264,7 +263,7 @@ void fnAddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int updateTo
}
if (checkHideOffline) {
- if (Clist_IsHiddenMode(dat, status) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
+ if (Clist_IsHiddenMode(dat, status) && (style & CLS_HIDEOFFLINE || group->bHideOffline)) {
if (updateTotalCount)
group->totalMembers++;
return;
@@ -349,8 +348,8 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat)
{
uint32_t style = GetWindowLongPtr(hwnd, GWL_STYLE);
- dat->list.expanded = 1;
- dat->list.hideOffline = db_get_b(0, "CLC", "HideOfflineRoot", 0) && (style & CLS_USEGROUPS);
+ dat->list.bExpanded = true;
+ dat->list.bHideOffline = db_get_b(0, "CLC", "HideOfflineRoot", 0) && (style & CLS_USEGROUPS);
dat->list.cl.destroy();
dat->list.totalMembers = 0;
dat->selection = -1;
@@ -391,7 +390,7 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat)
if (wcsstr(lowered_name, lowered_search))
g_clistApi.pfnAddContactToGroup(dat, group, hContact);
}
- else if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) {
+ else if (!(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->bHideOffline)) {
char *szProto = Proto_GetBaseAccountName(hContact);
if (szProto == nullptr) {
if (!Clist_IsHiddenMode(dat, ID_STATUS_OFFLINE) || g_clistApi.pfnIsVisibleContact(pce, group))
@@ -451,7 +450,7 @@ int fnGetGroupContentsCount(ClcGroup *group, int visibleOnly)
}
ClcContact *cc = group->cl[group->scanIndex];
- if (cc->type == CLCIT_GROUP && (!visibleOnly || cc->group->expanded)) {
+ if (cc->type == CLCIT_GROUP && (!visibleOnly || cc->group->bExpanded)) {
group = cc->group;
group->scanIndex = 0;
count += group->cl.getCount();
@@ -606,7 +605,8 @@ struct SavedContactState_t
struct SavedGroupState_t
{
- int groupId, expanded;
+ int groupId;
+ bool bExpanded, bSaveExpanded;
};
struct SavedInfoState_t
@@ -646,7 +646,7 @@ MIR_APP_DLL(void) Clist_SaveStateAndRebuildList(HWND hwnd, ClcData *dat)
SavedGroupState_t *p = new SavedGroupState_t;
p->groupId = group->groupId;
- p->expanded = group->expanded;
+ p->bExpanded = group->bExpanded;
saveGroup.insert(p);
continue;
}
@@ -687,7 +687,7 @@ MIR_APP_DLL(void) Clist_SaveStateAndRebuildList(HWND hwnd, ClcData *dat)
SavedGroupState_t tmp, *p;
tmp.groupId = group->groupId;
if ((p = saveGroup.find(&tmp)) != nullptr)
- group->expanded = p->expanded;
+ group->bExpanded = p->bExpanded;
continue;
}
else if (cc->type == CLCIT_CONTACT) {
diff --git a/src/mir_app/src/clcmsgs.cpp b/src/mir_app/src/clcmsgs.cpp
index b2b889245d..6d7b076ed0 100644
--- a/src/mir_app/src/clcmsgs.cpp
+++ b/src/mir_app/src/clcmsgs.cpp
@@ -100,7 +100,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar
break;
for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, tgroup, 1);
+ Clist_SetGroupExpand(hwnd, dat, tgroup, 1);
Clist_EnsureVisible(hwnd, dat, g_clistApi.pfnGetRowsPriorTo(&dat->list, group, group->cl.indexOf(contact)), 0);
break;
@@ -108,12 +108,20 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar
if (wParam) {
if (Clist_FindItem(hwnd, dat, wParam, &contact))
if (contact->type == CLCIT_GROUP)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, contact->group, lParam);
+ Clist_SetGroupExpand(hwnd, dat, contact->group, lParam);
}
else {
- for (auto &it: dat->list.cl)
- if (it->type == CLCIT_GROUP)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, it->group, lParam);
+ for (auto &it : dat->list.cl) {
+ if (it->type == CLCIT_GROUP) {
+ auto *pGroup = it->group;
+ if (lParam == -1) {
+ uint32_t flags;
+ if (Clist_GroupGetName(pGroup->groupId, &flags))
+ Clist_SetGroupExpand(hwnd, dat, pGroup, (flags & GROUPF_EXPANDED) != 0);
+ }
+ else Clist_SetGroupExpand(hwnd, dat, it->group, lParam);
+ }
+ }
}
break;
@@ -146,7 +154,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar
return CLE_INVALID;
if (contact->type != CLCIT_GROUP)
return CLE_INVALID;
- return contact->group->expanded;
+ return contact->group->bExpanded;
case CLM_SETEXTRASPACE:
dat->extraColumnSpacing = (int)wParam;
@@ -303,7 +311,7 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar
break;
for (ClcGroup *tgroup = group; tgroup; tgroup = tgroup->parent)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, tgroup, 1);
+ Clist_SetGroupExpand(hwnd, dat, tgroup, 1);
dat->selection = g_clistApi.pfnGetRowsPriorTo(&dat->list, group, group->cl.indexOf(contact));
Clist_EnsureVisible(hwnd, dat, dat->selection, 0);
break;
diff --git a/src/mir_app/src/clcutils.cpp b/src/mir_app/src/clcutils.cpp
index 1cd238ffc6..34a012ae34 100644
--- a/src/mir_app/src/clcutils.cpp
+++ b/src/mir_app/src/clcutils.cpp
@@ -287,42 +287,41 @@ void fnRecalcScrollBar(HWND hwnd, ClcData *dat)
SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm);
}
-void fnSetGroupExpand(HWND hwnd, ClcData *dat, ClcGroup *group, int newState)
+MIR_APP_DLL(void) Clist_SetGroupExpand(HWND hwnd, ClcData *dat, ClcGroup *group, int newState)
{
- int contentCount;
- int groupy;
- int newY, posY;
- RECT clRect;
- NMCLISTCONTROL nm;
-
if (newState == -1)
- group->expanded ^= 1;
+ group->bExpanded = !group->bExpanded;
else {
- if (group->expanded == (newState != 0))
+ if (group->bExpanded == (newState != 0))
return;
- group->expanded = newState != 0;
+ group->bExpanded = newState != 0;
}
+
g_clistApi.pfnInvalidateRect(hwnd, nullptr, FALSE);
- contentCount = g_clistApi.pfnGetGroupContentsCount(group, 1);
- groupy = g_clistApi.pfnGetRowsPriorTo(&dat->list, group, -1);
+ int contentCount = g_clistApi.pfnGetGroupContentsCount(group, 1);
+ int groupy = g_clistApi.pfnGetRowsPriorTo(&dat->list, group, -1);
if (dat->selection > groupy && dat->selection < groupy + contentCount)
dat->selection = groupy;
+
+ RECT clRect;
GetClientRect(hwnd, &clRect);
- newY = dat->yScroll;
- posY = g_clistApi.pfnGetRowBottomY(dat, groupy + contentCount);
+ int newY = dat->yScroll;
+ int posY = g_clistApi.pfnGetRowBottomY(dat, groupy + contentCount);
if (posY >= newY + clRect.bottom)
newY = posY - clRect.bottom;
posY = g_clistApi.pfnGetRowTopY(dat, groupy);
if (newY > posY)
newY = posY;
g_clistApi.pfnRecalcScrollBar(hwnd, dat);
- if (group->expanded)
+ if (group->bExpanded)
g_clistApi.pfnScrollTo(hwnd, dat, newY, 0);
+
+ NMCLISTCONTROL nm;
nm.hdr.code = CLN_EXPANDED;
nm.hdr.hwndFrom = hwnd;
nm.hdr.idFrom = GetDlgCtrlID(hwnd);
nm.hItem = (HANDLE)group->groupId;
- nm.action = group->expanded;
+ nm.action = group->bExpanded;
SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm);
}
@@ -339,7 +338,7 @@ MIR_APP_DLL(void) Clist_DoSelectionDefaultAction(HWND hwnd, ClcData *dat)
return;
if (contact->type == CLCIT_GROUP)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, contact->group, -1);
+ Clist_SetGroupExpand(hwnd, dat, contact->group, -1);
if (contact->type == CLCIT_CONTACT)
Clist_ContactDoubleClicked(contact->hContact);
@@ -375,11 +374,11 @@ int fnFindRowByText(HWND hwnd, ClcData *dat, const wchar_t *text, int prefixOk)
ClcGroup *contactGroup = group;
int contactScanIndex = group->scanIndex;
for (; group; group = group->parent)
- g_clistApi.pfnSetGroupExpand(hwnd, dat, group, 1);
+ Clist_SetGroupExpand(hwnd, dat, group, 1);
return g_clistApi.pfnGetRowsPriorTo(&dat->list, contactGroup, contactScanIndex);
}
if (cc->type == CLCIT_GROUP) {
- if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || cc->group->expanded) {
+ if (!(dat->exStyle & CLS_EX_QUICKSEARCHVISONLY) || cc->group->bExpanded) {
group = cc->group;
group->scanIndex = 0;
continue;
diff --git a/src/mir_app/src/clistcore.cpp b/src/mir_app/src/clistcore.cpp
index 99d52d3966..77800b9113 100644
--- a/src/mir_app/src/clistcore.cpp
+++ b/src/mir_app/src/clistcore.cpp
@@ -87,7 +87,6 @@ void InitClistCore()
g_clistApi.pfnHitTest = fnHitTest;
g_clistApi.pfnScrollTo = fnScrollTo;
g_clistApi.pfnRecalcScrollBar = fnRecalcScrollBar;
- g_clistApi.pfnSetGroupExpand = fnSetGroupExpand;
g_clistApi.pfnFindRowByText = fnFindRowByText;
g_clistApi.pfnBeginRenameSelection = fnBeginRenameSelection;
g_clistApi.pfnIsVisibleContact = fnIsVisibleContact;
diff --git a/src/mir_app/src/clistgroups.cpp b/src/mir_app/src/clistgroups.cpp
index 79d320515b..4c37179feb 100644
--- a/src/mir_app/src/clistgroups.cpp
+++ b/src/mir_app/src/clistgroups.cpp
@@ -32,13 +32,16 @@ struct CGroupInternal
CGroupInternal(int _id, const wchar_t *_name) :
groupId(_id),
groupName(mir_wstrdup(_name))
- {}
+ {
+ bSaveExpanded = (groupName[0] & GROUPF_EXPANDED) != 0;
+ }
~CGroupInternal()
{ mir_free(groupName);
}
- int groupId, oldId;
+ int groupId, oldId = -1;
+ bool bSaveExpanded;
wchar_t *groupName;
void save()
@@ -398,6 +401,25 @@ MIR_APP_DLL(int) Clist_GroupRename(MGROUP hGroup, const wchar_t *ptszNewName)
/////////////////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(void) Clist_GroupSaveExpanded()
+{
+ for (auto &it : arByIds)
+ it->bSaveExpanded = (it->groupName[0] & GROUPF_EXPANDED) != 0;
+}
+
+MIR_APP_DLL(void) Clist_GroupRestoreExpanded()
+{
+ for (auto &it : arByIds) {
+ if (it->bSaveExpanded)
+ it->groupName[0] |= GROUPF_EXPANDED;
+ else
+ it->groupName[0] &= ~GROUPF_EXPANDED;
+ it->save();
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(int) Clist_GroupSetExpanded(MGROUP hGroup, int iNewState)
{
CGroupInternal *pGroup = arByIds.find(hGroup-1);
diff --git a/src/mir_app/src/menu_groups.cpp b/src/mir_app/src/menu_groups.cpp
index 78bf39c3a3..a78320917d 100644
--- a/src/mir_app/src/menu_groups.cpp
+++ b/src/mir_app/src/menu_groups.cpp
@@ -243,7 +243,7 @@ static int OnBuildSubGroupMenu(WPARAM wParam, LPARAM)
{
ClcGroup *group = (ClcGroup*)wParam;
if (group != nullptr) // contact->group
- Menu_SetChecked(hHideOfflineUsersHereMenuItem, group->hideOffline != 0);
+ Menu_SetChecked(hHideOfflineUsersHereMenuItem, group->bHideOffline != 0);
return 0;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 5378bc2712..f5c81b2c9b 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -881,3 +881,6 @@ Clist_RemoveEvent @989
?getLocalName@FILE_BLOB@DB@@QBEPB_WXZ @998 NONAME
?setLocalName@FILE_BLOB@DB@@QAEXPB_W@Z @999 NONAME
?ResetFileName@OFDTHREAD@@QAEXPB_W@Z @1000 NONAME
+?Clist_SetGroupExpand@@YGXPAUHWND__@@PAUClcData@@PAUClcGroup@@H@Z @1001 NONAME
+Clist_GroupRestoreExpanded @1002 NONAME
+Clist_GroupSaveExpanded @1003 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 1b6fc9df48..b49d1d3ac8 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -881,3 +881,6 @@ Clist_RemoveEvent @989
?getLocalName@FILE_BLOB@DB@@QEBAPEB_WXZ @998 NONAME
?setLocalName@FILE_BLOB@DB@@QEAAXPEB_W@Z @999 NONAME
?ResetFileName@OFDTHREAD@@QEAAXPEB_W@Z @1000 NONAME
+?Clist_SetGroupExpand@@YAXPEAUHWND__@@PEAUClcData@@PEAUClcGroup@@H@Z @1001 NONAME
+Clist_GroupRestoreExpanded @1002 NONAME
+Clist_GroupSaveExpanded @1003 NONAME