Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_templates.c
| Show First 20 Lines • Show All 1,943 Lines • ▼ Show 20 Lines | |||||
| */ | */ | ||||
| static bool constraint_panel_is_bone(Panel *panel) | static bool constraint_panel_is_bone(Panel *panel) | ||||
| { | { | ||||
| return (panel->panelname[0] == 'B') && (panel->panelname[1] == 'O') && | return (panel->panelname[0] == 'B') && (panel->panelname[1] == 'O') && | ||||
| (panel->panelname[2] == 'N') && (panel->panelname[3] == 'E'); | (panel->panelname[2] == 'N') && (panel->panelname[3] == 'E'); | ||||
| } | } | ||||
| /** | /** | ||||
| * Get the constraints for the active pose bone or the active / pinned object. | |||||
| */ | |||||
| static ListBase *get_constraints(const bContext *C, bool use_bone_constraints) | |||||
| { | |||||
| ListBase *constraints = {NULL}; | |||||
| if (use_bone_constraints) { | |||||
| bPoseChannel *pose_bone = CTX_data_pointer_get(C, "pose_bone").data; | |||||
| if (pose_bone != NULL) { | |||||
| constraints = &pose_bone->constraints; | |||||
| } | |||||
| } | |||||
| else { | |||||
| Object *ob = ED_object_active_context(C); | |||||
| if (ob != NULL) { | |||||
| constraints = &ob->constraints; | |||||
| } | |||||
| } | |||||
| return constraints; | |||||
| } | |||||
| /** | |||||
| * Move a constraint to the index it's moved to after a drag and drop. | * Move a constraint to the index it's moved to after a drag and drop. | ||||
| */ | */ | ||||
| static void constraint_reorder(bContext *C, Panel *panel, int new_index) | static void constraint_reorder(bContext *C, Panel *panel, int new_index) | ||||
| { | { | ||||
| bool constraint_from_bone = constraint_panel_is_bone(panel); | 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; | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * Check if the constraint panels don't match the data and rebuild the panels if so. | * Check if the constraint panels don't match the data and rebuild the panels if so. | ||||
| */ | */ | ||||
| void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_constraints) | void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_constraints) | ||||
| { | { | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| ListBase *constraints = get_constraints(C, use_bone_constraints); | ListBase *constraints = {NULL}; | ||||
| if (use_bone_constraints) { | |||||
| constraints = ED_object_pose_constraint_list(C); | |||||
| } | |||||
| else { | |||||
| constraints = ED_object_constraint_active_list(ob); | |||||
| } | |||||
| /* Switch between the bone panel ID function and the object panel ID function. */ | /* Switch between the bone panel ID function and the object panel ID function. */ | ||||
| uiListPanelIDFromDataFunc panel_id_func = use_bone_constraints ? bone_constraint_panel_id : | uiListPanelIDFromDataFunc panel_id_func = use_bone_constraints ? bone_constraint_panel_id : | ||||
| object_constraint_panel_id; | object_constraint_panel_id; | ||||
| const bool panels_match = UI_panel_list_matches_data(region, constraints, panel_id_func); | const bool panels_match = UI_panel_list_matches_data(region, constraints, panel_id_func); | ||||
| if (!panels_match) { | if (!panels_match) { | ||||
| ▲ Show 20 Lines • Show All 5,364 Lines • Show Last 20 Lines | |||||