[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - include/vcl vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Tue Dec 19 21:16:38 UTC 2017
include/vcl/menu.hxx | 2 +-
vcl/source/window/menu.cxx | 9 +++++----
vcl/source/window/menubarwindow.cxx | 24 +++++++++++++++++-------
vcl/source/window/menufloatingwindow.cxx | 4 ++--
4 files changed, 25 insertions(+), 14 deletions(-)
New commits:
commit 7b36595ae2b59a8c4c41d6aedfd634aed8390851
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.
Reviewed-on: https://gerrit.libreoffice.org/46710
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
(cherry picked from commit e11234d8d8d8ff2744b77a128f845dbe8e6faa1e)
Change-Id: I2e9d6c686929fe1cd7e28368a8055c1e2df13c49
Reviewed-on: https://gerrit.libreoffice.org/46794
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 8c1b94788791..992d7b849b98 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -176,7 +176,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* pThisDataOnly = nullptr,
bool bHighlighted = false, bool bLayout = false, bool bRollover = false ) const;
SAL_DLLPRIVATE void ImplPaintMenuTitle(vcl::RenderContext&, const Rectangle& rRect) const;
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 24743fb2723a..5b7906ad8383 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1754,7 +1754,7 @@ void Menu::ImplPaintMenuTitle(vcl::RenderContext& rRenderContext, const Rectangl
rRenderContext.SetBackground(aOldBackground);
}
-void Menu::ImplPaint(vcl::RenderContext& rRenderContext,
+void Menu::ImplPaint(vcl::RenderContext& rRenderContext, Size const & rSize,
sal_uInt16 nBorder, long nStartY, MenuItemData* pThisItemOnly,
bool bHighlighted, bool bLayout, bool bRollover) const
{
@@ -1782,7 +1782,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)
@@ -2271,12 +2271,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 867da80b3f27..8eb2fb67a81d 100644
--- a/vcl/source/window/menubarwindow.cxx
+++ b/vcl/source/window/menubarwindow.cxx
@@ -589,6 +589,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 );
@@ -597,7 +601,7 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
if (pData->eType != MenuItemType::SEPARATOR)
{
// #107747# give menuitems the height of the menubar
- Rectangle aRect = Rectangle(Point(nX, 1), Size(pData->aSz.Width(), GetOutputSizePixel().Height() - 2));
+ Rectangle aRect = Rectangle(Point(nX, 1), Size(pData->aSz.Width(), aOutputSize.Height() - 2));
rRenderContext.Push(PushFlags::CLIPREGION);
rRenderContext.IntersectClipRegion(aRect);
bool bRollover = nPos != nHighlightedItem;
@@ -612,12 +616,12 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
Erase(rRenderContext);
else
{
- Rectangle aBgRegion(Point(), GetOutputSizePixel());
+ 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;
@@ -638,7 +642,7 @@ void MenuBarWindow::HighlightItem(vcl::RenderContext& rRenderContext, sal_uInt16
rRenderContext.DrawRect(aRect);
}
rRenderContext.Pop();
- pMenu->ImplPaint(rRenderContext, 0, 0, pData, true/*bHighlight*/, false, bRollover);
+ pMenu->ImplPaint(rRenderContext, aOutputSize, 0, 0, pData, true/*bHighlight*/, false, bRollover);
}
return;
}
@@ -844,6 +848,8 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
+ Size aOutputSize = GetOutputSizePixel();
+
// no VCL paint if native menus
if (pMenu->ImplGetSalMenu() && pMenu->ImplGetSalMenu()->VisibleMenuBar())
{
@@ -861,17 +867,21 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
else
{
Point aPt;
- Rectangle aCtrlRegion( aPt, GetOutputSizePixel() );
+ 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);
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index 0399149b309e..adafcacf2ef6 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -860,7 +860,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);
}
@@ -1174,7 +1174,7 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const Rectang
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