Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/armature/pose_group.c
| Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| /* only continue if there's an object, and a pose there too */ | /* only continue if there's an object, and a pose there too */ | ||||
| if (ELEM(NULL, ob, ob->pose)) | if (ELEM(NULL, ob, ob->pose)) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| pose = ob->pose; | pose = ob->pose; | ||||
| /* if there's no active group (or active is invalid), create a new menu to find it */ | /* if there's no active group (or active is invalid), create a new menu to find it */ | ||||
| if (pose->active_group <= 0) { | if (pose->active_group <= 0) { | ||||
| /* create a new menu, and start populating it with group names */ | /* create a new menu, and start populating it with group names */ | ||||
| pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); | pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE); | ||||
| layout = uiPupMenuLayout(pup); | layout = UI_popup_menu_layout(pup); | ||||
| /* special entry - allow to create new group, then use that | /* special entry - allow to create new group, then use that | ||||
| * (not to be used for removing though) | * (not to be used for removing though) | ||||
| */ | */ | ||||
| if (strstr(op->idname, "assign")) { | if (strstr(op->idname, "assign")) { | ||||
| uiItemIntO(layout, "New Group", ICON_NONE, op->idname, "type", 0); | uiItemIntO(layout, "New Group", ICON_NONE, op->idname, "type", 0); | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| } | } | ||||
| /* add entries for each group */ | /* add entries for each group */ | ||||
| for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++) | for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++) | ||||
| uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i); | uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i); | ||||
| /* finish building the menu, and process it (should result in calling self again) */ | /* finish building the menu, and process it (should result in calling self again) */ | ||||
| uiPupMenuEnd(C, pup); | UI_popup_menu_end(C, pup); | ||||
| return OPERATOR_INTERFACE; | return OPERATOR_INTERFACE; | ||||
| } | } | ||||
| else { | else { | ||||
| /* just use the active group index, and call the exec callback for the calling operator */ | /* just use the active group index, and call the exec callback for the calling operator */ | ||||
| RNA_int_set(op->ptr, "type", pose->active_group); | RNA_int_set(op->ptr, "type", pose->active_group); | ||||
| return op->type->exec(C, op); | return op->type->exec(C, op); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 352 Lines • Show Last 20 Lines | |||||