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

tdf#125550 vcl menu bar / floating window: fix text color

Regression from commit e8d5b8be
(tdf#113714 vcl menu bar window: avoid flicker, 2019-05-20), the problem
was that a freshly created VirtualDevice doesn't have the default text
color, so we need to initialize that explicitly based on the render
context text color.

Also introduce a BufferDevice to do this initialization, instead of
fixing this in MenuBarWindow::Paint(), then copy&pasting the fix to
MenuFloatingWindow::Paint().

Change-Id: Ib171cd52e7cabe0bc3c639821f558d8303039fe6
Reviewed-on: https://gerrit.libreoffice.org/73269Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst a415ba29
......@@ -124,6 +124,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/window/accel \
vcl/source/window/accmgr \
vcl/source/window/brdwin \
vcl/source/window/bufferdevice \
vcl/source/window/accessibility \
vcl/source/window/legacyaccessibility \
vcl/source/window/clipping \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "bufferdevice.hxx"
namespace vcl
{
BufferDevice::BufferDevice(const VclPtr<vcl::Window>& pWindow, vcl::RenderContext& rRenderContext)
: m_pBuffer(VclPtr<VirtualDevice>::Create())
, m_pWindow(pWindow)
, m_rRenderContext(rRenderContext)
{
m_pBuffer->SetOutputSizePixel(pWindow->GetOutputSizePixel(), false);
m_pBuffer->SetTextColor(rRenderContext.GetTextColor());
m_pBuffer->DrawOutDev(Point(0, 0), pWindow->GetOutputSizePixel(), Point(0, 0),
pWindow->GetOutputSizePixel(), rRenderContext);
}
BufferDevice::~BufferDevice()
{
m_rRenderContext.DrawOutDev(Point(0, 0), m_pWindow->GetOutputSizePixel(), Point(0, 0),
m_pWindow->GetOutputSizePixel(), *m_pBuffer);
}
vcl::RenderContext* BufferDevice::operator->() { return m_pBuffer.get(); }
vcl::RenderContext& BufferDevice::operator*() { return *m_pBuffer; }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_VCL_SOURCE_WINDOW_BUFFERDEVICE_HXX
#define INCLUDED_VCL_SOURCE_WINDOW_BUFFERDEVICE_HXX
#include <vcl/virdev.hxx>
#include <vcl/window.hxx>
namespace vcl
{
/// Buffers drawing on a vcl::RenderContext using a VirtualDevice.
class BufferDevice
{
ScopedVclPtr<VirtualDevice> m_pBuffer;
VclPtr<vcl::Window> m_pWindow;
vcl::RenderContext& m_rRenderContext;
public:
BufferDevice(const VclPtr<vcl::Window>& pWindow, vcl::RenderContext& rRenderContext);
~BufferDevice();
vcl::RenderContext* operator->();
vcl::RenderContext& operator*();
};
}
#endif // INCLUDED_VCL_SOURCE_WINDOW_BUFFERDEVICE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -33,6 +33,7 @@
#include <strings.hrc>
#include <bitmaps.hlst>
#include <window.h>
#include "bufferdevice.hxx"
// document closing button
#define IID_DOCUMENTCLOSE 1
......@@ -914,11 +915,7 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
}
// Make sure that all actual rendering happens in one go to avoid flicker.
ScopedVclPtrInstance<VirtualDevice> pBuffer;
pBuffer->SetOutputSizePixel(aOutputSize, false);
// Copy the current state to the buffer.
pBuffer->DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
rRenderContext);
vcl::BufferDevice pBuffer(this, rRenderContext);
if (rRenderContext.IsNativeControlSupported(ControlType::Menubar, ControlPart::Entire))
{
......@@ -961,10 +958,6 @@ void MenuBarWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Recta
Point(aSize.Width() - 1, aSize.Height() - 1));
pBuffer->Pop();
}
// Copy the current state from the buffer.
rRenderContext.DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
*pBuffer);
}
void MenuBarWindow::Resize()
......
......@@ -20,6 +20,7 @@
#include "menufloatingwindow.hxx"
#include "menuitemlist.hxx"
#include "menubarwindow.hxx"
#include "bufferdevice.hxx"
#include <sal/log.hxx>
#include <salmenu.hxx>
......@@ -1208,10 +1209,7 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools::
return;
// Make sure that all actual rendering happens in one go to avoid flicker.
ScopedVclPtrInstance<VirtualDevice> pBuffer;
pBuffer->SetOutputSizePixel(GetOutputSizePixel(), false);
pBuffer->DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
rRenderContext);
vcl::BufferDevice pBuffer(this, rRenderContext);
pBuffer->Push(PushFlags::CLIPREGION);
pBuffer->SetClipRegion(vcl::Region(rPaintRect));
......@@ -1239,9 +1237,6 @@ void MenuFloatingWindow::Paint(vcl::RenderContext& rRenderContext, const tools::
RenderHighlightItem(*pBuffer, nHighlightedItem);
pBuffer->Pop();
rRenderContext.DrawOutDev(Point(0, 0), GetOutputSizePixel(), Point(0, 0), GetOutputSizePixel(),
*pBuffer);
}
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