UI: support nested tools in toolbar

This commit is contained in:
Campbell Barton
2017-11-02 23:05:13 +11:00
parent 08141260ff
commit 1ca3e1a91d
6 changed files with 179 additions and 30 deletions

View File

@@ -58,7 +58,8 @@ typedef struct bToolDef {
char keymap[64];
char manipulator_group[64];
int spacetype;
int _pad;
/* index when a tool is a member of a group */
int index;
} bToolDef;
/**

View File

@@ -156,6 +156,11 @@ static void rna_def_workspace(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Active Tool", "Currently active tool manipulator");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "tool_index", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "tool.index");
RNA_def_property_ui_text(prop, "Active Tool Index", "Tool group index");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
prop = RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "transform_orientations", NULL);
RNA_def_property_struct_type(prop, "TransformOrientation");

View File

@@ -1760,6 +1760,9 @@ static int wm_operator_tool_set_exec(bContext *C, wmOperator *op)
char id_manipulator_group[sizeof(workspace->tool.manipulator_group)];
RNA_string_get(op->ptr, "keymap", id_keymap);
RNA_string_get(op->ptr, "manipulator_group", id_manipulator_group);
int index = RNA_int_get(op->ptr, "index");
workspace->tool.index = index;
if (workspace->tool.manipulator_group[0]) {
wmManipulatorGroupType *wgt = WM_manipulatorgrouptype_find(workspace->tool.manipulator_group, false);
@@ -1780,6 +1783,8 @@ static int wm_operator_tool_set_exec(bContext *C, wmOperator *op)
WM_manipulator_group_type_ensure(workspace->tool.manipulator_group);
}
ED_region_tag_redraw(CTX_wm_region(C));
return OPERATOR_FINISHED;
}
@@ -1795,6 +1800,7 @@ static void WM_OT_tool_set(wmOperatorType *ot)
RNA_def_string(ot->srna, "keymap", NULL, KMAP_MAX_NAME, "Key Map", "");
RNA_def_string(ot->srna, "manipulator_group", NULL, MAX_NAME, "Manipulator Group", "");
RNA_def_int(ot->srna, "index", 0, INT_MIN, INT_MAX, "Index", "", INT_MIN, INT_MAX);
}
#endif /* USE_WORKSPACE_TOOL */