[Libreoffice-commits] core.git: cui/source include/vcl sfx2/source vcl/inc vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue May 26 18:24:15 UTC 2020


 cui/source/customize/SvxMenuConfigPage.cxx |   12 ++++++------
 include/vcl/weld.hxx                       |    4 +++-
 sfx2/source/dialog/templdlg.cxx            |    2 +-
 vcl/inc/treeglue.hxx                       |    9 +++++++--
 vcl/source/app/salvtables.cxx              |    5 +++--
 vcl/unx/gtk3/gtk3gtkinst.cxx               |    4 ++--
 6 files changed, 22 insertions(+), 14 deletions(-)

New commits:
commit ef9ac1b9874ccd1f1df16e9eeb53f9453311337e
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue May 26 16:37:48 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue May 26 20:23:34 2020 +0200

    make highlight of get_dest_row_at_pos optional
    
    Change-Id: I280e1a49e938f45402f373896669fd6f7e8a66fc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94876
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/cui/source/customize/SvxMenuConfigPage.cxx b/cui/source/customize/SvxMenuConfigPage.cxx
index 064a0d508f8c..a0c6d316a0e5 100644
--- a/cui/source/customize/SvxMenuConfigPage.cxx
+++ b/cui/source/customize/SvxMenuConfigPage.cxx
@@ -528,9 +528,9 @@ IMPL_LINK( SvxMenuConfigPage, ContentContextMenuHdl, const CommandEvent&, rCEvt,
     weld::TreeView& rTreeView = m_xContentsListBox->get_widget();
 
     // Select clicked entry
-    std::unique_ptr<weld::TreeIter> rIter(rTreeView.make_iterator());
-    rTreeView.get_dest_row_at_pos( rCEvt.GetMousePosPixel(), &*rIter );
-    rTreeView.select(*rIter);
+    std::unique_ptr<weld::TreeIter> xIter(rTreeView.make_iterator());
+    rTreeView.get_dest_row_at_pos( rCEvt.GetMousePosPixel(), xIter.get(), false );
+    rTreeView.select(*xIter);
     SelectMenuEntry( rTreeView );
 
     int nSelectIndex = m_xContentsListBox->get_selected_index();
@@ -571,9 +571,9 @@ IMPL_LINK( SvxMenuConfigPage, FunctionContextMenuHdl, const CommandEvent&, rCEvt
     weld::TreeView& rTreeView = m_xFunctions->get_widget();
 
     // Select clicked entry
-    std::unique_ptr<weld::TreeIter> rIter(rTreeView.make_iterator());
-    rTreeView.get_dest_row_at_pos( rCEvt.GetMousePosPixel(), &*rIter );
-    rTreeView.select(*rIter);
+    std::unique_ptr<weld::TreeIter> xIter(rTreeView.make_iterator());
+    rTreeView.get_dest_row_at_pos( rCEvt.GetMousePosPixel(), xIter.get(), false );
+    rTreeView.select(*xIter);
     SelectFunctionHdl( rTreeView );
 
     std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder( &rTreeView, "cui/ui/entrycontextmenu.ui" ) );
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index a57f7f4321c3..7766749cd007 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -1157,7 +1157,9 @@ public:
     virtual void set_column_custom_renderer(int nColumn, bool bEnable) = 0;
 
     // for dnd
-    virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult) = 0;
+    virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult,
+                                     bool bHighLightTarget = true)
+        = 0;
     virtual void unset_drag_dest_row() = 0;
     virtual tools::Rectangle get_row_area(const weld::TreeIter& rIter) const = 0;
     // for dragging and dropping between TreeViews, return the active source
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 18be2cd2e1c6..c32c4f9e639b 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -336,7 +336,7 @@ void SfxCommonTemplateDialog_Impl::PrepareMenu(const Point& rPos)
 {
     weld::TreeView* pTreeView = mxTreeBox->get_visible() ? mxTreeBox.get() : mxFmtLb.get();
     std::unique_ptr<weld::TreeIter> xIter(pTreeView->make_iterator());
-    if (pTreeView->get_dest_row_at_pos(rPos, xIter.get()) && !pTreeView->is_selected(*xIter))
+    if (pTreeView->get_dest_row_at_pos(rPos, xIter.get(), false) && !pTreeView->is_selected(*xIter))
     {
         pTreeView->unselect_all();
         pTreeView->select(*xIter);
diff --git a/vcl/inc/treeglue.hxx b/vcl/inc/treeglue.hxx
index da4cc1ffeaf9..11c61944f5e1 100644
--- a/vcl/inc/treeglue.hxx
+++ b/vcl/inc/treeglue.hxx
@@ -127,7 +127,7 @@ public:
         m_aModelChangedHdl.Call(this);
     }
 
-    virtual SvTreeListEntry* GetDropTarget(const Point& rPos) override
+    SvTreeListEntry* GetTargetAtPoint(const Point& rPos, bool bHighLightTarget)
     {
         SvTreeListEntry* pOldTargetEntry = pTargetEntry;
         pTargetEntry = pImpl->GetEntry(rPos);
@@ -150,11 +150,16 @@ public:
             }
         }
 
-        if (pTargetEntry)
+        if (pTargetEntry && bHighLightTarget)
             ImplShowTargetEmphasis(pTargetEntry, true);
         return pTargetEntry;
     }
 
+    virtual SvTreeListEntry* GetDropTarget(const Point& rPos) override
+    {
+        return GetTargetAtPoint(rPos, true);
+    }
+
     virtual bool EditingEntry(SvTreeListEntry* pEntry, Selection&) override
     {
         return m_aEditingEntryHdl.Call(pEntry);
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 67cb4fad45e1..985503444597 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4502,9 +4502,10 @@ public:
 
     SvTabListBox& getTreeView() { return *m_xTreeView; }
 
-    virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult) override
+    virtual bool get_dest_row_at_pos(const Point& rPos, weld::TreeIter* pResult, bool bHighLightTarget) override
     {
-        SvTreeListEntry* pTarget = m_xTreeView->GetDropTarget(rPos);
+        LclTabListBox* pTreeView = !bHighLightTarget ? dynamic_cast<LclTabListBox*>(m_xTreeView.get()) : nullptr;
+        SvTreeListEntry* pTarget = pTreeView ? pTreeView->GetTargetAtPoint(rPos, false) : m_xTreeView->GetDropTarget(rPos);
 
         if (pTarget && pResult)
         {
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 16b2a1ae1d7c..f38c79f91a63 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -11134,7 +11134,7 @@ public:
         weld::TreeView::connect_popup_menu(rLink);
     }
 
-    virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter* pResult) override
+    virtual bool get_dest_row_at_pos(const Point &rPos, weld::TreeIter* pResult, bool bHighLightTarget) override
     {
         const bool bAsTree = gtk_tree_view_get_enable_tree_lines(m_pTreeView);
 
@@ -11184,7 +11184,7 @@ public:
             gtk_tree_model_get_iter(pModel, &rGtkIter.iter, path);
         }
 
-        if (m_bInDrag)
+        if (m_bInDrag && bHighLightTarget) // bHighLightTarget alone might be sufficient
         {
             // highlight the row
             gtk_tree_view_set_drag_dest_row(m_pTreeView, path, pos);


More information about the Libreoffice-commits mailing list