Added WM api to handle PanelType parent/child relationships #104464

Closed
Pratyaksh Raj wants to merge 1 commits from Pratyaksh-Raj/blender:my-feature1 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 20 additions and 0 deletions

View File

@ -11,6 +11,7 @@
*/
#include <stdio.h>
#include<stdbool.h>
#include "BLI_sys_types.h"
@ -23,6 +24,14 @@
#include "WM_api.h"
typedef struct PanelType {
char idname[64];
char label[64];
struct PanelType *parent;
ListBase children;
} PanelType;
static GHash *g_paneltypes_hash = NULL;
PanelType *WM_paneltype_find(const char *idname, bool quiet)
@ -44,11 +53,22 @@ PanelType *WM_paneltype_find(const char *idname, bool quiet)
bool WM_paneltype_add(PanelType *pt)
{
BLI_ghash_insert(g_paneltypes_hash, pt->idname, pt);
if (pt->parent) {
BLI_addtail(&pt->parent->children, pt);
}
return true;
}
void WM_paneltype_remove(PanelType *pt)
{
if (pt->parent) {
BLI_remlink(&pt->parent->children, pt);
}
const bool ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, NULL, NULL);
BLI_assert(ok);