diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-17 08:39:38 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-17 08:39:38 +0300 |
commit | c8e75c2b00cfb7e87bcb800c9acc8f126949749d (patch) | |
tree | 30dd08449c059cdc72d37b10359350b20c328860 /source/blender/editors/interface/interface_eyedropper_depth.c | |
parent | 4a3aac478ce0dd16faea52d224d9a8024cd9ee57 (diff) |
Fix T60554: Missing undo push changing color
Operators don't have a good way to skip undo,
for now check the button undo flag & return cancelled.
Diffstat (limited to 'source/blender/editors/interface/interface_eyedropper_depth.c')
-rw-r--r-- | source/blender/editors/interface/interface_eyedropper_depth.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index 49788c7cecf..4d0a95a6bbd 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -67,6 +67,7 @@ typedef struct DepthDropper { PointerRNA ptr; PropertyRNA *prop; + bool is_undo; float init_depth; /* for resetting on cancel */ @@ -99,7 +100,7 @@ static int depthdropper_init(bContext *C, wmOperator *op) DepthDropper *ddr = MEM_callocN(sizeof(DepthDropper), __func__); - UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &index_dummy); + uiBut *but = UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &index_dummy); /* fallback to the active camera's dof */ if (ddr->prop == NULL) { @@ -123,6 +124,8 @@ static int depthdropper_init(bContext *C, wmOperator *op) } op->customdata = ddr; + ddr->is_undo = UI_but_flag_is_set(but, UI_BUT_UNDO); + ddr->art = art; ddr->draw_handle_pixel = ED_region_draw_cb_activate(art, depthdropper_draw_cb, ddr, REGION_DRAW_POST_PIXEL); ddr->init_depth = RNA_property_float_get(&ddr->ptr, ddr->prop); @@ -268,6 +271,8 @@ static int depthdropper_modal(bContext *C, wmOperator *op, const wmEvent *event) depthdropper_cancel(C, op); return OPERATOR_CANCELLED; case EYE_MODAL_SAMPLE_CONFIRM: + { + const bool is_undo = ddr->is_undo; if (ddr->accum_tot == 0) { depthdropper_depth_sample(C, ddr, event->x, event->y); } @@ -275,7 +280,9 @@ static int depthdropper_modal(bContext *C, wmOperator *op, const wmEvent *event) depthdropper_depth_set_accum(C, ddr); } depthdropper_exit(C, op); - return OPERATOR_FINISHED; + /* Could support finished & undo-skip. */ + return is_undo ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + } case EYE_MODAL_SAMPLE_BEGIN: /* enable accum and make first sample */ ddr->accum_start = true; @@ -380,7 +387,7 @@ void UI_OT_eyedropper_depth(wmOperatorType *ot) ot->poll = depthdropper_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; + ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_INTERNAL; /* properties */ } |