From c92bfbf9506681468a471563a47eb84c6944a104 Mon Sep 17 00:00:00 2001 From: Rasmus Jonsson Date: Wed, 20 Mar 2019 21:27:03 +0100 Subject: tdf#119905 Infobar text overlap Make SfxInfoBarWindow text wrap (WB_WORDBREAK) by default. Make SfxInfoBarContainerWindow stretch to fit its content (the wrapped text) Change-Id: Ib6f68011b4f2a4813dc5e0316281583b9ac641ee Reviewed-on: https://gerrit.libreoffice.org/69482 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- sfx2/source/dialog/infobar.cxx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx index 4e66a9db55f4..a60c6c0c6b57 100644 --- a/sfx2/source/dialog/infobar.cxx +++ b/sfx2/source/dialog/infobar.cxx @@ -174,7 +174,7 @@ SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId, m_sId(sId), m_eType(ibType), m_pImage(VclPtr::Create(this, nMessageStyle)), - m_pMessage(VclPtr::Create(this, nMessageStyle)), + m_pMessage(VclPtr::Create(this, nMessageStyle | WB_WORDBREAK)), m_pCloseBtn(VclPtr::Create(this)), m_aActionBtns() { @@ -290,13 +290,23 @@ void SfxInfoBarWindow::Resize() nX -= nButtonGap; } - m_pImage->SetPosSizePixel(Point(4,4), Size(32* fScaleFactor, 32* fScaleFactor)); - Point aMessagePosition(32 * fScaleFactor + 10 * fScaleFactor, 10 * fScaleFactor); - Size aMessageSize(nX - 20 * fScaleFactor, 20 * fScaleFactor); + Size aMessageSize(nX - 35 * fScaleFactor, 20 * fScaleFactor); + Size aActualSize = m_pMessage->CalcMinimumSize(aMessageSize.getWidth()); + long aMinimumHeight = m_pMessage->CalcMinimumSize().getHeight(); + + long aExtraHeight = aActualSize.getHeight() - aMinimumHeight; - m_pMessage->SetPosSizePixel(aMessagePosition, aMessageSize); + // The message won't be legible and the window will get too high + if (aMessageSize.getWidth() < 30) + { + aExtraHeight = 0; + } + m_pMessage->SetPosSizePixel(aMessagePosition, aActualSize); + m_pImage->SetPosSizePixel(Point(4, 4), Size(32 * fScaleFactor, 32 * fScaleFactor)); + + SetPosSizePixel(Point(0, 0), Size(nWidth, INFO_BAR_BASE_HEIGHT * fScaleFactor + aExtraHeight * fScaleFactor)); } void SfxInfoBarWindow::Update( const OUString &sNewMessage, InfoBarType eType ) @@ -408,6 +418,7 @@ void SfxInfoBarContainerWindow::Resize() { // Only need to change the width of the infobars long nWidth = GetSizePixel().getWidth(); + long nHeight = GetSizePixel().getHeight(); for (auto& rxInfoBar : m_pInfoBars) { @@ -415,7 +426,15 @@ void SfxInfoBarContainerWindow::Resize() aSize.setWidth(nWidth); rxInfoBar->SetSizePixel(aSize); rxInfoBar->Resize(); + + // Stretch to fit the infobar(s) + if (aSize.getHeight() > nHeight) + { + nHeight = aSize.getHeight(); + } } + + SetSizePixel(Size(nWidth, nHeight)); } SFX_IMPL_POS_CHILDWINDOW_WITHID(SfxInfoBarContainerChild, SID_INFOBAR, SFX_OBJECTBAR_OBJECT); -- cgit