Related: tdf#142458 don't change border size during Paint
so GetOptimalSize/get_preferred_size before/after paint has the same result
Change-Id: I25abe31c069561e30a9af7c4b9b81582298e0f9d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121616
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 14c8593..19eca5b 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -500,8 +500,6 @@ public:
private:
virtual Size calculateRequisition() const override;
virtual void setAllocation(const Size &rAllocation) override;
// sets new border size and adapts scrollbar and child widget position/size as needed
void updateBorderWidth(tools::Long nBorderWidth);
int CalcBorderWidth() const;
DECL_LINK(ScrollBarHdl, ScrollBar*, void);
void InitScrollBars(const Size &rRequest);
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 680a650..d9f479e 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -2100,27 +2100,15 @@ bool VclScrolledWindow::EventNotify(NotifyEvent& rNEvt)
return bDone || VclBin::EventNotify( rNEvt );
}
void VclScrolledWindow::updateBorderWidth(tools::Long nBorderWidth)
{
if (m_nBorderWidth == nBorderWidth || nBorderWidth < 1)
return;
m_nBorderWidth = nBorderWidth;
// update scrollbars and child window
doSetAllocation(GetSizePixel(), false);
};
void VclScrolledWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
{
VclBin::Paint(rRenderContext, rRect);
const tools::Rectangle aRect(tools::Rectangle(Point(0,0), GetSizePixel()));
DecorationView aDecoView(&rRenderContext);
const tools::Rectangle aContentRect = aDecoView.DrawFrame(aRect, m_eDrawFrameStyle, m_eDrawFrameFlags);
// take potentially changed frame size into account before rendering content
const tools::Long nFrameWidth = (aRect.GetWidth() - aContentRect.GetWidth()) / 2;
updateBorderWidth(nFrameWidth);
VclBin::Paint(rRenderContext, rRect);
const auto nBorderWidth = (aRect.GetWidth() - aContentRect.GetWidth()) / 2;
SAL_WARN_IF(nBorderWidth > m_nBorderWidth, "vcl.layout", "desired border at paint " <<
nBorderWidth << " is larger than expected " << m_nBorderWidth);
}
void VclViewport::setAllocation(const Size &rAllocation)