diff options
author | Srijan Bhatia <srijanbhatiasun@gmail.com> | 2020-06-25 20:21:48 +0530 |
---|---|---|
committer | Heiko Tietze <heiko.tietze@documentfoundation.org> | 2020-06-28 08:20:48 +0200 |
commit | d53a4f126e9d3ec0a63684d4c7af3108f352791c (patch) | |
tree | 504821576f80e5605cbe4dce3b47f741b2119153 | |
parent | ab7fa407979bb5bc46201b28090e57dbd3e2c79e (diff) |
tdf#128964 fix shifting of icons when the pause/resume button changes
Added a property that specifies width of the button in the presenter toolbar.
Change-Id: I556ec0363064b36ef9fe80f2d947849cee356a1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97151
Tested-by: Jenkins
Tested-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
-rw-r--r-- | sdext/source/presenter/PresenterToolBar.cxx | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/sdext/source/presenter/PresenterToolBar.cxx b/sdext/source/presenter/PresenterToolBar.cxx index a0a57c6d8b44..bd69a262ee59 100644 --- a/sdext/source/presenter/PresenterToolBar.cxx +++ b/sdext/source/presenter/PresenterToolBar.cxx @@ -1459,9 +1459,24 @@ awt::Size Button::CreateBoundingSize ( return awt::Size(); geometry::RealRectangle2D aTextBBox (mpMode->maText.GetBoundingBox(rxCanvas)); + + // tdf#128964 This ensures that if the text of a button changes due to a change in + // the state of the button the other buttons of the toolbar do not move. The button is + // allotted the maximum size so that it doesn't resize during a change of state. + geometry::RealRectangle2D aTextBBoxNormal (mpNormal->maText.GetBoundingBox(rxCanvas)); + geometry::RealRectangle2D aTextBBoxMouseOver (mpMouseOver->maText.GetBoundingBox(rxCanvas)); + geometry::RealRectangle2D aTextBBoxSelected (mpSelected->maText.GetBoundingBox(rxCanvas)); + geometry::RealRectangle2D aTextBBoxDisabled (mpDisabled->maText.GetBoundingBox(rxCanvas)); + geometry::RealRectangle2D aTextBBoxMouseOverSelected (mpMouseOverSelected->maText.GetBoundingBox(rxCanvas)); + std::vector<sal_Int32> widths; + widths.push_back(sal::static_int_cast<sal_Int32>(0.5 + aTextBBoxNormal.X2 - aTextBBoxNormal.X1)); + widths.push_back(sal::static_int_cast<sal_Int32>(0.5 + aTextBBoxMouseOver.X2 - aTextBBoxMouseOver.X1)); + widths.push_back(sal::static_int_cast<sal_Int32>(0.5 + aTextBBoxSelected.X2 - aTextBBoxSelected.X1)); + widths.push_back(sal::static_int_cast<sal_Int32>(0.5 + aTextBBoxDisabled.X2 - aTextBBoxDisabled.X1)); + widths.push_back(sal::static_int_cast<sal_Int32>(0.5 + aTextBBoxMouseOverSelected.X2 - aTextBBoxMouseOverSelected.X1)); + const sal_Int32 nGap (5); sal_Int32 nTextHeight (sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.Y2 - aTextBBox.Y1)); - sal_Int32 nTextWidth (sal::static_int_cast<sal_Int32>(0.5 + aTextBBox.X2 - aTextBBox.X1)); Reference<rendering::XBitmap> xBitmap; if (mpMode->mpIcon) xBitmap = mpMode->mpIcon->GetNormalBitmap(); @@ -1469,11 +1484,13 @@ awt::Size Button::CreateBoundingSize ( { geometry::IntegerSize2D aSize (xBitmap->getSize()); return awt::Size( - ::std::max(aSize.Width, sal_Int32(0.5 + aTextBBox.X2 - aTextBBox.X1)), - aSize.Height+ nGap + nTextHeight); + ::std::max(aSize.Width, *std::max_element(widths.begin(), widths.end())), + aSize.Height + nGap + nTextHeight); } else - return awt::Size(nTextWidth,nTextHeight); + { + return awt::Size(*std::max_element(widths.begin(), widths.end()), nTextHeight); + } } void Button::PaintIcon ( |