Blender V5.0
wm_panel_type.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
14
15#include <cstdio>
16
18
19#include "BLI_utildefines.h"
20#include "BLI_vector_set.hh"
21
22#include "BKE_screen.hh"
23
24#include "WM_api.hh"
25
27
28static auto &get_panel_type_map()
29{
30 struct IDNameGetter {
31 StringRef operator()(const PanelType *value) const
32 {
33 return StringRef(value->idname);
34 }
35 };
37 return map;
38}
39
40PanelType *WM_paneltype_find(const StringRef idname, bool quiet)
41{
42 if (!idname.is_empty()) {
43 if (PanelType *const *pt = get_panel_type_map().lookup_key_ptr_as(idname)) {
44 return *pt;
45 }
46 }
47
48 if (!quiet) {
49 printf("search for unknown paneltype %s\n", std::string(idname).c_str());
50 }
51
52 return nullptr;
53}
54
56{
57 get_panel_type_map().add(pt);
58 return true;
59}
60
62{
63 const bool ok = get_panel_type_map().remove(pt);
64 BLI_assert(ok);
66}
67
69{
70 /* Reserve size is set based on blender default setup. */
71 get_panel_type_map().reserve(512);
72}
73
75{
76 get_panel_type_map().clear();
77}
78
80 const bContext * /*C*/,
81 PointerRNA * /*ptr*/,
82 PropertyRNA * /*prop*/,
83 const char * /*edit_text*/,
85{
86 for (PanelType *pt : get_panel_type_map()) {
88 visit_params.text = pt->idname;
89 visit_params.info = pt->label;
90 visit_fn(visit_params);
91 }
92}
#define BLI_assert(a)
Definition BLI_assert.h:46
#define UNUSED_VARS_NDEBUG(...)
SIMD_FORCE_INLINE btVector3 operator()(const btVector3 &x) const
Return the transform of the vector.
Definition btTransform.h:90
constexpr bool is_empty() const
#define printf(...)
VectorSet< T, InlineBufferCapacity, DefaultProbingStrategy, CustomIDHash< T, GetIDFn >, CustomIDEqual< T, GetIDFn > > CustomIDVectorSet
char idname[BKE_ST_MAXNAME]
std::optional< std::string > info
Definition RNA_types.hh:773
bool WM_paneltype_add(PanelType *pt)
static auto & get_panel_type_map()
void WM_paneltype_init()
void WM_paneltype_remove(PanelType *pt)
void WM_paneltype_idname_visit_for_search(const bContext *, PointerRNA *, PropertyRNA *, const char *, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn)
PanelType * WM_paneltype_find(const StringRef idname, bool quiet)
void WM_paneltype_clear()