[Libreoffice-commits] core.git: include/vcl vcl/source
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Thu Nov 19 17:11:47 UTC 2020
include/vcl/layout.hxx | 4 +++-
vcl/source/window/layout.cxx | 23 +++++++++++++++++++----
2 files changed, 22 insertions(+), 5 deletions(-)
New commits:
commit f39f21d92ec83c3a5062f29dd26214fc83012c06
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu Nov 19 11:51:13 2020 +0100
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Thu Nov 19 18:11:05 2020 +0100
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 at posteo.de>
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 9824078fa612..cea55a78755e 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -519,11 +519,13 @@ 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);
DECL_LINK(ScrollBarHdl, ScrollBar*, void);
void InitScrollBars(const Size &rRequest);
virtual bool EventNotify(NotifyEvent& rNEvt) override;
bool m_bUserManagedScrolling;
- const static tools::Long m_nBorderWidth;
+ tools::Long m_nBorderWidth;
DrawFrameStyle m_eDrawFrameStyle;
DrawFrameFlags m_eDrawFrameFlags;
VclPtr<ScrollBar> m_pVScroll;
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)
More information about the Libreoffice-commits
mailing list