Added custom imgui-node-editor changes.

This commit is contained in:
Martin Felis 2025-03-16 22:59:05 +01:00
parent 07d02a2e42
commit 1870a9d214
6 changed files with 28 additions and 8 deletions

View File

@ -929,7 +929,8 @@ struct Example:
{
auto cursorTopLeft = ImGui::GetCursorScreenPos();
util::BlueprintNodeBuilder builder(m_HeaderBackground, GetTextureWidth(m_HeaderBackground), GetTextureHeight(m_HeaderBackground));
// util::BlueprintNodeBuilder builder(m_HeaderBackground, GetTextureWidth(m_HeaderBackground), GetTextureHeight(m_HeaderBackground));
util::BlueprintNodeBuilder builder;
for (auto& node : m_Nodes)
{
@ -1832,4 +1833,4 @@ int Main(int argc, char** argv)
return exampe.Run();
return 0;
}
}

View File

@ -11,7 +11,7 @@
//------------------------------------------------------------------------------
# include <imgui_node_editor.h>
# include "3rdparty/imgui-node-editor/imgui_node_editor.h"
//------------------------------------------------------------------------------

View File

@ -1256,6 +1256,9 @@ void ed::EditorContext::End()
auto control = BuildControl(m_CurrentAction && m_CurrentAction->IsDragging()); // NavigateAction.IsMovingOverEdge()
//auto& editorStyle = GetStyle();
// martin.felis, 2024-05-01, Start: expose Hot Node
m_HotNode = control.HotNode ? control.HotNode->m_ID : 0;
// martin.felis, 2024-05-01, End: expose Hot Node
m_HoveredNode = control.HotNode && m_CurrentAction == nullptr ? control.HotNode->m_ID : 0;
m_HoveredPin = control.HotPin && m_CurrentAction == nullptr ? control.HotPin->m_ID : 0;
m_HoveredLink = control.HotLink && m_CurrentAction == nullptr ? control.HotLink->m_ID : 0;
@ -4391,15 +4394,15 @@ ed::EditorAction::AcceptResult ed::ShortcutAction::Accept(const Control& control
Action candidateAction = None;
auto& io = ImGui::GetIO();
if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_X)))
if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_X))
candidateAction = Cut;
if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C)))
if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_C))
candidateAction = Copy;
if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_V)))
if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_V))
candidateAction = Paste;
if (io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(GetKeyIndexForD()))
candidateAction = Duplicate;
if (!io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space)))
if (!io.KeyCtrl && !io.KeyShift && !io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_Space))
candidateAction = CreateNode;
if (candidateAction != None)
@ -4953,7 +4956,7 @@ ed::EditorAction::AcceptResult ed::DeleteItemsAction::Accept(const Control& cont
return False;
auto& io = ImGui::GetIO();
if (Editor->CanAcceptUserInput() && ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Delete)) && Editor->AreShortcutsEnabled())
if (Editor->CanAcceptUserInput() && ImGui::IsKeyPressed(ImGuiKey_Delete) && Editor->AreShortcutsEnabled())
{
auto& selection = Editor->GetSelectedObjects();
if (!selection.empty())

View File

@ -409,6 +409,9 @@ IMGUI_NODE_EDITOR_API void EndShortcut();
IMGUI_NODE_EDITOR_API float GetCurrentZoom();
// martin.felis, 2024-05-01, Start: expose Hot Node
IMGUI_NODE_EDITOR_API NodeId GetHotNode();
// martin.felis, 2024-05-01, Stop: expose Hot Node
IMGUI_NODE_EDITOR_API NodeId GetHoveredNode();
IMGUI_NODE_EDITOR_API PinId GetHoveredPin();
IMGUI_NODE_EDITOR_API LinkId GetHoveredLink();

View File

@ -667,6 +667,13 @@ float ax::NodeEditor::GetCurrentZoom()
return s_Editor->GetView().InvScale;
}
// martin.felis, 2024-05-01, Start: expose Hot Node
ax::NodeEditor::NodeId ax::NodeEditor::GetHotNode()
{
return s_Editor->GetHotNode();
}
// martin.felis, 2024-05-01, End: expose Hot Node
ax::NodeEditor::NodeId ax::NodeEditor::GetHoveredNode()
{
return s_Editor->GetHoveredNode();

View File

@ -1447,6 +1447,9 @@ struct EditorContext
void EnableShortcuts(bool enable);
bool AreShortcutsEnabled();
// martin.felis, 2024-05-01, Start: expose Hot Node
NodeId GetHotNode() const { return m_HotNode; }
// martin.felis, 2024-05-01, End: expose Hot Node
NodeId GetHoveredNode() const { return m_HoveredNode; }
PinId GetHoveredPin() const { return m_HoveredPin; }
LinkId GetHoveredLink() const { return m_HoveredLink; }
@ -1528,6 +1531,9 @@ private:
vector<AnimationController*> m_AnimationControllers;
FlowAnimationController m_FlowAnimationController;
// martin.felis, 2024-05-01, Start: expose Hot Node
NodeId m_HotNode;
// martin.felis, 2024-05-01, End: expose Hot Node
NodeId m_HoveredNode;
PinId m_HoveredPin;
LinkId m_HoveredLink;