diff options
author | Rasmus Jonsson <wasmus@zom.bi> | 2019-03-20 21:27:03 +0100 |
---|---|---|
committer | Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> | 2019-03-22 16:17:48 +0100 |
commit | c92bfbf9506681468a471563a47eb84c6944a104 (patch) | |
tree | b92f354bbb9ab327ad554cee11735a7d889306a9 /sfx2 | |
parent | bb4fcc3d968367d682d6da057083378e9d171a22 (diff) |
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 <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/infobar.cxx | 29 |
1 files changed, 24 insertions, 5 deletions
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<FixedImage>::Create(this, nMessageStyle)), - m_pMessage(VclPtr<FixedText>::Create(this, nMessageStyle)), + m_pMessage(VclPtr<FixedText>::Create(this, nMessageStyle | WB_WORDBREAK)), m_pCloseBtn(VclPtr<SfxCloseButton>::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); |