Merge branch 'master' into refactor-mesh-position-generic
This commit is contained in:
commit
8fa259604b
|
@ -16,6 +16,11 @@
|
|||
#include "DNA_object_enums.h"
|
||||
#include "RNA_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
# include "BLI_string_ref.hh"
|
||||
# include "BLI_vector.hh"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -84,22 +89,25 @@ typedef int /*eContextResult*/ (*bContextDataCallback)(const bContext *C,
|
|||
const char *member,
|
||||
bContextDataResult *result);
|
||||
|
||||
typedef struct bContextStoreEntry {
|
||||
struct bContextStoreEntry *next, *prev;
|
||||
#ifdef __cplusplus
|
||||
|
||||
char name[128];
|
||||
struct bContextStoreEntry {
|
||||
std::string name;
|
||||
PointerRNA ptr;
|
||||
} bContextStoreEntry;
|
||||
};
|
||||
|
||||
typedef struct bContextStore {
|
||||
struct bContextStore *next, *prev;
|
||||
struct bContextStore {
|
||||
bContextStore *next = nullptr;
|
||||
bContextStore *prev = nullptr;
|
||||
|
||||
ListBase entries;
|
||||
bool used;
|
||||
} bContextStore;
|
||||
blender::Vector<bContextStoreEntry> entries;
|
||||
bool used = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/* for the context's rna mode enum
|
||||
* keep aligned with data_mode_strings in context.c */
|
||||
* keep aligned with data_mode_strings in context.cc */
|
||||
typedef enum eContextObjectMode {
|
||||
CTX_MODE_EDIT_MESH = 0,
|
||||
CTX_MODE_EDIT_CURVE,
|
||||
|
@ -132,18 +140,23 @@ void CTX_free(bContext *C);
|
|||
|
||||
bContext *CTX_copy(const bContext *C);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
/* Stored Context */
|
||||
|
||||
bContextStore *CTX_store_add(ListBase *contexts, const char *name, const PointerRNA *ptr);
|
||||
bContextStore *CTX_store_add(ListBase *contexts,
|
||||
blender::StringRefNull name,
|
||||
const PointerRNA *ptr);
|
||||
bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context);
|
||||
bContextStore *CTX_store_get(bContext *C);
|
||||
void CTX_store_set(bContext *C, bContextStore *store);
|
||||
const PointerRNA *CTX_store_ptr_lookup(const bContextStore *store,
|
||||
const char *name,
|
||||
const StructRNA *type CPP_ARG_DEFAULT(nullptr));
|
||||
bContextStore *CTX_store_copy(bContextStore *store);
|
||||
blender::StringRefNull name,
|
||||
const StructRNA *type = nullptr);
|
||||
bContextStore *CTX_store_copy(const bContextStore *store);
|
||||
void CTX_store_free(bContextStore *store);
|
||||
void CTX_store_free_list(ListBase *contexts);
|
||||
|
||||
#endif
|
||||
|
||||
/* need to store if python is initialized or not */
|
||||
bool CTX_py_init_get(bContext *C);
|
||||
|
|
|
@ -97,7 +97,7 @@ set(SRC
|
|||
intern/colortools.c
|
||||
intern/compute_contexts.cc
|
||||
intern/constraint.c
|
||||
intern/context.c
|
||||
intern/context.cc
|
||||
intern/cpp_types.cc
|
||||
intern/crazyspace.cc
|
||||
intern/cryptomatte.cc
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* \ingroup bke
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
@ -58,15 +58,15 @@ struct bContext {
|
|||
|
||||
/* windowmanager context */
|
||||
struct {
|
||||
struct wmWindowManager *manager;
|
||||
struct wmWindow *window;
|
||||
struct WorkSpace *workspace;
|
||||
struct bScreen *screen;
|
||||
struct ScrArea *area;
|
||||
struct ARegion *region;
|
||||
struct ARegion *menu;
|
||||
struct wmGizmoGroup *gizmo_group;
|
||||
struct bContextStore *store;
|
||||
wmWindowManager *manager;
|
||||
wmWindow *window;
|
||||
WorkSpace *workspace;
|
||||
bScreen *screen;
|
||||
ScrArea *area;
|
||||
ARegion *region;
|
||||
ARegion *menu;
|
||||
wmGizmoGroup *gizmo_group;
|
||||
bContextStore *store;
|
||||
|
||||
/* Operator poll. */
|
||||
/**
|
||||
|
@ -82,8 +82,8 @@ struct bContext {
|
|||
|
||||
/* data context */
|
||||
struct {
|
||||
struct Main *main;
|
||||
struct Scene *scene;
|
||||
Main *main;
|
||||
Scene *scene;
|
||||
|
||||
int recursion;
|
||||
/** True if python is initialized. */
|
||||
|
@ -101,14 +101,15 @@ struct bContext {
|
|||
|
||||
bContext *CTX_create(void)
|
||||
{
|
||||
bContext *C = MEM_callocN(sizeof(bContext), "bContext");
|
||||
bContext *C = MEM_cnew<bContext>(__func__);
|
||||
|
||||
return C;
|
||||
}
|
||||
|
||||
bContext *CTX_copy(const bContext *C)
|
||||
{
|
||||
bContext *newC = MEM_dupallocN((void *)C);
|
||||
bContext *newC = MEM_new<bContext>(__func__);
|
||||
*newC = *C;
|
||||
|
||||
memset(&newC->wm.operator_poll_msg_dyn_params, 0, sizeof(newC->wm.operator_poll_msg_dyn_params));
|
||||
|
||||
|
@ -125,30 +126,26 @@ void CTX_free(bContext *C)
|
|||
|
||||
/* store */
|
||||
|
||||
bContextStore *CTX_store_add(ListBase *contexts, const char *name, const PointerRNA *ptr)
|
||||
bContextStore *CTX_store_add(ListBase *contexts,
|
||||
const blender::StringRefNull name,
|
||||
const PointerRNA *ptr)
|
||||
{
|
||||
/* ensure we have a context to put the entry in, if it was already used
|
||||
* we have to copy the context to ensure */
|
||||
bContextStore *ctx = contexts->last;
|
||||
bContextStore *ctx = static_cast<bContextStore *>(contexts->last);
|
||||
|
||||
if (!ctx || ctx->used) {
|
||||
if (ctx) {
|
||||
bContextStore *lastctx = ctx;
|
||||
ctx = MEM_dupallocN(lastctx);
|
||||
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
|
||||
ctx = MEM_new<bContextStore>(__func__, *ctx);
|
||||
}
|
||||
else {
|
||||
ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
ctx = MEM_new<bContextStore>(__func__);
|
||||
}
|
||||
|
||||
BLI_addtail(contexts, ctx);
|
||||
}
|
||||
|
||||
bContextStoreEntry *entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
|
||||
BLI_strncpy(entry->name, name, sizeof(entry->name));
|
||||
entry->ptr = *ptr;
|
||||
|
||||
BLI_addtail(&ctx->entries, entry);
|
||||
ctx->entries.append(bContextStoreEntry{name, *ptr});
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
@ -157,24 +154,21 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
|
|||
{
|
||||
/* ensure we have a context to put the entries in, if it was already used
|
||||
* we have to copy the context to ensure */
|
||||
bContextStore *ctx = contexts->last;
|
||||
bContextStore *ctx = static_cast<bContextStore *>(contexts->last);
|
||||
|
||||
if (!ctx || ctx->used) {
|
||||
if (ctx) {
|
||||
bContextStore *lastctx = ctx;
|
||||
ctx = MEM_dupallocN(lastctx);
|
||||
BLI_duplicatelist(&ctx->entries, &lastctx->entries);
|
||||
ctx = MEM_new<bContextStore>(__func__, *ctx);
|
||||
}
|
||||
else {
|
||||
ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
|
||||
ctx = MEM_new<bContextStore>(__func__);
|
||||
}
|
||||
|
||||
BLI_addtail(contexts, ctx);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (bContextStoreEntry *, tentry, &context->entries) {
|
||||
bContextStoreEntry *entry = MEM_dupallocN(tentry);
|
||||
BLI_addtail(&ctx->entries, entry);
|
||||
for (const bContextStoreEntry &src_entry : context->entries) {
|
||||
ctx->entries.append(src_entry);
|
||||
}
|
||||
|
||||
return ctx;
|
||||
|
@ -191,41 +185,27 @@ void CTX_store_set(bContext *C, bContextStore *store)
|
|||
}
|
||||
|
||||
const PointerRNA *CTX_store_ptr_lookup(const bContextStore *store,
|
||||
const char *name,
|
||||
const blender::StringRefNull name,
|
||||
const StructRNA *type)
|
||||
{
|
||||
bContextStoreEntry *entry = BLI_rfindstring(
|
||||
&store->entries, name, offsetof(bContextStoreEntry, name));
|
||||
if (!entry) {
|
||||
return NULL;
|
||||
for (auto entry = store->entries.rbegin(); entry != store->entries.rend(); ++entry) {
|
||||
if (entry->name == name) {
|
||||
if (type && RNA_struct_is_a(entry->ptr.type, type)) {
|
||||
return &entry->ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type && !RNA_struct_is_a(entry->ptr.type, type)) {
|
||||
return NULL;
|
||||
}
|
||||
return &entry->ptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bContextStore *CTX_store_copy(bContextStore *store)
|
||||
bContextStore *CTX_store_copy(const bContextStore *store)
|
||||
{
|
||||
bContextStore *ctx = MEM_dupallocN(store);
|
||||
BLI_duplicatelist(&ctx->entries, &store->entries);
|
||||
|
||||
return ctx;
|
||||
return MEM_new<bContextStore>(__func__, *store);
|
||||
}
|
||||
|
||||
void CTX_store_free(bContextStore *store)
|
||||
{
|
||||
BLI_freelistN(&store->entries);
|
||||
MEM_freeN(store);
|
||||
}
|
||||
|
||||
void CTX_store_free_list(ListBase *contexts)
|
||||
{
|
||||
bContextStore *ctx;
|
||||
while ((ctx = BLI_pophead(contexts))) {
|
||||
CTX_store_free(ctx);
|
||||
}
|
||||
MEM_delete(store);
|
||||
}
|
||||
|
||||
/* is python initialized? */
|
||||
|
@ -248,7 +228,7 @@ void *CTX_py_dict_get_orig(const bContext *C)
|
|||
return C->data.py_context_orig;
|
||||
}
|
||||
|
||||
void CTX_py_state_push(bContext *C, struct bContext_PyState *pystate, void *value)
|
||||
void CTX_py_state_push(bContext *C, bContext_PyState *pystate, void *value)
|
||||
{
|
||||
pystate->py_context = C->data.py_context;
|
||||
pystate->py_context_orig = C->data.py_context_orig;
|
||||
|
@ -256,7 +236,7 @@ void CTX_py_state_push(bContext *C, struct bContext_PyState *pystate, void *valu
|
|||
C->data.py_context = value;
|
||||
C->data.py_context_orig = value;
|
||||
}
|
||||
void CTX_py_state_pop(bContext *C, struct bContext_PyState *pystate)
|
||||
void CTX_py_state_pop(bContext *C, bContext_PyState *pystate)
|
||||
{
|
||||
C->data.py_context = pystate->py_context;
|
||||
C->data.py_context_orig = pystate->py_context_orig;
|
||||
|
@ -300,7 +280,7 @@ static void *ctx_wm_python_context_get(const bContext *C,
|
|||
|
||||
/* don't allow UI context access from non-main threads */
|
||||
if (!BLI_thread_is_main()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return fall_through;
|
||||
|
@ -318,14 +298,14 @@ static eContextResult ctx_data_get(bContext *C, const char *member, bContextData
|
|||
#ifdef WITH_PYTHON
|
||||
if (CTX_py_dict_get(C)) {
|
||||
if (BPY_context_member_get(C, member, result)) {
|
||||
return 1;
|
||||
return CTX_RESULT_OK;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* don't allow UI context access from non-main threads */
|
||||
if (!BLI_thread_is_main()) {
|
||||
return done;
|
||||
return CTX_RESULT_MEMBER_NOT_FOUND;
|
||||
}
|
||||
|
||||
/* we check recursion to ensure that we do not get infinite
|
||||
|
@ -340,7 +320,7 @@ static eContextResult ctx_data_get(bContext *C, const char *member, bContextData
|
|||
if (done != 1 && recursion < 1 && C->wm.store) {
|
||||
C->data.recursion = 1;
|
||||
|
||||
const PointerRNA *ptr = CTX_store_ptr_lookup(C->wm.store, member, NULL);
|
||||
const PointerRNA *ptr = CTX_store_ptr_lookup(C->wm.store, member, nullptr);
|
||||
|
||||
if (ptr) {
|
||||
result->ptr = *ptr;
|
||||
|
@ -367,7 +347,7 @@ static eContextResult ctx_data_get(bContext *C, const char *member, bContextData
|
|||
}
|
||||
|
||||
if (done != 1 && recursion < 4 && (screen = CTX_wm_screen(C))) {
|
||||
bContextDataCallback cb = screen->context;
|
||||
bContextDataCallback cb = reinterpret_cast<bContextDataCallback>(screen->context);
|
||||
C->data.recursion = 4;
|
||||
if (cb) {
|
||||
ret = cb(C, member, result);
|
||||
|
@ -379,7 +359,7 @@ static eContextResult ctx_data_get(bContext *C, const char *member, bContextData
|
|||
|
||||
C->data.recursion = recursion;
|
||||
|
||||
return done;
|
||||
return eContextResult(done);
|
||||
}
|
||||
|
||||
static void *ctx_data_pointer_get(const bContext *C, const char *member)
|
||||
|
@ -390,14 +370,14 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member)
|
|||
return result.ptr.data;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
|
||||
{
|
||||
/* if context is NULL, pointer must be NULL too and that is a valid return */
|
||||
if (C == NULL) {
|
||||
*pointer = NULL;
|
||||
/* if context is nullptr, pointer must be nullptr too and that is a valid return */
|
||||
if (C == nullptr) {
|
||||
*pointer = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -408,7 +388,7 @@ static bool ctx_data_pointer_verify(const bContext *C, const char *member, void
|
|||
return true;
|
||||
}
|
||||
|
||||
*pointer = NULL;
|
||||
*pointer = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -445,10 +425,11 @@ static int ctx_data_base_collection_get(const bContext *C, const char *member, L
|
|||
bool ok = false;
|
||||
|
||||
CollectionPointerLink *ctx_object;
|
||||
for (ctx_object = ctx_object_list.first; ctx_object; ctx_object = ctx_object->next) {
|
||||
Object *ob = ctx_object->ptr.data;
|
||||
for (ctx_object = static_cast<CollectionPointerLink *>(ctx_object_list.first); ctx_object;
|
||||
ctx_object = ctx_object->next) {
|
||||
Object *ob = static_cast<Object *>(ctx_object->ptr.data);
|
||||
Base *base = BKE_view_layer_base_find(view_layer, ob);
|
||||
if (base != NULL) {
|
||||
if (base != nullptr) {
|
||||
CTX_data_list_add(&result, &scene->id, &RNA_ObjectBase, base);
|
||||
ok = true;
|
||||
}
|
||||
|
@ -509,7 +490,7 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member)
|
|||
return result.list;
|
||||
}
|
||||
|
||||
ListBase list = {NULL, NULL};
|
||||
ListBase list = {nullptr, nullptr};
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -545,7 +526,7 @@ static void data_dir_add(ListBase *lb, const char *member, const bool use_all)
|
|||
return;
|
||||
}
|
||||
|
||||
link = MEM_callocN(sizeof(LinkData), "LinkData");
|
||||
link = MEM_cnew<LinkData>(__func__);
|
||||
link->data = (void *)member;
|
||||
BLI_addtail(lb, link);
|
||||
}
|
||||
|
@ -570,7 +551,7 @@ ListBase CTX_data_dir_get_ex(const bContext *C,
|
|||
|
||||
PropertyRNA *iterprop;
|
||||
PointerRNA ctx_ptr;
|
||||
RNA_pointer_create(NULL, &RNA_Context, (void *)C, &ctx_ptr);
|
||||
RNA_pointer_create(nullptr, &RNA_Context, (void *)C, &ctx_ptr);
|
||||
|
||||
iterprop = RNA_struct_iterator_property(ctx_ptr.type);
|
||||
|
||||
|
@ -586,10 +567,8 @@ ListBase CTX_data_dir_get_ex(const bContext *C,
|
|||
RNA_PROP_END;
|
||||
}
|
||||
if (use_store && C->wm.store) {
|
||||
bContextStoreEntry *entry;
|
||||
|
||||
for (entry = C->wm.store->entries.first; entry; entry = entry->next) {
|
||||
data_dir_add(&lb, entry->name, use_all);
|
||||
for (const bContextStoreEntry &entry : C->wm.store->entries) {
|
||||
data_dir_add(&lb, entry.name.c_str(), use_all);
|
||||
}
|
||||
}
|
||||
if ((region = CTX_wm_region(C)) && region->type && region->type->context) {
|
||||
|
@ -613,7 +592,7 @@ ListBase CTX_data_dir_get_ex(const bContext *C,
|
|||
}
|
||||
}
|
||||
if ((screen = CTX_wm_screen(C)) && screen->context) {
|
||||
bContextDataCallback cb = screen->context;
|
||||
bContextDataCallback cb = reinterpret_cast<bContextDataCallback>(screen->context);
|
||||
memset(&result, 0, sizeof(result));
|
||||
cb(C, "", &result);
|
||||
|
||||
|
@ -659,7 +638,7 @@ void CTX_data_pointer_set_ptr(bContextDataResult *result, const PointerRNA *ptr)
|
|||
|
||||
void CTX_data_id_list_add(bContextDataResult *result, ID *id)
|
||||
{
|
||||
CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add");
|
||||
CollectionPointerLink *link = MEM_cnew<CollectionPointerLink>(__func__);
|
||||
RNA_id_pointer_create(id, &link->ptr);
|
||||
|
||||
BLI_addtail(&result->list, link);
|
||||
|
@ -667,7 +646,7 @@ void CTX_data_id_list_add(bContextDataResult *result, ID *id)
|
|||
|
||||
void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void *data)
|
||||
{
|
||||
CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
|
||||
CollectionPointerLink *link = MEM_cnew<CollectionPointerLink>(__func__);
|
||||
RNA_pointer_create(id, type, data, &link->ptr);
|
||||
|
||||
BLI_addtail(&result->list, link);
|
||||
|
@ -675,7 +654,7 @@ void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void
|
|||
|
||||
void CTX_data_list_add_ptr(bContextDataResult *result, const PointerRNA *ptr)
|
||||
{
|
||||
CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
|
||||
CollectionPointerLink *link = MEM_cnew<CollectionPointerLink>(__func__);
|
||||
link->ptr = *ptr;
|
||||
|
||||
BLI_addtail(&result->list, link);
|
||||
|
@ -718,77 +697,79 @@ wmWindowManager *CTX_wm_manager(const bContext *C)
|
|||
|
||||
bool CTX_wm_interface_locked(const bContext *C)
|
||||
{
|
||||
return (bool)C->wm.manager->is_interface_locked;
|
||||
return bool(C->wm.manager->is_interface_locked);
|
||||
}
|
||||
|
||||
wmWindow *CTX_wm_window(const bContext *C)
|
||||
{
|
||||
return ctx_wm_python_context_get(C, "window", &RNA_Window, C->wm.window);
|
||||
return static_cast<wmWindow *>(
|
||||
ctx_wm_python_context_get(C, "window", &RNA_Window, C->wm.window));
|
||||
}
|
||||
|
||||
WorkSpace *CTX_wm_workspace(const bContext *C)
|
||||
{
|
||||
return ctx_wm_python_context_get(C, "workspace", &RNA_WorkSpace, C->wm.workspace);
|
||||
return static_cast<WorkSpace *>(
|
||||
ctx_wm_python_context_get(C, "workspace", &RNA_WorkSpace, C->wm.workspace));
|
||||
}
|
||||
|
||||
bScreen *CTX_wm_screen(const bContext *C)
|
||||
{
|
||||
return ctx_wm_python_context_get(C, "screen", &RNA_Screen, C->wm.screen);
|
||||
return static_cast<bScreen *>(ctx_wm_python_context_get(C, "screen", &RNA_Screen, C->wm.screen));
|
||||
}
|
||||
|
||||
ScrArea *CTX_wm_area(const bContext *C)
|
||||
{
|
||||
return ctx_wm_python_context_get(C, "area", &RNA_Area, C->wm.area);
|
||||
return static_cast<ScrArea *>(ctx_wm_python_context_get(C, "area", &RNA_Area, C->wm.area));
|
||||
}
|
||||
|
||||
SpaceLink *CTX_wm_space_data(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
return (area) ? area->spacedata.first : NULL;
|
||||
return (area) ? static_cast<SpaceLink *>(area->spacedata.first) : nullptr;
|
||||
}
|
||||
|
||||
ARegion *CTX_wm_region(const bContext *C)
|
||||
{
|
||||
return ctx_wm_python_context_get(C, "region", &RNA_Region, C->wm.region);
|
||||
return static_cast<ARegion *>(ctx_wm_python_context_get(C, "region", &RNA_Region, C->wm.region));
|
||||
}
|
||||
|
||||
void *CTX_wm_region_data(const bContext *C)
|
||||
{
|
||||
ARegion *region = CTX_wm_region(C);
|
||||
return (region) ? region->regiondata : NULL;
|
||||
return (region) ? region->regiondata : nullptr;
|
||||
}
|
||||
|
||||
struct ARegion *CTX_wm_menu(const bContext *C)
|
||||
ARegion *CTX_wm_menu(const bContext *C)
|
||||
{
|
||||
return C->wm.menu;
|
||||
}
|
||||
|
||||
struct wmGizmoGroup *CTX_wm_gizmo_group(const bContext *C)
|
||||
wmGizmoGroup *CTX_wm_gizmo_group(const bContext *C)
|
||||
{
|
||||
return C->wm.gizmo_group;
|
||||
}
|
||||
|
||||
struct wmMsgBus *CTX_wm_message_bus(const bContext *C)
|
||||
wmMsgBus *CTX_wm_message_bus(const bContext *C)
|
||||
{
|
||||
return C->wm.manager ? C->wm.manager->message_bus : NULL;
|
||||
return C->wm.manager ? C->wm.manager->message_bus : nullptr;
|
||||
}
|
||||
|
||||
struct ReportList *CTX_wm_reports(const bContext *C)
|
||||
ReportList *CTX_wm_reports(const bContext *C)
|
||||
{
|
||||
if (C->wm.manager) {
|
||||
return &(C->wm.manager->reports);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
View3D *CTX_wm_view3d(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_VIEW3D) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<View3D *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RegionView3D *CTX_wm_region_view3d(const bContext *C)
|
||||
|
@ -798,163 +779,163 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C)
|
|||
|
||||
if (area && area->spacetype == SPACE_VIEW3D) {
|
||||
if (region && region->regiontype == RGN_TYPE_WINDOW) {
|
||||
return region->regiondata;
|
||||
return static_cast<RegionView3D *>(region->regiondata);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceText *CTX_wm_space_text(const bContext *C)
|
||||
SpaceText *CTX_wm_space_text(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_TEXT) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceText *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceConsole *CTX_wm_space_console(const bContext *C)
|
||||
SpaceConsole *CTX_wm_space_console(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_CONSOLE) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceConsole *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceImage *CTX_wm_space_image(const bContext *C)
|
||||
SpaceImage *CTX_wm_space_image(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_IMAGE) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceImage *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceProperties *CTX_wm_space_properties(const bContext *C)
|
||||
SpaceProperties *CTX_wm_space_properties(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_PROPERTIES) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceProperties *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceFile *CTX_wm_space_file(const bContext *C)
|
||||
SpaceFile *CTX_wm_space_file(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_FILE) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceFile *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
|
||||
SpaceSeq *CTX_wm_space_seq(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_SEQ) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceSeq *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceOutliner *CTX_wm_space_outliner(const bContext *C)
|
||||
SpaceOutliner *CTX_wm_space_outliner(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_OUTLINER) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceOutliner *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceNla *CTX_wm_space_nla(const bContext *C)
|
||||
SpaceNla *CTX_wm_space_nla(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_NLA) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceNla *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceNode *CTX_wm_space_node(const bContext *C)
|
||||
SpaceNode *CTX_wm_space_node(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_NODE) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceNode *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceGraph *CTX_wm_space_graph(const bContext *C)
|
||||
SpaceGraph *CTX_wm_space_graph(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_GRAPH) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceGraph *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceAction *CTX_wm_space_action(const bContext *C)
|
||||
SpaceAction *CTX_wm_space_action(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_ACTION) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceAction *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceInfo *CTX_wm_space_info(const bContext *C)
|
||||
SpaceInfo *CTX_wm_space_info(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_INFO) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceInfo *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
|
||||
SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_USERPREF) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceUserPref *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceClip *CTX_wm_space_clip(const bContext *C)
|
||||
SpaceClip *CTX_wm_space_clip(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_CLIP) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceClip *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C)
|
||||
SpaceTopBar *CTX_wm_space_topbar(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_TOPBAR) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceTopBar *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct SpaceSpreadsheet *CTX_wm_space_spreadsheet(const bContext *C)
|
||||
SpaceSpreadsheet *CTX_wm_space_spreadsheet(const bContext *C)
|
||||
{
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
if (area && area->spacetype == SPACE_SPREADSHEET) {
|
||||
return area->spacedata.first;
|
||||
return static_cast<SpaceSpreadsheet *>(area->spacedata.first);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
|
||||
{
|
||||
C->wm.manager = wm;
|
||||
C->wm.window = NULL;
|
||||
C->wm.screen = NULL;
|
||||
C->wm.area = NULL;
|
||||
C->wm.region = NULL;
|
||||
C->wm.window = nullptr;
|
||||
C->wm.screen = nullptr;
|
||||
C->wm.area = nullptr;
|
||||
C->wm.region = nullptr;
|
||||
}
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
|
@ -970,14 +951,16 @@ void CTX_wm_window_set(bContext *C, wmWindow *win)
|
|||
if (win) {
|
||||
C->data.scene = win->scene;
|
||||
}
|
||||
C->wm.workspace = (win) ? BKE_workspace_active_get(win->workspace_hook) : NULL;
|
||||
C->wm.screen = (win) ? BKE_workspace_active_screen_get(win->workspace_hook) : NULL;
|
||||
C->wm.area = NULL;
|
||||
C->wm.region = NULL;
|
||||
C->wm.workspace = (win) ? BKE_workspace_active_get(win->workspace_hook) : nullptr;
|
||||
C->wm.screen = (win) ? BKE_workspace_active_screen_get(win->workspace_hook) : nullptr;
|
||||
C->wm.area = nullptr;
|
||||
C->wm.region = nullptr;
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
if (C->data.py_context != NULL) {
|
||||
BPY_context_dict_clear_members(C, PYCTX_WINDOW_MEMBERS);
|
||||
if (C->data.py_context != nullptr) {
|
||||
const char *members[] = {PYCTX_WINDOW_MEMBERS};
|
||||
BPY_context_dict_clear_members_array(
|
||||
&C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -985,12 +968,14 @@ void CTX_wm_window_set(bContext *C, wmWindow *win)
|
|||
void CTX_wm_screen_set(bContext *C, bScreen *screen)
|
||||
{
|
||||
C->wm.screen = screen;
|
||||
C->wm.area = NULL;
|
||||
C->wm.region = NULL;
|
||||
C->wm.area = nullptr;
|
||||
C->wm.region = nullptr;
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
if (C->data.py_context != NULL) {
|
||||
BPY_context_dict_clear_members(C, PYCTX_SCREEN_MEMBERS);
|
||||
if (C->data.py_context != nullptr) {
|
||||
const char *members[] = {PYCTX_SCREEN_MEMBERS};
|
||||
BPY_context_dict_clear_members_array(
|
||||
&C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -998,11 +983,13 @@ void CTX_wm_screen_set(bContext *C, bScreen *screen)
|
|||
void CTX_wm_area_set(bContext *C, ScrArea *area)
|
||||
{
|
||||
C->wm.area = area;
|
||||
C->wm.region = NULL;
|
||||
C->wm.region = nullptr;
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
if (C->data.py_context != NULL) {
|
||||
BPY_context_dict_clear_members(C, PYCTX_AREA_MEMBERS);
|
||||
if (C->data.py_context != nullptr) {
|
||||
const char *members[] = {PYCTX_AREA_MEMBERS};
|
||||
BPY_context_dict_clear_members_array(
|
||||
&C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1012,8 +999,10 @@ void CTX_wm_region_set(bContext *C, ARegion *region)
|
|||
C->wm.region = region;
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
if (C->data.py_context != NULL) {
|
||||
BPY_context_dict_clear_members(C, PYCTX_REGION_MEMBERS);
|
||||
if (C->data.py_context != nullptr) {
|
||||
const char *members[] = {PYCTX_REGION_MEMBERS};
|
||||
BPY_context_dict_clear_members_array(
|
||||
&C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1023,22 +1012,22 @@ void CTX_wm_menu_set(bContext *C, ARegion *menu)
|
|||
C->wm.menu = menu;
|
||||
}
|
||||
|
||||
void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *gzgroup)
|
||||
void CTX_wm_gizmo_group_set(bContext *C, wmGizmoGroup *gzgroup)
|
||||
{
|
||||
C->wm.gizmo_group = gzgroup;
|
||||
}
|
||||
|
||||
void CTX_wm_operator_poll_msg_clear(bContext *C)
|
||||
{
|
||||
struct bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params;
|
||||
if (params->free_fn != NULL) {
|
||||
bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params;
|
||||
if (params->free_fn != nullptr) {
|
||||
params->free_fn(C, params->user_data);
|
||||
}
|
||||
params->get_fn = NULL;
|
||||
params->free_fn = NULL;
|
||||
params->user_data = NULL;
|
||||
params->get_fn = nullptr;
|
||||
params->free_fn = nullptr;
|
||||
params->user_data = nullptr;
|
||||
|
||||
C->wm.operator_poll_msg = NULL;
|
||||
C->wm.operator_poll_msg = nullptr;
|
||||
}
|
||||
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
|
||||
{
|
||||
|
@ -1047,8 +1036,7 @@ void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
|
|||
C->wm.operator_poll_msg = msg;
|
||||
}
|
||||
|
||||
void CTX_wm_operator_poll_msg_set_dynamic(bContext *C,
|
||||
const struct bContextPollMsgDyn_Params *params)
|
||||
void CTX_wm_operator_poll_msg_set_dynamic(bContext *C, const bContextPollMsgDyn_Params *params)
|
||||
{
|
||||
CTX_wm_operator_poll_msg_clear(C);
|
||||
|
||||
|
@ -1057,10 +1045,10 @@ void CTX_wm_operator_poll_msg_set_dynamic(bContext *C,
|
|||
|
||||
const char *CTX_wm_operator_poll_msg_get(bContext *C, bool *r_free)
|
||||
{
|
||||
struct bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params;
|
||||
if (params->get_fn != NULL) {
|
||||
bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params;
|
||||
if (params->get_fn != nullptr) {
|
||||
char *msg = params->get_fn(C, params->user_data);
|
||||
if (msg != NULL) {
|
||||
if (msg != nullptr) {
|
||||
*r_free = true;
|
||||
}
|
||||
return msg;
|
||||
|
@ -1075,7 +1063,7 @@ const char *CTX_wm_operator_poll_msg_get(bContext *C, bool *r_free)
|
|||
Main *CTX_data_main(const bContext *C)
|
||||
{
|
||||
Main *bmain;
|
||||
if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain)) {
|
||||
if (ctx_data_pointer_verify(C, "blend_data", (void **)&bmain)) {
|
||||
return bmain;
|
||||
}
|
||||
|
||||
|
@ -1091,7 +1079,7 @@ void CTX_data_main_set(bContext *C, Main *bmain)
|
|||
Scene *CTX_data_scene(const bContext *C)
|
||||
{
|
||||
Scene *scene;
|
||||
if (ctx_data_pointer_verify(C, "scene", (void *)&scene)) {
|
||||
if (ctx_data_pointer_verify(C, "scene", (void **)&scene)) {
|
||||
return scene;
|
||||
}
|
||||
|
||||
|
@ -1102,7 +1090,7 @@ ViewLayer *CTX_data_view_layer(const bContext *C)
|
|||
{
|
||||
ViewLayer *view_layer;
|
||||
|
||||
if (ctx_data_pointer_verify(C, "view_layer", (void *)&view_layer)) {
|
||||
if (ctx_data_pointer_verify(C, "view_layer", (void **)&view_layer)) {
|
||||
return view_layer;
|
||||
}
|
||||
|
||||
|
@ -1129,7 +1117,7 @@ LayerCollection *CTX_data_layer_collection(const bContext *C)
|
|||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
LayerCollection *layer_collection;
|
||||
|
||||
if (ctx_data_pointer_verify(C, "layer_collection", (void *)&layer_collection)) {
|
||||
if (ctx_data_pointer_verify(C, "layer_collection", (void **)&layer_collection)) {
|
||||
if (BKE_view_layer_has_collection(view_layer, layer_collection->collection)) {
|
||||
return layer_collection;
|
||||
}
|
||||
|
@ -1142,7 +1130,7 @@ LayerCollection *CTX_data_layer_collection(const bContext *C)
|
|||
Collection *CTX_data_collection(const bContext *C)
|
||||
{
|
||||
Collection *collection;
|
||||
if (ctx_data_pointer_verify(C, "collection", (void *)&collection)) {
|
||||
if (ctx_data_pointer_verify(C, "collection", (void **)&collection)) {
|
||||
return collection;
|
||||
}
|
||||
|
||||
|
@ -1229,8 +1217,8 @@ enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit,
|
|||
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
|
||||
{
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Object *obact = obedit ? NULL : CTX_data_active_object(C);
|
||||
return CTX_data_mode_enum_ex(obedit, obact, obact ? obact->mode : OB_MODE_OBJECT);
|
||||
Object *obact = obedit ? nullptr : CTX_data_active_object(C);
|
||||
return CTX_data_mode_enum_ex(obedit, obact, obact ? eObjectMode(obact->mode) : OB_MODE_OBJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1260,7 +1248,7 @@ static const char *data_mode_strings[] = {
|
|||
"greasepencil_weight",
|
||||
"greasepencil_vertex",
|
||||
"curves_sculpt",
|
||||
NULL,
|
||||
nullptr,
|
||||
};
|
||||
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings) == CTX_MODE_NUM + 1,
|
||||
"Must have a string for each context mode")
|
||||
|
@ -1274,8 +1262,9 @@ void CTX_data_scene_set(bContext *C, Scene *scene)
|
|||
C->data.scene = scene;
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
if (C->data.py_context != NULL) {
|
||||
BPY_context_dict_clear_members(C, "scene");
|
||||
if (C->data.py_context != nullptr) {
|
||||
const char *members[] = {"scene"};
|
||||
BPY_context_dict_clear_members_array(&C->data.py_context, C->data.py_context_orig, members, 1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1288,7 +1277,7 @@ ToolSettings *CTX_data_tool_settings(const bContext *C)
|
|||
return scene->toolsettings;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CTX_data_selected_ids(const bContext *C, ListBase *list)
|
||||
|
@ -1351,17 +1340,17 @@ bool CTX_data_selectable_bases(const bContext *C, ListBase *list)
|
|||
return ctx_data_base_collection_get(C, "selectable_objects", list);
|
||||
}
|
||||
|
||||
struct Object *CTX_data_active_object(const bContext *C)
|
||||
Object *CTX_data_active_object(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "active_object");
|
||||
return static_cast<Object *>(ctx_data_pointer_get(C, "active_object"));
|
||||
}
|
||||
|
||||
struct Base *CTX_data_active_base(const bContext *C)
|
||||
Base *CTX_data_active_base(const bContext *C)
|
||||
{
|
||||
Object *ob = ctx_data_pointer_get(C, "active_object");
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
||||
if (ob == NULL) {
|
||||
return NULL;
|
||||
if (ob == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
|
@ -1369,39 +1358,39 @@ struct Base *CTX_data_active_base(const bContext *C)
|
|||
return BKE_view_layer_base_find(view_layer, ob);
|
||||
}
|
||||
|
||||
struct Object *CTX_data_edit_object(const bContext *C)
|
||||
Object *CTX_data_edit_object(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "edit_object");
|
||||
return static_cast<Object *>(ctx_data_pointer_get(C, "edit_object"));
|
||||
}
|
||||
|
||||
struct Image *CTX_data_edit_image(const bContext *C)
|
||||
Image *CTX_data_edit_image(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "edit_image");
|
||||
return static_cast<Image *>(ctx_data_pointer_get(C, "edit_image"));
|
||||
}
|
||||
|
||||
struct Text *CTX_data_edit_text(const bContext *C)
|
||||
Text *CTX_data_edit_text(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "edit_text");
|
||||
return static_cast<Text *>(ctx_data_pointer_get(C, "edit_text"));
|
||||
}
|
||||
|
||||
struct MovieClip *CTX_data_edit_movieclip(const bContext *C)
|
||||
MovieClip *CTX_data_edit_movieclip(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "edit_movieclip");
|
||||
return static_cast<MovieClip *>(ctx_data_pointer_get(C, "edit_movieclip"));
|
||||
}
|
||||
|
||||
struct Mask *CTX_data_edit_mask(const bContext *C)
|
||||
Mask *CTX_data_edit_mask(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "edit_mask");
|
||||
return static_cast<Mask *>(ctx_data_pointer_get(C, "edit_mask"));
|
||||
}
|
||||
|
||||
struct EditBone *CTX_data_active_bone(const bContext *C)
|
||||
EditBone *CTX_data_active_bone(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "active_bone");
|
||||
return static_cast<EditBone *>(ctx_data_pointer_get(C, "active_bone"));
|
||||
}
|
||||
|
||||
struct CacheFile *CTX_data_edit_cachefile(const bContext *C)
|
||||
CacheFile *CTX_data_edit_cachefile(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "edit_cachefile");
|
||||
return static_cast<CacheFile *>(ctx_data_pointer_get(C, "edit_cachefile"));
|
||||
}
|
||||
|
||||
bool CTX_data_selected_bones(const bContext *C, ListBase *list)
|
||||
|
@ -1424,9 +1413,9 @@ bool CTX_data_editable_bones(const bContext *C, ListBase *list)
|
|||
return ctx_data_collection_get(C, "editable_bones", list);
|
||||
}
|
||||
|
||||
struct bPoseChannel *CTX_data_active_pose_bone(const bContext *C)
|
||||
bPoseChannel *CTX_data_active_pose_bone(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "active_pose_bone");
|
||||
return static_cast<bPoseChannel *>(ctx_data_pointer_get(C, "active_pose_bone"));
|
||||
}
|
||||
|
||||
bool CTX_data_selected_pose_bones(const bContext *C, ListBase *list)
|
||||
|
@ -1446,17 +1435,17 @@ bool CTX_data_visible_pose_bones(const bContext *C, ListBase *list)
|
|||
|
||||
bGPdata *CTX_data_gpencil_data(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "gpencil_data");
|
||||
return static_cast<bGPdata *>(ctx_data_pointer_get(C, "gpencil_data"));
|
||||
}
|
||||
|
||||
bGPDlayer *CTX_data_active_gpencil_layer(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "active_gpencil_layer");
|
||||
return static_cast<bGPDlayer *>(ctx_data_pointer_get(C, "active_gpencil_layer"));
|
||||
}
|
||||
|
||||
bGPDframe *CTX_data_active_gpencil_frame(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "active_gpencil_frame");
|
||||
return static_cast<bGPDframe *>(ctx_data_pointer_get(C, "active_gpencil_frame"));
|
||||
}
|
||||
|
||||
bool CTX_data_visible_gpencil_layers(const bContext *C, ListBase *list)
|
||||
|
@ -1476,7 +1465,7 @@ bool CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
|
|||
|
||||
const AssetLibraryReference *CTX_wm_asset_library_ref(const bContext *C)
|
||||
{
|
||||
return ctx_data_pointer_get(C, "asset_library_ref");
|
||||
return static_cast<AssetLibraryReference *>(ctx_data_pointer_get(C, "asset_library_ref"));
|
||||
}
|
||||
|
||||
AssetHandle CTX_wm_asset_handle(const bContext *C, bool *r_is_valid)
|
||||
|
@ -1497,11 +1486,11 @@ AssetHandle CTX_wm_asset_handle(const bContext *C, bool *r_is_valid)
|
|||
(FileDirEntry *)CTX_data_pointer_get_type(C, "active_file", &RNA_FileSelectEntry).data;
|
||||
if (file && file->asset) {
|
||||
*r_is_valid = true;
|
||||
return (AssetHandle){.file_data = file};
|
||||
AssetHandle{file};
|
||||
}
|
||||
|
||||
*r_is_valid = false;
|
||||
return (AssetHandle){0};
|
||||
return AssetHandle{nullptr};
|
||||
}
|
||||
|
||||
Depsgraph *CTX_data_depsgraph_pointer(const bContext *C)
|
|
@ -2326,6 +2326,10 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
|
|||
node_src.typeinfo->copyfunc(dst_tree, node_dst, &node_src);
|
||||
}
|
||||
|
||||
if (dst_tree) {
|
||||
BKE_ntree_update_tag_node_new(dst_tree, node_dst);
|
||||
}
|
||||
|
||||
/* Only call copy function when a copy is made for the main database, not
|
||||
* for cases like the dependency graph and localization. */
|
||||
if (node_dst->typeinfo->copyfunc_api && !(flag & LIB_ID_CREATE_NO_MAIN)) {
|
||||
|
@ -2335,10 +2339,6 @@ bNode *node_copy_with_mapping(bNodeTree *dst_tree,
|
|||
node_dst->typeinfo->copyfunc_api(&ptr, &node_src);
|
||||
}
|
||||
|
||||
if (dst_tree) {
|
||||
BKE_ntree_update_tag_node_new(dst_tree, node_dst);
|
||||
}
|
||||
|
||||
/* Reset the declaration of the new node. */
|
||||
nodeDeclarationEnsure(dst_tree, node_dst);
|
||||
|
||||
|
|
|
@ -902,11 +902,11 @@ class Vector {
|
|||
|
||||
std::reverse_iterator<const T *> rbegin() const
|
||||
{
|
||||
return std::reverse_iterator<T *>(this->end());
|
||||
return std::reverse_iterator<const T *>(this->end());
|
||||
}
|
||||
std::reverse_iterator<const T *> rend() const
|
||||
{
|
||||
return std::reverse_iterator<T *>(this->begin());
|
||||
return std::reverse_iterator<const T *>(this->begin());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3470,16 +3470,17 @@ void UI_block_free(const bContext *C, uiBlock *block)
|
|||
MEM_freeN(block->func_argN);
|
||||
}
|
||||
|
||||
CTX_store_free_list(&block->contexts);
|
||||
LISTBASE_FOREACH_MUTABLE (bContextStore *, store, &block->contexts) {
|
||||
CTX_store_free(store);
|
||||
}
|
||||
|
||||
BLI_freelistN(&block->saferct);
|
||||
BLI_freelistN(&block->color_pickers.list);
|
||||
BLI_freelistN(&block->dynamic_listeners);
|
||||
|
||||
ui_block_free_button_groups(block);
|
||||
ui_block_free_views(block);
|
||||
|
||||
MEM_freeN(block);
|
||||
MEM_delete(block);
|
||||
}
|
||||
|
||||
void UI_block_listen(const uiBlock *block, const wmRegionListenerParams *listener_params)
|
||||
|
@ -3595,13 +3596,11 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, eU
|
|||
wmWindow *window = CTX_wm_window(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
uiBlock *block = MEM_cnew<uiBlock>(__func__);
|
||||
uiBlock *block = MEM_new<uiBlock>(__func__);
|
||||
block->active = true;
|
||||
block->emboss = emboss;
|
||||
block->evil_C = (void *)C; /* XXX */
|
||||
|
||||
BLI_listbase_clear(&block->button_groups);
|
||||
|
||||
if (scene) {
|
||||
/* store display device name, don't lookup for transformations yet
|
||||
* block could be used for non-color displays where looking up for transformation
|
||||
|
@ -4056,7 +4055,7 @@ uiBut *ui_but_change_type(uiBut *but, eButType new_type)
|
|||
ui_but_alloc_info(new_type, &alloc_size, &alloc_str, &new_has_custom_type);
|
||||
|
||||
if (new_has_custom_type || old_has_custom_type) {
|
||||
const void *old_but_ptr = but;
|
||||
const uiBut *old_but_ptr = but;
|
||||
/* Button may have pointer to a member within itself, this will have to be updated. */
|
||||
const bool has_str_ptr_to_self = but->str == but->strdata;
|
||||
const bool has_poin_ptr_to_self = but->poin == (char *)but;
|
||||
|
@ -4080,7 +4079,7 @@ uiBut *ui_but_change_type(uiBut *but, eButType new_type)
|
|||
}
|
||||
#ifdef WITH_PYTHON
|
||||
if (UI_editsource_enable_check()) {
|
||||
UI_editsource_but_replace(static_cast<const uiBut *>(old_but_ptr), but);
|
||||
UI_editsource_but_replace(old_but_ptr, but);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -17,54 +17,35 @@
|
|||
void ui_block_new_button_group(uiBlock *block, uiButtonGroupFlag flag)
|
||||
{
|
||||
/* Don't create a new group if there is a "lock" on new groups. */
|
||||
if (!BLI_listbase_is_empty(&block->button_groups)) {
|
||||
uiButtonGroup *last_button_group = static_cast<uiButtonGroup *>(block->button_groups.last);
|
||||
if (last_button_group->flag & UI_BUTTON_GROUP_LOCK) {
|
||||
if (!block->button_groups.is_empty()) {
|
||||
uiButtonGroup &last_group = block->button_groups.last();
|
||||
if (last_group.flag & UI_BUTTON_GROUP_LOCK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
uiButtonGroup *new_group = MEM_cnew<uiButtonGroup>(__func__);
|
||||
new_group->flag = flag;
|
||||
BLI_addtail(&block->button_groups, new_group);
|
||||
block->button_groups.append({});
|
||||
block->button_groups.last().flag = flag;
|
||||
}
|
||||
|
||||
void ui_button_group_add_but(uiBlock *block, uiBut *but)
|
||||
{
|
||||
if (BLI_listbase_is_empty(&block->button_groups)) {
|
||||
if (block->button_groups.is_empty()) {
|
||||
ui_block_new_button_group(block, uiButtonGroupFlag(0));
|
||||
}
|
||||
|
||||
uiButtonGroup *current_button_group = static_cast<uiButtonGroup *>(block->button_groups.last);
|
||||
|
||||
/* We can't use the button directly because adding it to
|
||||
* this list would mess with its `prev` and `next` pointers. */
|
||||
LinkData *button_link = BLI_genericNodeN(but);
|
||||
BLI_addtail(¤t_button_group->buttons, button_link);
|
||||
uiButtonGroup ¤t_group = block->button_groups.last();
|
||||
current_group.buttons.append(but);
|
||||
}
|
||||
|
||||
static void button_group_free(uiButtonGroup *button_group)
|
||||
void ui_button_group_replace_but_ptr(uiBlock *block, const uiBut *old_but_ptr, uiBut *new_but)
|
||||
{
|
||||
BLI_freelistN(&button_group->buttons);
|
||||
MEM_freeN(button_group);
|
||||
}
|
||||
|
||||
void ui_block_free_button_groups(uiBlock *block)
|
||||
{
|
||||
LISTBASE_FOREACH_MUTABLE (uiButtonGroup *, button_group, &block->button_groups) {
|
||||
button_group_free(button_group);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_button_group_replace_but_ptr(uiBlock *block, const void *old_but_ptr, uiBut *new_but)
|
||||
{
|
||||
LISTBASE_FOREACH (uiButtonGroup *, button_group, &block->button_groups) {
|
||||
LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) {
|
||||
if (link->data == old_but_ptr) {
|
||||
link->data = new_but;
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (uiButtonGroup &group : block->button_groups) {
|
||||
std::replace_if(
|
||||
group.buttons.begin(),
|
||||
group.buttons.end(),
|
||||
[&](const uiBut *ptr) { return ptr == old_but_ptr; },
|
||||
new_but);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
#include "RNA_types.h"
|
||||
|
@ -456,18 +457,6 @@ enum eBlockContentHints {
|
|||
UI_BLOCK_CONTAINS_SUBMENU_BUT = (1 << 0),
|
||||
};
|
||||
|
||||
/**
|
||||
* A group of button references, used by property search to keep track of sets of buttons that
|
||||
* should be searched together. For example, in property split layouts number buttons and their
|
||||
* labels (and even their decorators) are separate buttons, but they must be searched and
|
||||
* highlighted together.
|
||||
*/
|
||||
struct uiButtonGroup {
|
||||
void *next, *prev;
|
||||
ListBase buttons; /* #LinkData with #uiBut data field. */
|
||||
short flag;
|
||||
};
|
||||
|
||||
/* #uiButtonGroup.flag. */
|
||||
enum uiButtonGroupFlag {
|
||||
/** While this flag is set, don't create new button groups for layout item calls. */
|
||||
|
@ -477,6 +466,17 @@ enum uiButtonGroupFlag {
|
|||
};
|
||||
ENUM_OPERATORS(uiButtonGroupFlag, UI_BUTTON_GROUP_PANEL_HEADER);
|
||||
|
||||
/**
|
||||
* A group of button references, used by property search to keep track of sets of buttons that
|
||||
* should be searched together. For example, in property split layouts number buttons and their
|
||||
* labels (and even their decorators) are separate buttons, but they must be searched and
|
||||
* highlighted together.
|
||||
*/
|
||||
struct uiButtonGroup {
|
||||
blender::Vector<uiBut *> buttons;
|
||||
uiButtonGroupFlag flag;
|
||||
};
|
||||
|
||||
struct uiBlockDynamicListener {
|
||||
struct uiBlockDynamicListener *next, *prev;
|
||||
|
||||
|
@ -493,7 +493,7 @@ struct uiBlock {
|
|||
/** Used for `UI_butstore_*` runtime function. */
|
||||
ListBase butstore;
|
||||
|
||||
ListBase button_groups; /* #uiButtonGroup. */
|
||||
blender::Vector<uiButtonGroup> button_groups;
|
||||
|
||||
ListBase layouts;
|
||||
uiLayout *curlayout;
|
||||
|
@ -1273,8 +1273,7 @@ void ui_item_paneltype_func(bContext *C, uiLayout *layout, void *arg_pt);
|
|||
*/
|
||||
void ui_block_new_button_group(uiBlock *block, uiButtonGroupFlag flag);
|
||||
void ui_button_group_add_but(uiBlock *block, uiBut *but);
|
||||
void ui_button_group_replace_but_ptr(uiBlock *block, const void *old_but_ptr, uiBut *new_but);
|
||||
void ui_block_free_button_groups(uiBlock *block);
|
||||
void ui_button_group_replace_but_ptr(uiBlock *block, const uiBut *old_but_ptr, uiBut *new_but);
|
||||
|
||||
/* interface_drag.cc */
|
||||
|
||||
|
|
|
@ -5227,10 +5227,9 @@ static bool button_matches_search_filter(uiBut *but, const char *search_filter)
|
|||
/**
|
||||
* Test for a search result within a specific button group.
|
||||
*/
|
||||
static bool button_group_has_search_match(uiButtonGroup *button_group, const char *search_filter)
|
||||
static bool button_group_has_search_match(const uiButtonGroup &group, const char *search_filter)
|
||||
{
|
||||
LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) {
|
||||
uiBut *but = static_cast<uiBut *>(link->data);
|
||||
for (uiBut *but : group.buttons) {
|
||||
if (button_matches_search_filter(but, search_filter)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -5251,13 +5250,12 @@ static bool button_group_has_search_match(uiButtonGroup *button_group, const cha
|
|||
static bool block_search_filter_tag_buttons(uiBlock *block, const char *search_filter)
|
||||
{
|
||||
bool has_result = false;
|
||||
LISTBASE_FOREACH (uiButtonGroup *, button_group, &block->button_groups) {
|
||||
if (button_group_has_search_match(button_group, search_filter)) {
|
||||
for (const uiButtonGroup &group : block->button_groups) {
|
||||
if (button_group_has_search_match(group, search_filter)) {
|
||||
has_result = true;
|
||||
}
|
||||
else {
|
||||
LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) {
|
||||
uiBut *but = static_cast<uiBut *>(link->data);
|
||||
for (uiBut *but : group.buttons) {
|
||||
but->flag |= UI_SEARCH_FILTER_NO_MATCH;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -754,18 +754,16 @@ void UI_panel_header_buttons_end(Panel *panel)
|
|||
uiBlock *block = panel->runtime.block;
|
||||
|
||||
/* A button group should always be created in #UI_panel_header_buttons_begin. */
|
||||
BLI_assert(!BLI_listbase_is_empty(&block->button_groups));
|
||||
BLI_assert(!block->button_groups.is_empty());
|
||||
|
||||
uiButtonGroup *button_group = static_cast<uiButtonGroup *>(block->button_groups.last);
|
||||
|
||||
button_group->flag &= ~UI_BUTTON_GROUP_LOCK;
|
||||
uiButtonGroup &button_group = block->button_groups.last();
|
||||
button_group.flag &= ~UI_BUTTON_GROUP_LOCK;
|
||||
|
||||
/* Repurpose the first header button group if it is empty, in case the first button added to
|
||||
* the panel doesn't add a new group (if the button is created directly rather than through an
|
||||
* interface layout call). */
|
||||
if (BLI_listbase_is_single(&block->button_groups) &&
|
||||
BLI_listbase_is_empty(&button_group->buttons)) {
|
||||
button_group->flag &= ~UI_BUTTON_GROUP_PANEL_HEADER;
|
||||
if (block->button_groups.size() > 0) {
|
||||
button_group.flag &= ~UI_BUTTON_GROUP_PANEL_HEADER;
|
||||
}
|
||||
else {
|
||||
/* Always add a new button group. Although this may result in many empty groups, without it,
|
||||
|
@ -940,12 +938,11 @@ static void panel_remove_invisible_layouts_recursive(Panel *panel, const Panel *
|
|||
/* If sub-panels have no search results but the parent panel does, then the parent panel open
|
||||
* and the sub-panels will close. In that case there must be a way to hide the buttons in the
|
||||
* panel but keep the header buttons. */
|
||||
LISTBASE_FOREACH (uiButtonGroup *, button_group, &block->button_groups) {
|
||||
if (button_group->flag & UI_BUTTON_GROUP_PANEL_HEADER) {
|
||||
for (const uiButtonGroup &button_group : block->button_groups) {
|
||||
if (button_group.flag & UI_BUTTON_GROUP_PANEL_HEADER) {
|
||||
continue;
|
||||
}
|
||||
LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) {
|
||||
uiBut *but = static_cast<uiBut *>(link->data);
|
||||
for (uiBut *but : button_group.buttons) {
|
||||
but->flag |= UI_HIDDEN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1040,7 +1040,8 @@ static bool ui_search_menu_create_context_menu(struct bContext *C,
|
|||
MenuSearch_Item *item = (MenuSearch_Item *)active;
|
||||
bool has_menu = false;
|
||||
|
||||
memset(&data->context_menu_data, 0x0, sizeof(data->context_menu_data));
|
||||
new (&data->context_menu_data.but) uiBut();
|
||||
new (&data->context_menu_data.block) uiBlock();
|
||||
uiBut *but = &data->context_menu_data.but;
|
||||
uiBlock *block = &data->context_menu_data.block;
|
||||
|
||||
|
@ -1083,7 +1084,8 @@ static struct ARegion *ui_search_menu_create_tooltip(struct bContext *C,
|
|||
MenuSearch_Data *data = (MenuSearch_Data *)arg;
|
||||
MenuSearch_Item *item = (MenuSearch_Item *)active;
|
||||
|
||||
memset(&data->context_menu_data, 0x0, sizeof(data->context_menu_data));
|
||||
new (&data->context_menu_data.but) uiBut();
|
||||
new (&data->context_menu_data.block) uiBlock();
|
||||
uiBut *but = &data->context_menu_data.but;
|
||||
uiBlock *block = &data->context_menu_data.block;
|
||||
unit_m4(block->winmat);
|
||||
|
|
|
@ -106,11 +106,6 @@ void BPY_context_set(struct bContext *C);
|
|||
*/
|
||||
void BPY_context_update(struct bContext *C);
|
||||
|
||||
#define BPY_context_dict_clear_members(C, ...) \
|
||||
BPY_context_dict_clear_members_array(&((C)->data.py_context), \
|
||||
(C)->data.py_context_orig, \
|
||||
((const char *[]){__VA_ARGS__}), \
|
||||
VA_NARGS_COUNT(__VA_ARGS__))
|
||||
/**
|
||||
* Use for `CTX_*_set(..)` functions need to set values which are later read back as expected.
|
||||
* In this case we don't want the Python context to override the values as it causes problems
|
||||
|
@ -118,8 +113,6 @@ void BPY_context_update(struct bContext *C);
|
|||
*
|
||||
* \param dict_p: A pointer to #bContext.data.py_context so we can assign a new value.
|
||||
* \param dict_orig: The value of #bContext.data.py_context_orig to check if we need to copy.
|
||||
*
|
||||
* \note Typically accessed via #BPY_context_dict_clear_members macro.
|
||||
*/
|
||||
void BPY_context_dict_clear_members_array(void **dict_p,
|
||||
void *dict_orig,
|
||||
|
|
Loading…
Reference in New Issue