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

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Tue Dec 19 04:29:30 UTC 2017


 include/vcl/menu.hxx                     |    2 +-
 vcl/source/window/menu.cxx               |    9 +++++----
 vcl/source/window/menubarwindow.cxx      |   25 ++++++++++++++++++-------
 vcl/source/window/menufloatingwindow.cxx |    4 ++--
 4 files changed, 26 insertions(+), 14 deletions(-)

New commits:
commit e11234d8d8d8ff2744b77a128f845dbe8e6faa1e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Dec 18 17:42:00 2017 +0900

    menu: pass paint size to ImplPaint and account for buttons
    
    When a menu bar is painted it needs to take into account that
    the buttons (close) is positioned at the right side of the paint
    area. To do this we need to pass what the output size is when
    painting (ImplPaint) on the common menu code, instead of assuming
    the whole area can be used.
    
    Change-Id: I2e9d6c686929fe1cd7e28368a8055c1e2df13c49
    Reviewed-on: https://gerrit.libreoffice.org/46710
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index a45eed9e6c70..aa3ee35d2c49 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -169,7 +169,7 @@ protected:
     SAL_DLLPRIVATE sal_uInt16 ImplGetFirstVisible() const;
     SAL_DLLPRIVATE sal_uInt16 ImplGetPrevVisible( sal_uInt16 nPos ) const;
     SAL_DLLPRIVATE sal_uInt16 ImplGetNextVisible( sal_uInt16 nPos ) const;
-    SAL_DLLPRIVATE void ImplPaint(vcl::RenderContext& rRenderContext,
+    SAL_DLLPRIVATE void ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
                                   sal_uInt16 nBorder, long nOffY = 0, MenuItemData const * pThisDataOnly = nullptr,
                                   bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const;
     SAL_DLLPRIVATE void ImplPaintMenuTitle(vcl::RenderContext&, const tools::Rectangle& rRect) const;
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index f2f45eadd965..b6b2faa5206b 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1661,7 +1661,7 @@ void Menu::ImplPaintMenuTitle(vcl::RenderContext& rRenderContext, const tools::R
     rRenderContext.SetBackground(aOldBackground);
 }
 
-void Menu::ImplPaint(vcl::RenderContext& rRenderContext,
+void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
                      sal_uInt16 nBorder, long nStartY, MenuItemData const * pThisItemOnly,
                      bool bHighlighted, bool bLayout, bool bRollover) const
 {
@@ -1686,7 +1686,7 @@ void Menu::ImplPaint(vcl::RenderContext& rRenderContext,
     }
 
     // for the computations, use size of the underlying window, not of RenderContext
-    Size aOutSz = pWindow->GetOutputSizePixel();
+    Size aOutSz(rSize);
 
     size_t nCount = pItemList->size();
     if (bLayout)
@@ -2135,12 +2135,13 @@ void Menu::ImplFillLayoutData() const
         mpLayoutData = new MenuLayoutData;
         if (IsMenuBar())
         {
-            ImplPaint(*pWindow, 0, 0, nullptr, false, true); // FIXME
+            ImplPaint(*pWindow, pWindow->GetOutputSizePixel(), 0, 0, nullptr, false, true); // FIXME
         }
         else
         {
             MenuFloatingWindow* pFloat = static_cast<MenuFloatingWindow*>(pWindow.get());
-            ImplPaint(*pWindow, pFloat->nScrollerHeight, pFloat->ImplGetStartY(), nullptr, false, true); //FIXME
+            ImplPaint(*pWindow, pWindow->GetOutputSizePixel(), pFloat->nScrollerHeight, pFloat->ImplGetStartY(),
+                      nullptr, false, true); //FIXME
         }
     }
 }
diff --git a/vcl/source/window/menubarwindow.cxx b/vcl/source/window/menubarwindow.cxx
index 6486ffb86a9c..0b4e6b7df5bc 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -574,6 +574,10 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
 
     long nX = 0;
     size_t nCount = pMenu->pItemList->size();
