summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2020-11-19 11:51:13 +0100
committerMichael Weghorn <m.weghorn@posteo.de>2020-11-19 18:11:05 +0100
commitf39f21d92ec83c3a5062f29dd26214fc83012c06 (patch)
treea1d6dc2de67cf99ce80d1a1e3f64145f8d403e20 /vcl/source/window
parent411063bc99f7339afae2c2a25a146c7c5efeb2da (diff)
tdf#138010 (IV) VclScrolledWindow: Use actual border width
The frame drawn by 'DecorationView::DrawFrame' may use native drawing, in which case the frame may be wider than 1 pixel. Take that into account and calculate the frame width and resulting position/size of the scrollbars and child widget using the content rectangle returned when drawing the frame using 'DecorationView::DrawFrame'. This avoids that the child widget is drawn on top of the frame, which e.g. resulted in no visible border when using the Qt/KDE Breeze style, which has a frame width of 2, with the actual 1 pixel border being surrounded by a 1 pixel padding/margin, and the content being drawn on top of the 1 pixel border. With the child widget being drawn on top of the actual border, only the invisible padding was left where a visible border was expected. (The current implementation assumes that the same frame width is used on all sides, which matches the way Qt styles handle it, but could be further extended if necessary.) Change-Id: I44268728838406fc578774c0f4fcc167fb2798b5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106157 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/layout.cxx23
1 files changed, 19 insertions, 4 deletions
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 9069d1aa7132..9b562c340b6b 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1803,11 +1803,10 @@ IMPL_LINK( VclExpander, ClickHdl, CheckBox&, rBtn, void )
maExpandedHdl.Call(*this);
}
-const tools::Long VclScrolledWindow::m_nBorderWidth = 1;
-
VclScrolledWindow::VclScrolledWindow(vcl::Window *pParent)
: VclBin(pParent, WB_HIDE | WB_CLIPCHILDREN | WB_AUTOHSCROLL | WB_AUTOVSCROLL | WB_TABSTOP)
, m_bUserManagedScrolling(false)
+ , m_nBorderWidth(1)
, m_eDrawFrameStyle(DrawFrameStyle::NONE)
, m_eDrawFrameFlags(DrawFrameFlags::NONE)
, m_pVScroll(VclPtr<ScrollBar>::Create(this, WB_HIDE | WB_VERT))
@@ -2068,11 +2067,27 @@ 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);
- aDecoView.DrawFrame(tools::Rectangle(Point(0,0), GetSizePixel()), m_eDrawFrameStyle, m_eDrawFrameFlags);
+ 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);
}
void VclViewport::setAllocation(const Size &rAllocation)