Fix T97465: Moving compositor BG image cannot be cancelled
This was possible with the gizmo, but no using the operator (e.g. from the sidebar). Now store original offsets and reset to these on calcel (ESC or RMB). Maniphest Tasks: T97465 Differential Revision: https://developer.blender.org/D14704
This commit is contained in:
parent
01333cb47f
commit
298e9c7ebd
Notes:
blender-bot
2023-02-13 22:37:44 +01:00
Referenced by issue #97465, Cannot stop moving background image with escape in Compositor
|
@ -179,6 +179,8 @@ void NODE_OT_view_selected(wmOperatorType *ot)
|
|||
struct NodeViewMove {
|
||||
int mvalo[2];
|
||||
int xmin, ymin, xmax, ymax;
|
||||
/** Original Offset for cancel. */
|
||||
float xof_orig, yof_orig;
|
||||
};
|
||||
|
||||
static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
|
@ -207,13 +209,25 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e
|
|||
|
||||
case LEFTMOUSE:
|
||||
case MIDDLEMOUSE:
|
||||
case RIGHTMOUSE:
|
||||
if (event->val == KM_RELEASE) {
|
||||
MEM_freeN(nvm);
|
||||
op->customdata = nullptr;
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
break;
|
||||
case EVT_ESCKEY:
|
||||
case RIGHTMOUSE:
|
||||
snode->xof = nvm->xof_orig;
|
||||
snode->yof = nvm->yof_orig;
|
||||
ED_region_tag_redraw(region);
|
||||
WM_main_add_notifier(NC_NODE | ND_DISPLAY, nullptr);
|
||||
WM_main_add_notifier(NC_SPACE | ND_SPACE_NODE_VIEW, nullptr);
|
||||
|
||||
MEM_freeN(nvm);
|
||||
op->customdata = nullptr;
|
||||
|
||||
return OPERATOR_CANCELLED;
|
||||
break;
|
||||
}
|
||||
|
||||
return OPERATOR_RUNNING_MODAL;
|
||||
|
@ -249,6 +263,9 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
|
|||
nvm->ymin = -(region->winy / 2) - (ibuf->y * (0.5f * snode->zoom)) + pad;
|
||||
nvm->ymax = (region->winy / 2) + (ibuf->y * (0.5f * snode->zoom)) - pad;
|
||||
|
||||
nvm->xof_orig = snode->xof;
|
||||
nvm->yof_orig = snode->yof;
|
||||
|
||||
BKE_image_release_ibuf(ima, ibuf, lock);
|
||||
|
||||
/* add modal handler */
|
||||
|
|
Loading…
Reference in New Issue