Skip to content

Commit

Permalink
Editor: Make selection rect start at click point
Browse files Browse the repository at this point in the history
  • Loading branch information
thedmd committed Aug 21, 2022
1 parent 09ce80d commit 345becf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,4 @@ v0.9.1 (WIP):

BUGFIX: Editor: Improve link dragging with fast movement (#156)

BUGFIX: Editor: Make selection rect start at click point
2 changes: 1 addition & 1 deletion imgui_node_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3917,7 +3917,7 @@ ed::EditorAction::AcceptResult ed::SelectAction::Accept(const Control& control)
if (Editor->CanAcceptUserInput() && control.BackgroundHot && ImGui::IsMouseDragging(Editor->GetConfig().SelectButtonIndex, 1))
{
m_IsActive = true;
m_StartPoint = ImGui::GetMousePos();
m_StartPoint = ImGui_GetMouseClickPos(Editor->GetConfig().SelectButtonIndex);
m_EndPoint = m_StartPoint;

// Links and nodes cannot be selected together
Expand Down
1 change: 1 addition & 0 deletions imgui_node_editor_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void Log(const char* fmt, ...);
//inline ImRect ToRect(const ax::rectf& rect);
//inline ImRect ToRect(const ax::rect& rect);
inline ImRect ImGui_GetItemRect();
inline ImVec2 ImGui_GetMouseClickPos(ImGuiMouseButton buttonIndex);


//------------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions imgui_node_editor_internal.inl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ inline ImRect ImGui_GetItemRect()
return ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax());
}

inline ImVec2 ImGui_GetMouseClickPos(ImGuiMouseButton buttonIndex)
{
if (ImGui::IsMouseDown(buttonIndex))
return ImGui::GetIO().MouseClickedPos[buttonIndex];
else
return ImGui::GetMousePos();
}


//------------------------------------------------------------------------------
} // namespace Detail
Expand Down

0 comments on commit 345becf

Please sign in to comment.