diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 5 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 32 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 22 |
3 files changed, 25 insertions, 34 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 4f656420b06..5fcde98f200 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1717,7 +1717,8 @@ struct PointerRNA *UI_region_panel_custom_data_under_cursor(const struct bContex void UI_panel_custom_data_set(struct Panel *panel, struct PointerRNA *custom_data); /* Polyinstantiated panels for representing a list of data. */ -struct Panel *UI_panel_add_instanced(struct ARegion *region, +struct Panel *UI_panel_add_instanced(const struct bContext *C, + struct ARegion *region, struct ListBase *panels, char *panel_idname, struct PointerRNA *custom_data); @@ -1726,8 +1727,6 @@ void UI_panels_free_instanced(const struct bContext *C, struct ARegion *region); #define INSTANCED_PANEL_UNIQUE_STR_LEN 4 void UI_list_panel_unique_str(struct Panel *panel, char *r_name); -void UI_panel_set_expand_from_list_data(const struct bContext *C, struct Panel *panel); - typedef void (*uiListPanelIDFromDataFunc)(void *data_link, char *r_idname); bool UI_panel_list_matches_data(struct ARegion *region, struct ListBase *data, diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 66b9ec8685c..6304ce91688 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -116,6 +116,7 @@ typedef struct PanelSort { int new_offset_y; } PanelSort; +static void panel_set_expansion_from_list_data(const bContext *C, Panel *panel); 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 *a, const void *b); @@ -240,10 +241,10 @@ static bool panels_need_realign(ScrArea *area, ARegion *region, Panel **r_panel_ /** \name Functions for Instanced Panels * \{ */ -static Panel *UI_panel_add_instanced_ex(ARegion *region, - ListBase *panels, - PanelType *panel_type, - PointerRNA *custom_data) +static Panel *panel_add_instanced(ARegion *region, + ListBase *panels, + PanelType *panel_type, + PointerRNA *custom_data) { Panel *panel = MEM_callocN(sizeof(Panel), "instanced panel"); panel->type = panel_type; @@ -256,7 +257,7 @@ static Panel *UI_panel_add_instanced_ex(ARegion *region, * function to create them, as UI_panel_begin does other things we don't need to do. */ LISTBASE_FOREACH (LinkData *, child, &panel_type->children) { PanelType *child_type = child->data; - UI_panel_add_instanced_ex(region, &panel->children, child_type, custom_data); + panel_add_instanced(region, &panel->children, child_type, custom_data); } /* Make sure the panel is added to the end of the display-order as well. This is needed for @@ -281,7 +282,8 @@ static Panel *UI_panel_add_instanced_ex(ARegion *region, * Called in situations where panels need to be added dynamically rather than * having only one panel corresponding to each #PanelType. */ -Panel *UI_panel_add_instanced(ARegion *region, +Panel *UI_panel_add_instanced(const bContext *C, + ARegion *region, ListBase *panels, char *panel_idname, PointerRNA *custom_data) @@ -296,7 +298,12 @@ Panel *UI_panel_add_instanced(ARegion *region, return NULL; } - return UI_panel_add_instanced_ex(region, panels, panel_type, custom_data); + Panel *new_panel = panel_add_instanced(region, panels, panel_type, custom_data); + + /* Do this after #panel_add_instatnced so all subpanels are added. */ + panel_set_expansion_from_list_data(C, new_panel); + + return new_panel; } /** @@ -478,7 +485,7 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr } /** - * Recursive implementation for #UI_panel_set_expand_from_list_data. + * Recursive implementation for #panel_set_expansion_from_list_data. * * \return Whether the closed flag for the panel or any sub-panels changed. */ @@ -496,11 +503,10 @@ static bool panel_set_expand_from_list_data_recursive(Panel *panel, short flag, } /** - * Set the expansion of the panel and its sub-panels from the flag stored by the list data - * corresponding to this panel. The flag has expansion stored in each bit in depth first - * order. + * Set the expansion of the panel and its sub-panels from the flag stored in the + * corresponding list data. The flag has expansion stored in each bit in depth first order. */ -void UI_panel_set_expand_from_list_data(const bContext *C, Panel *panel) +static void panel_set_expansion_from_list_data(const bContext *C, Panel *panel) { BLI_assert(panel->type != NULL); BLI_assert(panel->type->flag & PNL_INSTANCED); @@ -527,7 +533,7 @@ static void region_panels_set_expansion_from_list_data(const bContext *C, ARegio if (panel->runtime_flag & PANEL_ACTIVE) { PanelType *panel_type = panel->type; if (panel_type != NULL && panel->type->flag & PNL_INSTANCED) { - UI_panel_set_expand_from_list_data(C, panel); + panel_set_expansion_from_list_data(C, panel); } } } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index f02d1e06220..680b469fd9e 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1921,11 +1921,7 @@ void uiTemplateModifiers(uiLayout *UNUSED(layout), bContext *C) PointerRNA *md_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); RNA_pointer_create(&ob->id, &RNA_Modifier, md, md_ptr); - Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, md_ptr); - - if (new_panel != NULL) { - UI_panel_set_expand_from_list_data(C, new_panel); - } + UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, md_ptr); } } else { @@ -2080,15 +2076,13 @@ void uiTemplateConstraints(uiLayout *UNUSED(layout), bContext *C, bool use_bone_ 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(region, ®ion->panels, panel_idname, con_ptr); + Panel *new_panel = UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, con_ptr); if (new_panel) { /* 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; - - UI_panel_set_expand_from_list_data(C, new_panel); } } } @@ -2162,11 +2156,7 @@ void uiTemplateGpencilModifiers(uiLayout *UNUSED(layout), bContext *C) 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(region, ®ion->panels, panel_idname, md_ptr); - - if (new_panel != NULL) { - UI_panel_set_expand_from_list_data(C, new_panel); - } + UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, md_ptr); } } else { @@ -2237,11 +2227,7 @@ void uiTemplateShaderFx(uiLayout *UNUSED(layout), bContext *C) PointerRNA *fx_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); RNA_pointer_create(&ob->id, &RNA_ShaderFx, fx, fx_ptr); - Panel *new_panel = UI_panel_add_instanced(region, ®ion->panels, panel_idname, fx_ptr); - - if (new_panel != NULL) { - UI_panel_set_expand_from_list_data(C, new_panel); - } + UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, fx_ptr); } } else { |