diff options
Diffstat (limited to 'source/blender/editors/interface/interface_panel.c')
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index dd3074d6258..d334007a097 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -117,7 +117,9 @@ typedef struct PanelSort { static int get_panel_real_size_y(const Panel *panel); static void panel_activate_state(const bContext *C, Panel *panel, uiHandlePanelState state); static int compare_panel(const void *a1, const void *a2); -static bool panel_type_context_poll(PanelType *panel_type, const char *context); +static bool panel_type_context_poll(ARegion *region, + const PanelType *panel_type, + const char *context); static void panel_title_color_get(bool show_background, uchar color[4]) { @@ -321,7 +323,7 @@ void UI_list_panel_unique_str(Panel *panel, char *r_name) * Remove the #uiBlock corresponding to a panel. The lookup is needed because panels don't store * a reference to their corresponding #uiBlock. */ -static void panel_free_block(ARegion *region, Panel *panel) +static void panel_free_block(const bContext *C, ARegion *region, Panel *panel) { BLI_assert(panel->type); @@ -334,7 +336,7 @@ static void panel_free_block(ARegion *region, Panel *panel) LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { if (STREQ(block->name, block_name)) { BLI_remlink(®ion->uiblocks, block); - UI_block_free(NULL, block); + UI_block_free(C, block); break; /* Only delete one block for this panel. */ } } @@ -347,15 +349,15 @@ static void panel_free_block(ARegion *region, Panel *panel) * \note The only panels that should need to be deleted at runtime are panels with the * #PNL_INSTANCED flag set. */ -static void panel_delete(ARegion *region, ListBase *panels, Panel *panel) +static void panel_delete(const bContext *C, ARegion *region, ListBase *panels, Panel *panel) { /* Recursively delete children. */ LISTBASE_FOREACH_MUTABLE (Panel *, child, &panel->children) { - panel_delete(region, &panel->children, child); + panel_delete(C, region, &panel->children, child); } BLI_freelistN(&panel->children); - panel_free_block(region, panel); + panel_free_block(C, region, panel); BLI_remlink(panels, panel); if (panel->activedata) { @@ -370,7 +372,7 @@ static void panel_delete(ARegion *region, ListBase *panels, Panel *panel) * \note Can be called with NULL \a C, but it should be avoided because * handlers might not be removed. */ -void UI_panels_free_instanced(bContext *C, ARegion *region) +void UI_panels_free_instanced(const bContext *C, ARegion *region) { /* Delete panels with the instanced flag. */ LISTBASE_FOREACH_MUTABLE (Panel *, panel, ®ion->panels) { @@ -386,7 +388,7 @@ void UI_panels_free_instanced(bContext *C, ARegion *region) } /* Free the panel and its sub-panels. */ - panel_delete(region, ®ion->panels, panel); + panel_delete(C, region, ®ion->panels, panel); } } } @@ -460,14 +462,17 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr return; } - char *context = drag_panel->type->context; + char *context = NULL; + if (!UI_panel_category_is_visible(region)) { + context = drag_panel->type->context; + } /* Find how many instanced panels with this context string. */ int list_panels_len = 0; LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { if (panel->type) { - if (panel_type_context_poll(panel->type, context)) { - if (panel->type->flag & PNL_INSTANCED) { + if (panel->type->flag & PNL_INSTANCED) { + if (panel_type_context_poll(region, panel->type, context)) { list_panels_len++; } } @@ -479,8 +484,8 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr PanelSort *sort_index = panel_sort; LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { if (panel->type) { - if (panel_type_context_poll(panel->type, context)) { - if (panel->type->flag & PNL_INSTANCED) { + if (panel->type->flag & PNL_INSTANCED) { + if (panel_type_context_poll(region, panel->type, context)) { sort_index->panel = MEM_dupallocN(panel); sort_index->orig = panel; sort_index++; @@ -657,11 +662,18 @@ static void panels_collapse_all(const bContext *C, set_panels_list_data_expand_flag(C, region); } -static bool panel_type_context_poll(PanelType *panel_type, const char *context) +static bool panel_type_context_poll(ARegion *region, + const PanelType *panel_type, + const char *context) { + if (UI_panel_category_is_visible(region)) { + return STREQ(panel_type->category, UI_panel_category_active_get(region, false)); + } + if (panel_type->context[0] && STREQ(panel_type->context, context)) { return true; } + return false; } |