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

Differential Revision: https://developer.blender.org/D6800
This commit is contained in:
Matthias Ellerbeck 2020-02-11 15:29:24 +01:00 committed by Brecht Van Lommel
parent 4aa0e2136c
commit 63de813914
1 changed files with 21 additions and 1 deletions

View File

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