diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2014-12-26 18:23:19 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2014-12-26 18:25:38 +0900 |
commit | 57626f2132f73e4e42b31e364b25c5867336e718 (patch) | |
tree | fbd15021cffbf84ced2d0ad29213aaf17a15fe09 | |
parent | e1043eca4b4c64c3c23affa97aeaeb09fb1f7cfb (diff) |
Scale menu icons by a HiDPI scaling factor
Change-Id: I358794f86d541d2b49a8281a7224e5c6c29066d9
-rw-r--r-- | vcl/source/window/menu.cxx | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 3c0a3e99d26e..cc96ce1b1e8b 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -1557,9 +1557,14 @@ Size Menu::ImplCalcSize( const vcl::Window* pWin ) } // Image: - if (!IsMenuBar()&& ((pData->eType == MenuItemType::IMAGE) || (pData->eType == MenuItemType::STRINGIMAGE))) + if (!IsMenuBar() && ((pData->eType == MenuItemType::IMAGE) || (pData->eType == MenuItemType::STRINGIMAGE))) { Size aImgSz = pData->aImage.GetSizePixel(); + + sal_Int32 nScaleFactor = pWindow->GetDPIScaleFactor(); + aImgSz.Height() *= nScaleFactor; + aImgSz.Width() *= nScaleFactor; + aImgSz.Height() += 4; // add a border for native marks aImgSz.Width() += 4; // add a border for native marks if ( aImgSz.Width() > aMaxImgSz.Width() ) @@ -1927,10 +1932,20 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI // Don't render an image for a check thing if( pData->bChecked ) ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted ); + + Image aImage = pData->aImage; + + sal_Int32 nScaleFactor = pWindow->GetDPIScaleFactor(); + if (nScaleFactor != 1) + { + BitmapEx aBitmap = aImage.GetBitmapEx(); + aBitmap.Scale(nScaleFactor, nScaleFactor, BMP_SCALE_FAST); + aImage = Image(aBitmap); + } aTmpPos = aOuterCheckRect.TopLeft(); - aTmpPos.X() += (aOuterCheckRect.GetWidth()-pData->aImage.GetSizePixel().Width())/2; - aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pData->aImage.GetSizePixel().Height())/2; - pWin->DrawImage( aTmpPos, pData->aImage, nImageStyle ); + aTmpPos.X() += (aOuterCheckRect.GetWidth() - aImage.GetSizePixel().Width()) / 2; + aTmpPos.Y() += (aOuterCheckRect.GetHeight() - aImage.GetSizePixel().Height()) / 2; + pWin->DrawImage(aTmpPos, aImage, nImageStyle); } // Text: |