[Bf-blender-cvs] [63de8139149] master: Node Editor: node resize can now be cancelled, like other operators

Matthias Ellerbeck noreply at git.blender.org
Tue Feb 11 15:34:52 CET 2020


Commit: 63de8139149e2074c11d474823b566c15824aa59
Author: Matthias Ellerbeck
Date:   Tue Feb 11 15:29:24 2020 +0100
Branches: master
https://developer.blender.org/rB63de8139149e2074c11d474823b566c15824aa59

Node Editor: node resize can now be cancelled, like other operators

Differential Revision: https://developer.blender.org/D6800

===================================================================

M	source/blender/editors/space_node/node_edit.c

===================================================================

diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 9fba78682dc..21e68c0b600 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -895,10 +895,24 @@ static void node_resize_init(
   WM_event_add_modal_handler(C, op);
 }
 
-static void node_resize_exit(bContext *C, wmOperator *op, bool UNUSED(cancel))
+static void node_resize_exit(bContext *C, wmOperator *op, bool cancel)
 {
   WM_cursor_modal_restore(CTX_wm_window(C));
 
+  /* Restore old data on cancel. */
+  if (cancel) {
+    SpaceNode *snode = CTX_wm_space_node(C);
+    bNode *node = nodeGetActive(snode->edittree);
+    NodeSizeWidget *nsw = op->customdata;
+
+    node->locx = nsw->oldlocx;
+    node->locy = nsw->oldlocy;
+    node->offsetx = nsw->oldoffsetx;
+    node->offsety = nsw->oldoffsety;
+    node->width = nsw->oldwidth;
+    node->height = nsw->oldheight;
+  }
+
   MEM_freeN(op->customdata);
   op->customdata = NULL;
 }
@@ -993,6 +1007,12 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
         return OPERATOR_FINISHED;
       }
+      else if (event->val == KM_PRESS) {
+        node_resize_exit(C, op, true);
+        ED_region_tag_redraw(ar);
+
+        return OPERATOR_CANCELLED;
+      }
       break;
   }



More information about the Bf-blender-cvs mailing list