diff options
author | George Hazan <george.hazan@gmail.com> | 2023-10-04 16:10:46 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-10-04 16:10:46 +0300 |
commit | 375ee2dde56a86f64fa44b83ede37bcb11c47cb3 (patch) | |
tree | 0daf2e63ad25a34bf3ecf263f78efa75bcd6719f | |
parent | d352f5a7dd20db6c0cf00c6b0c2a694edd04f955 (diff) |
tabSRMM: avatar resizer optimization
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgother.cpp | 21 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 2 |
3 files changed, 16 insertions, 11 deletions
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 16f49c55ac..af491bd4b0 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -635,8 +635,8 @@ void CMsgDialog::DM_RecalcPictureSize() if (hbm) {
BITMAP bminfo;
GetObject(hbm, sizeof(bminfo), &bminfo);
- CalcDynamicAvatarSize(&bminfo);
- Resize();
+ if (CalcDynamicAvatarSize(&bminfo))
+ Resize();
}
else m_pic.cy = m_pic.cx = 60;
}
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 445cf5e874..5f6a98e45b 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -86,10 +86,10 @@ void CMsgDialog::AdjustBottomAvatarDisplay() // calculates avatar layouting, based on splitter position to find the optimal size
// for the avatar w/o disturbing the toolbar too much.
-void CMsgDialog::CalcDynamicAvatarSize(BITMAP *bminfo)
+bool CMsgDialog::CalcDynamicAvatarSize(BITMAP *bminfo)
{
if (m_bWasBackgroundCreate || m_pContainer->cfg.flags.m_bDeferredConfigure || m_pContainer->cfg.flags.m_bCreateMinimized || IsIconic(m_pContainer->m_hwnd))
- return; // at this stage, the layout is not yet ready...
+ return false; // at this stage, the layout is not yet ready...
RECT rc;
GetClientRect(m_hwnd, &rc);
@@ -118,8 +118,13 @@ void CMsgDialog::CalcDynamicAvatarSize(BITMAP *bminfo) double newWidth = (double)bminfo->bmWidth * aspect;
if (newWidth > (double)(rc.right) * 0.8)
newWidth = (double)(rc.right) * 0.8;
- m_pic.cy = m_iRealAvatarHeight + 2;
- m_pic.cx = (int)newWidth + 2;
+
+ SIZE sz = { (int)newWidth + 2, m_iRealAvatarHeight + 2 };
+ if (m_pic.cx == sz.cx && m_pic.cy == sz.cy)
+ return false;
+
+ m_pic = sz;
+ return true;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -1377,13 +1382,13 @@ void CMsgDialog::LoadOwnAvatar() m_hOwnPic = PluginConfig.g_hbmUnknown;
if (m_pPanel.isActive() && m_pContainer->cfg.avatarMode != 3) {
- BITMAP bm;
-
m_iRealAvatarHeight = 0;
AdjustBottomAvatarDisplay();
+
+ BITMAP bm;
GetObject(m_hOwnPic, sizeof(bm), &bm);
- CalcDynamicAvatarSize(&bm);
- Resize();
+ if (CalcDynamicAvatarSize(&bm))
+ Resize();
}
}
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 29b34e0d32..c542919d86 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -414,7 +414,7 @@ class CMsgDialog : public CSrmmBaseDialog void DM_UpdateLastMessage(void) const;
void AdjustBottomAvatarDisplay(void);
- void CalcDynamicAvatarSize(BITMAP *bminfo);
+ bool CalcDynamicAvatarSize(BITMAP *bminfo);
void DetermineMinHeight(void);
BOOL DoRtfToTags(CMStringW &pszText) const;
int FindRTLLocale(void);
|