Kaydet (Commit) c04169c5 authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#125415 vcl menu floating window: avoid flicker

This is similar to e8d5b8be (tdf#113714
vcl menu bar window: avoid flicker, 2019-05-20), except that was for the
menu bar window, and this is for the floating window opening from that
one.

Change-Id: Ib24f4999ad3e8cbbecc058368e9d112e106e9178
Reviewed-on: https://gerrit.libreoffice.org/72688Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 845ebb4d
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <svdata.hxx> #include <svdata.hxx>
#include <vcl/decoview.hxx> #include <vcl/decoview.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <vcl/virdev.hxx>
#include <window.h> #include <window.h>
MenuFloatingWindow::MenuFloatingWindow( Menu* pMen, vcl::Window* pParent, WinBits nStyle ) : MenuFloatingWindow::MenuFloatingWindow( Menu* pMen, vcl::Window* pParent, WinBits nStyle ) :
...@@ -1206,32 +1207,41 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools:: ...@@ -1206,32 +1207,41 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools::
if (!pMenu) if (!pMenu)
return; return;
rRenderContext.Push( PushFlags::CLIPREGION ); // Make sure that all actual rendering happens in one go to avoid flicker.
rRenderContext.SetClipRegion(vcl::Region(rPaintRect)); ScopedVclPtrInstance<VirtualDevice> pBuffer;
pBuffer->SetOutputSizePixel(GetOutputSizePixel(), false);
pBuffer->DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
rRenderContext);
pBuffer->Push(PushFlags::CLIPREGION);
pBuffer->SetClipRegion(vcl::Region(rPaintRect));
if (rRenderContext.IsNativeControlSupported(ControlType::MenuPopup, ControlPart::Entire)) if (rRenderContext.IsNativeControlSupported(ControlType::MenuPopup, ControlPart::Entire))
{ {
rRenderContext.SetClipRegion(); pBuffer->SetClipRegion();
long nX = 0; long nX = 0;
Size aPxSize(GetOutputSizePixel()); Size aPxSize(GetOutputSizePixel());
aPxSize.AdjustWidth( -nX ); aPxSize.AdjustWidth( -nX );
ImplControlValue aVal(pMenu->nTextPos - GUTTERBORDER); ImplControlValue aVal(pMenu->nTextPos - GUTTERBORDER);
rRenderContext.DrawNativeControl(ControlType::MenuPopup, ControlPart::Entire, pBuffer->DrawNativeControl(ControlType::MenuPopup, ControlPart::Entire,
tools::Rectangle(Point(nX, 0), aPxSize), tools::Rectangle(Point(nX, 0), aPxSize), ControlState::ENABLED,
ControlState::ENABLED, aVal, OUString()); aVal, OUString());
InitMenuClipRegion(rRenderContext); InitMenuClipRegion(*pBuffer);
} }
if (IsScrollMenu()) if (IsScrollMenu())
{ {
ImplDrawScroller(rRenderContext, true); ImplDrawScroller(*pBuffer, true);
ImplDrawScroller(rRenderContext, false); ImplDrawScroller(*pBuffer, false);
} }
rRenderContext.SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor()); pBuffer->SetFillColor(rRenderContext.GetSettings().GetStyleSettings().GetMenuColor());
pMenu->ImplPaint(rRenderContext, GetOutputSizePixel(), nScrollerHeight, ImplGetStartY()); pMenu->ImplPaint(*pBuffer, GetOutputSizePixel(), nScrollerHeight, ImplGetStartY());
if (nHighlightedItem != ITEMPOS_INVALID) if (nHighlightedItem != ITEMPOS_INVALID)
RenderHighlightItem(rRenderContext, nHighlightedItem); RenderHighlightItem(*pBuffer, nHighlightedItem);
pBuffer->Pop();
rRenderContext.Pop(); rRenderContext.DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
*pBuffer);
} }
void MenuFloatingWindow::ImplDrawScroller(vcl::RenderContext& rRenderContext, bool bUp) void MenuFloatingWindow::ImplDrawScroller(vcl::RenderContext& rRenderContext, bool bUp)
......
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