Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-07-16 21:07:47 +0300
committerHans Goudey <h.goudey@me.com>2020-07-16 21:07:47 +0300
commit608d9b5aa1f199683a2e9fdd3b66b480779cb7ca (patch)
tree0252e7fae7154498fdb71ae67ce6219ebb823609 /source/blender/editors/interface
parentb13bbb22e4cb7b4cd21b33d1f1b165abcde5fe6e (diff)
UI: Add shortcuts for constraint 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. Some refactoring of the constraint delete operator was necessary, including adding an invoke function. Differential Revision: https://developer.blender.org/D8238
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_templates.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 3c0b5bd3027..21696b9c1ab 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -2027,6 +2027,7 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
ScrArea *sa = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
+ Object *ob = ED_object_active_context(C);
ListBase *constraints = get_constraints(C, use_bone_constraints);
/* Switch between the bone panel ID function and the object panel ID function. */
@@ -2042,11 +2043,15 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
char panel_idname[MAX_NAME];
panel_id_func(con, panel_idname);
+ /* Create custom data RNA pointer. */
+ PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata");
+ RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr);
+
Panel *new_panel = UI_panel_add_instanced(
- sa, region, &region->panels, panel_idname, i, NULL);
+ sa, region, &region->panels, panel_idname, i, con_ptr);
+
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->get_list_data_expand_flag = get_constraint_expand_flag;
new_panel->type->reorder = constraint_reorder;
@@ -2062,6 +2067,22 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_
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 (bConstraint *, con, constraints) {
+ /* Move to the next instanced panel corresponding to the next constraint. */
+ while ((panel->type == NULL) || !(panel->type->flag & PNL_INSTANCED)) {
+ panel = panel->next;
+ BLI_assert(panel != NULL); /* There shouldn't be fewer panels than constraint panels. */
+ }
+
+ PointerRNA *con_ptr = MEM_mallocN(sizeof(PointerRNA), "constraint panel customdata");
+ RNA_pointer_create(&ob->id, &RNA_Constraint, con, con_ptr);
+ UI_panel_custom_data_set(panel, con_ptr);
+
+ panel = panel->next;
+ }
}
}