Skip to content

Commit

Permalink
Editor: Ensure CreateItemAction is not activated fom invalid state, t…
Browse files Browse the repository at this point in the history
…hanks @pthom
  • Loading branch information
thedmd committed Sep 1, 2023
1 parent df1d2af commit 6e1cade
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ v0.9.2 (WIP):

CHANGE: Editor: Unary operator- for ImVec2 is defined by ImGui since r18955 (#248)

CHANGE: Editor: Ensure CreateItemAction is not activated fom invalid state, thanks @pthom

BUGFIX: Editor: Correctly initialize 'width' for view resize code (thx @gnif)

BUGFIX: Examples: Handle node deletion before links (#182)
Expand All @@ -45,6 +47,8 @@ v0.9.2 (WIP):

BUGFIX: Editor: Don't call Canvas.End() when Canvas.Begin() failed (#186), thanks @pthom, @TheZoc

BUGFIX: Examples: Call ed::EndCreate() and ed::EndDelete() only when ed::BeginCreate() and ed::BeginDelete() returned true


v0.9.1 (2022-08-27):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ struct Example:
// visual feedback by changing link thickness and color.
}
}
ed::EndCreate(); // Wraps up object creation action handling.
}
ed::EndCreate(); // Wraps up object creation action handling.


// Handle deletion action
Expand All @@ -181,9 +181,8 @@ struct Example:
// You may reject link deletion by calling:
// ed::RejectDeletedItem();
}
ed::EndDelete(); // Wrap up deletion action
}
ed::EndDelete(); // Wrap up deletion action



// End of interaction with editor.
Expand Down
7 changes: 4 additions & 3 deletions examples/blueprints-example/blueprints-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1543,12 +1543,12 @@ struct Example:
ed::Resume();
}
}

ed::EndCreate();
}
else
newLinkPin = nullptr;

ed::EndCreate();

if (ed::BeginDelete())
{
ed::NodeId nodeId = 0;
Expand All @@ -1572,8 +1572,9 @@ struct Example:
m_Links.erase(id);
}
}

ed::EndDelete();
}
ed::EndDelete();
}

ImGui::SetCursorScreenPos(cursorTopLeft);
Expand Down
4 changes: 2 additions & 2 deletions examples/widgets-example/widgets-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,8 @@ struct Example:
}
}
}
ed::EndCreate();
}
ed::EndCreate();

// Handle deletion action ---------------------------------------------------------------------------
if (ed::BeginDelete())
Expand All @@ -405,8 +405,8 @@ struct Example:
}
}
}
ed::EndDelete();
}
ed::EndDelete();

ed::End();
ed::SetCurrentEditor(nullptr);
Expand Down
8 changes: 4 additions & 4 deletions imgui_node_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4709,23 +4709,23 @@ bool ed::CreateItemAction::Begin()
{
IM_ASSERT(false == m_InActive);

if (m_NextStage == None)
return false;

m_InActive = true;
m_CurrentStage = m_NextStage;
m_UserAction = Unknown;
m_LinkColor = IM_COL32_WHITE;
m_LinkThickness = 1.0f;

if (m_CurrentStage == None)
return false;

m_LastChannel = Editor->GetDrawList()->_Splitter._Current;

return true;
}

void ed::CreateItemAction::End()
{
IM_ASSERT(m_InActive);
IM_ASSERT(m_InActive && "Please call End() only when Begin() was successful");

if (m_IsInGlobalSpace)
{
Expand Down

0 comments on commit 6e1cade

Please sign in to comment.