diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-11-18 10:19:33 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-11-18 13:16:56 +0100 |
commit | 06f36cc7ca8fc056dd8cf4d8cdbe682f9a003cef (patch) | |
tree | 00b14da769a9e8cc3ed455f4af863b716fd3190e /vcl/source/window | |
parent | fffc6b40b933f640a412233988bbb74bf6138af4 (diff) |
allow vcl gen menus to have non-square images
for the color menu in the calc autofilter
Change-Id: I90a4ccefa9c44f5c9d0b0e49dd8c254d13be0fe1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125444
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/window')
-rw-r--r-- | vcl/source/window/menu.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 4a497b84b02c..96797979558c 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -1421,6 +1421,8 @@ void Menu::ImplRemoveDel( ImplMenuDelData& rDel ) } } +constexpr int ImageBorder = 4; + Size Menu::ImplCalcSize( vcl::Window* pWin ) { // | Check/Radio/Image| Text| Accel/Popup| @@ -1487,8 +1489,8 @@ Size Menu::ImplCalcSize( vcl::Window* pWin ) { Size aImgSz = pData->aImage.GetSizePixel(); - aImgSz.AdjustHeight(4 ); // add a border for native marks - aImgSz.AdjustWidth(4 ); // add a border for native marks + aImgSz.AdjustHeight(ImageBorder); // add a border for native marks + aImgSz.AdjustWidth(ImageBorder); // add a border for native marks if ( aImgSz.Width() > aMaxImgSz.Width() ) aMaxImgSz.setWidth( aImgSz.Width() ); if ( aImgSz.Height() > aMaxImgSz.Height() ) @@ -1920,12 +1922,16 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize, // Image: if (!bLayout && !IsMenuBar() && ((pData->eType == MenuItemType::IMAGE) || (pData->eType == MenuItemType::STRINGIMAGE))) { + Image aImage = pData->aImage; + + auto nImgWidth = aImage.GetSizePixel().Width() + ImageBorder; + if (nImgWidth > aOuterCheckRect.GetWidth()) + aOuterCheckRect.setWidth(nImgWidth); + // Don't render an image for a check thing if (pData->bChecked) ImplPaintCheckBackground(rRenderContext, *pWindow, aOuterCheckRect, pThisItemOnly && bHighlighted); - Image aImage = pData->aImage; - aTmpPos = aOuterCheckRect.TopLeft(); aTmpPos.AdjustX((aOuterCheckRect.GetWidth() - aImage.GetSizePixel().Width()) / 2 ); aTmpPos.AdjustY((aOuterCheckRect.GetHeight() - aImage.GetSizePixel().Height()) / 2 ); |