diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 15 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 7 |
3 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 065b0a2d057..1ed10f37de3 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1766,6 +1766,8 @@ void UI_panel_header_buttons_begin(struct Panel *panel); void UI_panel_header_buttons_end(struct Panel *panel); void UI_panel_end(struct Panel *panel, int width, int height); +void UI_panel_context_pointer_set(struct Panel *panel, const char *name, struct PointerRNA *ptr); + bool UI_panel_is_closed(const struct Panel *panel); bool UI_panel_is_active(const struct Panel *panel); void UI_panel_label_offset(const struct uiBlock *block, int *r_x, int *r_y); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 072362492d8..3a8e06a3e49 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -486,8 +486,12 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr /* Set the bit to tell the interface to instanced the list. */ drag_panel->flag |= PNL_INSTANCED_LIST_ORDER_CHANGED; + CTX_store_set(C, drag_panel->runtime.context); + /* Finally, move this panel's list item to the new index in its list. */ drag_panel->type->reorder(C, drag_panel, move_to_index); + + CTX_store_set(C, NULL); } /** @@ -2458,6 +2462,17 @@ static void ui_panel_custom_data_set_recursive(Panel *panel, PointerRNA *custom_ } } +/** + * Set a context for this entire panel and its current layout. This should be used whenever panel + * callbacks that are called outside of regular drawing might require context. Currently it affects + * the #PanelType.reorder callback only. + */ +void UI_panel_context_pointer_set(Panel *panel, const char *name, PointerRNA *ptr) +{ + uiLayoutSetContextPointer(panel->layout, name, ptr); + panel->runtime.context = uiLayoutGetContextStore(panel->layout); +} + void UI_panel_custom_data_set(Panel *panel, PointerRNA *custom_data) { BLI_assert(panel->type != NULL); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1d349aa0596..ac2f1bc090c 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2727,7 +2727,12 @@ static void draw_constraint_header(uiLayout *layout, Object *ob, bConstraint *co PointerRNA ptr; RNA_pointer_create(&ob->id, &RNA_Constraint, con, &ptr); - uiLayoutSetContextPointer(layout, "constraint", &ptr); + if (block->panel) { + UI_panel_context_pointer_set(block->panel, "constraint", &ptr); + } + else { + uiLayoutSetContextPointer(layout, "constraint", &ptr); + } /* Constraint type icon. */ uiLayout *sub = uiLayoutRow(layout, false); |