From f11a71a26ce00c5fc5cdd4350b1303ed7bed9ad5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 6 May 2016 21:41:06 +0000 Subject: clist_modern: - functions ContactToHItem & ContactToItemHandle replaced with their kernel implementations; - dat->row_heights array isn't used when the row height is constant; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@16809 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Clist_modern/src/modern_clc.cpp | 8 +- plugins/Clist_modern/src/modern_clc.h | 6 +- plugins/Clist_modern/src/modern_clcidents.cpp | 45 ---- plugins/Clist_modern/src/modern_clcpaint.cpp | 248 ++++++++++----------- plugins/Clist_modern/src/modern_clcutils.cpp | 231 ++++++++----------- .../Clist_modern/src/modern_rowheight_funcs.cpp | 96 ++++---- 6 files changed, 273 insertions(+), 361 deletions(-) (limited to 'plugins/Clist_modern') diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index f1746e74a1..dcc8a50adc 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -794,7 +794,7 @@ static LRESULT clcOnLButtonDown(ClcData *dat, HWND hwnd, UINT, WPARAM, LPARAM lP nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetDlgCtrlID(hwnd); nm.flags = 0; - nm.hItem = ContactToItemHandle(contact, &nm.flags); + nm.hItem = pcli->pfnContactToItemHandle(contact, &nm.flags); SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm); } @@ -804,7 +804,7 @@ static LRESULT clcOnLButtonDown(ClcData *dat, HWND hwnd, UINT, WPARAM, LPARAM lP nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetDlgCtrlID(hwnd); nm.flags = 0; - nm.hItem = (hit == -1 || hitFlags & CLCHT_NOWHERE) ? NULL : ContactToItemHandle(contact, &nm.flags); + nm.hItem = (hit == -1 || hitFlags & CLCHT_NOWHERE) ? NULL : pcli->pfnContactToItemHandle(contact, &nm.flags); nm.iColumn = hitFlags & CLCHT_ONITEMEXTRA ? HIBYTE(HIWORD(hitFlags)) : -1; nm.pt = dat->ptDragStart; SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm); @@ -955,7 +955,7 @@ static LRESULT clcOnMouseMove(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPAR nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetDlgCtrlID(hwnd); nm.flags = 0; - nm.hItem = ContactToItemHandle(contact, &nm.flags); + nm.hItem = pcli->pfnContactToItemHandle(contact, &nm.flags); SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm); dat->dragStage &= ~DRAGSTAGEF_OUTSIDE; } @@ -1035,7 +1035,7 @@ static LRESULT clcOnMouseMove(ClcData *dat, HWND hwnd, UINT, WPARAM wParam, LPAR nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = GetDlgCtrlID(hwnd); nm.flags = 0; - nm.hItem = ContactToItemHandle(contact, &nm.flags); + nm.hItem = pcli->pfnContactToItemHandle(contact, &nm.flags); nm.pt = pt; if (SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm)) return 0; diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h index 261724c0f9..f180bd53d9 100644 --- a/plugins/Clist_modern/src/modern_clc.h +++ b/plugins/Clist_modern/src/modern_clc.h @@ -330,6 +330,10 @@ struct ClcData : public ClcDataBase XPTHANDLE hCheckBoxTheme; BYTE bCompactMode; + + __forceinline int getRowHeight(int iRow) const + { return (row_variable_height) ? row_heights[iRow] : rowHeight; + } }; typedef struct tagOVERLAYICONINFO @@ -347,8 +351,6 @@ void ClcOptionsChanged(void); int cliGetRowsPriorTo(ClcGroup *group, ClcGroup *subgroup, int contactIndex); int FindItem(HWND hwnd, ClcData *dat, DWORD hItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible, BOOL isIgnoreSubcontacts); int cliGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup **subgroup); -HANDLE ContactToHItem(ClcContact *contact); -HANDLE ContactToItemHandle(ClcContact *contact, DWORD *nmFlags); //clcitems.c void cliRebuildEntireList(HWND hwnd, ClcData *dat); diff --git a/plugins/Clist_modern/src/modern_clcidents.cpp b/plugins/Clist_modern/src/modern_clcidents.cpp index d22ac3a75f..12712894bd 100644 --- a/plugins/Clist_modern/src/modern_clcidents.cpp +++ b/plugins/Clist_modern/src/modern_clcidents.cpp @@ -24,23 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" -/* the CLC uses 3 different ways to identify elements in its list, this file -contains routines to convert between them. - -1) ClcContact/ClcGroup pair. Only ever used within the duration -of a single operation, but used at some point in nearly everything -2) index integer. The 0-based number of the item from the top. Only visible -items are counted (ie not closed groups). Used for saving selection and drag -highlight -3) hItem handle. Either the hContact or (hGroup|HCONTACT_ISGROUP). Used -exclusively externally - -1->2: cliGetRowsPriorTo() -1->3: ContactToHItem() -3->1: FindItem() -2->1: GetRowByIndex() -*/ - int GetContactIndex(ClcGroup *group, ClcContact *contact) { for (int i = 0; i < group->cl.count; i++) @@ -226,31 +209,3 @@ int cliGetRowByIndex(ClcData *dat, int testindex, ClcContact **contact, ClcGroup } return -1; } - -HANDLE ContactToHItem(ClcContact *contact) -{ - switch (contact->type) { - case CLCIT_CONTACT: - return (HANDLE)contact->hContact; - case CLCIT_GROUP: - return (HANDLE)(contact->groupId | HCONTACT_ISGROUP); - case CLCIT_INFO: - return (HANDLE)((DWORD_PTR)contact->hContact | HCONTACT_ISINFO); - } - return NULL; -} - -HANDLE ContactToItemHandle(ClcContact *contact, DWORD *nmFlags) -{ - switch (contact->type) { - case CLCIT_CONTACT: - return (HANDLE)contact->hContact; - case CLCIT_GROUP: - if (nmFlags) *nmFlags |= CLNF_ISGROUP; - return (HANDLE)contact->groupId; - case CLCIT_INFO: - if (nmFlags) *nmFlags |= CLNF_ISINFO; - return (HANDLE)((DWORD_PTR)contact->hContact | HCONTACT_ISINFO); - } - return NULL; -} \ No newline at end of file diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp index e2a9984e01..fee73399c8 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.cpp +++ b/plugins/Clist_modern/src/modern_clcpaint.cpp @@ -1647,7 +1647,8 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, line_num++; // Draw line, if needed - if (y > rcPaint->top - dat->row_heights[line_num]) { + int iRowHeight = dat->getRowHeight(line_num); + if (y > rcPaint->top - iRowHeight) { RECT rc; // Get item to draw @@ -1678,7 +1679,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, int right_pos = dat->rightMargin; // Border RECT row_rc; - SetRect(&row_rc, clRect.left, y, clRect.right, y + dat->row_heights[line_num]); + SetRect(&row_rc, clRect.left, y, clRect.right, y + iRowHeight); RECT free_row_rc = row_rc; free_row_rc.left += left_pos; @@ -1817,8 +1818,9 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, } } } - y += dat->row_heights[line_num]; - //increment by subcontacts + y += iRowHeight; + + // increment by subcontacts if ((group->cl.items && group->scanIndex < group->cl.count && group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP) && (group->cl.items[group->scanIndex]->SubExpanded && dat->expandMeta)) { if (subindex < group->cl.items[group->scanIndex]->SubAllocated - 1) @@ -1864,7 +1866,7 @@ void CLCPaint::_DrawInsertionMark(ClcData *dat, RECT& clRect, _PaintContext& pc) pts[3].y = pts[0].y - 1; pts[4].x = pts[3].x; pts[4].y = pts[0].y + 7; - pts[5].x = pts[2].x + 1; pts[5].y = pts[1].y + 2; + pts[5].x = pts[2].x + 1; pts[5].y = pts[1].y + 2; pts[6].x = pts[1].x; pts[6].y = pts[5].y; pts[7].x = pts[0].x; pts[7].y = pts[4].y; @@ -1932,11 +1934,12 @@ void CLCPaint::_PaintClc(HWND hwnd, ClcData *dat, HDC hdc, RECT *_rcPaint) // Draw background _DrawBackground(hwnd, dat, paintMode, rcPaint, clRect, pc); + // Draw lines - if (dat->row_heights) { + if (!dat->row_variable_height || dat->row_heights) { _DrawLines(hwnd, dat, paintMode, rcPaint, clRect, pc); - //insertion mark + // insertion mark if (dat->iInsertionMark != -1) _DrawInsertionMark(dat, clRect, pc); } @@ -1949,7 +1952,6 @@ void CLCPaint::_PaintClc(HWND hwnd, ClcData *dat, HDC hdc, RECT *_rcPaint) // all still non-validated animated avatars have to be removed AniAva_RemoveInvalidatedAvatars(); - } void CLCPaint::_StoreItemPos(ClcContact *contact, int ItemType, RECT *rc) @@ -2185,32 +2187,22 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT } if (text_left_pos < free_row_rc.right) { // Draw text - RECT text_rc; - RECT selection_text_rc; - SIZE text_size = { 0 }; - SIZE second_line_text_size = { 0 }; - SIZE third_line_text_size = { 0 }; - SIZE space_size = { 0 }; - SIZE counts_size = { 0 }; - TCHAR *szCounts = NULL;//mir_tstrdup( _T("")); - int free_width; - int free_height; int max_bottom_selection_border = SELECTION_BORDER; UINT uTextFormat = DT_NOPREFIX | /*DT_VCENTER |*/ DT_SINGLELINE | (dat->text_rtl ? DT_RTLREADING : 0) | (dat->text_align_right ? DT_RIGHT : 0); free_row_rc.left = text_left_pos; - free_width = free_row_rc.right - free_row_rc.left; - free_height = free_row_rc.bottom - free_row_rc.top; + int free_height = free_row_rc.bottom - free_row_rc.top; // Select font ChangeToFont(hdcMem, dat, GetBasicFontID(Drawing), NULL); // Get text size + SIZE text_size = { 0 }; GetTextSize(&text_size, hdcMem, free_row_rc, Drawing->szText, Drawing->ssText.plText, uTextFormat, dat->text_resize_smileys ? 0 : Drawing->ssText.iMaxSmileyHeight); // Get rect - text_rc = free_row_rc; + RECT text_rc = free_row_rc; free_height -= text_size.cy; text_rc.top += free_height >> 1; @@ -2221,15 +2213,14 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT else text_rc.right = min(free_row_rc.right, free_row_rc.left + text_size.cx); - selection_text_rc = text_rc; + RECT selection_text_rc = text_rc; + SIZE counts_size = { 0 }, second_line_text_size = { 0 }, third_line_text_size = { 0 }; // If group, can have the size of count if (Drawing->type == CLCIT_GROUP) { int full_text_width = text_size.cx; - // Group conts? - szCounts = pcli->pfnGetGroupCountsText(dat, Drawing); - // Has to draw the count? + TCHAR *szCounts = pcli->pfnGetGroupCountsText(dat, Drawing); if (szCounts && szCounts[0]) { RECT space_rc = free_row_rc; RECT counts_rc = free_row_rc; @@ -2239,20 +2230,17 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT // Get widths ske_DrawText(hdcMem, _T(" "), 1, &space_rc, DT_CALCRECT | DT_NOPREFIX); + + SIZE space_size; 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, NULL); DrawText(hdcMem, szCounts, (int)mir_tstrlen(szCounts), &counts_rc, DT_CALCRECT); - //Store position - //StoreItemPos( Drawing, CIT_SUBTEXT1, &counts_rc ); // Or not to comment? - counts_size.cx = counts_rc.right - counts_rc.left; counts_size.cy = min(counts_rc.bottom - counts_rc.top, free_height); - - counts_size.cx += 1; // FIXME: This is workaround for sometimes stripped user counts by one pixel, it somehow wrongly counts width of space or counts text (used wrong font?) - + counts_size.cx ++; // FIXME: This is workaround for sometimes stripped user counts by one pixel, it somehow wrongly counts width of space or counts text (used wrong font?) text_width = free_row_rc.right - free_row_rc.left - space_size.cx - counts_size.cx; if (text_width > 4) { @@ -2284,9 +2272,6 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT if (dat->row_align_group_mode == 1) { // center int x = free_row_rc.left + ((free_row_rc.right - free_row_rc.left - full_text_width) >> 1); - //int l = dat->leftMargin; - //int r = dat->rightMargin; - //x = l+row_rc.left+(( row_rc.right-row_rc.left-full_text_width-l-r )>>1 ); text_rc.left = x; text_rc.right = x + full_text_width; } @@ -2300,7 +2285,6 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT } } else if (Drawing->type == CLCIT_CONTACT && !CheckMiniMode(dat, selected)) { - int tmp; if (dat->secondLine.show) { if (dat->secondLine.type == TEXT_CONTACT_TIME && pdnce->hTimeZone) { // Get contact time @@ -2318,7 +2302,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssSecondLine.iMaxSmileyHeight); // Get rect - tmp = min(free_height, dat->secondLine.top_space + second_line_text_size.cy); + int tmp = min(free_height, dat->secondLine.top_space + second_line_text_size.cy); free_height -= tmp; text_rc.top = free_row_rc.top + (free_height >> 1); @@ -2344,8 +2328,6 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT pdnce->szThirdLineText = mir_tstrdup(buf); } if (pdnce->szThirdLineText != NULL && pdnce->szThirdLineText[0] && free_height > dat->thirdLine.top_space) { - //RECT rc_tmp = free_row_rc; - ChangeToFont(hdcMem, dat, FONTID_THIRDLINE, NULL); // Get sizes @@ -2353,7 +2335,7 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT uTextFormat, dat->text_resize_smileys ? 0 : pdnce->ssThirdLine.iMaxSmileyHeight); // Get rect - tmp = min(free_height, dat->thirdLine.top_space + third_line_text_size.cy); + int tmp = min(free_height, dat->thirdLine.top_space + third_line_text_size.cy); free_height -= tmp; text_rc.top = free_row_rc.top + (free_height >> 1); @@ -2389,126 +2371,124 @@ void CLCPaint::_CalcItemsPos(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT _StoreItemPos(Drawing, CIT_SELECTION, &selection_text_rc); Drawing->pos_rename_rect = free_row_rc; - { - // Draw text - uTextFormat = uTextFormat | (gl_TrimText ? DT_END_ELLIPSIS : 0); - switch (Drawing->type) { - case CLCIT_DIVIDER: - { - //devider - RECT trc = free_row_rc; - RECT rc = free_row_rc; - rc.top += (rc.bottom - rc.top) >> 1; - rc.bottom = rc.top + 2; - rc.right = rc.left + ((rc.right - rc.left - text_size.cx) >> 1) - 3; - trc.left = rc.right + 3; - trc.right = trc.left + text_size.cx + 6; - if (text_size.cy < trc.bottom - trc.top) { - trc.top += (trc.bottom - trc.top - text_size.cy) >> 1; - trc.bottom = trc.top + text_size.cy; - } - _StoreItemPos(Drawing, CIT_TEXT, &trc); - rc.left = rc.right + 6 + text_size.cx; - rc.right = free_row_rc.right; + // Draw text + uTextFormat = uTextFormat | (gl_TrimText ? DT_END_ELLIPSIS : 0); + + switch (Drawing->type) { + case CLCIT_DIVIDER: + { + //devider + RECT trc = free_row_rc; + RECT rc = free_row_rc; + rc.top += (rc.bottom - rc.top) >> 1; + rc.bottom = rc.top + 2; + rc.right = rc.left + ((rc.right - rc.left - text_size.cx) >> 1) - 3; + trc.left = rc.right + 3; + trc.right = trc.left + text_size.cx + 6; + if (text_size.cy < trc.bottom - trc.top) { + trc.top += (trc.bottom - trc.top - text_size.cy) >> 1; + trc.bottom = trc.top + text_size.cy; + } + _StoreItemPos(Drawing, CIT_TEXT, &trc); + rc.left = rc.right + 6 + text_size.cx; + rc.right = free_row_rc.right; + } + break; + case CLCIT_GROUP: + { + RECT rc = text_rc; + + // Get text rectangle + if (dat->text_align_right) + rc.left = rc.right - text_size.cx; + else + rc.right = rc.left + text_size.cx; + + if (text_size.cy < rc.bottom - rc.top) { + rc.top += (rc.bottom - rc.top - text_size.cy) >> 1; + rc.bottom = rc.top + text_size.cy; } - break; - case CLCIT_GROUP: - { - RECT rc = text_rc; - // Get text rectangle + // Draw text + _StoreItemPos(Drawing, CIT_TEXT, &rc); + + // Has to draw the count? + if (counts_size.cx > 0) { + RECT counts_rc = text_rc; + //counts_size.cx; if (dat->text_align_right) - rc.left = rc.right - text_size.cx; + counts_rc.right = text_rc.left + counts_size.cx; else - rc.right = rc.left + text_size.cx; + counts_rc.left = text_rc.right - counts_size.cx; - - if (text_size.cy < rc.bottom - rc.top) { - rc.top += (rc.bottom - rc.top - text_size.cy) >> 1; - rc.bottom = rc.top + text_size.cy; + if (counts_size.cy < counts_rc.bottom - counts_rc.top) { + counts_rc.top += (counts_rc.bottom - counts_rc.top - counts_size.cy + 1) >> 1; + counts_rc.bottom = counts_rc.top + counts_size.cy; } + // Draw counts + _StoreItemPos(Drawing, CIT_SUBTEXT1, &counts_rc); + } + } + break; + case CLCIT_CONTACT: + { + RECT free_rc = text_rc; + if (text_size.cx > 0 && free_rc.bottom > free_rc.top) { + RECT rc = free_rc; + rc.bottom = min(rc.bottom, rc.top + text_size.cy); - // Draw text - _StoreItemPos(Drawing, CIT_TEXT, &rc); - - // Has to draw the count? - if (counts_size.cx > 0) { - RECT counts_rc = text_rc; - //counts_size.cx; + if (text_size.cx < rc.right - rc.left) { if (dat->text_align_right) - counts_rc.right = text_rc.left + counts_size.cx; + rc.left = rc.right - text_size.cx; else - counts_rc.left = text_rc.right - counts_size.cx; - - if (counts_size.cy < counts_rc.bottom - counts_rc.top) { - counts_rc.top += (counts_rc.bottom - counts_rc.top - counts_size.cy + 1) >> 1; - counts_rc.bottom = counts_rc.top + counts_size.cy; - } - // Draw counts - _StoreItemPos(Drawing, CIT_SUBTEXT1, &counts_rc); + rc.right = rc.left + text_size.cx; } + uTextFormat |= DT_VCENTER; + _StoreItemPos(Drawing, CIT_TEXT, &rc); + free_rc.top = rc.bottom; } - break; - case CLCIT_CONTACT: - { - RECT free_rc = text_rc; - if (text_size.cx > 0 && free_rc.bottom > free_rc.top) { + uTextFormat &= ~DT_VCENTER; + if (second_line_text_size.cx > 0 && free_rc.bottom > free_rc.top) { + free_rc.top += dat->secondLine.top_space; + + if (free_rc.bottom > free_rc.top) { RECT rc = free_rc; - rc.bottom = min(rc.bottom, rc.top + text_size.cy); + rc.bottom = min(rc.bottom, rc.top + second_line_text_size.cy); - if (text_size.cx < rc.right - rc.left) { + if (second_line_text_size.cx < rc.right - rc.left) { if (dat->text_align_right) - rc.left = rc.right - text_size.cx; + rc.left = rc.right - second_line_text_size.cx; else - rc.right = rc.left + text_size.cx; + rc.right = rc.left + second_line_text_size.cx; } - uTextFormat |= DT_VCENTER; - _StoreItemPos(Drawing, CIT_TEXT, &rc); + _StoreItemPos(Drawing, CIT_SUBTEXT1, &rc); free_rc.top = rc.bottom; } - uTextFormat &= ~DT_VCENTER; - if (second_line_text_size.cx > 0 && free_rc.bottom > free_rc.top) { - free_rc.top += dat->secondLine.top_space; - - if (free_rc.bottom > free_rc.top) { - RECT rc = free_rc; - rc.bottom = min(rc.bottom, rc.top + second_line_text_size.cy); - - if (second_line_text_size.cx < rc.right - rc.left) { - if (dat->text_align_right) - rc.left = rc.right - second_line_text_size.cx; - else - rc.right = rc.left + second_line_text_size.cx; - } - _StoreItemPos(Drawing, CIT_SUBTEXT1, &rc); - free_rc.top = rc.bottom; - } - } + } - if (third_line_text_size.cx > 0 && free_rc.bottom > free_rc.top) { - free_rc.top += dat->thirdLine.top_space; + if (third_line_text_size.cx > 0 && free_rc.bottom > free_rc.top) { + free_rc.top += dat->thirdLine.top_space; - if (free_rc.bottom > free_rc.top) { - RECT rc = free_rc; - rc.bottom = min(rc.bottom, rc.top + third_line_text_size.cy); + if (free_rc.bottom > free_rc.top) { + RECT rc = free_rc; + rc.bottom = min(rc.bottom, rc.top + third_line_text_size.cy); - if (third_line_text_size.cx < rc.right - rc.left) { - if (dat->text_align_right) - rc.left = rc.right - third_line_text_size.cx; - else - rc.right = rc.left + third_line_text_size.cx; - } - _StoreItemPos(Drawing, CIT_SUBTEXT2, &rc); - free_rc.top = rc.bottom; + if (third_line_text_size.cx < rc.right - rc.left) { + if (dat->text_align_right) + rc.left = rc.right - third_line_text_size.cx; + else + rc.right = rc.left + third_line_text_size.cx; } + _StoreItemPos(Drawing, CIT_SUBTEXT2, &rc); + free_rc.top = rc.bottom; } } - break; - - default: // CLCIT_INFO - _StoreItemPos(Drawing, CIT_TEXT, &text_rc); } + break; + + default: // CLCIT_INFO + _StoreItemPos(Drawing, CIT_TEXT, &text_rc); } } @@ -2560,7 +2540,7 @@ void CLCPaint::_GetBlendMode(IN ClcData *dat, IN ClcContact *Drawing, IN BOOL se } } -void CLCPaint::_DrawContactAvatar(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *row_rc, int& selected, int& hottrack, RECT *prcItem) +void CLCPaint::_DrawContactAvatar(HDC hdcMem, ClcData *dat, ClcContact *Drawing, RECT *row_rc, int &selected, int &hottrack, RECT *prcItem) { if (Drawing->avatar_pos == AVATAR_POS_ANIMATED) { int overlayIdx = -1; diff --git a/plugins/Clist_modern/src/modern_clcutils.cpp b/plugins/Clist_modern/src/modern_clcutils.cpp index 2843dd748d..29ca5e9ceb 100644 --- a/plugins/Clist_modern/src/modern_clcutils.cpp +++ b/plugins/Clist_modern/src/modern_clcutils.cpp @@ -37,8 +37,7 @@ int cliHitTest(HWND hwnd, ClcData *dat, int testx, int testy, ClcContact **conta ClcGroup *hitgroup = NULL; int hit = -1; RECT clRect; - if (CLUI_TestCursorOnBorders() != 0) - { + if (CLUI_TestCursorOnBorders() != 0) { if (flags) *flags = CLCHT_NOWHERE; return -1; } @@ -72,54 +71,39 @@ int cliHitTest(HWND hwnd, ClcData *dat, int testx, int testy, ClcContact **conta if (group) *group = hitgroup; ///////// - if (((testx < hitcontact->pos_indent) && !dat->text_rtl) || - ((testx>clRect.right - hitcontact->pos_indent) && dat->text_rtl)) - { + if (((testx < hitcontact->pos_indent) && !dat->text_rtl) || ((testx>clRect.right - hitcontact->pos_indent) && dat->text_rtl)) { if (flags) *flags |= CLCHT_ONITEMINDENT; return hit; } - if (RectHitTest(&hitcontact->pos_check, testx, testy)) - { + if (RectHitTest(&hitcontact->pos_check, testx, testy)) { if (flags) *flags |= CLCHT_ONITEMCHECK; return hit; } - if (RectHitTest(&hitcontact->pos_avatar, testx, testy)) - { + if (RectHitTest(&hitcontact->pos_avatar, testx, testy)) { if (flags) *flags |= CLCHT_ONITEMICON; return hit; } - if (RectHitTest(&hitcontact->pos_icon, testx, testy)) - { + if (RectHitTest(&hitcontact->pos_icon, testx, testy)) { if (flags) *flags |= CLCHT_ONITEMICON; return hit; } - // if (testx>hitcontact->pos_extra) { - // if (flags) - { - // int c = -1; - int i; - for (i = 0; i < dat->extraColumnsCount; i++) - { - if (RectHitTest(&hitcontact->pos_extra[i], testx, testy)) - { - if (flags) *flags |= CLCHT_ONITEMEXTRA | (i << 24); - return hit; - } + for (int i = 0; i < dat->extraColumnsCount; i++) { + if (RectHitTest(&hitcontact->pos_extra[i], testx, testy)) { + if (flags) *flags |= CLCHT_ONITEMEXTRA | (i << 24); + return hit; } } - if (dat->HiLightMode == 1) - { + if (dat->HiLightMode == 1) { if (flags) *flags |= CLCHT_ONITEMLABEL; return hit; } - if (RectHitTest(&hitcontact->pos_label, testx, testy)) - { + if (RectHitTest(&hitcontact->pos_label, testx, testy)) { if (flags) *flags |= CLCHT_ONITEMLABEL; return hit; } @@ -159,8 +143,7 @@ void cliScrollTo(HWND hwnd, ClcData *dat, int desty, int noSmooth) | GetKeyState(VK_HOME) | GetKeyState(VK_END)) & 0x8000); - if (!noSmooth && !keyDown) - { + if (!noSmooth && !keyDown) { startTick = GetTickCount(); for (;;) { nowTick = GetTickCount(); @@ -168,8 +151,7 @@ void cliScrollTo(HWND hwnd, ClcData *dat, int desty, int noSmooth) dat->yScroll = oldy + (desty - oldy)*(int)(nowTick - startTick) / dat->scrollTime; if (/*dat->backgroundBmpUse&CLBF_SCROLL || dat->hBmpBackground == NULL && */FALSE) ScrollWindowEx(hwnd, 0, previousy - dat->yScroll, NULL, NULL, NULL, NULL, SW_INVALIDATE); - else - { + else { CallService(MS_SKINENG_UPTATEFRAMEIMAGE, (WPARAM)hwnd, (LPARAM)0); //InvalidateRectZ(hwnd,NULL,FALSE); } @@ -184,17 +166,16 @@ void cliScrollTo(HWND hwnd, ClcData *dat, int desty, int noSmooth) SetScrollPos(hwnd, SB_VERT, dat->yScroll, TRUE); } - void cliRecalcScrollBar(HWND hwnd, ClcData *dat) { - SCROLLINFO si = { 0 }; - RECT clRect; - NMCLISTCONTROL nm; if (LOCK_RECALC_SCROLLBAR) return; RowHeights_CalcRowHeights(dat, hwnd); + RECT clRect; GetClientRect(hwnd, &clRect); + + SCROLLINFO si = { 0 }; si.cbSize = sizeof(si); si.fMask = SIF_ALL; si.nMin = 0; @@ -202,11 +183,11 @@ void cliRecalcScrollBar(HWND hwnd, ClcData *dat) si.nPage = clRect.bottom; si.nPos = dat->yScroll; + NMCLISTCONTROL nm; nm.hdr.code = CLN_LISTSIZECHANGE; nm.hdr.hwndFrom = hwnd; nm.hdr.idFrom = 0;//GetDlgCtrlID(hwnd); nm.pt.y = si.nMax; - SendMessage(GetParent(hwnd), WM_NOTIFY, 0, (LPARAM)&nm); //post GetClientRect(hwnd, &clRect); @@ -221,8 +202,8 @@ void cliRecalcScrollBar(HWND hwnd, ClcData *dat) if (dat->noVScrollbar == 0) SetScrollInfo(hwnd, SB_VERT, &si, TRUE); //else SetScrollInfo(hwnd,SB_VERT,&si,FALSE); } - else - SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + else SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + g_mutex_bSizing = 1; cliScrollTo(hwnd, dat, dat->yScroll, 1); g_mutex_bSizing = 0; @@ -231,7 +212,7 @@ void cliRecalcScrollBar(HWND hwnd, ClcData *dat) static LRESULT CALLBACK RenameEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { + switch (uMsg) { case WM_KEYDOWN: switch (wParam) { case VK_RETURN: @@ -259,62 +240,54 @@ static LRESULT CALLBACK RenameEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wPar void cliBeginRenameSelection(HWND hwnd, ClcData *dat) { - ClcContact *contact; - ClcGroup *group; - int indent, x, y, subident, h, w; - RECT clRect; - RECT r; - - KillTimer(hwnd, TIMERID_RENAME); ReleaseCapture(); dat->iHotTrack = -1; + + ClcGroup *group; + ClcContact *contact; dat->selection = cliGetRowByIndex(dat, dat->selection, &contact, &group); - if (dat->selection == -1) return; - if (contact->type != CLCIT_CONTACT && contact->type != CLCIT_GROUP) return; + if (dat->selection == -1 || (contact->type != CLCIT_CONTACT && contact->type != CLCIT_GROUP)) + return; + int indent, subindent; if (contact->type == CLCIT_CONTACT && contact->isSubcontact) - subident = dat->subIndent; + subindent = dat->subIndent; else - subident = 0; + subindent = 0; - for (indent = 0; group->parent; indent++, group = group->parent); + RECT clRect; GetClientRect(hwnd, &clRect); - x = indent*dat->groupIndent + dat->iconXSpace - 2 + subident; - w = clRect.right - x; - y = cliGetRowTopY(dat, dat->selection) - dat->yScroll; - h = dat->row_heights[dat->selection]; - { - int i; - for (i = 0; i <= FONTID_MODERN_MAX; i++) - if (h < dat->fontModernInfo[i].fontHeight + 4) h = dat->fontModernInfo[i].fontHeight + 4; - } - //TODO contact->pos_label + for (indent = 0; group->parent; indent++, group = group->parent); + int x = indent*dat->groupIndent + dat->iconXSpace - 2 + subindent; + int w = clRect.right - x; + int y = cliGetRowTopY(dat, dat->selection) - dat->yScroll; + int h = dat->getRowHeight(dat->selection); + for (int i = 0; i <= FONTID_MODERN_MAX; i++) + if (h < dat->fontModernInfo[i].fontHeight + 4) + h = dat->fontModernInfo[i].fontHeight + 4; - { - RECT rectW; - GetWindowRect(hwnd, &rectW); + RECT rectW; + GetWindowRect(hwnd, &rectW); - x = contact->pos_rename_rect.left + rectW.left; - y = contact->pos_label.top + rectW.top; - w = contact->pos_rename_rect.right - contact->pos_rename_rect.left; - h = contact->pos_label.bottom - contact->pos_label.top + 4; - } + x = contact->pos_rename_rect.left + rectW.left; + y = contact->pos_label.top + rectW.top; + w = contact->pos_rename_rect.right - contact->pos_rename_rect.left; + h = contact->pos_label.bottom - contact->pos_label.top + 4; - { - int a = 0; - if (contact->type == CLCIT_GROUP) - { - if (dat->row_align_group_mode == 1) a |= ES_CENTER; - else if (dat->row_align_group_mode == 2) a |= ES_RIGHT; - } - if (dat->text_rtl) a |= EN_ALIGN_RTL_EC; - if (contact->type == CLCIT_GROUP) - dat->hwndRenameEdit = CreateWindow(_T("EDIT"), contact->szText, WS_POPUP | WS_BORDER | ES_AUTOHSCROLL | a, x, y, w, h, hwnd, NULL, g_hInst, NULL); - else - dat->hwndRenameEdit = CreateWindow(_T("EDIT"), pcli->pfnGetContactDisplayName(contact->hContact, 0), WS_POPUP | WS_BORDER | ES_AUTOHSCROLL | a, x, y, w, h, hwnd, NULL, g_hInst, NULL); + int a = 0; + if (contact->type == CLCIT_GROUP) { + if (dat->row_align_group_mode == 1) a |= ES_CENTER; + else if (dat->row_align_group_mode == 2) a |= ES_RIGHT; } + if (dat->text_rtl) + a |= EN_ALIGN_RTL_EC; + if (contact->type == CLCIT_GROUP) + dat->hwndRenameEdit = CreateWindow(_T("EDIT"), contact->szText, WS_POPUP | WS_BORDER | ES_AUTOHSCROLL | a, x, y, w, h, hwnd, NULL, g_hInst, NULL); + else + dat->hwndRenameEdit = CreateWindow(_T("EDIT"), pcli->pfnGetContactDisplayName(contact->hContact, 0), WS_POPUP | WS_BORDER | ES_AUTOHSCROLL | a, x, y, w, h, hwnd, NULL, g_hInst, NULL); + SetWindowLongPtr(dat->hwndRenameEdit, GWL_STYLE, GetWindowLongPtr(dat->hwndRenameEdit, GWL_STYLE)&(~WS_CAPTION) | WS_BORDER); SetWindowLongPtr(dat->hwndRenameEdit, GWLP_USERDATA, (LONG_PTR)dat); mir_subclassWindow(dat->hwndRenameEdit, RenameEditSubclassProc); @@ -322,13 +295,11 @@ void cliBeginRenameSelection(HWND hwnd, ClcData *dat) SendMessage(dat->hwndRenameEdit, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN | EC_USEFONTINFO, 0); SendMessage(dat->hwndRenameEdit, EM_SETSEL, 0, -1); + RECT r; r.top = 1; r.bottom = h - 1; r.left = 0; r.right = w; - - //ES_MULTILINE - SendMessage(dat->hwndRenameEdit, EM_SETRECT, 0, (LPARAM)&r); CLUI_ShowWindowMod(dat->hwndRenameEdit, SW_SHOW); @@ -338,24 +309,26 @@ void cliBeginRenameSelection(HWND hwnd, ClcData *dat) int GetDropTargetInformation(HWND hwnd, ClcData *dat, POINT pt) { - RECT clRect; - int hit; ClcContact *contact = NULL, *movecontact = NULL; ClcGroup *group, *movegroup; - DWORD hitFlags; - int nSetSelection = -1; + RECT clRect; GetClientRect(hwnd, &clRect); + dat->selection = dat->iDragItem; dat->iInsertionMark = -1; dat->nInsertionLevel = 0; - if (!PtInRect(&clRect, pt)) return DROPTARGET_OUTSIDE; + if (!PtInRect(&clRect, pt)) + return DROPTARGET_OUTSIDE; - hit = cliHitTest(hwnd, dat, pt.x, pt.y, &contact, &group, &hitFlags); + DWORD hitFlags; + int hit = cliHitTest(hwnd, dat, pt.x, pt.y, &contact, &group, &hitFlags); cliGetRowByIndex(dat, dat->iDragItem, &movecontact, &movegroup); if (hit == dat->iDragItem) return DROPTARGET_ONSELF; - if (hit == -1 || hitFlags&CLCHT_ONITEMEXTRA || !movecontact) return DROPTARGET_ONNOTHING; + if (hit == -1 || hitFlags & CLCHT_ONITEMEXTRA || !movecontact) + return DROPTARGET_ONNOTHING; + int nSetSelection = -1; if (movecontact->type == CLCIT_GROUP) { ClcContact *bottomcontact = NULL, *topcontact = NULL; ClcGroup *topgroup = NULL, *bottomgroup = NULL; @@ -370,32 +343,25 @@ 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.count > 0)) - { + || (contact->type == CLCIT_GROUP && contact->group->expanded && contact->group->cl.count > 0)) { //could be insertion mark (below) topItem = hit; bottomItem = hit + 1; topcontact = contact; topgroup = group; bottomItem = cliGetRowByIndex(dat, bottomItem, &bottomcontact, &bottomgroup); ok = 1; } - if (ok) - { - if (bottomItem == -1 && contact->type == CLCIT_GROUP) - { + if (ok) { + if (bottomItem == -1 && contact->type == CLCIT_GROUP) { bottomItem = topItem + 1; } - else - { - if (bottomItem == -1 && contact->type != CLCIT_GROUP && contact->groupId == 0) - { + else { + if (bottomItem == -1 && contact->type != CLCIT_GROUP && contact->groupId == 0) { bottomItem = topItem; cliGetRowByIndex(dat, bottomItem, &bottomcontact, &bottomgroup); } - if (bottomItem != -1 && bottomcontact->type != CLCIT_GROUP) - { + if (bottomItem != -1 && bottomcontact->type != CLCIT_GROUP) { ClcGroup *gr = bottomgroup; - do - { + do { bottomItem = cliGetRowByIndex(dat, bottomItem - 1, &bottomcontact, &bottomgroup); } while (bottomItem >= 0 && bottomcontact->type != CLCIT_GROUP && bottomgroup == gr); nSetSelection = bottomItem; @@ -403,37 +369,37 @@ int GetDropTargetInformation(HWND hwnd, ClcData *dat, POINT pt) } } - if (bottomItem == -1) bottomItem = topItem + 1; - { - int bi = cliGetRowByIndex(dat, bottomItem, &bottomcontact, &bottomgroup); - if (bi != -1) - { - group = bottomgroup; - if (bottomcontact == movecontact || group == movecontact->group) return DROPTARGET_ONSELF; - dat->nInsertionLevel = -1; // decreasing here - for (; group; group = group->parent) - { - dat->nInsertionLevel++; - if (group == movecontact->group) return DROPTARGET_ONSELF; - } + if (bottomItem == -1) + bottomItem = topItem + 1; + + int bi = cliGetRowByIndex(dat, bottomItem, &bottomcontact, &bottomgroup); + if (bi != -1) { + group = bottomgroup; + if (bottomcontact == movecontact || group == movecontact->group) + return DROPTARGET_ONSELF; + + dat->nInsertionLevel = -1; // decreasing here + for (; group; group = group->parent) { + dat->nInsertionLevel++; + if (group == movecontact->group) + return DROPTARGET_ONSELF; } } + dat->iInsertionMark = bottomItem; dat->selection = nSetSelection; return DROPTARGET_INSERTION; } } - if (contact->type == CLCIT_GROUP) - { - if (dat->iInsertionMark == -1) - { - if (movecontact->type == CLCIT_GROUP) - { //check not moving onto its own subgroup + + if (contact->type == CLCIT_GROUP) { + if (dat->iInsertionMark == -1) { + if (movecontact->type == CLCIT_GROUP) { //check not moving onto its own subgroup dat->iInsertionMark = hit + 1; - for (; group; group = group->parent) - { + for (; group; group = group->parent) { dat->nInsertionLevel++; - if (group == movecontact->group) return DROPTARGET_ONSELF; + if (group == movecontact->group) + return DROPTARGET_ONSELF; } } dat->selection = hit; @@ -448,13 +414,16 @@ int GetDropTargetInformation(HWND hwnd, ClcData *dat, POINT pt) return DROPTARGET_ONSUBCONTACT; return DROPTARGET_ONCONTACT; } -COLORREF sttGetColor(char * module, char * color, COLORREF defColor) + +COLORREF sttGetColor(char *module, char *color, COLORREF defColor) { BOOL useWinColor = db_get_b(NULL, module, "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS); if (useWinColor) return defColor; else return db_get_dw(NULL, module, color, defColor); } + void RegisterCLUIFonts(void); + void LoadCLCFonts(HWND hwnd, ClcData *dat) { RegisterCLUIFonts(); @@ -462,10 +431,8 @@ void LoadCLCFonts(HWND hwnd, ClcData *dat) HDC hdc = GetDC(hwnd); HFONT holdfont = (HFONT)GetCurrentObject(hdc, OBJ_FONT); - for (int i = 0; i <= FONTID_MODERN_MAX; i++) - { - if (!dat->fontModernInfo[i].changed && dat->fontModernInfo[i].hFont) - { + for (int i = 0; i <= FONTID_MODERN_MAX; i++) { + if (!dat->fontModernInfo[i].changed && dat->fontModernInfo[i].hFont) { DeleteObject(dat->fontModernInfo[i].hFont); } LOGFONT lf; diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp index 0023a90089..93f51e9cdc 100644 --- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp +++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp @@ -461,7 +461,7 @@ void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd) else RowHeight_CalcRowHeight(dat, Drawing, line_num); - //increment by subcontacts + // increment by subcontacts if (group->cl.items[group->scanIndex]->subcontacts != NULL && group->cl.items[group->scanIndex]->type != CLCIT_GROUP) { if (group->cl.items[group->scanIndex]->SubExpanded && dat->expandMeta) { if (subindex < group->cl.items[group->scanIndex]->SubAllocated - 1) @@ -487,75 +487,74 @@ void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd) // Calc and store row height int RowHeights_GetRowHeight(ClcData *dat, HWND hwnd, ClcContact *contact, int item) { + if (!dat->row_variable_height) + return dat->rowHeight; + if (gl_RowRoot) return RowHeight_CalcRowHeight(dat, contact, item); DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE); //TODO replace futher code with new rowheight definition - int tmp; - BOOL selected = ((item == dat->selection) && (dat->hwndRenameEdit != NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || g_clcPainter.IsForegroundWindow(hwnd)) && contact->type != CLCIT_DIVIDER); + BOOL selected = ((item == dat->selection) && (dat->hwndRenameEdit != NULL || dat->showSelAlways || dat->exStyle & CLS_EX_SHOWSELALWAYS || g_clcPainter.IsForegroundWindow(hwnd)) && contact->type != CLCIT_DIVIDER); BOOL minimalistic = (g_clcPainter.CheckMiniMode(dat, selected)); + if (!RowHeights_Alloc(dat, item + 1)) return -1; int height = 0; ClcCacheEntry *pdnce = contact->pce; - if (dat->row_variable_height) { - if (!dat->text_ignore_size_for_row_height) { - tmp = dat->fontModernInfo[g_clcPainter.GetBasicFontID(contact)].fontHeight; - if (dat->text_replace_smileys && dat->first_line_draw_smileys && !dat->text_resize_smileys) - tmp = max(tmp, contact->ssText.iMaxSmileyHeight); - height += tmp; - - if (pdnce && !minimalistic) { - if (dat->secondLine.show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { - tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight; - if (dat->text_replace_smileys && dat->secondLine.draw_smileys && !dat->text_resize_smileys) - tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight); - height += dat->secondLine.top_space + tmp; - } + if (!dat->text_ignore_size_for_row_height) { + int tmp = dat->fontModernInfo[g_clcPainter.GetBasicFontID(contact)].fontHeight; + if (dat->text_replace_smileys && dat->first_line_draw_smileys && !dat->text_resize_smileys) + tmp = max(tmp, contact->ssText.iMaxSmileyHeight); + height += tmp; + + if (pdnce && !minimalistic) { + if (dat->secondLine.show && pdnce->szSecondLineText && pdnce->szSecondLineText[0]) { + tmp = dat->fontModernInfo[FONTID_SECONDLINE].fontHeight; + if (dat->text_replace_smileys && dat->secondLine.draw_smileys && !dat->text_resize_smileys) + tmp = max(tmp, pdnce->ssSecondLine.iMaxSmileyHeight); + height += dat->secondLine.top_space + tmp; + } - if (dat->thirdLine.show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { - tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight; - if (dat->text_replace_smileys && dat->thirdLine.draw_smileys && !dat->text_resize_smileys) - tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight); - height += dat->thirdLine.top_space + tmp; - } + if (dat->thirdLine.show && pdnce->szThirdLineText && pdnce->szThirdLineText[0]) { + tmp = dat->fontModernInfo[FONTID_THIRDLINE].fontHeight; + if (dat->text_replace_smileys && dat->thirdLine.draw_smileys && !dat->text_resize_smileys) + tmp = max(tmp, pdnce->ssThirdLine.iMaxSmileyHeight); + height += dat->thirdLine.top_space + tmp; } } + } - // Avatar size - if (dat->avatars_show && !dat->avatars_ignore_size_for_row_height && contact->type == CLCIT_CONTACT && contact->avatar_data != NULL && !minimalistic) - height = max(height, dat->avatars_maxheight_size); + // Avatar size + if (dat->avatars_show && !dat->avatars_ignore_size_for_row_height && contact->type == CLCIT_CONTACT && contact->avatar_data != NULL && !minimalistic) + height = max(height, dat->avatars_maxheight_size); - // Checkbox size - if (contact->isCheckBox(style)) - height = max(height, dat->checkboxSize); + // Checkbox size + if (contact->isCheckBox(style)) + height = max(height, dat->checkboxSize); - // Icon size - if (!dat->icon_ignore_size_for_row_height) { - if (contact->type == CLCIT_GROUP || - (contact->type == CLCIT_CONTACT && contact->iImage != -1 && !(dat->icon_hide_on_avatar && dat->avatars_show && contact->avatar_data != NULL && !contact->image_is_special))) { - height = max(height, ICON_HEIGHT); - } + // Icon size + if (!dat->icon_ignore_size_for_row_height) { + if (contact->type == CLCIT_GROUP || + (contact->type == CLCIT_CONTACT && contact->iImage != -1 && !(dat->icon_hide_on_avatar && dat->avatars_show && contact->avatar_data != NULL && !contact->image_is_special))) { + height = max(height, ICON_HEIGHT); } - - height += 2 * dat->row_border; - - // Min size - height = max(height, dat->row_min_heigh); } - else height = dat->rowHeight; - dat->row_heights[item] = height; + height += 2 * dat->row_border; - return height; + // Min size + return dat->row_heights[item] = max(height, dat->row_min_heigh); } // Calc item top Y (using stored data) int cliGetRowTopY(ClcData *dat, int item) { + if (!dat->row_variable_height) + return item * dat->rowHeight; + if (item >= dat->row_heights_size) return cliGetRowBottomY(dat, item - 1); @@ -568,6 +567,9 @@ int cliGetRowTopY(ClcData *dat, int item) // Calc item bottom Y (using stored data) int cliGetRowBottomY(ClcData *dat, int item) { + if (!dat->row_variable_height) + return (item+1) * dat->rowHeight; + if (item >= dat->row_heights_size) return -1; @@ -581,6 +583,9 @@ int cliGetRowBottomY(ClcData *dat, int item) // Calc total height of rows (using stored data) int cliGetRowTotalHeight(ClcData *dat) { + if (!dat->row_variable_height) + return dat->rowHeight * dat->row_heights_size; + int y = 0; for (int i = 0; i < dat->row_heights_size; i++) y += dat->row_heights[i]; @@ -594,6 +599,9 @@ int cliRowHitTest(ClcData *dat, int pos_y) if (pos_y < 0) return -1; + if (!dat->row_variable_height && dat->rowHeight) + return pos_y / dat->rowHeight; + int y = 0; for (int i = 0; i < dat->row_heights_size; i++) { y += dat->row_heights[i]; @@ -606,7 +614,7 @@ int cliRowHitTest(ClcData *dat, int pos_y) int cliGetRowHeight(ClcData *dat, int item) { - if (item >= dat->row_heights_size || item < 0) + if (!dat->row_variable_height || item >= dat->row_heights_size || item < 0) return dat->rowHeight; return dat->row_heights[item]; -- cgit v1.2.3