From 4018c021b02a8fd75ccc19199d7e58a1b734f236 Mon Sep 17 00:00:00 2001 From: gradient Date: Fri, 20 Oct 2017 18:53:25 -0500 Subject: [PATCH] node editor: dragging! --- src/gui/node_editor.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/node_editor.h b/src/gui/node_editor.h index aec44f8..e98e5d0 100644 --- a/src/gui/node_editor.h +++ b/src/gui/node_editor.h @@ -119,7 +119,7 @@ public: Rect viewportRect = Rect(scrolling, canvas_size); - for (const auto &node : nodeList) { + for (auto &node : nodeList) { bool visible = viewportRect.intersects(node.bbox); if (visible) { // TODO: this is garbage @@ -128,6 +128,13 @@ public: // -- Draw the node boxes draw_list->ChannelsSetCurrent(0); // Switch to the background layer + // draw an invisible button in the background, for dragging/hovering + ImGui::SetCursorScreenPos(offset + node.bbox.pos); + ImGui::InvisibleButton("node", node.bbox.size); + + if (ImGui::IsItemActive() && ImGui::IsMouseDragging(0)) + node.bbox.pos += ImGui::GetIO().MouseDelta; + ImVec2 upper_left = offset + node.bbox.pos; ImVec2 lower_right = upper_left + node.bbox.size;