From 375ee2dde56a86f64fa44b83ede37bcb11c47cb3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 4 Oct 2023 16:10:46 +0300 Subject: tabSRMM: avatar resizer optimization --- plugins/TabSRMM/src/generic_msghandlers.cpp | 4 ++-- plugins/TabSRMM/src/msgdlgother.cpp | 21 +++++++++++++-------- plugins/TabSRMM/src/msgs.h | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'plugins/TabSRMM/src') 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); -- cgit v1.2.3