[Libreoffice-commits] core.git: vcl/source

Caolán McNamara caolanm at redhat.com
Thu Aug 15 09:14:07 PDT 2013


 vcl/source/window/builder.cxx |   16 +++++++++-------
 vcl/source/window/layout.cxx  |   26 ++++++++++++++++++--------
 2 files changed, 27 insertions(+), 15 deletions(-)

New commits:
commit 101a8f0f0770b5789181812425ddfc8847f7206a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Aug 15 17:12:45 2013 +0100

    Related: fdo#65546 sort PACK_END into visual order for tabbing
    
    and then reverse them for layout packing
    
    Change-Id: I417bb3f6667ddc10103623867fea1a9b8061f5eb

diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 4c25fae..728eae5 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -1720,13 +1720,15 @@ bool VclBuilder::sortIntoBestTabTraversalOrder::operator()(const Window *pA, con
         if (bPackA > bPackB)
             return false;
     }
-    //honour relative box positions with pack group
-    bPackA = m_pBuilder->get_window_packing_data(pA).m_nPosition;
-    bPackB = m_pBuilder->get_window_packing_data(pB).m_nPosition;
-    if (bPackA < bPackB)
-        return true;
-    if (bPackA > bPackB)
-        return false;
+    //honour relative box positions with pack group, (numerical order is reversed
+    //for VCL_PACK_END, they are packed from the end back, but here we need
+    //them in visual layout order so that tabbing works as expected)
+    sal_Int32 nPackA = m_pBuilder->get_window_packing_data(pA).m_nPosition;
+    sal_Int32 nPackB = m_pBuilder->get_window_packing_data(pB).m_nPosition;
+    if (nPackA < nPackB)
+        return ePackA == VCL_PACK_START ? true : false;
+    if (nPackA > nPackB)
+        return ePackA == VCL_PACK_START ? false : true;
     //sort labels of Frames before body
     if (pA->GetParent() == pB->GetParent())
     {
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 4332881..118298b 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -222,6 +222,22 @@ void VclBox::setAllocation(const Size &rAllocation)
         nExtraSpace = (getPrimaryDimension(rAllocation) - getPrimaryDimension(aRequisition)) / nExpandChildren;
     }
 
+    //Split into those we pack from the start onwards, and those we pack from the end backwards
+    std::vector<Window*> aWindows[2];
+    for (Window *pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild->GetWindow(WINDOW_NEXT))
+    {
+        if (!pChild->IsVisible())
+            continue;
+
+        sal_Int32 ePacking = pChild->get_pack_type();
+        aWindows[ePacking].push_back(pChild);
+    }
+
+    //See VclBuilder::sortIntoBestTabTraversalOrder for why they are in visual
+    //order under the parent which requires us to reverse them here to
+    //pack from the end back
+    std::reverse(aWindows[VCL_PACK_END].begin(),aWindows[VCL_PACK_END].end());
+
     for (sal_Int32 ePackType = VCL_PACK_START; ePackType <= VCL_PACK_END; ++ePackType)
     {
         Point aPos(0, 0);
@@ -231,15 +247,9 @@ void VclBox::setAllocation(const Size &rAllocation)
             setPrimaryCoordinate(aPos, nPrimaryCoordinate + nAllocPrimaryDimension);
         }
 
-        for (Window *pChild = GetWindow(WINDOW_FIRSTCHILD); pChild; pChild = pChild->GetWindow(WINDOW_NEXT))
+        for (std::vector<Window*>::iterator aI = aWindows[ePackType].begin(), aEnd = aWindows[ePackType].end(); aI != aEnd; ++aI)
         {
-            if (!pChild->IsVisible())
-                continue;
-
-            sal_Int32 ePacking = pChild->get_pack_type();
-
-            if (ePacking != ePackType)
-                continue;
+            Window *pChild = *aI;
 
             long nPadding = pChild->get_padding();
 


More information about the Libreoffice-commits mailing list