summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-30 07:19:31 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-30 07:19:31 +0000
commit48d2e7b444ca50e09e42a09078956839e922cb17 (patch)
treeca067c75f458c771fc7ab14f5e3b488fcd322279 /plugins
parent1a93578f19372a5bf33e5e62eb4048bb9ff86428 (diff)
- fix for the eternal loop in avatar drawing;
- code optimization & reordering git-svn-id: http://svn.miranda-ng.org/main/trunk@9986 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp4
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp35
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.h2
-rw-r--r--plugins/TabSRMM/src/msgs.h6
-rw-r--r--plugins/TabSRMM/src/themes.cpp6
5 files changed, 28 insertions, 25 deletions
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index f94d5e955e..bc2d36bf19 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -1042,9 +1042,9 @@ static int MessageDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *
urc->rcItem.left = urc->rcItem.right - (dat->pic.cx + 2);
if ((urc->rcItem.bottom - urc->rcItem.top) < (dat->pic.cy/* + 2*/) && dat->showPic) {
urc->rcItem.top = urc->rcItem.bottom - dat->pic.cy;
- dat->fMustOffset = TRUE;
+ dat->fMustOffset = true;
}
- else dat->fMustOffset = FALSE;
+ else dat->fMustOffset = false;
if (showToolbar && bBottomToolbar && (PluginConfig.m_AlwaysFullToolbarWidth || ((dat->pic.cy - DPISCALEY_S(6)) < rc.bottom))) {
urc->rcItem.bottom -= DPISCALEY_S(22);
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index 13672ea199..62cdc862c5 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -542,7 +542,7 @@ void TSAPI HandleIconFeedback(TWindowData *dat, HICON iIcon)
// retrieve the visiblity of the avatar window, depending on the global setting
// and local mode
-int TSAPI GetAvatarVisibility(HWND hwndDlg, TWindowData *dat)
+bool TSAPI GetAvatarVisibility(HWND hwndDlg, TWindowData *dat)
{
BYTE bAvatarMode = dat->pContainer->avatarMode;
BYTE bOwnAvatarMode = dat->pContainer->ownAvatarMode;
@@ -553,7 +553,7 @@ int TSAPI GetAvatarVisibility(HWND hwndDlg, TWindowData *dat)
if (dat->Panel->isActive() && bAvatarMode != 3) {
if (bOwnAvatarMode)
- dat->showPic = FALSE;
+ dat->showPic = false;
else {
dat->showPic = (dat->hOwnPic && dat->hOwnPic != PluginConfig.g_hbmUnknown) ? 1 : 0;
if (!PluginConfig.g_bDisableAniAvatars && !dat->hwndContactPic)
@@ -1612,20 +1612,23 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat)
return TRUE;
}
- if ((dis->hwndItem == GetDlgItem(hwndDlg, IDC_CONTACTPIC) && (dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown) && dat->showPic) || (dis->hwndItem == hwndDlg && dat->Panel->isActive() && (dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown))) {
+ HBITMAP hbmAvatar = dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown;
+ if ((dis->hwndItem == GetDlgItem(hwndDlg, IDC_CONTACTPIC) && dat->showPic) || (dis->hwndItem == hwndDlg && dat->Panel->isActive())) {
+ if (hbmAvatar == NULL)
+ return TRUE;
+
BITMAP bminfo;
double dAspect = 0, dNewWidth = 0, dNewHeight = 0;
DWORD iMaxHeight = 0, top, cx, cy;
RECT rc, rcClient, rcFrame;
- BOOL bPanelPic = dis->hwndItem == hwndDlg;
+ bool bPanelPic = dis->hwndItem == hwndDlg;
DWORD aceFlags = 0;
- HPEN hPenBorder = 0, hPenOld = 0;
HRGN clipRgn = 0;
int iRad = PluginConfig.m_WinVerMajor >= 5 ? 4 : 6;
- bool bInfoPanel = dat->Panel->isActive();
+ bool bDrawOwnAvatar = dat->Panel->isActive() && dat->pContainer->avatarMode != 3;
if (bPanelPic) {
- GetObject(dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown, sizeof(bminfo), &bminfo);
+ GetObject(hbmAvatar, sizeof(bminfo), &bminfo);
if ((dat->ace && dat->showInfoPic && !(dat->ace->dwFlags & AVS_HIDEONCLIST)) || dat->showInfoPic)
aceFlags = dat->ace ? dat->ace->dwFlags : 0;
@@ -1639,14 +1642,14 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat)
}
}
else {
- if (!bInfoPanel || dat->pContainer->avatarMode == 3) {
+ if (!bDrawOwnAvatar) {
if (dat->ace)
aceFlags = dat->ace->dwFlags;
}
else if (dat->ownAce)
aceFlags = dat->ownAce->dwFlags;
- GetObject((bInfoPanel && dat->pContainer->avatarMode != 3) ? dat->hOwnPic : (dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown), sizeof(bminfo), &bminfo);
+ GetObject(bDrawOwnAvatar ? dat->hOwnPic : hbmAvatar, sizeof(bminfo), &bminfo);
}
GetClientRect(hwndDlg, &rc);
@@ -1728,8 +1731,8 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat)
else FillRect(hdcDraw, &rcFrame, GetSysColorBrush(COLOR_3DFACE));
}
- hPenBorder = CreatePen(PS_SOLID, 1, CSkin::m_avatarBorderClr);
- hPenOld = (HPEN)SelectObject(hdcDraw, hPenBorder);
+ HPEN hPenBorder = CreatePen(PS_SOLID, 1, CSkin::m_avatarBorderClr);
+ HPEN hPenOld = (HPEN)SelectObject(hdcDraw, hPenBorder);
if (CSkin::m_bAvatarBorderType == 1)
Rectangle(hdcDraw, rcEdge.left, rcEdge.top, rcEdge.right, rcEdge.bottom);
@@ -1737,11 +1740,13 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat)
clipRgn = CreateRoundRectRgn(rcEdge.left, rcEdge.top, rcEdge.right + 1, rcEdge.bottom + 1, iRad, iRad);
SelectClipRgn(hdcDraw, clipRgn);
}
+
+ SelectObject(hdcDraw, hPenOld);
+ DeleteObject(hPenBorder);
}
- if ((((bInfoPanel && dat->pContainer->avatarMode != 3) ? dat->hOwnPic : (dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown)) && dat->showPic) || bPanelPic) {
+ if (((bDrawOwnAvatar ? dat->hOwnPic : hbmAvatar) && dat->showPic) || bPanelPic) {
HDC hdcMem = CreateCompatibleDC(dis->hDC);
- HBITMAP hbmAvatar = bPanelPic ? (dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown) : ((bInfoPanel && dat->pContainer->avatarMode != 3) ? dat->hOwnPic : (dat->ace ? dat->ace->hbmPic : PluginConfig.g_hbmUnknown));
HBITMAP hbmMem = 0;
if (bPanelPic) {
bool bBorder = (CSkin::m_bAvatarBorderType ? true : false);
@@ -1801,7 +1806,7 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat)
DeleteObject(hbmNew);
}
else {
- hbmMem = (HBITMAP)SelectObject(hdcMem, hbmAvatar);
+ hbmMem = (HBITMAP)SelectObject(hdcMem, (bDrawOwnAvatar) ? dat->hOwnPic : hbmAvatar);
LONG xy_off = 1; //CSkin::m_bAvatarBorderType ? 1 : 0;
LONG width_off = 0; //= CSkin::m_bAvatarBorderType ? 0 : 2;
@@ -1835,9 +1840,7 @@ int TSAPI MsgWindowDrawHandler(WPARAM wParam, LPARAM lParam, TWindowData *dat)
DeleteObject(clipRgn);
}
}
- SelectObject(hdcDraw, hPenOld);
SelectObject(hdcDraw, hOldBrush);
- DeleteObject(hPenBorder);
if (!bPanelPic)
BitBlt(dis->hDC, 0, 0, cx, cy, hdcDraw, 0, 0, SRCCOPY);
SelectObject(hdcDraw, hbmOld);
diff --git a/plugins/TabSRMM/src/msgdlgutils.h b/plugins/TabSRMM/src/msgdlgutils.h
index e3380f24d8..a4addcd2fc 100644
--- a/plugins/TabSRMM/src/msgdlgutils.h
+++ b/plugins/TabSRMM/src/msgdlgutils.h
@@ -38,7 +38,7 @@ void TSAPI CalcDynamicAvatarSize(TWindowData *dat, BITMAP *bminfo);
char* TSAPI GetCurrentMetaContactProto(TWindowData *dat);
int TSAPI MsgWindowUpdateMenu(TWindowData *dat, HMENU submenu, int menuID);
int TSAPI MsgWindowMenuHandler(TWindowData *dat, int selection, int menuId);
-int TSAPI GetAvatarVisibility(HWND hwndDlg, TWindowData *dat);
+bool TSAPI GetAvatarVisibility(HWND hwndDlg, TWindowData *dat);
void TSAPI UpdateStatusBar(const TWindowData *dat);
int TSAPI CheckValidSmileyPack(const char *szProto, MCONTACT hContact);
TCHAR* TSAPI QuoteText(const TCHAR *text, int charsPerLine, int removeExistingQuotes);
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h
index d5ef3a7a5a..dad1e5dd68 100644
--- a/plugins/TabSRMM/src/msgs.h
+++ b/plugins/TabSRMM/src/msgs.h
@@ -283,9 +283,9 @@ struct TWindowData
DWORD dwTickLastEvent, dwUnread;
HBITMAP hOwnPic;
SIZE pic;
- int showPic, showInfoPic;
- BOOL fMustOffset;
- BOOL isHistory;
+ bool showPic, showInfoPic;
+ bool fMustOffset;
+ bool isHistory;
int doSmileys;
UINT codePage;
HICON hSmileyIcon;
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp
index f9d80db420..3937a842a9 100644
--- a/plugins/TabSRMM/src/themes.cpp
+++ b/plugins/TabSRMM/src/themes.cpp
@@ -1701,6 +1701,9 @@ void CSkin::setupAeroSkins()
M.getAeroState();
UnloadAeroTabs();
+ if (!m_fAeroSkinsValid)
+ return;
+
TCHAR tszFilename[MAX_PATH], tszBasePath[MAX_PATH];
_tcsncpy_s(tszBasePath, M.getDataPath(), _TRUNCATE);
if (tszBasePath[lstrlen(tszBasePath) - 1] != '\\')
@@ -1719,9 +1722,6 @@ void CSkin::setupAeroSkins()
}
}
- if (!m_fAeroSkinsValid)
- return;
-
mir_sntprintf(tszFilename, MAX_PATH, _T("%scustom_tabskin_aero.png"), tszBasePath);
if (!PathFileExists(tszFilename))
mir_sntprintf(tszFilename, MAX_PATH, _T("%stabskin_aero.png"), tszBasePath);