diff options
author | Hans Goudey <h.goudey@me.com> | 2020-07-06 22:35:21 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-07-06 22:35:21 +0300 |
commit | 053e0c0af377133f046f33304a43497a7f8a22c8 (patch) | |
tree | 2bea655822e1612d286c04f6f776302e2b738f47 /source/blender/editors/interface | |
parent | 12817083ec615f9d3e3f0261d5d4247b81bfbbf8 (diff) |
UI: Add shortcuts for shader effect panels
Only the delete shortcut applies here, although the move up and down
operators can optionally be assigned in the keymap.
See rB1fa40c9f8a81 for more details and rB5d2005cbb54b for the
grease pencil modifier panel implementation, which is the same.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 19dfd6fedd6..402d345b99a 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2187,8 +2187,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); } @@ -2201,6 +2206,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; + } } } |