diff options
author | Hans Goudey <h.goudey@me.com> | 2020-06-30 04:04:45 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-06-30 04:04:45 +0300 |
commit | 5d2005cbb54bf2c53551815eab524ec293f1e8f0 (patch) | |
tree | 0da9175313edb29f62c4316647d75e6336db2ada /source/blender/editors/interface/interface_templates.c | |
parent | 1d29822fa9a66d318eb42e023d67aa5759f37c1b (diff) |
UI: Add shortcuts for grease pencil modifier panels
See rB1fa40c9f8a81 for more details. The implementation is the same.
The only difference to the mesh modifier commit is a slight rework of
edit_modifier_invoke_properties in order to pass through to check for
other keymap items with the same shortcut.
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 359966a28f2..de5894388a6 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2083,7 +2083,7 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_ /** \} */ /* -------------------------------------------------------------------- */ -/** \name Grease Pencil Modifier Template +/** \name Grease Pencil Modifiers Template * \{ */ /** @@ -2109,15 +2109,22 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C) GpencilModifierData *md = modifiers->first; for (int i = 0; md; i++, md = md->next) { const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type); - if (mti->panelRegister) { - char panel_idname[MAX_NAME]; - gpencil_modifier_panel_id(md, panel_idname); - - Panel *new_panel = UI_panel_add_instanced( - sa, region, ®ion->panels, panel_idname, i, NULL); - if (new_panel != NULL) { - UI_panel_set_expand_from_list_data(C, new_panel); - } + if (mti->panelRegister == NULL) { + continue; + } + + char panel_idname[MAX_NAME]; + gpencil_modifier_panel_id(md, panel_idname); + + /* Create custom data RNA pointer. */ + PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); + RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr); + + Panel *new_panel = UI_panel_add_instanced( + sa, region, ®ion->panels, panel_idname, i, md_ptr); + + if (new_panel != NULL) { + UI_panel_set_expand_from_list_data(C, new_panel); } } } @@ -2127,6 +2134,27 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C) if ((panel->type != NULL) && (panel->type->flag & PNL_INSTANCED)) 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 (ModifierData *, md, modifiers) { + const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type); + if (mti->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 *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); + RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, md_ptr); + UI_panel_custom_data_set(panel, md_ptr); + + panel = panel->next; + } } } |