aboutsummaryrefslogtreecommitdiff
path: root/3rdparty/imgui-node-editor/imgui_node_editor_api.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/imgui-node-editor/imgui_node_editor_api.cpp')
-rw-r--r--3rdparty/imgui-node-editor/imgui_node_editor_api.cpp115
1 files changed, 106 insertions, 9 deletions
diff --git a/3rdparty/imgui-node-editor/imgui_node_editor_api.cpp b/3rdparty/imgui-node-editor/imgui_node_editor_api.cpp
index d468b4e..cc6cdc0 100644
--- a/3rdparty/imgui-node-editor/imgui_node_editor_api.cpp
+++ b/3rdparty/imgui-node-editor/imgui_node_editor_api.cpp
@@ -1,4 +1,6 @@
//------------------------------------------------------------------------------
+// VERSION 0.9.1
+//
// LICENSE
// This software is dual-licensed to the public domain and under the following
// license: you are granted a perpetual, irrevocable license to copy, modify,
@@ -31,8 +33,7 @@ static int BuildIdList(C& container, I* list, int listSize, F&& accept)
{
list[count] = I(object->ID().AsPointer());
++count;
- --listSize;
- }
+ --listSize;}
}
return count;
@@ -50,12 +51,18 @@ ax::NodeEditor::EditorContext* ax::NodeEditor::CreateEditor(const Config* config
void ax::NodeEditor::DestroyEditor(EditorContext* ctx)
{
- if (GetCurrentEditor() == ctx)
- SetCurrentEditor(nullptr);
+ auto lastContext = GetCurrentEditor();
+
+ // Set context we're about to destroy as current, to give callback valid context
+ if (lastContext != ctx)
+ SetCurrentEditor(ctx);
auto editor = reinterpret_cast<ax::NodeEditor::Detail::EditorContext*>(ctx);
delete editor;
+
+ if (lastContext != ctx)
+ SetCurrentEditor(lastContext);
}
void ax::NodeEditor::SetCurrentEditor(EditorContext* ctx)
@@ -211,10 +218,10 @@ bool ax::NodeEditor::Link(LinkId id, PinId startPinId, PinId endPinId, const ImV
return s_Editor->DoLink(id, startPinId, endPinId, ImColor(color), thickness);
}
-void ax::NodeEditor::Flow(LinkId linkId)
+void ax::NodeEditor::Flow(LinkId linkId, FlowDirection direction)
{
if (auto link = s_Editor->FindLink(linkId))
- s_Editor->Flow(link);
+ s_Editor->Flow(link, direction);
}
bool ax::NodeEditor::BeginCreate(const ImVec4& color, float thickness)
@@ -341,11 +348,11 @@ bool ax::NodeEditor::QueryDeletedNode(NodeId* nodeId)
return context.QueryNode(nodeId);
}
-bool ax::NodeEditor::AcceptDeletedItem()
+bool ax::NodeEditor::AcceptDeletedItem(bool deleteDependencies)
{
auto& context = s_Editor->GetItemDeleter();
- return context.AcceptItem();
+ return context.AcceptItem(deleteDependencies);
}
void ax::NodeEditor::RejectDeletedItem()
@@ -367,6 +374,11 @@ void ax::NodeEditor::SetNodePosition(NodeId nodeId, const ImVec2& position)
s_Editor->SetNodePosition(nodeId, position);
}
+void ax::NodeEditor::SetGroupSize(NodeId nodeId, const ImVec2& size)
+{
+ s_Editor->SetGroupSize(nodeId, size);
+}
+
ImVec2 ax::NodeEditor::GetNodePosition(NodeId nodeId)
{
return s_Editor->GetNodePosition(nodeId);
@@ -383,6 +395,16 @@ void ax::NodeEditor::CenterNodeOnScreen(NodeId nodeId)
node->CenterOnScreenInNextFrame();
}
+void ax::NodeEditor::SetNodeZPosition(NodeId nodeId, float z)
+{
+ s_Editor->SetNodeZPosition(nodeId, z);
+}
+
+float ax::NodeEditor::GetNodeZPosition(NodeId nodeId)
+{
+ return s_Editor->GetNodeZPosition(nodeId);
+}
+
void ax::NodeEditor::RestoreNodeState(NodeId nodeId)
{
if (auto node = s_Editor->FindNode(nodeId))
@@ -406,7 +428,7 @@ bool ax::NodeEditor::IsSuspended()
bool ax::NodeEditor::IsActive()
{
- return s_Editor->IsActive();
+ return s_Editor->IsFocused();
}
bool ax::NodeEditor::HasSelectionChanged()
@@ -435,6 +457,22 @@ int ax::NodeEditor::GetSelectedLinks(LinkId* links, int size)
});
}
+bool ax::NodeEditor::IsNodeSelected(NodeId nodeId)
+{
+ if (auto node = s_Editor->FindNode(nodeId))
+ return s_Editor->IsSelected(node);
+ else
+ return false;
+}
+
+bool ax::NodeEditor::IsLinkSelected(LinkId linkId)
+{
+ if (auto link = s_Editor->FindLink(linkId))
+ return s_Editor->IsSelected(link);
+ else
+ return false;
+}
+
void ax::NodeEditor::ClearSelection()
{
s_Editor->ClearSelection();
@@ -490,6 +528,26 @@ bool ax::NodeEditor::DeleteLink(LinkId linkId)
return false;
}
+bool ax::NodeEditor::HasAnyLinks(NodeId nodeId)
+{
+ return s_Editor->HasAnyLinks(nodeId);
+}
+
+bool ax::NodeEditor::HasAnyLinks(PinId pinId)
+{
+ return s_Editor->HasAnyLinks(pinId);
+}
+
+int ax::NodeEditor::BreakLinks(NodeId nodeId)
+{
+ return s_Editor->BreakLinks(nodeId);
+}
+
+int ax::NodeEditor::BreakLinks(PinId pinId)
+{
+ return s_Editor->BreakLinks(pinId);
+}
+
void ax::NodeEditor::NavigateToContent(float duration)
{
s_Editor->NavigateTo(s_Editor->GetContentBounds(), true, duration);
@@ -591,6 +649,21 @@ float ax::NodeEditor::GetCurrentZoom()
return s_Editor->GetView().InvScale;
}
+ax::NodeEditor::NodeId ax::NodeEditor::GetHoveredNode()
+{
+ return s_Editor->GetHoveredNode();
+}
+
+ax::NodeEditor::PinId ax::NodeEditor::GetHoveredPin()
+{
+ return s_Editor->GetHoveredPin();
+}
+
+ax::NodeEditor::LinkId ax::NodeEditor::GetHoveredLink()
+{
+ return s_Editor->GetHoveredLink();
+}
+
ax::NodeEditor::NodeId ax::NodeEditor::GetDoubleClickedNode()
{
return s_Editor->GetDoubleClickedNode();
@@ -616,6 +689,20 @@ bool ax::NodeEditor::IsBackgroundDoubleClicked()
return s_Editor->IsBackgroundDoubleClicked();
}
+bool ax::NodeEditor::GetLinkPins(LinkId linkId, PinId* startPinId, PinId* endPinId)
+{
+ auto link = s_Editor->FindLink(linkId);
+ if (!link)
+ return false;
+
+ if (startPinId)
+ *startPinId = link->m_StartPin->m_ID;
+ if (endPinId)
+ *endPinId = link->m_EndPin->m_ID;
+
+ return true;
+}
+
bool ax::NodeEditor::PinHadAnyLinks(PinId pinId)
{
return s_Editor->PinHadAnyLinks(pinId);
@@ -635,3 +722,13 @@ ImVec2 ax::NodeEditor::CanvasToScreen(const ImVec2& pos)
{
return s_Editor->ToScreen(pos);
}
+
+int ax::NodeEditor::GetNodeCount()
+{
+ return s_Editor->CountLiveNodes();
+}
+
+int ax::NodeEditor::GetOrderedNodeIds(NodeId* nodes, int size)
+{
+ return s_Editor->GetNodeIds(nodes, size);
+}