Node Editor: node resize can now be cancelled, like other operators
Differential Revision: https://developer.blender.org/D6800
This commit is contained in:
parent
4aa0e2136c
commit
63de813914
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue