[Bf-blender-cvs] [3648b3f9165] master: Cleanup: remove duplicate color picker operator

Campbell Barton noreply at git.blender.org
Thu Jan 17 05:28:47 CET 2019


Commit: 3648b3f9165a096cf4204bb9ad082e62cc714c90
Author: Campbell Barton
Date:   Thu Jan 17 15:27:24 2019 +1100
Branches: master
https://developer.blender.org/rB3648b3f9165a096cf4204bb9ad082e62cc714c90

Cleanup: remove duplicate color picker operator

Use internal boolean option to disable accumulation for crypto-matte.

===================================================================

M	source/blender/editors/interface/interface_eyedropper.c
M	source/blender/editors/interface/interface_eyedropper_color.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_ops.c
M	source/blender/editors/interface/interface_templates.c

===================================================================

diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 3a799c6e7db..4567440b8ac 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -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");
diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c
index 8e80d5657d7..141870905b3 100644
--- a/source/blender/editors/interface/interface_eyedropper_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_color.c
@@ -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;
+	/* properties */
+	PropertyRNA *prop;
 
-	/* flags */
-	ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
+	/* 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);
 }
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 20671ae8162..1c361be1b3d 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -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);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 31ae3bc7b4b..051e7c9fb01 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -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);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index ed3e2e863b7..5aaad34874e 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -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 ************************/



More information about the Bf-blender-cvs mailing list