Blender  V3.3
wm_panel_type.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
13 #include <stdio.h>
14 
15 #include "BLI_sys_types.h"
16 
18 
19 #include "BLI_ghash.h"
20 #include "BLI_utildefines.h"
21 
22 #include "BKE_screen.h"
23 
24 #include "WM_api.h"
25 
27 
28 PanelType *WM_paneltype_find(const char *idname, bool quiet)
29 {
30  if (idname[0]) {
32  if (pt) {
33  return pt;
34  }
35  }
36 
37  if (!quiet) {
38  printf("search for unknown paneltype %s\n", idname);
39  }
40 
41  return NULL;
42 }
43 
45 {
47  return true;
48 }
49 
51 {
52  const bool ok = BLI_ghash_remove(g_paneltypes_hash, pt->idname, NULL, NULL);
53 
54  BLI_assert(ok);
56 }
57 
59 {
60  /* reserve size is set based on blender default setup */
61  g_paneltypes_hash = BLI_ghash_str_new_ex("g_paneltypes_hash gh", 512);
62 }
63 
65 {
67 }
68 
71  PropertyRNA *UNUSED(prop),
72  const char *UNUSED(edit_text),
74  void *visit_user_data)
75 {
76  GHashIterator gh_iter;
77  GHASH_ITER (gh_iter, g_paneltypes_hash) {
78  PanelType *pt = BLI_ghashIterator_getValue(&gh_iter);
79 
80  StringPropertySearchVisitParams visit_params = {NULL};
81  visit_params.text = pt->idname;
82  visit_params.info = pt->label;
83  visit_fn(visit_user_data, &visit_params);
84  }
85 }
#define BLI_assert(a)
Definition: BLI_assert.h:46
GHash * BLI_ghash_str_new_ex(const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.h:302
#define GHASH_ITER(gh_iter_, ghash_)
Definition: BLI_ghash.h:321
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:734
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:790
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:710
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:863
#define UNUSED_VARS_NDEBUG(...)
#define UNUSED(x)
void(* StringPropertySearchVisitFunc)(void *visit_user_data, const StringPropertySearchVisitParams *params)
Definition: RNA_types.h:568
#define C
Definition: RandGen.cpp:25
char idname[BKE_ST_MAXNAME]
Definition: BKE_screen.h:223
char label[BKE_ST_MAXNAME]
Definition: BKE_screen.h:224
PointerRNA * ptr
Definition: wm_files.c:3480
static GHash * g_paneltypes_hash
Definition: wm_panel_type.c:26
bool WM_paneltype_add(PanelType *pt)
Definition: wm_panel_type.c:44
void WM_paneltype_init(void)
Definition: wm_panel_type.c:58
void WM_paneltype_remove(PanelType *pt)
Definition: wm_panel_type.c:50
PanelType * WM_paneltype_find(const char *idname, bool quiet)
Definition: wm_panel_type.c:28
void WM_paneltype_clear(void)
Definition: wm_panel_type.c:64
void WM_paneltype_idname_visit_for_search(const bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), const char *UNUSED(edit_text), StringPropertySearchVisitFunc visit_fn, void *visit_user_data)
Definition: wm_panel_type.c:69