Browse Source

node editor: dragging!

master
gradient 8 years ago
parent
commit
4018c021b0
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      src/gui/node_editor.h

+ 8
- 1
src/gui/node_editor.h View File

@ -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;


Loading…
Cancel
Save