Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_pose.c
| Show First 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| bPoseChannel *pchan = ptr->data; | bPoseChannel *pchan = ptr->data; | ||||
| char name_esc[sizeof(pchan->name) * 2]; | char name_esc[sizeof(pchan->name) * 2]; | ||||
| BLI_strescape(name_esc, pchan->name, sizeof(name_esc)); | BLI_strescape(name_esc, pchan->name, sizeof(name_esc)); | ||||
| return BLI_sprintfN("pose.bones[\"%s\"]", name_esc); | return BLI_sprintfN("pose.bones[\"%s\"]", name_esc); | ||||
| } | } | ||||
| /* Bone groups only. */ | |||||
| static bActionGroup *rna_bone_group_new(ID *id, bPose *pose, const char *name) | |||||
| { | |||||
| bActionGroup *grp = BKE_pose_add_group(pose, name); | |||||
| WM_main_add_notifier(NC_OBJECT | ND_POSE | NA_ADDED, id); | |||||
| return grp; | |||||
| } | |||||
| static void rna_bone_group_remove(ID *id, bPose *pose, ReportList *reports, PointerRNA *grp_ptr) | |||||
| { | |||||
| bActionGroup *grp = grp_ptr->data; | |||||
| const int grp_idx = BLI_findindex(&pose->agroups, grp); | |||||
| if (grp_idx == -1) { | |||||
| BKE_reportf(reports, RPT_ERROR, "Bone group '%s' not found in this object", grp->name); | |||||
| return; | |||||
| } | |||||
| BKE_pose_remove_group(pose, grp, grp_idx); | |||||
| WM_main_add_notifier(NC_OBJECT | ND_POSE | NA_REMOVED, id); | |||||
| } | |||||
| /* shared for actions groups and bone groups */ | /* shared for actions groups and bone groups */ | ||||
| void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value) | void rna_ActionGroup_colorset_set(PointerRNA *ptr, int value) | ||||
| { | { | ||||
| bActionGroup *grp = ptr->data; | bActionGroup *grp = ptr->data; | ||||
| /* ensure only valid values get set */ | /* ensure only valid values get set */ | ||||
| if ((value >= -1) && (value < 21)) { | if ((value >= -1) && (value < 21)) { | ||||
| grp->customCol = value; | grp->customCol = value; | ||||
| ▲ Show 20 Lines • Show All 1,084 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* pose.bone_groups */ | /* pose.bone_groups */ | ||||
| static void rna_def_bone_groups(BlenderRNA *brna, PropertyRNA *cprop) | static void rna_def_bone_groups(BlenderRNA *brna, PropertyRNA *cprop) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| /* FunctionRNA *func; */ | FunctionRNA *func; | ||||
| /* PropertyRNA *parm; */ | PropertyRNA *parm; | ||||
| RNA_def_property_srna(cprop, "BoneGroups"); | RNA_def_property_srna(cprop, "BoneGroups"); | ||||
| srna = RNA_def_struct(brna, "BoneGroups", NULL); | srna = RNA_def_struct(brna, "BoneGroups", NULL); | ||||
| RNA_def_struct_sdna(srna, "bPose"); | RNA_def_struct_sdna(srna, "bPose"); | ||||
| RNA_def_struct_ui_text(srna, "Bone Groups", "Collection of bone groups"); | RNA_def_struct_ui_text(srna, "Bone Groups", "Collection of bone groups"); | ||||
| func = RNA_def_function(srna, "new", "rna_bone_group_new"); | |||||
| RNA_def_function_ui_description(func, "Add a new bone group to the object"); | |||||
| RNA_def_function_flag(func, FUNC_USE_SELF_ID); /* ID needed for refresh */ | |||||
| RNA_def_string(func, "name", "Group", MAX_NAME, "", "Name of the new group"); | |||||
| /* return type */ | |||||
| parm = RNA_def_pointer(func, "group", "BoneGroup", "", "New bone group"); | |||||
| RNA_def_function_return(func, parm); | |||||
| func = RNA_def_function(srna, "remove", "rna_bone_group_remove"); | |||||
| RNA_def_function_ui_description(func, "Remove a bone group from this object"); | |||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); /* ID needed for refresh */ | |||||
| /* bone group to remove */ | |||||
| parm = RNA_def_pointer(func, "group", "BoneGroup", "", "Removed bone group"); | |||||
| RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); | |||||
| RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); | |||||
| prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_struct_type(prop, "BoneGroup"); | RNA_def_property_struct_type(prop, "BoneGroup"); | ||||
| RNA_def_property_flag(prop, PROP_EDITABLE); | RNA_def_property_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_pointer_funcs(prop, "rna_Pose_active_bone_group_get", | RNA_def_property_pointer_funcs(prop, "rna_Pose_active_bone_group_get", | ||||
| "rna_Pose_active_bone_group_set", NULL, NULL); | "rna_Pose_active_bone_group_set", NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Active Bone Group", "Active bone group for this pose"); | RNA_def_property_ui_text(prop, "Active Bone Group", "Active bone group for this pose"); | ||||
| RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); | RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_update"); | ||||
| ▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines | |||||