[Bf-blender-cvs] [34020882c35] greasepencil-object: New enum property for drawing brushes

Antonio Vazquez noreply at git.blender.org
Sun Jun 11 13:33:23 CEST 2017


Commit: 34020882c35ad7c52a6ef5d252cbdf0f5abd4312
Author: Antonio Vazquez
Date:   Sun Jun 11 13:33:03 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB34020882c35ad7c52a6ef5d252cbdf0f5abd4312

New enum property for drawing brushes

This property is necessary to include a icon view in the UI panel

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

M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index f8bb07acfe0..6791ff6b38d 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -437,6 +437,13 @@ EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = {
 	{0, NULL, 0, NULL, NULL}
 };
 
+/* loaded dynamic only defined as dummy */
+EnumPropertyItem rna_enum_gpencil_drawing_brushes_items[] = {
+	{ 0, "BASIC", ICON_BRUSH_SCULPT_DRAW, "Basic", "Basic drawing brush" },
+	{ 0, NULL, 0, NULL, NULL }
+};
+
+
 EnumPropertyItem rna_enum_layer_collection_mode_settings_type_items[] = {
 	{COLLECTION_MODE_OBJECT, "OBJECT", 0, "Object", ""},
 	{COLLECTION_MODE_EDIT, "EDIT", 0, "Edit", ""},
@@ -619,6 +626,36 @@ static void rna_GPencilBrush_name_set(PointerRNA *ptr, const char *value)
 	BLI_uniquename(&ts->gp_brushes, brush, DATA_("GP_Brush"), '.', offsetof(bGPDbrush, info), sizeof(brush->info));
 }
 
+/* Dynamic Enums of GP Brushes */
+static EnumPropertyItem *rna_GPencilBrush_enum_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
+	bool *r_free)
+{
+	ToolSettings *ts = ((Scene *)ptr->id.data)->toolsettings;
+	bGPDbrush *brush;
+	EnumPropertyItem *item = NULL, item_tmp = { 0 };
+	int totitem = 0;
+	int i = 0;
+
+	if (ELEM(NULL, ts)) {
+		return rna_enum_gpencil_drawing_brushes_items;
+	}
+
+	/* Existing brushes */
+	for (brush = ts->gp_brushes.first; brush; brush = brush->next, i++) {
+		item_tmp.identifier = brush->info;
+		item_tmp.name = brush->info;
+		item_tmp.value = i;
+		item_tmp.icon = ICON_BRUSH_DATA;
+
+		RNA_enum_item_add(&item, &totitem, &item_tmp);
+	}
+
+	RNA_enum_item_end(&item, &totitem);
+	*r_free = true;
+
+	return item;
+}
+
 /* ----------------- end of Grease pencil drawing brushes ------------*/
 
 static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
@@ -3723,6 +3760,12 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
 	RNA_def_property_ui_text(prop, "Grease Pencil Brushes", "Grease Pencil drawing brushes");
 	rna_def_gpencil_brushes(brna, prop);
 
+	prop = RNA_def_property(srna, "gpencil_brushes_enum", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_items(prop, rna_enum_gpencil_drawing_brushes_items);
+	RNA_def_property_enum_funcs(prop, "rna_GPencilBrushes_index_get", "rna_GPencilBrushes_index_set", "rna_GPencilBrush_enum_itemf");
+	RNA_def_property_ui_text(prop, "Enum of drawing brushes", "");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
 	/* Grease Pencil - 3D View Stroke Placement */
 	prop = RNA_def_property(srna, "gpencil_stroke_placement_view3d", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_v3d_align");




More information about the Bf-blender-cvs mailing list