Cleanup: remove duplicate color picker operator

Use internal boolean option to disable accumulation for crypto-matte.
This commit is contained in:
2019-01-17 15:27:24 +11:00
parent b6854770c7
commit 3648b3f916
5 changed files with 17 additions and 25 deletions

View File

@@ -73,7 +73,6 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf)
/* assign to operators */
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_colorband");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color_crypto");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_id");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_depth");
WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_driver");

View File

@@ -53,6 +53,8 @@
#include "WM_api.h"
#include "WM_types.h"
#include "RNA_define.h"
#include "interface_intern.h"
#include "ED_image.h"
@@ -74,7 +76,7 @@ typedef struct Eyedropper {
float accum_col[3];
int accum_tot;
bool accumulate; /* Color picking for cryptomatte, without accumulation. */
bool use_accum;
} Eyedropper;
static bool eyedropper_init(bContext *C, wmOperator *op)
@@ -83,7 +85,7 @@ static bool eyedropper_init(bContext *C, wmOperator *op)
Eyedropper *eye;
op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper");
eye->accumulate = !STREQ(op->type->idname, "UI_OT_eyedropper_color_crypto");
eye->use_accum = RNA_boolean_get(op->ptr, "use_accumulate");
UI_context_active_but_prop_get(C, &eye->ptr, &eye->prop, &eye->index);
@@ -217,7 +219,7 @@ static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my
float col[3];
eyedropper_color_sample_fl(C, mx, my, col);
if (eye->accumulate) {
if (eye->use_accum) {
add_v3_v3(eye->accum_col, col);
eye->accum_tot++;
}
@@ -342,22 +344,11 @@ void UI_OT_eyedropper_color(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
}
void UI_OT_eyedropper_color_crypto(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Cryptomatte Eyedropper";
ot->idname = "UI_OT_eyedropper_color_crypto";
ot->description = "Pick a color from Cryptomatte node Pick output image";
/* api callbacks */
ot->invoke = eyedropper_invoke;
ot->modal = eyedropper_modal;
ot->cancel = eyedropper_cancel;
ot->exec = eyedropper_exec;
ot->poll = eyedropper_poll;
/* flags */
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
/* properties */
PropertyRNA *prop;
/* Needed for color picking with crypto-matte. */
prop = RNA_def_boolean(ot->srna, "use_accumulate", true, "Accumulate", "");
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}

View File

@@ -872,7 +872,6 @@ struct wmKeyMap *eyedropper_colorband_modal_keymap(struct wmKeyConfig *keyconf);
/* interface_eyedropper_color.c */
void UI_OT_eyedropper_color(struct wmOperatorType *ot);
void UI_OT_eyedropper_color_crypto(struct wmOperatorType *ot);
/* interface_eyedropper_colorband.c */
void UI_OT_eyedropper_colorband(struct wmOperatorType *ot);

View File

@@ -1630,7 +1630,6 @@ void ED_operatortypes_ui(void)
/* external */
WM_operatortype_append(UI_OT_eyedropper_color);
WM_operatortype_append(UI_OT_eyedropper_color_crypto);
WM_operatortype_append(UI_OT_eyedropper_colorband);
WM_operatortype_append(UI_OT_eyedropper_colorband_point);
WM_operatortype_append(UI_OT_eyedropper_id);

View File

@@ -3464,10 +3464,14 @@ void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propn
block = uiLayoutGetBlock(layout);
but = uiDefIconTextButO(block, UI_BTYPE_BUT, "UI_OT_eyedropper_color_crypto", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, RNA_property_ui_name(prop), 0, 0, UI_UNIT_X, UI_UNIT_Y, RNA_property_ui_description(prop));
but = uiDefIconTextButO(block, UI_BTYPE_BUT, "UI_OT_eyedropper_color", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, RNA_property_ui_name(prop), 0, 0, UI_UNIT_X, UI_UNIT_Y, RNA_property_ui_description(prop));
but->rnapoin = *ptr;
but->rnaprop = prop;
but->rnaindex = -1;
PointerRNA *opptr = UI_but_operator_ptr_get(but);
/* Important for crypto-matte operation. */
RNA_boolean_set(opptr, "use_accumulate", false);
}
/********************* Layer Buttons Template ************************/