[Bf-blender-cvs] [264a4a8f97a] blender2.8: RNA: add tool index access

Campbell Barton noreply at git.blender.org
Wed May 30 22:18:20 CEST 2018


Commit: 264a4a8f97ab34aa495372199566b76199e10193
Author: Campbell Barton
Date:   Wed May 30 22:11:48 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB264a4a8f97ab34aa495372199566b76199e10193

RNA: add tool index access

Needed for changing the active tool from Python.

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

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

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

diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c
index af9a200c3b9..041b2b9157f 100644
--- a/source/blender/makesrna/intern/rna_workspace.c
+++ b/source/blender/makesrna/intern/rna_workspace.c
@@ -146,6 +146,12 @@ const EnumPropertyItem *rna_WorkSpace_tools_mode_itemf(
 	return DummyRNA_DEFAULT_items;
 }
 
+static int rna_WorkspaceTool_index_get(PointerRNA *ptr)
+{
+	bToolRef *tref = ptr->data;
+	return (tref->runtime) ? tref->runtime->index : 0;
+}
+
 #else /* RNA_RUNTIME */
 
 static void rna_def_workspace_owner(BlenderRNA *brna)
@@ -213,6 +219,11 @@ static void rna_def_workspace_tool(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Name", "");
 	RNA_def_struct_name_property(srna, prop);
 
+	prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Index", "");
+	RNA_def_property_int_funcs(prop, "rna_WorkspaceTool_index_get", NULL, NULL);
+
 	RNA_api_workspace_tool(srna);
 }



More information about the Bf-blender-cvs mailing list