diff options
author | George Hazan <george.hazan@gmail.com> | 2016-05-06 15:28:18 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-05-06 15:28:18 +0000 |
commit | f6c3afc4b7eb38a4c2a189fa7e5ba9d44c095cc4 (patch) | |
tree | e8d746f72c44344150c53c57a58618e6a47a3406 /plugins | |
parent | 5b3107408e96484e0c98c172c39dde66c8fe9897 (diff) |
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@16806 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Clist_modern/src/modern_clc.h | 6 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clcpaint.cpp | 46 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_clui.cpp | 3 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_commonprototypes.h | 1 | ||||
-rw-r--r-- | plugins/Clist_modern/src/modern_rowheight_funcs.cpp | 49 |
5 files changed, 27 insertions, 78 deletions
diff --git a/plugins/Clist_modern/src/modern_clc.h b/plugins/Clist_modern/src/modern_clc.h index f5908e29c4..261724c0f9 100644 --- a/plugins/Clist_modern/src/modern_clc.h +++ b/plugins/Clist_modern/src/modern_clc.h @@ -211,9 +211,11 @@ struct ClcContact : public ClcContactBase BOOL ext_fItemsValid;
tContactItems ext_mpItemsDesc[EXTRA_ICON_COUNT + 10]; //up to 10 items
+ __forceinline bool isCheckBox(DWORD_PTR style) const
+ { return (style & CLS_CHECKBOXES && type == CLCIT_CONTACT) || (style & CLS_GROUPCHECKBOXES && type == CLCIT_GROUP) || (type == CLCIT_INFO && flags & CLCIIF_CHECKBOX);
+ }
__forceinline bool isChat() const
- {
- return (type == CLCIT_CONTACT) && (db_get_b(hContact, proto, "ChatRoom", 0) != 0);
+ { return (type == CLCIT_CONTACT) && (db_get_b(hContact, proto, "ChatRoom", 0) != 0);
}
};
diff --git a/plugins/Clist_modern/src/modern_clcpaint.cpp b/plugins/Clist_modern/src/modern_clcpaint.cpp index c1c3176790..e2a9984e01 100644 --- a/plugins/Clist_modern/src/modern_clcpaint.cpp +++ b/plugins/Clist_modern/src/modern_clcpaint.cpp @@ -1624,11 +1624,9 @@ void CLCPaint::_DrawBackground(HWND hWnd, ClcData *dat, int paintMode, RECT *rcP void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, RECT& clRect, _PaintContext& pc)
{
- ClcContact *Drawing;
ClcGroup *group = &dat->list;
group->scanIndex = 0;
int indent = 0;
- int subident = 0;
int subindex = -1;
int line_num = -1;
int y = -dat->yScroll;
@@ -1650,19 +1648,16 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, // Draw line, if needed
if (y > rcPaint->top - dat->row_heights[line_num]) {
- int free_row_height;
- RECT row_rc;
- RECT free_row_rc;
RECT rc;
// Get item to draw
+ int subident = 0;
+ ClcContact *Drawing;
if (group->scanIndex < group->cl.count) {
- if (subindex == -1) {
+ if (subindex == -1)
Drawing = group->cl.items[group->scanIndex];
- subident = 0;
- }
else {
- Drawing = &(group->cl.items[group->scanIndex]->subcontacts[subindex]);
+ Drawing = &group->cl.items[group->scanIndex]->subcontacts[subindex];
subident = dat->subIndent;
}
}
@@ -1678,17 +1673,18 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, // Init settings
int selected = ((line_num == dat->selection) && (dat->hwndRenameEdit != NULL || dat->showSelAlways || dat->exStyle&CLS_EX_SHOWSELALWAYS || is_foreground) && Drawing->type != CLCIT_DIVIDER);
- int hottrack = dat->exStyle&CLS_EX_TRACKSELECT && Drawing->type != CLCIT_DIVIDER && dat->iHotTrack == line_num;
+ int hottrack = dat->exStyle & CLS_EX_TRACKSELECT && Drawing->type != CLCIT_DIVIDER && dat->iHotTrack == line_num;
int left_pos = clRect.left + dat->leftMargin + indent * dat->groupIndent + subident;
int right_pos = dat->rightMargin; // Border
+ RECT row_rc;
SetRect(&row_rc, clRect.left, y, clRect.right, y + dat->row_heights[line_num]);
- free_row_rc = row_rc;
+
+ RECT free_row_rc = row_rc;
free_row_rc.left += left_pos;
free_row_rc.right -= right_pos;
free_row_rc.top += dat->row_border;
free_row_rc.bottom -= dat->row_border;
- free_row_height = free_row_rc.bottom - free_row_rc.top;
{
HRGN rgn = CreateRectRgn(row_rc.left, row_rc.top, row_rc.right, row_rc.bottom);
SelectClipRgn(pc.hdcMem, rgn);
@@ -1752,13 +1748,6 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, }
}
else {
- int checkboxWidth;
- if ((lStyle&CLS_CHECKBOXES && Drawing->type == CLCIT_CONTACT) ||
- (lStyle&CLS_GROUPCHECKBOXES && Drawing->type == CLCIT_GROUP) ||
- (Drawing->type == CLCIT_INFO && Drawing->flags&CLCIIF_CHECKBOX))
- checkboxWidth = dat->checkboxSize + 2;
- else checkboxWidth = 0;
-
// background
if (selected) {
switch (dat->HiLightMode) {
@@ -1769,7 +1758,7 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, for (int i = y; i < y + row_height; i += max(dat->row_min_heigh, 1)) {
ImageList_DrawEx(dat->himlHighlight, 0, pc.hdcMem, 0, i, clRect.right,
min(y + row_height - i, max(dat->row_min_heigh, 1)), CLR_NONE, CLR_NONE,
- dat->exStyle&CLS_EX_NOTRANSLUCENTSEL ? ILD_NORMAL : ILD_BLEND25);
+ dat->exStyle & CLS_EX_NOTRANSLUCENTSEL ? ILD_NORMAL : ILD_BLEND25);
}
SetTextColor(pc.hdcMem, paintMode&DM_CONTROL ? GetSysColor(COLOR_HIGHLIGHTTEXT) : dat->selTextColour);
}
@@ -1780,18 +1769,15 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, for (int i = y + 1; i < y + row_height; i += max(dat->row_min_heigh, 1)) {
ImageList_DrawEx(dat->himlHighlight, 0, pc.hdcMem, 1, i, clRect.right - 2,
min(y + row_height - i, max(dat->row_min_heigh, 1)), CLR_NONE, CLR_NONE,
- dat->exStyle&CLS_EX_NOTRANSLUCENTSEL ? ILD_NORMAL : ILD_BLEND25);
+ dat->exStyle & CLS_EX_NOTRANSLUCENTSEL ? ILD_NORMAL : ILD_BLEND25);
}
- SetTextColor(pc.hdcMem, paintMode&DM_CONTROL ? GetSysColor(COLOR_HIGHLIGHTTEXT) : dat->selTextColour);
+ SetTextColor(pc.hdcMem, paintMode & DM_CONTROL ? GetSysColor(COLOR_HIGHLIGHTTEXT) : dat->selTextColour);
break;
}
}
}
//**** Checkboxes
- if ((lStyle&CLS_CHECKBOXES && Drawing->type == CLCIT_CONTACT) ||
- (lStyle&CLS_GROUPCHECKBOXES && Drawing->type == CLCIT_GROUP) ||
- (Drawing->type == CLCIT_INFO && Drawing->flags&CLCIIF_CHECKBOX)) {
- //RECT rc;
+ if (Drawing->isCheckBox(lStyle)) {
rc = free_row_rc;
rc.right = rc.left + dat->checkboxSize;
rc.top += (rc.bottom - rc.top - dat->checkboxSize) >> 1;
@@ -1799,10 +1785,10 @@ void CLCPaint::_DrawLines(HWND hWnd, ClcData *dat, int paintMode, RECT* rcPaint, if (dat->text_rtl != 0) _RTLRect(&rc, free_row_rc.right);
- if (xpt_IsThemed(dat->hCheckBoxTheme)) {
- xpt_DrawThemeBackground(dat->hCheckBoxTheme, pc.hdcMem, BP_CHECKBOX, Drawing->flags&CONTACTF_CHECKED ? (hottrack ? CBS_CHECKEDHOT : CBS_CHECKEDNORMAL) : (hottrack ? CBS_UNCHECKEDHOT : CBS_UNCHECKEDNORMAL), &rc, &rc);
- }
- else DrawFrameControl(pc.hdcMem, &rc, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_FLAT | (Drawing->flags&CONTACTF_CHECKED ? DFCS_CHECKED : 0) | (hottrack ? DFCS_HOT : 0));
+ if (xpt_IsThemed(dat->hCheckBoxTheme))
+ xpt_DrawThemeBackground(dat->hCheckBoxTheme, pc.hdcMem, BP_CHECKBOX, Drawing->flags & CONTACTF_CHECKED ? (hottrack ? CBS_CHECKEDHOT : CBS_CHECKEDNORMAL) : (hottrack ? CBS_UNCHECKEDHOT : CBS_UNCHECKEDNORMAL), &rc, &rc);
+ else
+ DrawFrameControl(pc.hdcMem, &rc, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_FLAT | (Drawing->flags & CONTACTF_CHECKED ? DFCS_CHECKED : 0) | (hottrack ? DFCS_HOT : 0));
left_pos += dat->checkboxSize + EXTRA_CHECKBOX_SPACE + HORIZONTAL_SPACE;
free_row_rc.left = row_rc.left + left_pos;
diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp index 1b7121dbc7..2f1d258d2c 100644 --- a/plugins/Clist_modern/src/modern_clui.cpp +++ b/plugins/Clist_modern/src/modern_clui.cpp @@ -544,10 +544,9 @@ static BOOL CLUI_WaitThreadsCompletion() static const BYTE bcMAX_AWAITING_RETRY = 10; // repeat awaiting only 10 times
TRACE("CLUI_WaitThreadsCompletion Enter");
if (bEntersCount < bcMAX_AWAITING_RETRY &&
- (g_mutex_nCalcRowHeightLock || g_CluiData.mutexPaintLock || g_hAwayMsgThread || g_hGetTextAsyncThread || g_hSmoothAnimationThread) && !Miranda_Terminated())
+ (g_CluiData.mutexPaintLock || g_hAwayMsgThread || g_hGetTextAsyncThread || g_hSmoothAnimationThread) && !Miranda_Terminated())
{
TRACE("Waiting threads");
- TRACEVAR("g_mutex_nCalcRowHeightLock: %x", g_mutex_nCalcRowHeightLock);
TRACEVAR("g_CluiData.mutexPaintLock: %x", g_CluiData.mutexPaintLock);
TRACEVAR("g_hAwayMsgThread: %x", g_hAwayMsgThread);
TRACEVAR("g_hGetTextAsyncThread: %x", g_hGetTextAsyncThread);
diff --git a/plugins/Clist_modern/src/modern_commonprototypes.h b/plugins/Clist_modern/src/modern_commonprototypes.h index ff65753ae4..752b682f63 100644 --- a/plugins/Clist_modern/src/modern_commonprototypes.h +++ b/plugins/Clist_modern/src/modern_commonprototypes.h @@ -35,7 +35,6 @@ extern SKINOBJECTSLIST g_SkinObjectList; extern CURRWNDIMAGEDATA *g_pCachedWindow;
extern char *g_szConnectingProto;
extern BOOL g_mutex_bLockUpdating;
-extern int g_mutex_nCalcRowHeightLock;
extern int g_mutex_bOnTrayRightClick;
extern BOOL g_flag_bPostWasCanceled;
extern BOOL g_flag_bFullRepaint;
diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp index a71a40ba8e..0023a90089 100644 --- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp +++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp @@ -27,17 +27,8 @@ Created by Pescuma, modified by Artem Shpynov #include "stdafx.h"
#include "modern_clcpaint.h"
-int g_mutex_nCalcRowHeightLock = 0;
-int mod_CalcRowHeight_worker(ClcData *dat, ClcContact *contact, int item);
-void RowHeights_CalcRowHeights_Worker(ClcData *dat, HWND hwnd);
-int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item);
-
-/*
-*
-*/
-
-ROWCELL * gl_RowTabAccess[TC_ELEMENTSCOUNT + 1] = { 0 }; // Массив, через который осуществляется доступ к элементам контакта.
-ROWCELL * gl_RowRoot;
+ROWCELL *gl_RowTabAccess[TC_ELEMENTSCOUNT + 1] = { 0 }; // Массив, через который осуществляется доступ к элементам контакта.
+ROWCELL *gl_RowRoot;
void FreeRowCell()
{
@@ -68,15 +59,6 @@ SIZE GetAvatarSize(int imageWidth, int imageHeight, int maxWidth, int maxHeight) int RowHeight_CalcRowHeight(ClcData *dat, ClcContact *contact, int item)
{
- if (MirandaExiting()) return 0;
- g_mutex_nCalcRowHeightLock++;
- int res = mod_CalcRowHeight_worker(dat, contact, item);
- g_mutex_nCalcRowHeightLock--;
- return res;
-}
-
-int mod_CalcRowHeight_worker(ClcData *dat, ClcContact *contact, int item)
-{
if (!RowHeights_Alloc(dat, item + 1))
return -1;
@@ -439,26 +421,19 @@ int RowHeights_GetMaxRowHeight(ClcData *dat, HWND hwnd) void RowHeights_CalcRowHeights(ClcData *dat, HWND hwnd)
{
if (MirandaExiting()) return;
- g_mutex_nCalcRowHeightLock++;
- RowHeights_CalcRowHeights_Worker(dat, hwnd);
- g_mutex_nCalcRowHeightLock--;
-}
-
-void RowHeights_CalcRowHeights_Worker(ClcData *dat, HWND hwnd)
-{
- if (MirandaExiting()) return;
// Draw lines
ClcGroup *group = &dat->list;
- ClcContact *Drawing;
group->scanIndex = 0;
- int indent = 0, subident;
+ int indent = 0;
int subindex = -1;
int line_num = -1;
RowHeights_Clear(dat);
while (TRUE) {
+ int subident;
+ ClcContact *Drawing;
if (subindex == -1) {
if (group->scanIndex == group->cl.count) {
group = group->parent;
@@ -512,15 +487,6 @@ void RowHeights_CalcRowHeights_Worker(ClcData *dat, HWND hwnd) // Calc and store row height
int RowHeights_GetRowHeight(ClcData *dat, HWND hwnd, ClcContact *contact, int item)
{
- if (MirandaExiting()) return 0;
- g_mutex_nCalcRowHeightLock++;
- int res = RowHeights_GetRowHeight_worker(dat, hwnd, contact, item);
- g_mutex_nCalcRowHeightLock--;
- return res;
-}
-
-int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, int item)
-{
if (gl_RowRoot)
return RowHeight_CalcRowHeight(dat, contact, item);
@@ -564,11 +530,8 @@ int RowHeights_GetRowHeight_worker(ClcData *dat, HWND hwnd, ClcContact *contact, height = max(height, dat->avatars_maxheight_size);
// Checkbox size
- if ((style & CLS_CHECKBOXES && contact->type == CLCIT_CONTACT) ||
- (style & CLS_GROUPCHECKBOXES && contact->type == CLCIT_GROUP) ||
- (contact->type == CLCIT_INFO && contact->flags & CLCIIF_CHECKBOX)) {
+ if (contact->isCheckBox(style))
height = max(height, dat->checkboxSize);
- }
// Icon size
if (!dat->icon_ignore_size_for_row_height) {
|