Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_templates.c
| Show First 20 Lines • Show All 1,876 Lines • ▼ Show 20 Lines | for (int i = 0; md; i++, md = md->next) { | ||||
| char panel_idname[MAX_NAME]; | char panel_idname[MAX_NAME]; | ||||
| modifier_panel_id(md, panel_idname); | modifier_panel_id(md, panel_idname); | ||||
| /* Create custom data RNA pointer. */ | /* Create custom data RNA pointer. */ | ||||
| PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | ||||
| RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr); | RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr); | ||||
| Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, i, md_ptr); | Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, md_ptr); | ||||
| if (new_panel != NULL) { | if (new_panel != NULL) { | ||||
| UI_panel_set_expand_from_list_data(C, new_panel); | UI_panel_set_expand_from_list_data(C, new_panel); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* The expansion might have been changed elsewhere, so we still need to set it. */ | /* The expansion might have been changed elsewhere, so we still need to set it. */ | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** | /** | ||||
| * 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); | ||||
| ListBase *lb = get_constraints(C, constraint_from_bone); | |||||
| bConstraint *con = BLI_findlink(lb, panel->runtime.list_index); | PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | ||||
| bConstraint *con = (bConstraint *)con_ptr->data; | |||||
| 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); | ||||
| } | } | ||||
| /** | /** | ||||
| * 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 *C, Panel *panel) | static short get_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel) | ||||
| { | { | ||||
| bool constraint_from_bone = constraint_panel_is_bone(panel); | PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | ||||
| ListBase *lb = get_constraints(C, constraint_from_bone); | bConstraint *con = (bConstraint *)con_ptr->data; | ||||
| bConstraint *con = BLI_findlink(lb, panel->runtime.list_index); | |||||
| return con->ui_expand_flag; | return con->ui_expand_flag; | ||||
| } | } | ||||
| /** | /** | ||||
| * Save the expand flag for the panel and sub-panels to the constraint. | * Save the expand flag for the panel and sub-panels to the constraint. | ||||
| */ | */ | ||||
| static void set_constraint_expand_flag(const bContext *C, Panel *panel, short expand_flag) | static void set_constraint_expand_flag(const bContext *UNUSED(C), Panel *panel, short expand_flag) | ||||
| { | { | ||||
| bool constraint_from_bone = constraint_panel_is_bone(panel); | PointerRNA *con_ptr = UI_panel_custom_data_get(panel); | ||||
| ListBase *lb = get_constraints(C, constraint_from_bone); | bConstraint *con = (bConstraint *)con_ptr->data; | ||||
| bConstraint *con = BLI_findlink(lb, panel->runtime.list_index); | |||||
| con->ui_expand_flag = expand_flag; | con->ui_expand_flag = expand_flag; | ||||
| } | } | ||||
| /** | /** | ||||
| * Function with void * argument for #uiListPanelIDFromDataFunc. | * Function with void * argument for #uiListPanelIDFromDataFunc. | ||||
| * | * | ||||
| * \note: Constraint panel types are assumed to be named with the struct name field | * \note: Constraint panel types are assumed to be named with the struct name field | ||||
| * concatenated to the defined prefix. | * concatenated to the defined prefix. | ||||
| Show All 38 Lines | if (!panels_match) { | ||||
| for (int i = 0; con; i++, con = con->next) { | for (int i = 0; con; i++, con = con->next) { | ||||
| char panel_idname[MAX_NAME]; | char panel_idname[MAX_NAME]; | ||||
| panel_id_func(con, panel_idname); | panel_id_func(con, panel_idname); | ||||
| /* Create custom data RNA pointer. */ | /* Create custom data RNA pointer. */ | ||||
| PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | ||||
| RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr); | ||||
| Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, i, con_ptr); | Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, con_ptr); | ||||
| if (new_panel) { | if (new_panel) { | ||||
| /* Set the list panel functionality function pointers since we don't do it with python. */ | /* Set the list panel functionality function pointers since we don't do it with python. */ | ||||
| new_panel->type->set_list_data_expand_flag = set_constraint_expand_flag; | new_panel->type->set_list_data_expand_flag = set_constraint_expand_flag; | ||||
| new_panel->type->get_list_data_expand_flag = get_constraint_expand_flag; | new_panel->type->get_list_data_expand_flag = get_constraint_expand_flag; | ||||
| new_panel->type->reorder = constraint_reorder; | new_panel->type->reorder = constraint_reorder; | ||||
| UI_panel_set_expand_from_list_data(C, new_panel); | UI_panel_set_expand_from_list_data(C, new_panel); | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | for (int i = 0; md; i++, md = md->next) { | ||||
| char panel_idname[MAX_NAME]; | char panel_idname[MAX_NAME]; | ||||
| gpencil_modifier_panel_id(md, panel_idname); | gpencil_modifier_panel_id(md, panel_idname); | ||||
| /* Create custom data RNA pointer. */ | /* Create custom data RNA pointer. */ | ||||
| PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | ||||
| RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr); | RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr); | ||||
| Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, i, md_ptr); | Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, md_ptr); | ||||
| if (new_panel != NULL) { | if (new_panel != NULL) { | ||||
| UI_panel_set_expand_from_list_data(C, new_panel); | UI_panel_set_expand_from_list_data(C, new_panel); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* The expansion might have been changed elsewhere, so we still need to set it. */ | /* The expansion might have been changed elsewhere, so we still need to set it. */ | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | if (!panels_match) { | ||||
| for (int i = 0; fx; i++, fx = fx->next) { | for (int i = 0; fx; i++, fx = fx->next) { | ||||
| char panel_idname[MAX_NAME]; | char panel_idname[MAX_NAME]; | ||||
| shaderfx_panel_id(fx, panel_idname); | shaderfx_panel_id(fx, panel_idname); | ||||
| /* Create custom data RNA pointer. */ | /* Create custom data RNA pointer. */ | ||||
| PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); | ||||
| RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr); | RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr); | ||||
| Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, i, fx_ptr); | Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, fx_ptr); | ||||
| if (new_panel != NULL) { | if (new_panel != NULL) { | ||||
| UI_panel_set_expand_from_list_data(C, new_panel); | UI_panel_set_expand_from_list_data(C, new_panel); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* The expansion might have been changed elsewhere, so we still need to set it. */ | /* The expansion might have been changed elsewhere, so we still need to set it. */ | ||||
| ▲ Show 20 Lines • Show All 5,161 Lines • Show Last 20 Lines | |||||