Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions imgui_node_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@
static bool const value = sizeof(test<T>(0)) == sizeof(yes); \
};

// LOCAL NAMESPACE TO DEFINE FLOOR FUNCTION, deprecated in imgui
namespace {
void FloorRect(ImRect & rect)
{
rect.Min.x = IM_TRUNC(rect.Min.x);
rect.Min.y = IM_TRUNC(rect.Min.y);
rect.Max.x = IM_TRUNC(rect.Max.x);
rect.Max.y = IM_TRUNC(rect.Max.y);
}
}
namespace ImGui {
ImGuiKey GetKeyIndex(ImGuiKey key)
{
IM_ASSERT(IsNamedKey(key));
return key; // already the correct 'index' in modern ImGui
}
}



namespace ax {
namespace NodeEditor {
Expand Down Expand Up @@ -1648,7 +1667,7 @@ void ed::EditorContext::SetNodePosition(NodeId nodeId, const ImVec2& position)
if (node->m_Bounds.Min != position)
{
node->m_Bounds.Translate(position - node->m_Bounds.Min);
node->m_Bounds.Floor();
FloorRect(node->m_Bounds);
MakeDirty(NodeEditor::SaveReasonFlags::Position, node);
}
}
Expand All @@ -1668,7 +1687,7 @@ void ed::EditorContext::SetGroupSize(NodeId nodeId, const ImVec2& size)
{
node->m_GroupBounds.Min = node->m_Bounds.Min;
node->m_GroupBounds.Max = node->m_Bounds.Min + size;
node->m_GroupBounds.Floor();
FloorRect(node->m_GroupBounds);
MakeDirty(NodeEditor::SaveReasonFlags::Size, node);
}
}
Expand Down Expand Up @@ -1746,10 +1765,10 @@ void ed::EditorContext::UpdateNodeState(Node* node)

node->m_Bounds.Min = settings->m_Location;
node->m_Bounds.Max = node->m_Bounds.Min + settings->m_Size;
node->m_Bounds.Floor();
FloorRect(node->m_Bounds);
node->m_GroupBounds.Min = settings->m_Location;
node->m_GroupBounds.Max = node->m_GroupBounds.Min + settings->m_GroupSize;
node->m_GroupBounds.Floor();
FloorRect(node->m_GroupBounds);
}

void ed::EditorContext::RemoveSettings(Object* object)
Expand Down Expand Up @@ -3799,7 +3818,7 @@ bool ed::SizeAction::Process(const Control& control)
if ((m_Pivot & NodeRegion::Right) == NodeRegion::Right)
newBounds.Max.x = ImMax(newBounds.Min.x + minimumSize.x, Editor->AlignPointToGrid(newBounds.Max.x + dragOffset.x));

newBounds.Floor();
FloorRect(newBounds);

m_LastSize = newBounds.GetSize();

Expand Down Expand Up @@ -5309,7 +5328,7 @@ void ed::NodeBuilder::End()
ImGui::EndGroup();

m_NodeRect = ImGui_GetItemRect();
m_NodeRect.Floor();
FloorRect(m_NodeRect);

if (m_CurrentNode->m_Bounds.GetSize() != m_NodeRect.GetSize())
{
Expand Down Expand Up @@ -5417,7 +5436,7 @@ void ed::NodeBuilder::PinRect(const ImVec2& a, const ImVec2& b)
IM_ASSERT(nullptr != m_CurrentPin);

m_CurrentPin->m_Bounds = ImRect(a, b);
m_CurrentPin->m_Bounds.Floor();
FloorRect(m_CurrentPin->m_Bounds);
m_ResolvePinRect = false;
}

Expand Down Expand Up @@ -5467,7 +5486,7 @@ void ed::NodeBuilder::Group(const ImVec2& size)
ImGui::Dummy(size);

m_GroupBounds = ImGui_GetItemRect();
m_GroupBounds.Floor();
FloorRect(m_GroupBounds);
}

ImDrawList* ed::NodeBuilder::GetUserBackgroundDrawList() const
Expand Down