Kaydet (Commit) 57626f21 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

Scale menu icons by a HiDPI scaling factor

Change-Id: I358794f86d541d2b49a8281a7224e5c6c29066d9
üst e1043eca
...@@ -1557,9 +1557,14 @@ Size Menu::ImplCalcSize( const vcl::Window* pWin ) ...@@ -1557,9 +1557,14 @@ Size Menu::ImplCalcSize( const vcl::Window* pWin )
} }
// Image: // 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(); 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.Height() += 4; // add a border for native marks
aImgSz.Width() += 4; // add a border for native marks aImgSz.Width() += 4; // add a border for native marks
if ( aImgSz.Width() > aMaxImgSz.Width() ) if ( aImgSz.Width() > aMaxImgSz.Width() )
...@@ -1927,10 +1932,20 @@ void Menu::ImplPaint( vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuI ...@@ -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 // Don't render an image for a check thing
if( pData->bChecked ) if( pData->bChecked )
ImplPaintCheckBackground( pWin, aOuterCheckRect, pThisItemOnly && bHighlighted ); 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 = aOuterCheckRect.TopLeft();
aTmpPos.X() += (aOuterCheckRect.GetWidth()-pData->aImage.GetSizePixel().Width())/2; aTmpPos.X() += (aOuterCheckRect.GetWidth() - aImage.GetSizePixel().Width()) / 2;
aTmpPos.Y() += (aOuterCheckRect.GetHeight()-pData->aImage.GetSizePixel().Height())/2; aTmpPos.Y() += (aOuterCheckRect.GetHeight() - aImage.GetSizePixel().Height()) / 2;
pWin->DrawImage( aTmpPos, pData->aImage, nImageStyle ); pWin->DrawImage(aTmpPos, aImage, nImageStyle);
} }
// Text: // Text:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment