diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-10-05 14:08:28 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-10-05 14:37:50 +0100 |
commit | 8f6d8d471d62f412956cb3dad339e5ab9a99dd5f (patch) | |
tree | 7a222080eb467a53c6370063ec130449d8e98be4 /vcl | |
parent | 06e3724d1c166e6715455555788f5b11c310d60a (diff) |
sort by grid position, then pack type, then pack position
so that focus ends up on the visually first enabled control
Change-Id: Ia279c4531536305ce43eb8372abde2445769487d
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/builder.hxx | 12 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 53 |
2 files changed, 40 insertions, 25 deletions
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx index 191079151e21..246f68dd208c 100644 --- a/vcl/inc/vcl/builder.hxx +++ b/vcl/inc/vcl/builder.hxx @@ -121,6 +121,18 @@ private: Window *get_by_name(OString sID); void delete_by_name(OString sID); + + class sortIntoBestTabTraversalOrder + : public std::binary_function<const Window*, const Window*, bool> + { + VclBuilder *m_pBuilder; + public: + sortIntoBestTabTraversalOrder(VclBuilder *pBuilder) + : m_pBuilder(pBuilder) + { + } + bool operator()(const Window *pA, const Window *pB) const; + }; public: VclBuilder(Window *pParent, OUString sUIRootDir, OUString sUIFile, OString sID = OString()); ~VclBuilder(); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index e4213202250d..1fdad861112b 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -869,20 +869,32 @@ void VclBuilder::handleTabChild(Window *pParent, xmlreader::XmlReader &reader) pTabControl->RemovePage(pTabControl->GetCurPageId()); } -namespace +//so that tabbing between controls goes in a visually sensible sequence +//we sort these into a best-tab-order sequence +bool VclBuilder::sortIntoBestTabTraversalOrder::operator()(const Window *pA, const Window *pB) const { - bool sortByGridPositions(Window *pA, Window *pB) - { - sal_Int32 nTopA = pA->get_grid_top_attach(); - sal_Int32 nTopB = pB->get_grid_top_attach(); - if (nTopA < nTopB) - return true; - if (nTopA > nTopB) - return false; - sal_Int32 nLeftA = pA->get_grid_left_attach(); - sal_Int32 nLeftB = pB->get_grid_left_attach(); - return nLeftA < nLeftB; - } + //sort child order within parent list by grid position + sal_Int32 nTopA = pA->get_grid_top_attach(); + sal_Int32 nTopB = pB->get_grid_top_attach(); + if (nTopA < nTopB) + return true; + if (nTopA > nTopB) + return false; + sal_Int32 nLeftA = pA->get_grid_left_attach(); + sal_Int32 nLeftB = pB->get_grid_left_attach(); + if (nLeftA < nLeftB) + return true; + if (nLeftA > nLeftB) + return false; + //sort into two groups of pack start and pack end + VclPackType ePackA = pA->get_pack_type(); + VclPackType ePackB = pB->get_pack_type(); + if (ePackA < ePackB) + return true; + if (ePackA > ePackB) + return false; + //honour relative box positions with pack group + return m_pBuilder->get_window_packing_position(pA) < m_pBuilder->get_window_packing_position(pB); } void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader) @@ -943,20 +955,11 @@ void VclBuilder::handleChild(Window *pParent, xmlreader::XmlReader &reader) aChilds.push_back(pChild); } - //sort child order within parent list by grid position - //so that tabbing between controls goes in a visually sensible sequence - std::stable_sort(aChilds.begin(), aChilds.end(), sortByGridPositions); + //sort child order within parent so that tabbing + //between controls goes in a visually sensible sequence + std::stable_sort(aChilds.begin(), aChilds.end(), sortIntoBestTabTraversalOrder(this)); for (size_t i = 0; i < aChilds.size(); ++i) reorderWithinParent(*aChilds[i], i); - - //honour box positions if there is any - for (size_t i = 0; i < aChilds.size(); ++i) - { - sal_Int32 nPosition = get_window_packing_position(aChilds[i]); - if (nPosition == -1) - continue; - reorderWithinParent(*aChilds[i], nPosition); - } } } } |