From 8b142a05e55c4423f8243adea6acdc0a4aa84bea Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Sat, 14 Jan 2023 14:14:42 +0100 Subject: [PATCH] visual tools: Add EndDrag and EndHold hooks --- src/visual_tool.cpp | 4 ++++ src/visual_tool.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/visual_tool.cpp b/src/visual_tool.cpp index 61d320722..81fef285f 100644 --- a/src/visual_tool.cpp +++ b/src/visual_tool.cpp @@ -208,6 +208,9 @@ void VisualTool::OnMouseEvent(wxMouseEvent &event) { else SetSelection(active_feature, true); } + } else { + for (auto sel : sel_features) + EndDrag(sel); } active_feature = nullptr; @@ -218,6 +221,7 @@ void VisualTool::OnMouseEvent(wxMouseEvent &event) { else if (holding) { if (!event.LeftIsDown()) { holding = false; + EndHold(); parent->ReleaseMouse(); parent->SetFocus(); diff --git a/src/visual_tool.h b/src/visual_tool.h index 82cc3bea4..a8d518021 100644 --- a/src/visual_tool.h +++ b/src/visual_tool.h @@ -166,6 +166,8 @@ private: virtual bool InitializeHold() { return false; } /// @brief Called on every mouse event during a hold virtual void UpdateHold() { } + /// @brief Called when the hold ended + virtual void EndHold() { } /// @brief Called at the beginning of a drag /// @param feature The visual feature clicked on @@ -174,6 +176,9 @@ private: /// @brief Called on every mouse event during a drag /// @param feature The current feature to process; not necessarily the one clicked on virtual void UpdateDrag(FeatureType *feature) { } + /// @brief Called at the end of a drag + /// @param feature The current feature to process; not necessarily the one clicked on + virtual void EndDrag(FeatureType *feature) { } protected: std::set sel_features; ///< Currently selected visual features