[Bf-blender-cvs] [ab5be294cec] blender2.8: Manipulator: split alpha out of color property

Campbell Barton noreply at git.blender.org
Mon Jul 17 06:57:54 CEST 2017


Commit: ab5be294cec70d48ca73405f6c1641d0007035df
Author: Campbell Barton
Date:   Mon Jul 17 15:06:18 2017 +1000
Branches: blender2.8
https://developer.blender.org/rBab5be294cec70d48ca73405f6c1641d0007035df

Manipulator: split alpha out of color property

Gives more convenient access from Python: `mathutils.Color`

Also correct some copy-paste error w/ property subtypes.

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

M	release/scripts/templates_py/manipulator_operator.py
M	release/scripts/templates_py/manipulator_operator_target.py
M	release/scripts/templates_py/manipulator_simple.py
M	source/blender/makesrna/intern/rna_wm_manipulator.c

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

diff --git a/release/scripts/templates_py/manipulator_operator.py b/release/scripts/templates_py/manipulator_operator.py
index 0ba871bea84..00b24736b8e 100644
--- a/release/scripts/templates_py/manipulator_operator.py
+++ b/release/scripts/templates_py/manipulator_operator.py
@@ -130,8 +130,12 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
 
         mpr.use_draw_value = True
 
-        mpr.color = 0.8, 0.8, 0.8, 0.5
-        mpr.color_highlight = 1.0, 1.0, 1.0, 1.0
+        mpr.color = 0.8, 0.8, 0.8
+        mpr.alpha = 0.5
+
+        mpr.color_highlight = 1.0, 1.0, 1.0
+        mpr.alpha_highlight = 1.0
+
         mpr.scale_basis = 0.2
 
         self.widget_grab = mpr
@@ -162,8 +166,11 @@ class SelectSideOfPlaneManipulatorGroup(ManipulatorGroup):
 
         mpr.use_draw_value = True
 
-        mpr.color = 0.8, 0.8, 0.8, 0.5
+        mpr.color = 0.8, 0.8, 0.8
+        mpr.alpha = 0.5
+
         mpr.color_highlight = 1.0, 1.0, 1.0, 1.0
+        mpr.alpha_highlight = 1.0
 
         self.widget_dial = mpr
 
diff --git a/release/scripts/templates_py/manipulator_operator_target.py b/release/scripts/templates_py/manipulator_operator_target.py
index eafe8b1a863..0abf6f2f654 100644
--- a/release/scripts/templates_py/manipulator_operator_target.py
+++ b/release/scripts/templates_py/manipulator_operator_target.py
@@ -32,8 +32,11 @@ class MyCameraWidgetGroup(ManipulatorGroup):
         mpr.matrix_basis = ob.matrix_world.normalized()
         mpr.line_width = 3
 
-        mpr.color = 0.8, 0.8, 0.8, 0.5
-        mpr.color_highlight = 1.0, 1.0, 1.0, 1.0
+        mpr.color = 0.8, 0.8, 0.8
+        mpr.alpha = 0.5
+
+        mpr.color_highlight = 1.0, 1.0, 1.0
+        mpr.alpha_highlight = 1.0
 
         self.roll_widget = mpr
 
diff --git a/release/scripts/templates_py/manipulator_simple.py b/release/scripts/templates_py/manipulator_simple.py
index 6cb232312e8..7e02940d527 100644
--- a/release/scripts/templates_py/manipulator_simple.py
+++ b/release/scripts/templates_py/manipulator_simple.py
@@ -29,8 +29,11 @@ class MyLampWidgetGroup(ManipulatorGroup):
         mpr.matrix_basis = ob.matrix_world.normalized()
         mpr.draw_style = 'BOX'
 
-        mpr.color = 1, 0.5, 0, 0.5
-        mpr.color_highlight = 1, 0.5, 1, 0.5
+        mpr.color = 1.0, 0.5, 0.0
+        mpr.alpha = 0.5
+
+        mpr.color_highlight = 1.0, 0.5, 1.0
+        mpr.alpha_highlight = 0.5
 
         self.energy_widget = mpr
 
