Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_templates.c
| Show First 20 Lines • Show All 2,030 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| static void constraint_reorder(bContext *C, Panel *panel, int new_index) | static void constraint_reorder(bContext *C, Panel *panel, int new_index) | ||||
| { | { | ||||
| const bool constraint_from_bone = constraint_panel_is_bone(panel); | const bool constraint_from_bone = constraint_panel_is_bone(panel); | ||||
| PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | ||||
| bConstraint *con = (bConstraint *)con_ptr->data; | bConstraint *con = (bConstraint *)con_ptr->data; | ||||
| /* Ensure called operator does have a context with the expected "constraint" member. */ | |||||
| ListBase contexts = {NULL}; | |||||
| bContextStore *previous_context_store = CTX_store_get(C); | |||||
| if (previous_context_store != NULL) { | |||||
| BLI_addtail(&contexts, previous_context_store); | |||||
| } | |||||
| bContextStore *constraint_context_store = CTX_store_add(&contexts, "constraint", con_ptr); | |||||
| CTX_store_set(C, constraint_context_store); | |||||
| PointerRNA props_ptr; | PointerRNA props_ptr; | ||||
| wmOperatorType *ot = WM_operatortype_find("CONSTRAINT_OT_move_to_index", false); | wmOperatorType *ot = WM_operatortype_find("CONSTRAINT_OT_move_to_index", false); | ||||
| WM_operator_properties_create_ptr(&props_ptr, ot); | WM_operator_properties_create_ptr(&props_ptr, ot); | ||||
| RNA_string_set(&props_ptr, "constraint", con->name); | RNA_string_set(&props_ptr, "constraint", con->name); | ||||
| RNA_int_set(&props_ptr, "index", new_index); | RNA_int_set(&props_ptr, "index", new_index); | ||||
| /* Set owner to #EDIT_CONSTRAINT_OWNER_OBJECT or #EDIT_CONSTRAINT_OWNER_BONE. */ | /* Set owner to #EDIT_CONSTRAINT_OWNER_OBJECT or #EDIT_CONSTRAINT_OWNER_BONE. */ | ||||
| RNA_enum_set(&props_ptr, "owner", constraint_from_bone ? 1 : 0); | RNA_enum_set(&props_ptr, "owner", constraint_from_bone ? 1 : 0); | ||||
| WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr); | WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr); | ||||
| WM_operator_properties_free(&props_ptr); | WM_operator_properties_free(&props_ptr); | ||||
| /* Cleanup modified context. */ | |||||
| CTX_store_set(C, previous_context_store); | |||||
| if (previous_context_store != constraint_context_store) { | |||||
| CTX_store_free(constraint_context_store); | |||||
| } | |||||
| } | } | ||||
| /** | /** | ||||
| * Get the expand flag from the active constraint to use for the panel. | * Get the expand flag from the active constraint to use for the panel. | ||||
| */ | */ | ||||
| static short get_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel) | static short get_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel) | ||||
| { | { | ||||
| PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | ||||
| ▲ Show 20 Lines • Show All 4,549 Lines • Show Last 20 Lines | |||||