+
+    Size aOutputSize = GetOutputSizePixel();
+    aOutputSize.Width() -= aCloseBtn->GetSizePixel().Width();
+
     for (size_t n = 0; n < nCount; n++)
     {
         MenuItemData* pData = pMenu->pItemList->GetDataFromPos( n );
@@ -582,7 +586,7 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
             if (pData->eType != MenuItemType::SEPARATOR)
             {
                 // #107747# give menuitems the height of the menubar
-                tools::Rectangle aRect = tools::Rectangle(Point(nX, 1), Size(pData->aSz.Width(), GetOutputSizePixel().Height() - 2));
+                tools::Rectangle aRect = tools::Rectangle(Point(nX, 1), Size(pData->aSz.Width(), aOutputSize.Height() - 2));
                 rRenderContext.Push(PushFlags::CLIPREGION);
                 rRenderContext.IntersectClipRegion(aRect);
                 bool bRollover, bHighlight;
@@ -607,12 +611,12 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
                          Erase(rRenderContext);
                     else
                     {
-                        tools::Rectangle aBgRegion(Point(), GetOutputSizePixel());
+                        tools::Rectangle aBgRegion(Point(), aOutputSize);
                         rRenderContext.DrawNativeControl(ControlType::Menubar, ControlPart::Entire, aBgRegion,
                                                          ControlState::ENABLED, aControlValue, OUString());
                     }
 
-                    ImplAddNWFSeparator(rRenderContext, GetOutputSizePixel(), aControlValue);
+                    ImplAddNWFSeparator(rRenderContext, aOutputSize, aControlValue);
 
                     // draw selected item
                     ControlState nState = ControlState::ENABLED;
@@ -633,7 +637,8 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
                     rRenderContext.DrawRect(aRect);
                 }
                 rRenderContext.Pop();
-                pMenu->ImplPaint(rRenderContext, 0, 0, pData, bHighlight, false, bRollover);
+
+                pMenu->ImplPaint(rRenderContext, aOutputSize, 0, 0, pData, bHighlight, false, bRollover);
             }
             return;
         }
@@ -854,6 +859,8 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
 
     const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
 
+    Size aOutputSize = GetOutputSizePixel();
+
     // no VCL paint if native menus
     if (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar())
     {
@@ -871,17 +878,21 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
         else
         {
             Point aPt;
-            tools::Rectangle aCtrlRegion( aPt, GetOutputSizePixel() );
+            tools::Rectangle aCtrlRegion( aPt, aOutputSize );
 
             rRenderContext.DrawNativeControl(ControlType::Menubar, ControlPart::Entire, aCtrlRegion,
                                              ControlState::ENABLED, aMenubarValue, OUString());
         }
 
-        ImplAddNWFSeparator(rRenderContext, GetOutputSizePixel(), aMenubarValue);
+        ImplAddNWFSeparator(rRenderContext, aOutputSize, aMenubarValue);
     }
+
+    // shrink the area of the buttons
+    aOutputSize.Width() -= aCloseBtn->GetSizePixel().Width();
+
     rRenderContext.SetFillColor(rStyleSettings.GetMenuColor());
 
-    pMenu->ImplPaint(rRenderContext, 0);
+    pMenu->ImplPaint(rRenderContext, aOutputSize, 0);
     if (nHighlightedItem != ITEMPOS_INVALID)
         HighlightItem(rRenderContext, nHighlightedItem);
     else if (ImplGetSVData()->maNWFData.mbRolloverMenubar && nRolloveredItem != ITEMPOS_INVALID)
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 601434cbb8c7..c66510cf8f1a 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -869,7 +869,7 @@ void MenuFloatingWindow::RenderHighlightItem(vcl::RenderContext& rRenderContext,
 
                     rRenderContext.DrawRect(aItemRect);
                 }
-                pMenu->ImplPaint(rRenderContext, nScrollerHeight, nStartY, pData, true/*bHighlight*/);
+                pMenu->ImplPaint(rRenderContext, GetOutputSizePixel(), nScrollerHeight, nStartY, pData, true/*bHighlight*/);
                 if (bRestoreLineColor)
                     rRenderContext.SetLineColor(oldLineColor);
             }
@@ -1195,7 +1195,7 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools::
         ImplDrawScroller(rRenderContext, false);
     }
     rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
-    pMenu->ImplPaint(rRenderContext, nScrollerHeight, ImplGetStartY());
+    pMenu->ImplPaint(rRenderContext, GetOutputSizePixel(), nScrollerHeight, ImplGetStartY());
     if (nHighlightedItem != ITEMPOS_INVALID)
         RenderHighlightItem(rRenderContext, nHighlightedItem);
 


More information about the Libreoffice-commits mailing list