[RAPPS] Recalculate the toolbar max buttons width when deleting the buttons (#6655)

Done so that the toolbar can display correctly the buttons,
and their labels if possible, when resizing the RAPPS window.
This commit is contained in:
Hermès Bélusca-Maïto 2024-03-22 21:55:43 +01:00
parent 9835ea27d2
commit f23394986a
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 18 additions and 5 deletions

View file

@ -193,10 +193,8 @@ CMainToolbar::Create(HWND hwndParent)
AddButtons(_countof(Buttons), Buttons);
/* Remember ideal width to use as a max width of buttons */
SIZE size;
GetIdealSize(FALSE, &size);
m_dButtonsWidthMax = size.cx;
/* Remember the ideal width to use as a max width of buttons */
UpdateMaxButtonsWidth();
return m_hWnd;
}
@ -211,6 +209,14 @@ CMainToolbar::ShowButtonCaption(bool bShow)
SendMessageW(TB_SETEXTENDEDSTYLE, 0, dCurrentExStyle | TBSTYLE_EX_MIXEDBUTTONS);
}
void
CMainToolbar::UpdateMaxButtonsWidth()
{
SIZE size;
GetIdealSize(FALSE, &size);
m_dButtonsWidthMax = size.cx;
}
DWORD
CMainToolbar::GetMaxButtonsWidth() const
{
@ -1553,8 +1559,12 @@ CApplicationView::ProcessWindowMessage(
index = m_Toolbar->GetButtonInfo(ID_RESETDB, &info);
if (index >= 0) m_Toolbar->DeleteButton(index);
/* Update the ideal width to use as a max width of buttons */
m_Toolbar->UpdateMaxButtonsWidth();
}
/* Resize the toolbar */
m_Toolbar->AutoSize();
RECT rTop;
@ -1793,7 +1803,7 @@ CApplicationView::OnSize(HWND hwnd, WPARAM wParam, LPARAM lParam)
if (wParam == SIZE_MINIMIZED)
return;
/* Size tool bar */
/* Resize the toolbar */
m_Toolbar->AutoSize();
/* Automatically hide captions */

View file

@ -297,6 +297,9 @@ class CMainToolbar : public CUiWindow<CToolbar<>>
void
ShowButtonCaption(bool bShow);
void
UpdateMaxButtonsWidth();
DWORD
GetMaxButtonsWidth() const;
};