From 2e4740361b7bddb924807f6d5be64818b72bf15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Tue, 30 Apr 2024 17:41:45 +0200 Subject: [PATCH 1/2] std::terminate lives in header --- crude_json.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/crude_json.cpp b/crude_json.cpp index 078427a2..a30fc65f 100644 --- a/crude_json.cpp +++ b/crude_json.cpp @@ -12,6 +12,7 @@ # include "crude_json.h" # include # include +# include # include # include # include From e1a4cf22a73a6ca8e15b2ab4602ac5870afb7b5d Mon Sep 17 00:00:00 2001 From: Daniel Nicoletti Date: Thu, 1 May 2025 18:36:52 -0300 Subject: [PATCH 2/2] Store information wheter a node was positioned by the user Signed-off-by: Daniel Nicoletti --- imgui_node_editor.cpp | 3 +++ imgui_node_editor.h | 2 +- imgui_node_editor_api.cpp | 8 ++++++++ imgui_node_editor_internal.h | 2 ++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/imgui_node_editor.cpp b/imgui_node_editor.cpp index 1d2bb060..3de0d44b 100644 --- a/imgui_node_editor.cpp +++ b/imgui_node_editor.cpp @@ -635,10 +635,12 @@ void ed::Node::UpdateDrag(const ImVec2& offset) auto size = m_Bounds.GetSize(); m_Bounds.Min = ImFloor(m_DragStart + offset); m_Bounds.Max = m_Bounds.Min + size; + m_userPositioned = m_Bounds.Min != m_DragStart; } bool ed::Node::EndDrag() { + m_userPositioned = m_Bounds.Min != m_DragStart; return m_Bounds.Min != m_DragStart; } @@ -1647,6 +1649,7 @@ void ed::EditorContext::SetNodePosition(NodeId nodeId, const ImVec2& position) if (node->m_Bounds.Min != position) { + node->m_userPositioned = false; node->m_Bounds.Translate(position - node->m_Bounds.Min); node->m_Bounds.Floor(); MakeDirty(NodeEditor::SaveReasonFlags::Position, node); diff --git a/imgui_node_editor.h b/imgui_node_editor.h index c79f41ad..225638fc 100644 --- a/imgui_node_editor.h +++ b/imgui_node_editor.h @@ -431,7 +431,7 @@ IMGUI_NODE_EDITOR_API ImVec2 CanvasToScreen(const ImVec2& pos); IMGUI_NODE_EDITOR_API int GetNodeCount(); // Returns number of submitted nodes since Begin() call IMGUI_NODE_EDITOR_API int GetOrderedNodeIds(NodeId* nodes, int size); // Fills an array with node id's in order they're drawn; up to 'size` elements are set. Returns actual size of filled id's. - +IMGUI_NODE_EDITOR_API bool GetWasUserPositioned(NodeId node); diff --git a/imgui_node_editor_api.cpp b/imgui_node_editor_api.cpp index c8c7c3ff..ffd37a8c 100644 --- a/imgui_node_editor_api.cpp +++ b/imgui_node_editor_api.cpp @@ -760,3 +760,11 @@ int ax::NodeEditor::GetOrderedNodeIds(NodeId* nodes, int size) { return s_Editor->GetNodeIds(nodes, size); } + +bool ax::NodeEditor::GetWasUserPositioned(ax::NodeEditor::NodeId nodeId) +{ + if (auto node = s_Editor->FindNode(nodeId)) { + return node->m_userPositioned; + } + return false; +} diff --git a/imgui_node_editor_internal.h b/imgui_node_editor_internal.h index 0d018cf5..e057d8bb 100644 --- a/imgui_node_editor_internal.h +++ b/imgui_node_editor_internal.h @@ -404,6 +404,7 @@ struct Node final: Object bool m_RestoreState; bool m_CenterOnScreen; + bool m_userPositioned; Node(EditorContext* editor, NodeId id) : Object(editor) @@ -422,6 +423,7 @@ struct Node final: Object , m_HighlightConnectedLinks(false) , m_RestoreState(false) , m_CenterOnScreen(false) + , m_userPositioned(false) { }