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_colorband.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_colorband.c')
-rw-r--r-- | source/blender/editors/interface/interface_eyedropper_colorband.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_eyedropper_colorband.c b/source/blender/editors/interface/interface_eyedropper_colorband.c index 262aed77b37..dd4524c9066 100644 --- a/source/blender/editors/interface/interface_eyedropper_colorband.c +++ b/source/blender/editors/interface/interface_eyedropper_colorband.c @@ -72,6 +72,7 @@ typedef struct EyedropperColorband { ColorBand *color_band; PointerRNA ptr; PropertyRNA *prop; + bool is_undo; } EyedropperColorband; /* For user-data only. */ @@ -110,6 +111,7 @@ static bool eyedropper_colorband_init(bContext *C, wmOperator *op) eye->init_color_band = *eye->color_band; eye->ptr = ((Colorband_RNAUpdateCb *)but->func_argN)->ptr; eye->prop = ((Colorband_RNAUpdateCb *)but->func_argN)->prop; + eye->is_undo = UI_but_flag_is_set(but, UI_BUT_UNDO); op->customdata = eye; @@ -192,10 +194,14 @@ static int eyedropper_colorband_modal(bContext *C, wmOperator *op, const wmEvent eyedropper_colorband_cancel(C, op); return OPERATOR_CANCELLED; case EYE_MODAL_SAMPLE_CONFIRM: + { + const bool is_undo = eye->is_undo; eyedropper_colorband_sample_segment(C, eye, event->x, event->y); eyedropper_colorband_apply(C, op); eyedropper_colorband_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 */ eye->sample_start = true; @@ -312,7 +318,7 @@ void UI_OT_eyedropper_colorband(wmOperatorType *ot) ot->poll = eyedropper_colorband_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; + ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_INTERNAL; /* properties */ } @@ -332,7 +338,7 @@ void UI_OT_eyedropper_colorband_point(wmOperatorType *ot) ot->poll = eyedropper_colorband_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; + ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_INTERNAL; /* properties */ } |