diff options
author | Hans Goudey <h.goudey@me.com> | 2020-08-12 19:56:10 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-08-12 19:56:10 +0300 |
commit | 1da053956a920c34324917becbfe1455b929c824 (patch) | |
tree | 4823a94ba21015edd1e3275cf479e7c1f004fb86 /source | |
parent | 6238eabcd4340893c1c52dcd9a0ffbc7658abe67 (diff) |
UI: Category support for instanced panels
This adds support for panel categories to the instanced panel system
used for modifiers and others. The change is pulled from D7997 where
it is needed for FCurve modifiers, but it is unused now.
The change is simple and basically amounts to checking the panel
category where it was overlooked before.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 26 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 48 |
2 files changed, 46 insertions, 28 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 799a3b7fd5e..1b48ed8a7a1 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]) { @@ -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; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 58fb934ebf0..38bac3afef6 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2658,29 +2658,35 @@ void ED_region_panels_layout_ex(const bContext *C, if (has_instanced_panel) { LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { if (panel->type == NULL) { - continue; /* Some panels don't have a type.. */ + continue; /* Some panels don't have a type. */ } - if (panel->type->flag & PNL_INSTANCED) { - if (panel && UI_panel_is_dragging(panel)) { - /* Prevent View2d.tot rectangle size changes while dragging panels. */ - update_tot_size = false; - } - - /* Use a unique identifier for instanced panels, otherwise an old block for a different - * panel of the same type might be found. */ - char unique_panel_str[8]; - UI_list_panel_unique_str(panel, unique_panel_str); - ed_panel_draw(C, - area, - region, - ®ion->panels, - panel->type, - panel, - (panel->type->flag & PNL_DRAW_BOX) ? w_box_panel : w, - em, - vertical, - unique_panel_str); + if (!(panel->type->flag & PNL_INSTANCED)) { + continue; } + if (use_category_tabs && panel->type->category[0] && + !STREQ(category, panel->type->category)) { + continue; + } + + if (panel && UI_panel_is_dragging(panel)) { + /* Prevent View2d.tot rectangle size changes while dragging panels. */ + update_tot_size = false; + } + + /* Use a unique identifier for instanced panels, otherwise an old block for a different + * panel of the same type might be found. */ + char unique_panel_str[8]; + UI_list_panel_unique_str(panel, unique_panel_str); + ed_panel_draw(C, + area, + region, + ®ion->panels, + panel->type, + panel, + (panel->type->flag & PNL_DRAW_BOX) ? w_box_panel : w, + em, + vertical, + unique_panel_str); } } |