diff options
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 8f98f380854..3c0b5bd3027 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -362,12 +362,13 @@ static bool id_search_add(const bContext *C, */ char name_ui[MAX_ID_FULL_NAME_UI]; int iconid = ui_id_icon_get(C, id, template_ui->preview); - bool has_sep_char = (id->lib != NULL); + const bool use_lib_prefix = template_ui->preview || iconid; + const bool has_sep_char = (id->lib != NULL); /* When using previews, the library hint (linked, overridden, missing) is added with a * character prefix, otherwise we can use a icon. */ - BKE_id_full_name_ui_prefix_get(name_ui, id, template_ui->preview, UI_SEP_CHAR); - if (!template_ui->preview) { + BKE_id_full_name_ui_prefix_get(name_ui, id, use_lib_prefix, UI_SEP_CHAR); + if (!use_lib_prefix) { iconid = UI_library_icon_get(id); } @@ -521,7 +522,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) switch (event) { case UI_ID_BROWSE: case UI_ID_PIN: - RNA_warning("warning, id event %d shouldnt come here", event); + RNA_warning("warning, id event %d shouldn't come here", event); break; case UI_ID_OPEN: case UI_ID_ADD_NEW: @@ -558,7 +559,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) case UI_ID_LOCAL: if (id) { Main *bmain = CTX_data_main(C); - if (BKE_lib_override_library_is_enabled() && CTX_wm_window(C)->eventstate->shift) { + if (CTX_wm_window(C)->eventstate->shift) { if (ID_IS_OVERRIDABLE_LIBRARY(id)) { /* Only remap that specific ID usage to overriding local data-block. */ ID *override_id = BKE_lib_override_library_create_from_id(bmain, id, false); @@ -568,6 +569,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) /* Assign new pointer, takes care of updates/notifiers */ RNA_id_pointer_create(override_id, &idptr); } + undo_push_label = "Make Library Override"; } } else { @@ -576,11 +578,13 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) /* reassign to get get proper updates/notifiers */ idptr = RNA_property_pointer_get(&template_ui->ptr, template_ui->prop); + undo_push_label = "Make Local"; } } - RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL); - RNA_property_update(C, &template_ui->ptr, template_ui->prop); - undo_push_label = "Make Local"; + if (undo_push_label != NULL) { + RNA_property_pointer_set(&template_ui->ptr, template_ui->prop, idptr, NULL); + RNA_property_update(C, &template_ui->ptr, template_ui->prop); + } } break; case UI_ID_OVERRIDE: @@ -930,10 +934,8 @@ static void template_ID(const bContext *C, 0, 0, 0, - BKE_lib_override_library_is_enabled() ? - TIP_("Direct linked library data-block, click to make local, " - "Shift + Click to create a library override") : - TIP_("Direct linked library data-block, click to make local")); + TIP_("Direct linked library data-block, click to make local, " + "Shift + Click to create a library override")); if (disabled) { UI_but_flag_enable(but, UI_BUT_DISABLED); } @@ -2186,8 +2188,13 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) char panel_idname[MAX_NAME]; shaderfx_panel_id(fx, panel_idname); + /* Create custom data RNA pointer. */ + PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); + RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr); + Panel *new_panel = UI_panel_add_instanced( - sa, region, ®ion->panels, panel_idname, i, NULL); + sa, region, ®ion->panels, panel_idname, i, fx_ptr); + if (new_panel != NULL) { UI_panel_set_expand_from_list_data(C, new_panel); } @@ -2200,6 +2207,27 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) UI_panel_set_expand_from_list_data(C, panel); } } + + /* Assuming there's only one group of instanced panels, update the custom data pointers. */ + Panel *panel = region->panels.first; + LISTBASE_FOREACH (ShaderFxData *, fx, shaderfx) { + const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(fx->type); + if (fxi->panelRegister == NULL) { + continue; + } + + /* Move to the next instanced panel corresponding to the next modifier. */ + while ((panel->type == NULL) || !(panel->type->flag & PNL_INSTANCED)) { + panel = panel->next; + BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */ + } + + PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); + RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr); + UI_panel_custom_data_set(panel, fx_ptr); + + panel = panel->next; + } } } @@ -4821,6 +4849,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp /* Preset selector */ /* There is probably potential to use simpler "uiItemR" functions here, but automatic updating * after a preset is selected would be more complicated. */ + row = uiLayoutRow(layout, true); bt = uiDefBlockBut( block, CurveProfile_buttons_presets, profile, "Preset", 0, 0, UI_UNIT_X, UI_UNIT_X, ""); UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), NULL); |