diff --git a/source/blender/makesrna/intern/rna_wm_manipulator.c b/source/blender/makesrna/intern/rna_wm_manipulator.c
index ee5f8160280..3042553ed0e 100644
--- a/source/blender/makesrna/intern/rna_wm_manipulator.c
+++ b/source/blender/makesrna/intern/rna_wm_manipulator.c
@@ -309,6 +309,17 @@ static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \
 	wmManipulator *mpr = ptr->data; \
 	mpr->member_id = value; \
 }
+#define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(func_id, member_id, index) \
+static float rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
+{ \
+	wmManipulator *mpr = ptr->data; \
+	return mpr->member_id[index]; \
+} \
+static void rna_Manipulator_##func_id##_set(PointerRNA *ptr, float value) \
+{ \
+	wmManipulator *mpr = ptr->data; \
+	mpr->member_id[index] = value; \
+}
 /* wmManipulator.float[len] */
 #define RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(func_id, member_id, len) \
 static void rna_Manipulator_##func_id##_get(PointerRNA *ptr, float value[len]) \
@@ -342,8 +353,11 @@ static int rna_Manipulator_##func_id##_get(PointerRNA *ptr) \
 	return (mpr->member_id & flag_value) != 0; \
 }
 
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 4);
-RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 4);
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color, color, 3);
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(color_hi, color_hi, 3);
+
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha, color, 3);
+RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_INDEX_RW_DEF(alpha_hi, color_hi, 3);
 
 RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_basis, matrix_basis, 16);
 RNA_MANIPULATOR_GENERIC_FLOAT_ARRAY_RW_DEF(matrix_offset, matrix_offset, 16);
@@ -984,14 +998,27 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
 	RNA_def_struct_name_property(srna, prop);
 	RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL);
 
+	/* Color & Alpha */
 	prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
-	RNA_def_property_array(prop, 4);
+	RNA_def_property_array(prop, 3);
 	RNA_def_property_float_funcs(prop, "rna_Manipulator_color_get", "rna_Manipulator_color_set", NULL);
 
+	prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_ui_text(prop, "Alpha", "");
+	RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_get", "rna_Manipulator_alpha_set", NULL);
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
+
+	/* Color & Alpha (highlight) */
 	prop = RNA_def_property(srna, "color_highlight", PROP_FLOAT, PROP_COLOR);
-	RNA_def_property_array(prop, 4);
+	RNA_def_property_array(prop, 3);
 	RNA_def_property_float_funcs(prop, "rna_Manipulator_color_hi_get", "rna_Manipulator_color_hi_set", NULL);
-	RNA_def_property_ui_text(prop, "Color", "");
+
+	prop = RNA_def_property(srna, "alpha_highlight", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_ui_text(prop, "Alpha", "");
+	RNA_def_property_float_funcs(prop, "rna_Manipulator_alpha_hi_get", "rna_Manipulator_alpha_hi_set", NULL);
+	RNA_def_property_range(prop, 0.0f, 1.0f);
+	RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
 
 	prop = RNA_def_property(srna, "matrix_basis", PROP_FLOAT, PROP_MATRIX);
 	RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
@@ -1005,13 +1032,13 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
 	RNA_def_property_float_funcs(prop, "rna_Manipulator_matrix_offset_get", "rna_Manipulator_matrix_offset_set", NULL);
 	RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
 
-	prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_MATRIX);
+	prop = RNA_def_property(srna, "scale_basis", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_ui_text(prop, "Scale Basis", "");
 	RNA_def_property_float_funcs(prop, "rna_Manipulator_scale_basis_get", "rna_Manipulator_scale_basis_set", NULL);
 	RNA_def_property_range(prop, 0.0f, FLT_MAX);
 	RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
 
-	prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_MATRIX);
+	prop = RNA_def_property(srna, "line_width", PROP_FLOAT, PROP_PIXEL);
 	RNA_def_property_ui_text(prop, "Line Width", "");
 	RNA_def_property_float_funcs(prop, "rna_Manipulator_line_width_get", "rna_Manipulator_line_width_set", NULL);
 	RNA_def_property_range(prop, 0.0f, FLT_MAX);




More information about the Bf-blender-cvs mailing list