From 1cc1d396e93a94ffe28a0ed32a87e3e517b1d31b Mon Sep 17 00:00:00 2001 From: "Andrew D. Zonenberg" Date: Fri, 24 Nov 2023 22:22:54 -0800 Subject: [PATCH] Can now create groups from the context menu. No way to rename them and they don't do anything special WRT ports yet. See #639. --- src/ngscopeclient/FilterGraphEditor.cpp | 76 ++++++++++++++++++------- 1 file changed, 55 insertions(+), 21 deletions(-) diff --git a/src/ngscopeclient/FilterGraphEditor.cpp b/src/ngscopeclient/FilterGraphEditor.cpp index e92c574ec..15f981992 100644 --- a/src/ngscopeclient/FilterGraphEditor.cpp +++ b/src/ngscopeclient/FilterGraphEditor.cpp @@ -85,14 +85,6 @@ FilterGraphEditor::FilterGraphEditor(Session& session, MainWindow* parent) m_parent->GetTextureManager()->LoadTexture("input-k-dual", FindDataFile("icons/filters/input-k-dual.png")); m_parent->GetTextureManager()->LoadTexture("input-k", FindDataFile("icons/filters/input-k.png")); m_parent->GetTextureManager()->LoadTexture("input-sma", FindDataFile("icons/filters/input-sma.png")); - - //DEBUG: make a group - /* - auto group = make_shared(); - auto id = GetID(group); - group->m_name = string("Group ") + to_string((intptr_t)id.AsPointer()); - m_groups.emplace(group, id); - */ } FilterGraphEditor::~FilterGraphEditor() @@ -427,8 +419,12 @@ void FilterGraphEditor::HandleOverlaps() nodes.resize(nnodes); ax::NodeEditor::GetOrderedNodeIds(&nodes[0], nnodes); - LogDebug("FilterGraphEditor::HandleOverlaps (%d nodes)\n", nnodes); - LogIndenter li; + //Need to use internal APIs to figure out if we're dragging the current node + //in order to properly implement collision detection + auto action = reinterpret_cast(m_context)->GetCurrentAction(); + ax::NodeEditor::Detail::DragAction* drag = nullptr; + if(action) + drag = action->AsDrag(); //Loop over all nodes and find potential collisions for(int i=0; im_Objects) + { + auto n = o->AsNode(); + if(!n) + continue; + + if(n->m_ID == gid) + { + //draggingGroup = true; + break; + } + if(n->m_ID == nid) + { + draggingNode = true; + break; + } + } + } + + //If dragging group, we should push nodes away + + //But if dragging the node, allow it to go into the group + if(draggingNode) continue; - */ } //If no overlap, no action required @@ -1479,6 +1503,16 @@ void FilterGraphEditor::DoAddMenu() ImGui::EndMenu(); } + + ImGui::Separator(); + + if(ImGui::MenuItem("New Group")) + { + auto group = make_shared(); + auto id = GetID(group); + group->m_name = string("Group ") + to_string((intptr_t)id.AsPointer()); + m_groups.emplace(group, id); + } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////