[Libreoffice-commits] core.git: vcl/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Fri Dec 26 01:26:52 PST 2014


 vcl/source/window/menu.cxx |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

New commits:
commit 57626f2132f73e4e42b31e364b25c5867336e718
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Dec 26 18:23:19 2014 +0900

    Scale menu icons by a HiDPI scaling factor
    
    Change-Id: I358794f86d541d2b49a8281a7224e5c6c29066d9

diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 3c0a3e9..cc96ce1 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:


More information about the Libreoffice-commits mailing list