Blender V4.5
blenkernel/intern/context.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
8
9#include <cstddef>
10#include <cstdlib>
11#include <cstring>
12
13#include "MEM_guardedalloc.h"
14
16#include "DNA_object_types.h"
17#include "DNA_scene_types.h"
18#include "DNA_screen_types.h"
19#include "DNA_space_types.h"
20#include "DNA_view3d_types.h"
22#include "DNA_workspace_types.h"
23
24#include "DEG_depsgraph.hh"
25
26#include "BLI_listbase.h"
27#include "BLI_threads.h"
28#include "BLI_utildefines.h"
29
30#include "BLT_translation.hh"
31
32#include "BKE_context.hh"
33#include "BKE_layer.hh"
34#include "BKE_main.hh"
35#include "BKE_scene.hh"
36#include "BKE_screen.hh"
37#include "BKE_sound.h"
38#include "BKE_wm_runtime.hh"
39#include "BKE_workspace.hh"
40
41#include "RE_engine.h"
42
43#include "RNA_access.hh"
44#include "RNA_prototypes.hh"
45
46#include "CLG_log.h"
47
48#ifdef WITH_PYTHON
49# include "BPY_extern.hh"
50#endif
51
52using blender::Vector;
53
54static CLG_LogRef LOG = {"bke.context"};
55
56/* struct */
57
101
102/* context */
103
105{
106 bContext *C = MEM_callocN<bContext>(__func__);
107
108 return C;
109}
110
112{
113 bContext *newC = MEM_callocN<bContext>(__func__);
114 *newC = *C;
115
116 memset(&newC->wm.operator_poll_msg_dyn_params, 0, sizeof(newC->wm.operator_poll_msg_dyn_params));
117
118 return newC;
119}
120
122{
123 /* This may contain a dynamically allocated message, free. */
125
126 MEM_freeN(C);
127}
128
129/* store */
130
134static bContextStore *ctx_store_extend(Vector<std::unique_ptr<bContextStore>> &contexts)
135{
136 /* ensure we have a context to put the entry in, if it was already used
137 * we have to copy the context to ensure */
138 if (contexts.is_empty()) {
139 contexts.append(std::make_unique<bContextStore>());
140 }
141 else if (contexts.last()->used) {
142 auto new_ctx = std::make_unique<bContextStore>(bContextStore{contexts.last()->entries, false});
143 contexts.append(std::move(new_ctx));
144 }
145
146 return contexts.last().get();
147}
148
149bContextStore *CTX_store_add(Vector<std::unique_ptr<bContextStore>> &contexts,
150 const blender::StringRef name,
151 const PointerRNA *ptr)
152{
153 bContextStore *ctx = ctx_store_extend(contexts);
154 ctx->entries.append(bContextStoreEntry{name, *ptr});
155 return ctx;
156}
157
158bContextStore *CTX_store_add(Vector<std::unique_ptr<bContextStore>> &contexts,
159 const blender::StringRef name,
161{
162 bContextStore *ctx = ctx_store_extend(contexts);
163 ctx->entries.append(bContextStoreEntry{name, std::string{str}});
164 return ctx;
165}
166
167bContextStore *CTX_store_add(Vector<std::unique_ptr<bContextStore>> &contexts,
168 const blender::StringRef name,
169 const int64_t value)
170{
171 bContextStore *ctx = ctx_store_extend(contexts);
172 ctx->entries.append(bContextStoreEntry{name, value});
173 return ctx;
174}
175
176bContextStore *CTX_store_add_all(Vector<std::unique_ptr<bContextStore>> &contexts,
177 const bContextStore *context)
178{
179 bContextStore *ctx = ctx_store_extend(contexts);
180 for (const bContextStoreEntry &src_entry : context->entries) {
181 ctx->entries.append(src_entry);
182 }
183 return ctx;
184}
185
187{
188 return C->wm.store;
189}
190
192{
193 C->wm.store = store;
194}
195
197 const blender::StringRef name,
198 const StructRNA *type)
199{
200 for (auto entry = store->entries.rbegin(); entry != store->entries.rend(); ++entry) {
201 if (entry->name == name && std::holds_alternative<PointerRNA>(entry->value)) {
202 const PointerRNA &ptr = std::get<PointerRNA>(entry->value);
203 if (!type || RNA_struct_is_a(ptr.type, type)) {
204 return &ptr;
205 }
206 }
207 }
208 return nullptr;
209}
210
211template<typename T>
213{
214 for (auto entry = store->entries.rbegin(); entry != store->entries.rend(); ++entry) {
215 if (entry->name == name && std::holds_alternative<T>(entry->value)) {
216 return &std::get<T>(entry->value);
217 }
218 }
219 return nullptr;
220}
221
222std::optional<blender::StringRefNull> CTX_store_string_lookup(const bContextStore *store,
223 const blender::StringRef name)
224{
225 if (const std::string *value = ctx_store_lookup_impl<std::string>(store, name)) {
226 return *value;
227 }
228 return {};
229}
230
231std::optional<int64_t> CTX_store_int_lookup(const bContextStore *store,
232 const blender::StringRef name)
233{
234 if (const int64_t *value = ctx_store_lookup_impl<int64_t>(store, name)) {
235 return *value;
236 }
237 return {};
238}
239
240/* is python initialized? */
241
243{
244 return C->data.py_init;
245}
246void CTX_py_init_set(bContext *C, bool value)
247{
248 C->data.py_init = value;
249}
250
252{
253 return C->data.py_context;
254}
256{
257 return C->data.py_context_orig;
258}
259
260void CTX_py_state_push(bContext *C, bContext_PyState *pystate, void *value)
261{
262 pystate->py_context = C->data.py_context;
263 pystate->py_context_orig = C->data.py_context_orig;
264
265 C->data.py_context = value;
266 C->data.py_context_orig = value;
267}
269{
270 C->data.py_context = pystate->py_context;
271 C->data.py_context_orig = pystate->py_context_orig;
272}
273
274/* data context utility functions */
275
280 int index;
282 std::optional<int64_t> int_value;
283 const char **dir;
284 short type; /* 0: normal, 1: seq */
285};
286
288 const char *member,
289 const StructRNA *member_type,
290 void *fall_through)
291{
292#ifdef WITH_PYTHON
293 if (UNLIKELY(C && CTX_py_dict_get(C))) {
296
297 if (result.ptr.data) {
298 if (RNA_struct_is_a(result.ptr.type, member_type)) {
299 return result.ptr.data;
300 }
301
302 CLOG_WARN(&LOG,
303 "PyContext '%s' is a '%s', expected a '%s'",
304 member,
306 RNA_struct_identifier(member_type));
307 }
308 }
309#else
310 UNUSED_VARS(C, member, member_type);
311#endif
312
313 /* don't allow UI context access from non-main threads */
314 if (!BLI_thread_is_main()) {
315 return nullptr;
316 }
317
318 return fall_through;
319}
320
322{
323 bScreen *screen;
324 ScrArea *area;
325 ARegion *region;
326 int done = 0, recursion = C->data.recursion;
327 int ret = 0;
328
329 *result = {};
330#ifdef WITH_PYTHON
331 if (CTX_py_dict_get(C)) {
332 if (BPY_context_member_get(C, member, result)) {
333 return CTX_RESULT_OK;
334 }
335 }
336#endif
337
338 /* don't allow UI context access from non-main threads */
339 if (!BLI_thread_is_main()) {
341 }
342
343 /* we check recursion to ensure that we do not get infinite
344 * loops requesting data from ourselves in a context callback */
345
346 /* Ok, this looks evil...
347 * if (ret) done = -(-ret | -done);
348 *
349 * Values in order of importance
350 * (0, -1, 1) - Where 1 is highest priority
351 */
352 if (done != 1 && recursion < 1 && C->wm.store) {
353 C->data.recursion = 1;
354
355 if (const PointerRNA *ptr = CTX_store_ptr_lookup(C->wm.store, member, nullptr)) {
356 result->ptr = *ptr;
357 done = 1;
358 }
359 else if (std::optional<blender::StringRefNull> str = CTX_store_string_lookup(C->wm.store,
360 member))
361 {
362 result->str = *str;
364 done = 1;
365 }
366 else if (std::optional<int64_t> int_value = CTX_store_int_lookup(C->wm.store, member)) {
367 result->int_value = int_value;
369 done = 1;
370 }
371 }
372 if (done != 1 && recursion < 2 && (region = CTX_wm_region(C))) {
373 C->data.recursion = 2;
374 if (region->runtime->type && region->runtime->type->context) {
375 ret = region->runtime->type->context(C, member, result);
376 if (ret) {
377 done = -(-ret | -done);
378 }
379 }
380 }
381 if (done != 1 && recursion < 3 && (area = CTX_wm_area(C))) {
382 C->data.recursion = 3;
383 if (area->type && area->type->context) {
384 ret = area->type->context(C, member, result);
385 if (ret) {
386 done = -(-ret | -done);
387 }
388 }
389 }
390
391 if (done != 1 && recursion < 4 && (screen = CTX_wm_screen(C))) {
392 bContextDataCallback cb = reinterpret_cast<bContextDataCallback>(screen->context);
393 C->data.recursion = 4;
394 if (cb) {
395 ret = cb(C, member, result);
396 if (ret) {
397 done = -(-ret | -done);
398 }
399 }
400 }
401
402 C->data.recursion = recursion;
403
404 return eContextResult(done);
405}
406
407static void *ctx_data_pointer_get(const bContext *C, const char *member)
408{
410 if (C && ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
412 return result.ptr.data;
413 }
414
415 return nullptr;
416}
417
418static bool ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
419{
420 /* if context is nullptr, pointer must be nullptr too and that is a valid return */
421 if (C == nullptr) {
422 *pointer = nullptr;
423 return true;
424 }
425
427 if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
429 *pointer = result.ptr.data;
430 return true;
431 }
432
433 *pointer = nullptr;
434 return false;
435}
436
438 const char *member,
439 Vector<PointerRNA> *list)
440{
442 if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
444 *list = std::move(result.list);
445 return true;
446 }
447
448 list->clear();
449 return false;
450}
451
453 const char *member,
454 Vector<PointerRNA> *list)
455{
456 Vector<PointerRNA> ctx_object_list;
457 if ((ctx_data_collection_get(C, member, &ctx_object_list) == false) ||
458 ctx_object_list.is_empty())
459 {
460 list->clear();
461 return false;
462 }
463
465
466 Scene *scene = CTX_data_scene(C);
467 ViewLayer *view_layer = CTX_data_view_layer(C);
468 BKE_view_layer_synced_ensure(scene, view_layer);
469
470 bool ok = false;
471
472 for (PointerRNA &ctx_object : ctx_object_list) {
473 Object *ob = static_cast<Object *>(ctx_object.data);
474 Base *base = BKE_view_layer_base_find(view_layer, ob);
475 if (base != nullptr) {
476 CTX_data_list_add(&result, &scene->id, &RNA_ObjectBase, base);
477 ok = true;
478 }
479 }
481
482 *list = std::move(result.list);
483 return ok;
484}
485
486PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
487{
489 if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
491 return result.ptr;
492 }
493
494 return PointerRNA_NULL;
495}
496
497PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
498{
500
501 if (ptr.data) {
502 if (RNA_struct_is_a(ptr.type, type)) {
503 return ptr;
504 }
505
506 CLOG_WARN(&LOG,
507 "member '%s' is '%s', not '%s'",
508 member,
511 }
512
513 return PointerRNA_NULL;
514}
515
517{
519
520 if (ptr.data && RNA_struct_is_a(ptr.type, type)) {
521 return ptr;
522 }
523
524 return PointerRNA_NULL;
525}
526
528{
530 if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
532 return result.list;
533 }
534 return {};
535}
536
538 const char *propname)
539{
540 for (PointerRNA &ptr : collection_pointers) {
541 ptr = RNA_pointer_get(&ptr, propname);
542 }
543}
544
545std::optional<blender::StringRefNull> CTX_data_string_get(const bContext *C, const char *member)
546{
548 if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
550 return result.str;
551 }
552
553 return {};
554}
555
556std::optional<int64_t> CTX_data_int_get(const bContext *C, const char *member)
557{
559 if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
561 return result.int_value;
562 }
563
564 return {};
565}
566
567int /*eContextResult*/ CTX_data_get(const bContext *C,
568 const char *member,
569 PointerRNA *r_ptr,
570 Vector<PointerRNA> *r_lb,
571 PropertyRNA **r_prop,
572 int *r_index,
573 blender::StringRef *r_str,
574 std::optional<int64_t> *r_int_value,
575 short *r_type)
576{
579
580 if (ret == CTX_RESULT_OK) {
581 *r_ptr = result.ptr;
582 *r_lb = result.list;
583 *r_prop = result.prop;
584 *r_index = result.index;
585 *r_str = result.str;
586 *r_int_value = result.int_value;
587 *r_type = result.type;
588 }
589 else {
590 *r_ptr = {};
591 r_lb->clear();
592 *r_str = "";
593 *r_int_value = {};
594 *r_type = 0;
595 }
596
597 return ret;
598}
599
600static void data_dir_add(ListBase *lb, const char *member, const bool use_all)
601{
602 LinkData *link;
603
604 if ((use_all == false) && STREQ(member, "scene")) { /* exception */
605 return;
606 }
607
608 if (BLI_findstring(lb, member, offsetof(LinkData, data))) {
609 return;
610 }
611
612 link = MEM_callocN<LinkData>(__func__);
613 link->data = (void *)member;
614 BLI_addtail(lb, link);
615}
616
618 const bool use_store,
619 const bool use_rna,
620 const bool use_all)
621{
623 ListBase lb;
624 bScreen *screen;
625 ScrArea *area;
626 ARegion *region;
627 int a;
628
629 memset(&lb, 0, sizeof(lb));
630
631 if (use_rna) {
632 char name_buf[256], *name;
633 int namelen;
634
635 PropertyRNA *iterprop;
636 PointerRNA ctx_ptr = RNA_pointer_create_discrete(nullptr, &RNA_Context, (void *)C);
637
638 iterprop = RNA_struct_iterator_property(ctx_ptr.type);
639
640 RNA_PROP_BEGIN (&ctx_ptr, itemptr, iterprop) {
641 name = RNA_struct_name_get_alloc(&itemptr, name_buf, sizeof(name_buf), &namelen);
642 data_dir_add(&lb, name, use_all);
643 if (name != name_buf) {
644 MEM_freeN(name);
645 }
646 }
648 }
649 if (use_store && C->wm.store) {
650 for (const bContextStoreEntry &entry : C->wm.store->entries) {
651 data_dir_add(&lb, entry.name.c_str(), use_all);
652 }
653 }
654 if ((region = CTX_wm_region(C)) && region->runtime->type && region->runtime->type->context) {
655 region->runtime->type->context(C, "", &result);
656
657 if (result.dir) {
658 for (a = 0; result.dir[a]; a++) {
659 data_dir_add(&lb, result.dir[a], use_all);
660 }
661 }
662 }
663 if ((area = CTX_wm_area(C)) && area->type && area->type->context) {
664 area->type->context(C, "", &result);
665
666 if (result.dir) {
667 for (a = 0; result.dir[a]; a++) {
668 data_dir_add(&lb, result.dir[a], use_all);
669 }
670 }
671 }
672 if ((screen = CTX_wm_screen(C)) && screen->context) {
673 bContextDataCallback cb = reinterpret_cast<bContextDataCallback>(screen->context);
674 cb(C, "", &result);
675
676 if (result.dir) {
677 for (a = 0; result.dir[a]; a++) {
678 data_dir_add(&lb, result.dir[a], use_all);
679 }
680 }
681 }
682
683 return lb;
684}
685
687{
688 return CTX_data_dir_get_ex(C, true, false, false);
689}
690
691bool CTX_data_equals(const char *member, const char *str)
692{
693 return STREQ(member, str);
694}
695
696bool CTX_data_dir(const char *member)
697{
698 return member[0] == '\0';
699}
700
705
707{
708 result->ptr = RNA_pointer_create_discrete(id, type, data);
709}
710
715
720
722{
723 result->list.append(RNA_pointer_create_discrete(id, type, data));
724}
725
727{
728 result->list.append(*ptr);
729}
730
732 bool (*func)(const bContext *, blender::Vector<PointerRNA> *))
733{
735 if (func(C, &list)) {
736 return list.size();
737 }
738 return 0;
739}
740
742{
743 result->prop = prop;
744 result->index = index;
745}
746
748{
749 result->dir = dir;
750}
751
753{
754 result->type = type;
755}
756
758{
759 return result->type;
760}
761
762/* window manager context */
763
765{
766 return C->wm.manager;
767}
768
770{
771 return C->wm.manager->runtime->is_interface_locked;
772}
773
775{
776 return static_cast<wmWindow *>(
777 ctx_wm_python_context_get(C, "window", &RNA_Window, C->wm.window));
778}
779
781{
782 return static_cast<WorkSpace *>(
783 ctx_wm_python_context_get(C, "workspace", &RNA_WorkSpace, C->wm.workspace));
784}
785
787{
788 return static_cast<bScreen *>(ctx_wm_python_context_get(C, "screen", &RNA_Screen, C->wm.screen));
789}
790
792{
793 return static_cast<ScrArea *>(ctx_wm_python_context_get(C, "area", &RNA_Area, C->wm.area));
794}
795
797{
798 ScrArea *area = CTX_wm_area(C);
799 return (area) ? static_cast<SpaceLink *>(area->spacedata.first) : nullptr;
800}
801
803{
804 return static_cast<ARegion *>(ctx_wm_python_context_get(C, "region", &RNA_Region, C->wm.region));
805}
806
808{
809 ARegion *region = CTX_wm_region(C);
810 return (region) ? region->regiondata : nullptr;
811}
812
814{
815 return C->wm.region_popup;
816}
817
819{
820 return C->wm.gizmo_group;
821}
822
824{
825 return C->wm.manager ? C->wm.manager->message_bus : nullptr;
826}
827
829{
830 if (C->wm.manager) {
831 return &(C->wm.manager->runtime->reports);
832 }
833
834 return nullptr;
835}
836
838{
839 ScrArea *area = CTX_wm_area(C);
840 if (area && area->spacetype == SPACE_VIEW3D) {
841 return static_cast<View3D *>(area->spacedata.first);
842 }
843 return nullptr;
844}
845
847{
848 ScrArea *area = CTX_wm_area(C);
849 ARegion *region = CTX_wm_region(C);
850
851 if (area && area->spacetype == SPACE_VIEW3D) {
852 if (region && region->regiontype == RGN_TYPE_WINDOW) {
853 return static_cast<RegionView3D *>(region->regiondata);
854 }
855 }
856 return nullptr;
857}
858
860{
861 ScrArea *area = CTX_wm_area(C);
862 if (area && area->spacetype == SPACE_TEXT) {
863 return static_cast<SpaceText *>(area->spacedata.first);
864 }
865 return nullptr;
866}
867
869{
870 ScrArea *area = CTX_wm_area(C);
871 if (area && area->spacetype == SPACE_CONSOLE) {
872 return static_cast<SpaceConsole *>(area->spacedata.first);
873 }
874 return nullptr;
875}
876
878{
879 ScrArea *area = CTX_wm_area(C);
880 if (area && area->spacetype == SPACE_IMAGE) {
881 return static_cast<SpaceImage *>(area->spacedata.first);
882 }
883 return nullptr;
884}
885
887{
888 ScrArea *area = CTX_wm_area(C);
889 if (area && area->spacetype == SPACE_PROPERTIES) {
890 return static_cast<SpaceProperties *>(area->spacedata.first);
891 }
892 return nullptr;
893}
894
896{
897 ScrArea *area = CTX_wm_area(C);
898 if (area && area->spacetype == SPACE_FILE) {
899 return static_cast<SpaceFile *>(area->spacedata.first);
900 }
901 return nullptr;
902}
903
905{
906 ScrArea *area = CTX_wm_area(C);
907 if (area && area->spacetype == SPACE_SEQ) {
908 return static_cast<SpaceSeq *>(area->spacedata.first);
909 }
910 return nullptr;
911}
912
914{
915 ScrArea *area = CTX_wm_area(C);
916 if (area && area->spacetype == SPACE_OUTLINER) {
917 return static_cast<SpaceOutliner *>(area->spacedata.first);
918 }
919 return nullptr;
920}
921
923{
924 ScrArea *area = CTX_wm_area(C);
925 if (area && area->spacetype == SPACE_NLA) {
926 return static_cast<SpaceNla *>(area->spacedata.first);
927 }
928 return nullptr;
929}
930
932{
933 ScrArea *area = CTX_wm_area(C);
934 if (area && area->spacetype == SPACE_NODE) {
935 return static_cast<SpaceNode *>(area->spacedata.first);
936 }
937 return nullptr;
938}
939
941{
942 ScrArea *area = CTX_wm_area(C);
943 if (area && area->spacetype == SPACE_GRAPH) {
944 return static_cast<SpaceGraph *>(area->spacedata.first);
945 }
946 return nullptr;
947}
948
950{
951 ScrArea *area = CTX_wm_area(C);
952 if (area && area->spacetype == SPACE_ACTION) {
953 return static_cast<SpaceAction *>(area->spacedata.first);
954 }
955 return nullptr;
956}
957
959{
960 ScrArea *area = CTX_wm_area(C);
961 if (area && area->spacetype == SPACE_INFO) {
962 return static_cast<SpaceInfo *>(area->spacedata.first);
963 }
964 return nullptr;
965}
966
968{
969 ScrArea *area = CTX_wm_area(C);
970 if (area && area->spacetype == SPACE_USERPREF) {
971 return static_cast<SpaceUserPref *>(area->spacedata.first);
972 }
973 return nullptr;
974}
975
977{
978 ScrArea *area = CTX_wm_area(C);
979 if (area && area->spacetype == SPACE_CLIP) {
980 return static_cast<SpaceClip *>(area->spacedata.first);
981 }
982 return nullptr;
983}
984
986{
987 ScrArea *area = CTX_wm_area(C);
988 if (area && area->spacetype == SPACE_TOPBAR) {
989 return static_cast<SpaceTopBar *>(area->spacedata.first);
990 }
991 return nullptr;
992}
993
995{
996 ScrArea *area = CTX_wm_area(C);
997 if (area && area->spacetype == SPACE_SPREADSHEET) {
998 return static_cast<SpaceSpreadsheet *>(area->spacedata.first);
999 }
1000 return nullptr;
1001}
1002
1004{
1005 C->wm.manager = wm;
1006 C->wm.window = nullptr;
1007 C->wm.screen = nullptr;
1008 C->wm.area = nullptr;
1009 C->wm.region = nullptr;
1010}
1011
1012#ifdef WITH_PYTHON
1013# define PYCTX_REGION_MEMBERS "region", "region_data"
1014# define PYCTX_AREA_MEMBERS "area", "space_data", PYCTX_REGION_MEMBERS
1015# define PYCTX_SCREEN_MEMBERS "screen", PYCTX_AREA_MEMBERS
1016# define PYCTX_WINDOW_MEMBERS "window", "scene", "workspace", PYCTX_SCREEN_MEMBERS
1017#endif
1018
1020{
1021 C->wm.window = win;
1022 if (win) {
1023 C->data.scene = win->scene;
1024 }
1025 C->wm.workspace = (win) ? BKE_workspace_active_get(win->workspace_hook) : nullptr;
1026 C->wm.screen = (win) ? BKE_workspace_active_screen_get(win->workspace_hook) : nullptr;
1027 C->wm.area = nullptr;
1028 C->wm.region = nullptr;
1029
1030#ifdef WITH_PYTHON
1031 if (C->data.py_context != nullptr) {
1032 const char *members[] = {PYCTX_WINDOW_MEMBERS};
1034 &C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
1035 }
1036#endif
1037}
1038
1040{
1041 C->wm.screen = screen;
1042 C->wm.area = nullptr;
1043 C->wm.region = nullptr;
1044
1045#ifdef WITH_PYTHON
1046 if (C->data.py_context != nullptr) {
1047 const char *members[] = {PYCTX_SCREEN_MEMBERS};
1049 &C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
1050 }
1051#endif
1052}
1053
1055{
1056 C->wm.area = area;
1057 C->wm.region = nullptr;
1058
1059#ifdef WITH_PYTHON
1060 if (C->data.py_context != nullptr) {
1061 const char *members[] = {PYCTX_AREA_MEMBERS};
1063 &C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
1064 }
1065#endif
1066}
1067
1069{
1070 C->wm.region = region;
1071
1072#ifdef WITH_PYTHON
1073 if (C->data.py_context != nullptr) {
1074 const char *members[] = {PYCTX_REGION_MEMBERS};
1076 &C->data.py_context, C->data.py_context_orig, members, ARRAY_SIZE(members));
1077 }
1078#endif
1079}
1080
1082{
1083 BLI_assert(region_popup == nullptr || region_popup->regiontype == RGN_TYPE_TEMPORARY);
1084 C->wm.region_popup = region_popup;
1085}
1086
1088{
1089 C->wm.gizmo_group = gzgroup;
1090}
1091
1093{
1094 bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params;
1095 if (params->free_fn != nullptr) {
1096 params->free_fn(C, params->user_data);
1097 }
1098 params->get_fn = nullptr;
1099 params->free_fn = nullptr;
1100 params->user_data = nullptr;
1101
1102 C->wm.operator_poll_msg = nullptr;
1103}
1105{
1107
1108 C->wm.operator_poll_msg = msg;
1109}
1110
1112{
1114
1115 C->wm.operator_poll_msg_dyn_params = *params;
1116}
1117
1118const char *CTX_wm_operator_poll_msg_get(bContext *C, bool *r_free)
1119{
1120 bContextPollMsgDyn_Params *params = &C->wm.operator_poll_msg_dyn_params;
1121 if (params->get_fn != nullptr) {
1122 char *msg = params->get_fn(C, params->user_data);
1123 if (msg != nullptr) {
1124 *r_free = true;
1125 }
1126 return msg;
1127 }
1128
1129 *r_free = false;
1130 return IFACE_(C->wm.operator_poll_msg);
1131}
1132
1133/* data context */
1134
1136{
1137 Main *bmain;
1138 if (ctx_data_pointer_verify(C, "blend_data", (void **)&bmain)) {
1139 return bmain;
1140 }
1141
1142 return C->data.main;
1143}
1144
1146{
1147 C->data.main = bmain;
1149}
1150
1152{
1153 Scene *scene;
1154 if (ctx_data_pointer_verify(C, "scene", (void **)&scene)) {
1155 return scene;
1156 }
1157
1158 return C->data.scene;
1159}
1160
1162{
1163 ViewLayer *view_layer;
1164
1165 if (ctx_data_pointer_verify(C, "view_layer", (void **)&view_layer)) {
1166 return view_layer;
1167 }
1168
1169 wmWindow *win = CTX_wm_window(C);
1170 Scene *scene = CTX_data_scene(C);
1171 if (win) {
1172 view_layer = BKE_view_layer_find(scene, win->view_layer_name);
1173 if (view_layer) {
1174 return view_layer;
1175 }
1176 }
1177
1178 return BKE_view_layer_default_view(scene);
1179}
1180
1182{
1183 Scene *scene = CTX_data_scene(C);
1184 return RE_engines_find(scene->r.engine);
1185}
1186
1188{
1189 ViewLayer *view_layer = CTX_data_view_layer(C);
1190 LayerCollection *layer_collection;
1191
1192 if (ctx_data_pointer_verify(C, "layer_collection", (void **)&layer_collection)) {
1193 if (BKE_view_layer_has_collection(view_layer, layer_collection->collection)) {
1194 return layer_collection;
1195 }
1196 }
1197
1198 /* fallback */
1199 return BKE_layer_collection_get_active(view_layer);
1200}
1201
1203{
1204 Collection *collection;
1205 if (ctx_data_pointer_verify(C, "collection", (void **)&collection)) {
1206 return collection;
1207 }
1208
1209 LayerCollection *layer_collection = CTX_data_layer_collection(C);
1210 if (layer_collection) {
1211 return layer_collection->collection;
1212 }
1213
1214 /* fallback */
1215 Scene *scene = CTX_data_scene(C);
1216 return scene->master_collection;
1217}
1218
1220 const Object *ob,
1221 const eObjectMode object_mode)
1222{
1223 // Object *obedit = CTX_data_edit_object(C);
1224 if (obedit) {
1225 switch (obedit->type) {
1226 case OB_MESH:
1227 return CTX_MODE_EDIT_MESH;
1228 case OB_CURVES_LEGACY:
1229 return CTX_MODE_EDIT_CURVE;
1230 case OB_SURF:
1231 return CTX_MODE_EDIT_SURFACE;
1232 case OB_FONT:
1233 return CTX_MODE_EDIT_TEXT;
1234 case OB_ARMATURE:
1236 case OB_MBALL:
1238 case OB_LATTICE:
1239 return CTX_MODE_EDIT_LATTICE;
1240 case OB_CURVES:
1241 return CTX_MODE_EDIT_CURVES;
1242 case OB_GREASE_PENCIL:
1244 case OB_POINTCLOUD:
1246 }
1247 }
1248 else {
1249 // Object *ob = CTX_data_active_object(C);
1250 if (ob) {
1251 if (object_mode & OB_MODE_POSE) {
1252 return CTX_MODE_POSE;
1253 }
1254 if (object_mode & OB_MODE_SCULPT) {
1255 return CTX_MODE_SCULPT;
1256 }
1257 if (object_mode & OB_MODE_WEIGHT_PAINT) {
1258 return CTX_MODE_PAINT_WEIGHT;
1259 }
1260 if (object_mode & OB_MODE_VERTEX_PAINT) {
1261 return CTX_MODE_PAINT_VERTEX;
1262 }
1263 if (object_mode & OB_MODE_TEXTURE_PAINT) {
1265 }
1266 if (object_mode & OB_MODE_PARTICLE_EDIT) {
1267 return CTX_MODE_PARTICLE;
1268 }
1269 if (object_mode & OB_MODE_PAINT_GREASE_PENCIL) {
1270 if (ob->type == OB_GREASE_PENCIL) {
1272 }
1273 }
1274 if (object_mode & OB_MODE_EDIT_GPENCIL_LEGACY) {
1276 }
1277 if (object_mode & OB_MODE_SCULPT_GREASE_PENCIL) {
1278 if (ob->type == OB_GREASE_PENCIL) {
1280 }
1281 }
1282 if (object_mode & OB_MODE_WEIGHT_GREASE_PENCIL) {
1283 if (ob->type == OB_GREASE_PENCIL) {
1285 }
1286 }
1287 if (object_mode & OB_MODE_VERTEX_GREASE_PENCIL) {
1288 if (ob->type == OB_GREASE_PENCIL) {
1290 }
1291 }
1292 if (object_mode & OB_MODE_SCULPT_CURVES) {
1294 }
1295 }
1296 }
1297
1298 return CTX_MODE_OBJECT;
1299}
1300
1302{
1303 Object *obedit = CTX_data_edit_object(C);
1304 Object *obact = obedit ? nullptr : CTX_data_active_object(C);
1305 return CTX_data_mode_enum_ex(obedit, obact, obact ? eObjectMode(obact->mode) : OB_MODE_OBJECT);
1306}
1307
1313static const char *data_mode_strings[] = {
1314 "mesh_edit",
1315 "curve_edit",
1316 "surface_edit",
1317 "text_edit",
1318 "armature_edit",
1319 "mball_edit",
1320 "lattice_edit",
1321 "curves_edit",
1322 "grease_pencil_edit",
1323 "pointcloud_edit",
1324 "posemode",
1325 "sculpt_mode",
1326 "weightpaint",
1327 "vertexpaint",
1328 "imagepaint",
1329 "particlemode",
1330 "objectmode",
1331 "greasepencil_paint",
1332 "greasepencil_edit",
1333 "greasepencil_sculpt",
1334 "greasepencil_weight",
1335 "greasepencil_vertex",
1336 "curves_sculpt",
1337 "grease_pencil_paint",
1338 "grease_pencil_sculpt",
1339 "grease_pencil_weight",
1340 "grease_pencil_vertex",
1341 nullptr,
1342};
1344 "Must have a string for each context mode")
1345const char *CTX_data_mode_string(const bContext *C)
1346{
1348}
1349
1351{
1352 C->data.scene = scene;
1353
1354#ifdef WITH_PYTHON
1355 if (C->data.py_context != nullptr) {
1356 const char *members[] = {"scene"};
1357 BPY_context_dict_clear_members_array(&C->data.py_context, C->data.py_context_orig, members, 1);
1358 }
1359#endif
1360}
1361
1363{
1364 Scene *scene = CTX_data_scene(C);
1365
1366 if (scene) {
1367 return scene->toolsettings;
1368 }
1369
1370 return nullptr;
1371}
1372
1374{
1375 return ctx_data_collection_get(C, "selected_ids", list);
1376}
1377
1379{
1380 return ctx_data_collection_get(C, "selected_nodes", list);
1381}
1382
1384{
1385 return ctx_data_collection_get(C, "selected_editable_objects", list);
1386}
1387
1389{
1390 return ctx_data_base_collection_get(C, "selected_editable_objects", list);
1391}
1392
1394{
1395 return ctx_data_collection_get(C, "editable_objects", list);
1396}
1397
1399{
1400 return ctx_data_base_collection_get(C, "editable_objects", list);
1401}
1402
1404{
1405 return ctx_data_collection_get(C, "selected_objects", list);
1406}
1407
1409{
1410 return ctx_data_base_collection_get(C, "selected_objects", list);
1411}
1412
1414{
1415 return ctx_data_collection_get(C, "visible_objects", list);
1416}
1417
1419{
1420 return ctx_data_base_collection_get(C, "visible_objects", list);
1421}
1422
1424{
1425 return ctx_data_collection_get(C, "selectable_objects", list);
1426}
1427
1429{
1430 return ctx_data_base_collection_get(C, "selectable_objects", list);
1431}
1432
1434{
1435 return static_cast<Object *>(ctx_data_pointer_get(C, "active_object"));
1436}
1437
1439{
1441
1442 if (ob == nullptr) {
1443 return nullptr;
1444 }
1445 const Scene *scene = CTX_data_scene(C);
1446 ViewLayer *view_layer = CTX_data_view_layer(C);
1447 BKE_view_layer_synced_ensure(scene, view_layer);
1448 return BKE_view_layer_base_find(view_layer, ob);
1449}
1450
1452{
1453 return static_cast<Object *>(ctx_data_pointer_get(C, "edit_object"));
1454}
1455
1457{
1458 return static_cast<Image *>(ctx_data_pointer_get(C, "edit_image"));
1459}
1460
1462{
1463 return static_cast<Text *>(ctx_data_pointer_get(C, "edit_text"));
1464}
1465
1467{
1468 return static_cast<MovieClip *>(ctx_data_pointer_get(C, "edit_movieclip"));
1469}
1470
1472{
1473 return static_cast<Mask *>(ctx_data_pointer_get(C, "edit_mask"));
1474}
1475
1477{
1478 return static_cast<EditBone *>(ctx_data_pointer_get(C, "active_bone"));
1479}
1480
1482{
1483 return static_cast<CacheFile *>(ctx_data_pointer_get(C, "edit_cachefile"));
1484}
1485
1487{
1488 return ctx_data_collection_get(C, "selected_bones", list);
1489}
1490
1492{
1493 return ctx_data_collection_get(C, "selected_editable_bones", list);
1494}
1495
1497{
1498 return ctx_data_collection_get(C, "visible_bones", list);
1499}
1500
1502{
1503 return ctx_data_collection_get(C, "editable_bones", list);
1504}
1505
1507{
1508 return static_cast<bPoseChannel *>(ctx_data_pointer_get(C, "active_pose_bone"));
1509}
1510
1512{
1513 return ctx_data_collection_get(C, "selected_pose_bones", list);
1514}
1515
1518{
1519 return ctx_data_collection_get(C, "selected_pose_bones_from_active_object", list);
1520}
1521
1523{
1524 return ctx_data_collection_get(C, "visible_pose_bones", list);
1525}
1526
1528{
1529 return static_cast<AssetLibraryReference *>(ctx_data_pointer_get(C, "asset_library_reference"));
1530}
1531
1532static AssetHandle ctx_wm_asset_handle(const bContext *C, bool *r_is_valid)
1533{
1534 AssetHandle *asset_handle_p =
1535 (AssetHandle *)CTX_data_pointer_get_type(C, "asset_handle", &RNA_AssetHandle).data;
1536 if (asset_handle_p) {
1537 *r_is_valid = true;
1538 return *asset_handle_p;
1539 }
1540
1541 /* If the asset handle was not found in context directly, try if there's an active file with
1542 * asset data there instead. Not nice to have this here, would be better to have this in
1543 * `ED_asset.hh`, but we can't include that in BKE. Even better would be not needing this at all
1544 * and being able to have editors return this in the usual `context` callback. But that would
1545 * require returning a non-owning pointer, which we don't have in the Asset Browser (yet). */
1546 FileDirEntry *file =
1547 (FileDirEntry *)CTX_data_pointer_get_type(C, "active_file", &RNA_FileSelectEntry).data;
1548 if (file && file->asset) {
1549 *r_is_valid = true;
1550 return AssetHandle{file};
1551 }
1552
1553 *r_is_valid = false;
1554 return AssetHandle{nullptr};
1555}
1556
1558{
1559 if (auto *asset = static_cast<blender::asset_system::AssetRepresentation *>(
1560 ctx_data_pointer_get(C, "asset")))
1561 {
1562 return asset;
1563 }
1564
1565 /* Expose the asset representation from the asset-handle.
1566 * TODO(Julian): #AssetHandle should be properly replaced by #AssetRepresentation. */
1567 bool is_valid;
1568 if (AssetHandle handle = ctx_wm_asset_handle(C, &is_valid); is_valid) {
1569 return handle.file_data->asset;
1570 }
1571
1572 return nullptr;
1573}
1574
1576{
1577 Main *bmain = CTX_data_main(C);
1578 Scene *scene = CTX_data_scene(C);
1579 ViewLayer *view_layer = CTX_data_view_layer(C);
1580 Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
1581 /* Dependency graph might have been just allocated, and hence it will not be marked.
1582 * This confuses redo system due to the lack of flushing changes back to the original data.
1583 * In the future we would need to check whether the CTX_wm_window(C) is in editing mode (as an
1584 * opposite of playback-preview-only) and set active flag based on that. */
1586 return depsgraph;
1587}
1588
1590{
1592 /* TODO(sergey): Assert that the dependency graph is fully evaluated.
1593 * Note that first the depsgraph and scene post-evaluation hooks needs to run extra round of
1594 * updates first to make check here really reliable. */
1595 return depsgraph;
1596}
1597
1599{
1601 Main *bmain = CTX_data_main(C);
1603 return depsgraph;
1604}
1605
1607{
1608 Scene *scene = CTX_data_scene(C);
1609 ViewLayer *view_layer = CTX_data_view_layer(C);
1610 return BKE_scene_get_depsgraph(scene, view_layer);
1611}
const char * CTX_data_mode_string(const bContext *C)
eContextObjectMode
@ CTX_MODE_PAINT_GREASE_PENCIL
@ CTX_MODE_EDIT_CURVE
@ CTX_MODE_PAINT_TEXTURE
@ CTX_MODE_EDIT_SURFACE
@ CTX_MODE_SCULPT_GREASE_PENCIL
@ CTX_MODE_PARTICLE
@ CTX_MODE_SCULPT
@ CTX_MODE_OBJECT
@ CTX_MODE_EDIT_MESH
@ CTX_MODE_EDIT_POINTCLOUD
@ CTX_MODE_EDIT_GREASE_PENCIL
@ CTX_MODE_SCULPT_CURVES
@ CTX_MODE_EDIT_TEXT
@ CTX_MODE_EDIT_CURVES
@ CTX_MODE_EDIT_ARMATURE
@ CTX_MODE_EDIT_LATTICE
@ CTX_MODE_WEIGHT_GREASE_PENCIL
@ CTX_MODE_VERTEX_GREASE_PENCIL
@ CTX_MODE_PAINT_VERTEX
@ CTX_MODE_EDIT_METABALL
@ CTX_MODE_PAINT_WEIGHT
@ CTX_MODE_EDIT_GPENCIL_LEGACY
@ CTX_MODE_POSE
#define CTX_MODE_NUM
eContextResult
@ CTX_RESULT_MEMBER_NOT_FOUND
@ CTX_RESULT_OK
@ CTX_DATA_TYPE_INT64
@ CTX_DATA_TYPE_POINTER
@ CTX_DATA_TYPE_COLLECTION
@ CTX_DATA_TYPE_STRING
int(*)(const bContext *C, const char *member, bContextDataResult *result) bContextDataCallback
bool BKE_view_layer_has_collection(const ViewLayer *view_layer, const Collection *collection)
LayerCollection * BKE_layer_collection_get_active(ViewLayer *view_layer)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
ViewLayer * BKE_view_layer_default_view(const Scene *scene)
ViewLayer * BKE_view_layer_find(const Scene *scene, const char *layer_name)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
void BKE_scene_graph_evaluated_ensure(Depsgraph *depsgraph, Main *bmain)
Definition scene.cc:2623
Depsgraph * BKE_scene_ensure_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer)
Definition scene.cc:3427
Depsgraph * BKE_scene_get_depsgraph(const Scene *scene, const ViewLayer *view_layer)
Definition scene.cc:3414
void BKE_sound_refresh_callback_bmain(struct Main *bmain)
bScreen * BKE_workspace_active_screen_get(const WorkSpaceInstanceHook *hook) GETTER_ATTRS
Definition workspace.cc:612
WorkSpace * BKE_workspace_active_get(WorkSpaceInstanceHook *hook) GETTER_ATTRS
Definition workspace.cc:561
#define BLI_STATIC_ASSERT(a, msg)
Definition BLI_assert.h:83
#define BLI_assert(a)
Definition BLI_assert.h:46
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:608
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:111
int BLI_thread_is_main(void)
Definition threads.cc:179
#define ARRAY_SIZE(arr)
#define UNUSED_VARS(...)
#define UNLIKELY(x)
#define STREQ(a, b)
#define IFACE_(msgid)
void BPY_context_dict_clear_members_array(void **dict_p, void *dict_orig, const char *context_members[], uint context_members_len)
int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *result)
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:181
void DEG_make_active(Depsgraph *depsgraph)
Definition depsgraph.cc:336
Object groups, one object can be in many groups at once.
eObjectMode
@ OB_MODE_VERTEX_GREASE_PENCIL
@ OB_MODE_PARTICLE_EDIT
@ OB_MODE_EDIT_GPENCIL_LEGACY
@ OB_MODE_WEIGHT_PAINT
@ OB_MODE_SCULPT
@ OB_MODE_SCULPT_CURVES
@ OB_MODE_PAINT_GREASE_PENCIL
@ OB_MODE_SCULPT_GREASE_PENCIL
@ OB_MODE_POSE
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_OBJECT
@ OB_MODE_WEIGHT_GREASE_PENCIL
@ OB_MODE_VERTEX_PAINT
Object is a sort of wrapper for general info.
@ OB_LATTICE
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_GREASE_PENCIL
@ OB_ARMATURE
@ OB_MESH
@ OB_POINTCLOUD
@ OB_CURVES_LEGACY
@ OB_CURVES
@ RGN_TYPE_TEMPORARY
@ RGN_TYPE_WINDOW
@ SPACE_TEXT
@ SPACE_CLIP
@ SPACE_ACTION
@ SPACE_CONSOLE
@ SPACE_OUTLINER
@ SPACE_TOPBAR
@ SPACE_NODE
@ SPACE_SPREADSHEET
@ SPACE_USERPREF
@ SPACE_FILE
@ SPACE_PROPERTIES
@ SPACE_NLA
@ SPACE_SEQ
@ SPACE_IMAGE
@ SPACE_GRAPH
@ SPACE_VIEW3D
@ SPACE_INFO
Read Guarded memory(de)allocation.
#define RNA_PROP_END
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
#define C
Definition RandGen.cpp:29
bContextStore * CTX_store_add_all(Vector< std::unique_ptr< bContextStore > > &contexts, const bContextStore *context)
short CTX_data_type_get(bContextDataResult *result)
SpaceGraph * CTX_wm_space_graph(const bContext *C)
Image * CTX_data_edit_image(const bContext *C)
bool CTX_data_selectable_bases(const bContext *C, blender::Vector< PointerRNA > *list)
Depsgraph * CTX_data_expect_evaluated_depsgraph(const bContext *C)
void CTX_data_main_set(bContext *C, Main *bmain)
PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
void CTX_wm_gizmo_group_set(bContext *C, wmGizmoGroup *gzgroup)
void CTX_py_state_push(bContext *C, bContext_PyState *pystate, void *value)
WorkSpace * CTX_wm_workspace(const bContext *C)
bool CTX_data_visible_bones(const bContext *C, blender::Vector< PointerRNA > *list)
bool CTX_wm_interface_locked(const bContext *C)
SpaceText * CTX_wm_space_text(const bContext *C)
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
bool CTX_data_selected_bones(const bContext *C, blender::Vector< PointerRNA > *list)
bPoseChannel * CTX_data_active_pose_bone(const bContext *C)
PointerRNA CTX_data_pointer_get_type_silent(const bContext *C, const char *member, StructRNA *type)
SpaceUserPref * CTX_wm_space_userpref(const bContext *C)
SpaceTopBar * CTX_wm_space_topbar(const bContext *C)
void CTX_data_id_list_add(bContextDataResult *result, ID *id)
SpaceImage * CTX_wm_space_image(const bContext *C)
bool CTX_data_equals(const char *member, const char *str)
ReportList * CTX_wm_reports(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
SpaceNla * CTX_wm_space_nla(const bContext *C)
bool CTX_data_visible_bases(const bContext *C, blender::Vector< PointerRNA > *list)
bool CTX_data_visible_objects(const bContext *C, blender::Vector< PointerRNA > *list)
Mask * CTX_data_edit_mask(const bContext *C)
bool CTX_py_init_get(bContext *C)
void CTX_data_prop_set(bContextDataResult *result, PropertyRNA *prop, int index)
static AssetHandle ctx_wm_asset_handle(const bContext *C, bool *r_is_valid)
void CTX_data_pointer_set(bContextDataResult *result, ID *id, StructRNA *type, void *data)
LayerCollection * CTX_data_layer_collection(const bContext *C)
bool CTX_data_selected_pose_bones_from_active_object(const bContext *C, blender::Vector< PointerRNA > *list)
SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
std::optional< int64_t > CTX_store_int_lookup(const bContextStore *store, const blender::StringRef name)
int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, Vector< PointerRNA > *r_lb, PropertyRNA **r_prop, int *r_index, blender::StringRef *r_str, std::optional< int64_t > *r_int_value, short *r_type)
static void * ctx_wm_python_context_get(const bContext *C, const char *member, const StructRNA *member_type, void *fall_through)
static eContextResult ctx_data_get(bContext *C, const char *member, bContextDataResult *result)
CacheFile * CTX_data_edit_cachefile(const bContext *C)
MovieClip * CTX_data_edit_movieclip(const bContext *C)
bool CTX_data_dir(const char *member)
static void data_dir_add(ListBase *lb, const char *member, const bool use_all)
void CTX_data_id_pointer_set(bContextDataResult *result, ID *id)
void * CTX_wm_region_data(const bContext *C)
static const char * data_mode_strings[]
void CTX_py_state_pop(bContext *C, bContext_PyState *pystate)
SpaceAction * CTX_wm_space_action(const bContext *C)
SpaceConsole * CTX_wm_space_console(const bContext *C)
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
ARegion * CTX_wm_region_popup(const bContext *C)
void CTX_wm_operator_poll_msg_clear(bContext *C)
void CTX_py_init_set(bContext *C, bool value)
SpaceFile * CTX_wm_space_file(const bContext *C)
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
SpaceNode * CTX_wm_space_node(const bContext *C)
bContext * CTX_copy(const bContext *C)
SpaceProperties * CTX_wm_space_properties(const bContext *C)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
bool CTX_data_editable_bones(const bContext *C, blender::Vector< PointerRNA > *list)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
static bool ctx_data_base_collection_get(const bContext *C, const char *member, Vector< PointerRNA > *list)
static bContextStore * ctx_store_extend(Vector< std::unique_ptr< bContextStore > > &contexts)
static void * ctx_data_pointer_get(const bContext *C, const char *member)
void CTX_free(bContext *C)
Object * CTX_data_active_object(const bContext *C)
Vector< PointerRNA > CTX_data_collection_get(const bContext *C, const char *member)
ListBase CTX_data_dir_get(const bContext *C)
const AssetLibraryReference * CTX_wm_asset_library_ref(const bContext *C)
void CTX_wm_operator_poll_msg_set_dynamic(bContext *C, const bContextPollMsgDyn_Params *params)
Text * CTX_data_edit_text(const bContext *C)
blender::asset_system::AssetRepresentation * CTX_wm_asset(const bContext *C)
std::optional< int64_t > CTX_data_int_get(const bContext *C, const char *member)
RenderEngineType * CTX_data_engine_type(const bContext *C)
SpaceLink * CTX_wm_space_data(const bContext *C)
void CTX_wm_screen_set(bContext *C, bScreen *screen)
void CTX_data_scene_set(bContext *C, Scene *scene)
Scene * CTX_data_scene(const bContext *C)
static bool ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
ListBase CTX_data_dir_get_ex(const bContext *C, const bool use_store, const bool use_rna, const bool use_all)
int ctx_data_list_count(const bContext *C, bool(*func)(const bContext *, blender::Vector< PointerRNA > *))
SpaceSeq * CTX_wm_space_seq(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void *data)
bool CTX_data_selectable_objects(const bContext *C, blender::Vector< PointerRNA > *list)
Base * CTX_data_active_base(const bContext *C)
enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectMode object_mode)
void CTX_wm_window_set(bContext *C, wmWindow *win)
bool CTX_data_selected_objects(const bContext *C, blender::Vector< PointerRNA > *list)
Main * CTX_data_main(const bContext *C)
bool CTX_data_selected_editable_objects(const bContext *C, blender::Vector< PointerRNA > *list)
bool CTX_data_visible_pose_bones(const bContext *C, blender::Vector< PointerRNA > *list)
bool CTX_data_editable_objects(const bContext *C, blender::Vector< PointerRNA > *list)
bool CTX_data_editable_bases(const bContext *C, blender::Vector< PointerRNA > *list)
void * CTX_py_dict_get_orig(const bContext *C)
static bool ctx_data_collection_get(const bContext *C, const char *member, Vector< PointerRNA > *list)
const bContextStore * CTX_store_get(const bContext *C)
void CTX_data_list_add_ptr(bContextDataResult *result, const PointerRNA *ptr)
const PointerRNA * CTX_store_ptr_lookup(const bContextStore *store, const blender::StringRef name, const StructRNA *type)
bool CTX_data_selected_nodes(const bContext *C, blender::Vector< PointerRNA > *list)
const char * CTX_wm_operator_poll_msg_get(bContext *C, bool *r_free)
void CTX_data_pointer_set_ptr(bContextDataResult *result, const PointerRNA *ptr)
void CTX_store_set(bContext *C, const bContextStore *store)
wmGizmoGroup * CTX_wm_gizmo_group(const bContext *C)
ToolSettings * CTX_data_tool_settings(const bContext *C)
bool CTX_data_selected_editable_bases(const bContext *C, blender::Vector< PointerRNA > *list)
SpaceInfo * CTX_wm_space_info(const bContext *C)
bool CTX_data_selected_pose_bones(const bContext *C, blender::Vector< PointerRNA > *list)
const T * ctx_store_lookup_impl(const bContextStore *store, const blender::StringRef name)
void CTX_data_collection_remap_property(blender::MutableSpan< PointerRNA > collection_pointers, const char *propname)
void CTX_wm_area_set(bContext *C, ScrArea *area)
SpaceClip * CTX_wm_space_clip(const bContext *C)
bool CTX_data_selected_bases(const bContext *C, blender::Vector< PointerRNA > *list)
EditBone * CTX_data_active_bone(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
Collection * CTX_data_collection(const bContext *C)
bool CTX_data_selected_editable_bones(const bContext *C, blender::Vector< PointerRNA > *list)
void * CTX_py_dict_get(const bContext *C)
Depsgraph * CTX_data_depsgraph_on_load(const bContext *C)
SpaceSpreadsheet * CTX_wm_space_spreadsheet(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
bContext * CTX_create()
std::optional< blender::StringRefNull > CTX_data_string_get(const bContext *C, const char *member)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
void CTX_data_type_set(bContextDataResult *result, short type)
std::optional< blender::StringRefNull > CTX_store_string_lookup(const bContextStore *store, const blender::StringRef name)
bContextStore * CTX_store_add(Vector< std::unique_ptr< bContextStore > > &contexts, const blender::StringRef name, const PointerRNA *ptr)
void CTX_wm_region_popup_set(bContext *C, ARegion *region_popup)
View3D * CTX_wm_view3d(const bContext *C)
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
bool CTX_data_selected_ids(const bContext *C, blender::Vector< PointerRNA > *list)
BMesh const char void * data
BPy_StructRNA * depsgraph
long long int int64_t
std::reverse_iterator< T * > rbegin()
void append(const T &value)
std::reverse_iterator< T * > rend()
int64_t size() const
bool is_empty() const
#define offsetof(t, d)
#define str(s)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
RenderEngineType * RE_engines_find(const char *idname)
#define LOG(severity)
Definition log.h:32
static char ** members
Definition makesdna.cc:69
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
#define T
return ret
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
char * RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
const PointerRNA PointerRNA_NULL
const char * RNA_struct_identifier(const StructRNA *type)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_struct_iterator_property(StructRNA *type)
PointerRNA RNA_id_pointer_create(ID *id)
void * regiondata
ARegionRuntimeHandle * runtime
AssetRepresentationHandle * asset
Definition DNA_ID.h:404
struct Collection * collection
void * data
void * first
StructRNA * type
Definition RNA_types.hh:52
void * data
Definition RNA_types.hh:53
char engine[32]
struct Collection * master_collection
struct ToolSettings * toolsettings
struct RenderData r
ListBase spacedata
struct SpaceType * type
bContextDataCallback context
std::optional< int64_t > int_value
blender::StringRefNull str
blender::Vector< bContextStoreEntry > entries
const char * operator_poll_msg
bContextPollMsgDyn_Params operator_poll_msg_dyn_params
const bContextStore * store
struct bContext::@356210030170374202354026020347217254375374146133 wm
wmGizmoGroup * gizmo_group
wmWindowManager * manager
struct Scene * scene
struct WorkSpaceInstanceHook * workspace_hook
PointerRNA * ptr
Definition wm_files.cc:4227