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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 1 19:09:05 UTC 2020


 include/vcl/treelistbox.hxx         |    8 ++++++--
 vcl/source/treelist/svimpbox.cxx    |    6 +++++-
 vcl/source/treelist/treelistbox.cxx |    6 +++++-
 3 files changed, 16 insertions(+), 4 deletions(-)

New commits:
commit d56ed8a462fb672f61a07279f30eb8597033f40b
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun May 31 19:13:54 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Jun 1 21:08:30 2020 +0200

    support hover-selection in SvTreeListBox
    
    Change-Id: I5ad124d7c9e5219a557069bc7283208124c734af
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95269
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/treelistbox.hxx b/include/vcl/treelistbox.hxx
index 288314af8232..586686e81de1 100644
--- a/include/vcl/treelistbox.hxx
+++ b/include/vcl/treelistbox.hxx
@@ -221,8 +221,9 @@ class VCL_DLLPUBLIC SvTreeListBox
     bool mbContextBmpExpanded;
     bool mbAlternatingRowColors;
     bool mbUpdateAlternatingRows;
-    bool mbQuickSearch;     // Enables type-ahead search in the check list box.
-    bool mbActivateOnSingleClick;     // Make single click "activate" a row like a double-click normally does
+    bool mbQuickSearch; // Enables type-ahead search in the check list box.
+    bool mbActivateOnSingleClick; // Make single click "activate" a row like a double-click normally does
+    bool mbHoverSelection; // Make mouse over a row "select" a row like a single-click normally does
 
     SvTreeListEntry*    pHdlEntry;
 
@@ -723,6 +724,9 @@ public:
     // Make single click "activate" a row like a double-click normally does
     void            SetActivateOnSingleClick(bool bEnable) { mbActivateOnSingleClick = bEnable; }
 
+    // Make mouse over a row "select" a row like a single-click normally does
+    void            SetHoverSelection(bool bEnable) { mbHoverSelection = bEnable; }
+
     void            SetForceMakeVisible(bool bEnable);
 
     virtual FactoryFunction GetUITestFactory() const override;
diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx
index 2fc2d0bf9d3c..dff21f931e5f 100644
--- a/vcl/source/treelist/svimpbox.cxx
+++ b/vcl/source/treelist/svimpbox.cxx
@@ -2074,7 +2074,11 @@ void SvImpLBox::MouseMove( const MouseEvent& rMEvt)
 {
     SvTreeListEntry* pEntry = GetClickedEntry( rMEvt.GetPosPixel() );
     if ( !MouseMoveCheckCtrl( rMEvt, pEntry ) && ( m_aSelEng.GetSelectionMode() != SelectionMode::NONE ) )
-        m_aSelEng.SelMouseMove( rMEvt );
+    {
+        m_aSelEng.SelMouseMove(rMEvt);
+        if (m_pView->mbHoverSelection && !m_pView->IsSelected(pEntry))
+            m_pView->Select(pEntry);
+    }
 }
 
 void SvImpLBox::ExpandAll()
diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx
index 3c68f1331f0b..389ed170828f 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -403,6 +403,7 @@ SvTreeListBox::SvTreeListBox(vcl::Window* pParent, WinBits nWinStyle) :
     mbUpdateAlternatingRows(false),
     mbQuickSearch(false),
     mbActivateOnSingleClick(false),
+    mbHoverSelection(false),
     eSelMode(SelectionMode::NONE),
     nMinWidthInChars(0),
     mnDragAction(DND_ACTION_COPYMOVE | DND_ACTION_LINK),
@@ -2337,7 +2338,6 @@ void SvTreeListBox::MouseMove( const MouseEvent& rMEvt )
     pImpl->MouseMove( rMEvt );
 }
 
-
 void SvTreeListBox::SetUpdateMode( bool bUpdate )
 {
     pImpl->SetUpdateMode( bUpdate );
@@ -3585,6 +3585,10 @@ bool SvTreeListBox::set_property(const OString &rKey, const OUString &rValue)
     {
         SetActivateOnSingleClick(toBool(rValue));
     }
+    else if (rKey == "hover-selection")
+    {
+        SetHoverSelection(toBool(rValue));
+    }
     else if (rKey == "reorderable")
     {
         if (toBool(rValue))


More information about the Libreoffice-commits mailing list