From f458500fc5152680d2e5b7183090791003394f7c Mon Sep 17 00:00:00 2001 From: lnd3 Date: Fri, 23 Aug 2024 18:57:07 +0200 Subject: [PATCH] Add ui link disconnect logic. --- packages/rendering/source/common/ui/UIVisitors.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/rendering/source/common/ui/UIVisitors.cpp b/packages/rendering/source/common/ui/UIVisitors.cpp index 030e551a..c759fb00 100644 --- a/packages/rendering/source/common/ui/UIVisitors.cpp +++ b/packages/rendering/source/common/ui/UIVisitors.cpp @@ -261,6 +261,16 @@ namespace l::ui { return true; } } + if (container.HasConfigFlag(UIContainer_LinkFlag) && !mDragging && input.mStarted && mLinkContainer.get() == nullptr && container.GetCoParent() != nullptr) { + ImVec2 pCenter = container.GetCoParent()->GetPosition(); + ImVec2 size = container.GetCoParent()->GetSize(); + ImVec2 pT = container.GetCoParent()->GetLayoutArea().Transform(pCenter, input.mRootPos); + if (OverlapCircle(input.mCurPos, pT, size.x * container.GetCoParent()->GetLayoutArea().mScale)) { + mDragging = true; + mLinkContainer.mContainer = &container; + return true; + } + } if (mDragging && mLinkContainer.get() != nullptr && container.HasConfigFlag(UIContainer_LinkFlag) && mLinkContainer.get() == &container) { // On the newly created link container, drag the end point along the mouse movement