WIP:#104303:WM panel parent API #105645
|
@ -210,8 +210,7 @@ static PanelType *fmodifier_subpanel_register(ARegionType *region_type,
|
|||
|
||||
BLI_assert(parent != NULL);
|
||||
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
|
||||
panel_type->parent = parent;
|
||||
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
|
||||
WM_paneltype_subpanel_add(parent, NULL, false);
|
||||
BLI_addtail(®ion_type->paneltypes, panel_type);
|
||||
|
||||
return panel_type;
|
||||
|
|
|
@ -665,10 +665,9 @@ void nla_buttons_register(ARegionType *art)
|
|||
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
||||
pt->draw = nla_panel_evaluation;
|
||||
pt->draw_header = nla_panel_animated_influence_header;
|
||||
pt->parent = pt_properties;
|
||||
WM_paneltype_subpanel_add(NULL, pt, false);
|
||||
pt->flag = PANEL_TYPE_DEFAULT_CLOSED;
|
||||
pt->poll = nla_strip_eval_panel_poll;
|
||||
BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt));
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
|
||||
pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel animated strip time");
|
||||
|
@ -679,10 +678,9 @@ void nla_buttons_register(ARegionType *art)
|
|||
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
||||
pt->draw = nla_panel_animated_strip_time;
|
||||
pt->draw_header = nla_panel_animated_strip_time_header;
|
||||
pt->parent = pt_properties;
|
||||
WM_paneltype_subpanel_add(NULL, pt, false);
|
||||
pt->flag = PANEL_TYPE_DEFAULT_CLOSED;
|
||||
pt->poll = nla_strip_eval_panel_poll;
|
||||
BLI_addtail(&pt_properties->children, BLI_genericNodeN(pt));
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
|
||||
pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers");
|
||||
|
|
|
@ -393,8 +393,7 @@ PanelType *gpencil_modifier_subpanel_register(ARegionType *region_type,
|
|||
|
||||
BLI_assert(parent != NULL);
|
||||
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
|
||||
panel_type->parent = parent;
|
||||
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
|
||||
WM_paneltype_subpanel_add(parent, NULL, false);
|
||||
BLI_addtail(®ion_type->paneltypes, panel_type);
|
||||
|
||||
return panel_type;
|
||||
|
|
|
@ -403,18 +403,7 @@ static StructRNA *rna_Panel_register(Main *bmain,
|
|||
/* Insert into list. */
|
||||
BLI_insertlinkafter(&art->paneltypes, pt_iter, pt);
|
||||
|
||||
if (parent) {
|
||||
pt->parent = parent;
|
||||
LinkData *pt_child_iter = parent->children.last;
|
||||
for (; pt_child_iter; pt_child_iter = pt_child_iter->prev) {
|
||||
PanelType *pt_child = pt_child_iter->data;
|
||||
if (pt_child->order <= pt->order) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
BLI_insertlinkafter(&parent->children, pt_child_iter, BLI_genericNodeN(pt));
|
||||
}
|
||||
|
||||
WM_paneltype_subpanel_add(parent, pt, true);
|
||||
{
|
||||
const char *owner_id = RNA_struct_state_owner_get();
|
||||
if (owner_id) {
|
||||
|
|
|
@ -496,8 +496,7 @@ PanelType *modifier_subpanel_register(ARegionType *region_type,
|
|||
|
||||
BLI_assert(parent != NULL);
|
||||
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
|
||||
panel_type->parent = parent;
|
||||
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
|
||||
WM_paneltype_subpanel_add(parent, NULL, false);
|
||||
BLI_addtail(®ion_type->paneltypes, panel_type);
|
||||
|
||||
return panel_type;
|
||||
|
|
|
@ -264,8 +264,7 @@ PanelType *shaderfx_subpanel_register(ARegionType *region_type,
|
|||
|
||||
BLI_assert(parent != NULL);
|
||||
BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME);
|
||||
panel_type->parent = parent;
|
||||
BLI_addtail(&parent->children, BLI_genericNodeN(panel_type));
|
||||
WM_paneltype_subpanel_add(parent, NULL, false);
|
||||
BLI_addtail(®ion_type->paneltypes, panel_type);
|
||||
|
||||
return panel_type;
|
||||
|
|
|
@ -1163,6 +1163,7 @@ void WM_paneltype_init(void);
|
|||
void WM_paneltype_clear(void);
|
||||
struct PanelType *WM_paneltype_find(const char *idname, bool quiet);
|
||||
bool WM_paneltype_add(struct PanelType *pt);
|
||||
void WM_paneltype_subpanel_add(struct PanelType *parent, struct PanelType *pt, bool use_order);
|
||||
void WM_paneltype_remove(struct PanelType *pt);
|
||||
|
||||
void WM_paneltype_idname_visit_for_search(const struct bContext *C,
|
||||
|
|
|
@ -47,6 +47,27 @@ bool WM_paneltype_add(PanelType *pt)
|
|||
return true;
|
||||
}
|
||||
|
||||
void WM_paneltype_subpanel_add(PanelType *parent, PanelType *pt, bool use_order)
|
||||
{
|
||||
pt->parent = parent;
|
||||
|
||||
if (parent) {
|
||||
if (use_order) {
|
||||
LinkData *pt_child_iter = parent->children.last;
|
||||
for (; pt_child_iter; pt_child_iter = pt_child_iter->prev) {
|
||||
PanelType *pt_child = pt_child_iter->data;
|
||||
if (pt_child->order <= pt->order) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
BLI_insertlinkafter(&parent->children, pt_child_iter, BLI_genericNodeN(pt));
|
||||
}
|
||||
else {
|
||||
BLI_addtail(&parent->children, BLI_genericNodeN(pt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WM_paneltype_remove(PanelType *pt)
|
||||
{
|
||||
const bool ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, NULL, NULL);
|
||||
|
|
Loading…
Reference in New Issue