include/vcl/window.hxx | 2 + vcl/inc/salvtables.hxx | 2 + vcl/source/app/salvtables.cxx | 54 ++++++++++++++++++++++++++++++++---------- 3 files changed, 46 insertions(+), 12 deletions(-)
New commits: commit 73b590484023d59300e795e52f80da3f4de448f2 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Feb 4 20:48:41 2021 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Feb 5 15:54:44 2021 +0100 improve SalInstanceWidget::draw Change-Id: I9acb8dfceee586b343feb184e0788491d66d24a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110427 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx index 4decec615469..d2129d2b0163 100644 --- a/include/vcl/window.hxx +++ b/include/vcl/window.hxx @@ -432,6 +432,7 @@ class FloatingWindow; class GroupBox; class PushButton; class RadioButton; +class SalInstanceWidget; class SystemChildWindow; class ImplDockingWindowWrapper; class ImplPopupFloatWin; @@ -493,6 +494,7 @@ class VCL_DLLPUBLIC Window : public ::OutputDevice friend class ::GroupBox; friend class ::PushButton; friend class ::RadioButton; + friend class ::SalInstanceWidget; friend class ::SystemChildWindow; friend class ::ImplBorderWindow; friend class ::PaintHelper; diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 6f3fccc87005..8f431002359d 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -174,6 +174,8 @@ private: DECL_LINK(MouseEventListener, VclSimpleEvent&, void); DECL_LINK(MnemonicActivateHdl, vcl::Window&, bool); + static void DoRecursivePaint(vcl::Window* pWindow, const Point& rPos, OutputDevice& rOutput); + const bool m_bTakeOwnership; bool m_bEventListener; bool m_bKeyEventListener; diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index c1ac2432ff7c..f983237dafed 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1172,39 +1172,69 @@ std::unique_ptr<weld::Container> SalInstanceWidget::weld_parent() const return std::make_unique<SalInstanceContainer>(pParent, m_pBuilder, false); } -namespace -{ -void DoRecursivePaint(vcl::Window* pWindow, const Point& rPos, OutputDevice& rOutput) +void SalInstanceWidget::DoRecursivePaint(vcl::Window* pWindow, const Point& rRenderLogicPos, + OutputDevice& rOutput) { - Size aSize = pWindow->GetSizePixel(); + pWindow->Push(); + bool bOldMapModeEnabled = pWindow->IsMapModeEnabled(); + + if (pWindow->GetMapMode().GetMapUnit() != rOutput.GetMapMode().GetMapUnit()) + { + // This is needed for e.g. the scrollbar in writer comments in margins that has its map unit in pixels + // as seen with bin/run gtktiledviewer --enable-tiled-annotations on a document containing a comment + // long enough to need a scrollbar + pWindow->EnableMapMode(); + MapMode aMapMode = pWindow->GetMapMode(); + aMapMode.SetMapUnit(rOutput.GetMapMode().GetMapUnit()); + aMapMode.SetScaleX(rOutput.GetMapMode().GetScaleX()); + aMapMode.SetScaleY(rOutput.GetMapMode().GetScaleY()); + pWindow->SetMapMode(aMapMode); + } VclPtr<VirtualDevice> xOutput(VclPtr<VirtualDevice>::Create(DeviceFormat::DEFAULT)); - xOutput->SetOutputSizePixel(aSize); - xOutput->DrawOutDev(Point(), aSize, rPos, aSize, rOutput); + Size aChildSizePixel(pWindow->GetSizePixel()); + xOutput->SetOutputSizePixel(aChildSizePixel); - //set ReallyVisible to match Visible, we restore the original - //state after Paint + MapMode aMapMode(xOutput->GetMapMode()); + aMapMode.SetMapUnit(rOutput.GetMapMode().GetMapUnit()); + aMapMode.SetScaleX(rOutput.GetMapMode().GetScaleX()); + aMapMode.SetScaleY(rOutput.GetMapMode().GetScaleY()); + xOutput->SetMapMode(aMapMode); + + Size aTempLogicSize(xOutput->PixelToLogic(aChildSizePixel)); + Size aRenderLogicSize(rOutput.PixelToLogic(aChildSizePixel)); + + xOutput->DrawOutDev(Point(), aTempLogicSize, rRenderLogicPos, aRenderLogicSize, rOutput); + + //set ReallyVisible to match Visible, we restore the original state after Paint WindowImpl* pImpl = pWindow->ImplGetWindowImpl(); bool bRVisible = pImpl->mbReallyVisible; pImpl->mbReallyVisible = pWindow->IsVisible(); - pWindow->Paint(*xOutput, tools::Rectangle(Point(), pWindow->PixelToLogic(aSize))); + pWindow->ApplySettings(*xOutput); + pWindow->Paint(*xOutput, tools::Rectangle(Point(), pWindow->PixelToLogic(aChildSizePixel))); pImpl->mbReallyVisible = bRVisible; - rOutput.DrawOutDev(rPos, aSize, Point(), aSize, *xOutput); + rOutput.DrawOutDev(rRenderLogicPos, aRenderLogicSize, Point(), aTempLogicSize, *xOutput); xOutput.disposeAndClear(); + pWindow->EnableMapMode(bOldMapModeEnabled); + pWindow->Pop(); + for (vcl::Window* pChild = pWindow->GetWindow(GetWindowType::FirstChild); pChild; pChild = pChild->GetWindow(GetWindowType::Next)) { if (!pChild->IsVisible()) continue; - DoRecursivePaint(pChild, rPos + rOutput.PixelToLogic(pChild->GetPosPixel()), rOutput); + Point aRelPos(pChild->GetPosPixel()); + Size aRelLogicOffset(rOutput.PixelToLogic(Size(aRelPos.X(), aRelPos.Y()))); + DoRecursivePaint(pChild, + rRenderLogicPos + Point(aRelLogicOffset.Width(), aRelLogicOffset.Height()), + rOutput); } } -} void SalInstanceWidget::draw(OutputDevice& rOutput, const Point& rPos, const Size& rSizePixel) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits