vcl/source/window/menu.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
New commits: commit 06f36cc7ca8fc056dd8cf4d8cdbe682f9a003cef Author: Caolán McNamara <[email protected]> AuthorDate: Thu Nov 18 10:19:33 2021 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Nov 18 13:16:56 2021 +0100 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 <[email protected]> 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 );
