diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-02 23:08:10 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-02 23:08:21 +0300 |
commit | 060edd0d612ff8be1dd43284fd5469e6e47e93c6 (patch) | |
tree | 5842b7dc1703b7e3b4460b778049152b34e7f1e5 /src/mir_core | |
parent | 403de4add1193c54e6b4387485fd8eab0c3c00bb (diff) |
more optimal tab control resizer
Diffstat (limited to 'src/mir_core')
-rw-r--r-- | src/mir_core/src/ui_utils.cpp | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/src/mir_core/src/ui_utils.cpp b/src/mir_core/src/ui_utils.cpp index 89a5ba09e8..66078c8c66 100644 --- a/src/mir_core/src/ui_utils.cpp +++ b/src/mir_core/src/ui_utils.cpp @@ -2223,6 +2223,21 @@ void CCtrlTreeView::SortChildrenCB(TVSORTCB *cb, BOOL fRecurse) /////////////////////////////////////////////////////////////////////////////////////////
// CCtrlPages
+struct CCtrlPages::TPageInfo : public MZeroedObject
+{
+ ~TPageInfo()
+ {
+ if (m_hIcon)
+ DestroyIcon(m_hIcon);
+ }
+
+ int m_pageId;
+ ptrW m_ptszHeader;
+ HICON m_hIcon;
+ bool m_bChanged, m_bScheduledResize;
+ CDlgBase *m_pDlg;
+};
+
CCtrlPages::CCtrlPages(CDlgBase *dlg, int ctrlId)
: CCtrlBase(dlg, ctrlId),
m_hIml(NULL),
@@ -2261,15 +2276,20 @@ LRESULT CCtrlPages::CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam) switch (msg) {
case WM_SIZE:
- RECT rc;
- GetClientRect(m_hwnd, &rc);
- TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
-
- tabCount = GetCount();
- for (int i = 0; i < tabCount; i++) {
- TPageInfo *p = GetItemPage(i);
- if (p && p->m_pDlg->GetHwnd() != NULL)
- SetWindowPos(p->m_pDlg->GetHwnd(), HWND_TOP, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
+ if (TPageInfo *pCurrInfo = GetCurrPage()) {
+ tabCount = GetCount();
+ for (int i = 0; i < tabCount; i++) {
+ TPageInfo *p = GetItemPage(i);
+ if (p == nullptr)
+ continue;
+ if (p == pCurrInfo) {
+ RECT rc;
+ GetClientRect(m_hwnd, &rc);
+ TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
+ SetWindowPos(p->m_pDlg->GetHwnd(), NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOZORDER);
+ }
+ else p->m_bScheduledResize = true;
+ }
}
break;
@@ -2327,6 +2347,12 @@ void CCtrlPages::ActivatePage(int iPage) ShowWindow(m_pActivePage->GetHwnd(), SW_HIDE);
m_pActivePage = info->m_pDlg;
+ if (m_pActivePage->GetHwnd() && info->m_bScheduledResize) {
+ RECT rc;
+ GetClientRect(m_hwnd, &rc);
+ TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
+ SetWindowPos(m_pActivePage->GetHwnd(), NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOACTIVATE | SWP_NOZORDER);
+ }
ShowPage(m_pActivePage);
TabCtrl_SetCurSel(m_hwnd, info->m_pageId);
|