include/vcl/layout.hxx       |    1 +
 vcl/source/window/layout.cxx |   30 ++++++++++++++++--------------
 2 files changed, 17 insertions(+), 14 deletions(-)

New commits:
commit 411063bc99f7339afae2c2a25a146c7c5efeb2da
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Nov 19 11:42:54 2020 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Nov 19 18:10:44 2020 +0100

    tdf#138010 (III) Extract VclScrolledWindow border width to var
    
        commit 1fe4a1a76da8fd3c196ccd9529b01ee093516b25
        Date:   Fri Mar 30 13:30:38 2018 +0100
    
            draw a border around scrolled window
    
    had added a 1 pixel border for scrolled windows.
    
    Extract the value for the border width (currently hard-coded
    to 1) to a variable.
    
    This will be extended to take into account the actual width
    of natively drawn frames in a follow-up commit.
    
    Change-Id: I2503105c42fae9eae66ec931d54c9d6883f83bf0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106156
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 663dea045784..9824078fa612 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -523,6 +523,7 @@ private:
     void InitScrollBars(const Size &rRequest);
     virtual bool EventNotify(NotifyEvent& rNEvt) override;
     bool m_bUserManagedScrolling;
+    const static 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 245befc2c3a7..9069d1aa7132 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1803,6 +1803,8 @@ 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)
@@ -1876,8 +1878,8 @@ Size VclScrolledWindow::calculateRequisition() const
     if (GetStyle() & WB_HSCROLL)
         aRet.AdjustHeight(getLayoutRequisition(*m_pHScroll).Height() );
 
-    aRet.AdjustHeight(2);
-    aRet.AdjustWidth(2);
+    aRet.AdjustHeight(2 * m_nBorderWidth);
+    aRet.AdjustWidth(2 * m_nBorderWidth);
 
     return aRet;
 }
@@ -1910,8 +1912,8 @@ void VclScrolledWindow::doSetAllocation(const Size 
&rAllocation, bool bRetryOnFa
     if (pChild && pChild->IsVisible())
         aChildReq = getLayoutRequisition(*pChild);
 
-    tools::Long nAvailHeight = rAllocation.Height() - 2;
-    tools::Long nAvailWidth = rAllocation.Width() - 2;
+    tools::Long nAvailHeight = rAllocation.Height() - 2 * m_nBorderWidth;
+    tools::Long nAvailWidth = rAllocation.Width() - 2 * m_nBorderWidth;
     // vert. ScrollBar
     if (GetStyle() & WB_AUTOVSCROLL)
     {
@@ -1939,8 +1941,8 @@ void VclScrolledWindow::doSetAllocation(const Size 
&rAllocation, bool bRetryOnFa
         m_pHScroll->Show((GetStyle() & WB_HSCROLL) != 0);
 
     Size aInnerSize(rAllocation);
-    aInnerSize.AdjustWidth(-2);
-    aInnerSize.AdjustHeight(-2);
+    aInnerSize.AdjustWidth(-2 * m_nBorderWidth);
+    aInnerSize.AdjustHeight(-2 * m_nBorderWidth);
 
     bool bBothVisible = m_pVScroll->IsVisible() && m_pHScroll->IsVisible();
     auto nScrollBarWidth = getLayoutRequisition(*m_pVScroll).Width();
@@ -1948,8 +1950,8 @@ void VclScrolledWindow::doSetAllocation(const Size 
&rAllocation, bool bRetryOnFa
 
     if (m_pVScroll->IsVisible())
     {
-        Point aScrollPos(rAllocation.Width() - nScrollBarWidth - 1, 1);
-        Size aScrollSize(nScrollBarWidth, rAllocation.Height() - 2);
+        Point aScrollPos(rAllocation.Width() - nScrollBarWidth - 
m_nBorderWidth, m_nBorderWidth);
+        Size aScrollSize(nScrollBarWidth, rAllocation.Height() - 2 * 
m_nBorderWidth);
         if (bBothVisible)
             aScrollSize.AdjustHeight(-nScrollBarHeight);
         setLayoutAllocation(*m_pVScroll, aScrollPos, aScrollSize);
@@ -1958,8 +1960,8 @@ void VclScrolledWindow::doSetAllocation(const Size 
&rAllocation, bool bRetryOnFa
 
     if (m_pHScroll->IsVisible())
     {
-        Point aScrollPos(1, rAllocation.Height() - nScrollBarHeight);
-        Size aScrollSize(rAllocation.Width() - 2, nScrollBarHeight);
+        Point aScrollPos(m_nBorderWidth, rAllocation.Height() - 
nScrollBarHeight);
+        Size aScrollSize(rAllocation.Width() - 2 * m_nBorderWidth, 
nScrollBarHeight);
         if (bBothVisible)
             aScrollSize.AdjustWidth(-nScrollBarWidth);
         setLayoutAllocation(*m_pHScroll, aScrollPos, aScrollSize);
@@ -1968,7 +1970,7 @@ void VclScrolledWindow::doSetAllocation(const Size 
&rAllocation, bool bRetryOnFa
 
     if (bBothVisible)
     {
-        Point aBoxPos(aInnerSize.Width() + 1, aInnerSize.Height() + 1);
+        Point aBoxPos(aInnerSize.Width() + m_nBorderWidth, aInnerSize.Height() 
+ m_nBorderWidth);
         m_aScrollBarBox->SetPosSizePixel(aBoxPos, Size(nScrollBarWidth, 
nScrollBarHeight));
         m_aScrollBarBox->Show();
     }
@@ -1983,7 +1985,7 @@ void VclScrolledWindow::doSetAllocation(const Size 
&rAllocation, bool bRetryOnFa
 
         WinBits nOldBits = (GetStyle() & (WB_AUTOVSCROLL | WB_VSCROLL | 
WB_AUTOHSCROLL | WB_HSCROLL));
 
-        setLayoutAllocation(*pChild, Point(1, 1), aInnerSize);
+        setLayoutAllocation(*pChild, Point(m_nBorderWidth, m_nBorderWidth), 
aInnerSize);
 
         // tdf#128758 if the layout allocation triggered some callback that
         // immediately invalidates the layout by adding scrollbars then
@@ -2014,8 +2016,8 @@ Size VclScrolledWindow::getVisibleChildSize() const
         aRet.AdjustWidth( -(m_pVScroll->GetSizePixel().Width()) );
     if (m_pHScroll->IsVisible())
         aRet.AdjustHeight( -(m_pHScroll->GetSizePixel().Height()) );
-    aRet.AdjustHeight(-2);
-    aRet.AdjustWidth(-2);
+    aRet.AdjustHeight(-2 * m_nBorderWidth);
+    aRet.AdjustWidth(-2 * m_nBorderWidth);
     return aRet;
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to