summaryrefslogtreecommitdiff
path: root/vcl/source/app
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-02-04 20:48:41 +0000
committerCaolán McNamara <caolanm@redhat.com>2021-02-05 15:54:44 +0100
commit73b590484023d59300e795e52f80da3f4de448f2 (patch)
tree8b096a555b9bbe4d1f03984ccf7d876815756264 /vcl/source/app
parentdbaf1d75601cb911d1c17e1e63d2c7047f2cf9e1 (diff)
improve SalInstanceWidget::draw
Change-Id: I9acb8dfceee586b343feb184e0788491d66d24a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110427 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/app')
-rw-r--r--vcl/source/app/salvtables.cxx54
1 files changed, 42 insertions, 12 deletions
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)
{