Blender  V2.93
context.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <stddef.h>
22 #include <stdlib.h>
23 #include <string.h>
24 
25 #include "MEM_guardedalloc.h"
26 
27 #include "DNA_collection_types.h"
28 #include "DNA_gpencil_types.h"
29 #include "DNA_linestyle_types.h"
30 #include "DNA_object_types.h"
31 #include "DNA_scene_types.h"
32 #include "DNA_screen_types.h"
33 #include "DNA_space_types.h"
34 #include "DNA_view3d_types.h"
36 #include "DNA_workspace_types.h"
37 
38 #include "DEG_depsgraph.h"
39 
40 #include "BLI_listbase.h"
41 #include "BLI_string.h"
42 #include "BLI_threads.h"
43 #include "BLI_utildefines.h"
44 
45 #include "BLT_translation.h"
46 
47 #include "BKE_context.h"
48 #include "BKE_layer.h"
49 #include "BKE_main.h"
50 #include "BKE_scene.h"
51 #include "BKE_screen.h"
52 #include "BKE_sound.h"
53 #include "BKE_workspace.h"
54 
55 #include "RE_engine.h"
56 
57 #include "RNA_access.h"
58 
59 #include "CLG_log.h"
60 
61 #ifdef WITH_PYTHON
62 # include "BPY_extern.h"
63 #endif
64 
65 static CLG_LogRef LOG = {"bke.context"};
66 
67 /* struct */
68 
69 struct bContext {
70  int thread;
71 
72  /* windowmanager context */
73  struct {
75  struct wmWindow *window;
77  struct bScreen *screen;
78  struct ScrArea *area;
79  struct ARegion *region;
80  struct ARegion *menu;
83  const char *operator_poll_msg; /* reason for poll failing */
84  } wm;
85 
86  /* data context */
87  struct {
88  struct Main *main;
89  struct Scene *scene;
90 
91  int recursion;
93  bool py_init;
94  void *py_context;
100  } data;
101 };
102 
103 /* context */
104 
106 {
107  bContext *C = MEM_callocN(sizeof(bContext), "bContext");
108 
109  return C;
110 }
111 
113 {
114  bContext *newC = MEM_dupallocN((void *)C);
115 
116  return newC;
117 }
118 
120 {
121  MEM_freeN(C);
122 }
123 
124 /* store */
125 
126 bContextStore *CTX_store_add(ListBase *contexts, const char *name, const PointerRNA *ptr)
127 {
128  /* ensure we have a context to put the entry in, if it was already used
129  * we have to copy the context to ensure */
130  bContextStore *ctx = contexts->last;
131 
132  if (!ctx || ctx->used) {
133  if (ctx) {
134  bContextStore *lastctx = ctx;
135  ctx = MEM_dupallocN(lastctx);
136  BLI_duplicatelist(&ctx->entries, &lastctx->entries);
137  }
138  else {
139  ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
140  }
141 
142  BLI_addtail(contexts, ctx);
143  }
144 
145  bContextStoreEntry *entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
146  BLI_strncpy(entry->name, name, sizeof(entry->name));
147  entry->ptr = *ptr;
148 
149  BLI_addtail(&ctx->entries, entry);
150 
151  return ctx;
152 }
153 
155 {
156  /* ensure we have a context to put the entries in, if it was already used
157  * we have to copy the context to ensure */
158  bContextStore *ctx = contexts->last;
159 
160  if (!ctx || ctx->used) {
161  if (ctx) {
162  bContextStore *lastctx = ctx;
163  ctx = MEM_dupallocN(lastctx);
164  BLI_duplicatelist(&ctx->entries, &lastctx->entries);
165  }
166  else {
167  ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
168  }
169 
170  BLI_addtail(contexts, ctx);
171  }
172 
173  LISTBASE_FOREACH (bContextStoreEntry *, tentry, &context->entries) {
174  bContextStoreEntry *entry = MEM_dupallocN(tentry);
175  BLI_addtail(&ctx->entries, entry);
176  }
177 
178  return ctx;
179 }
180 
182 {
183  return C->wm.store;
184 }
185 
187 {
188  C->wm.store = store;
189 }
190 
192 {
193  bContextStore *ctx = MEM_dupallocN(store);
194  BLI_duplicatelist(&ctx->entries, &store->entries);
195 
196  return ctx;
197 }
198 
200 {
201  BLI_freelistN(&store->entries);
202  MEM_freeN(store);
203 }
204 
206 {
207  bContextStore *ctx;
208  while ((ctx = BLI_pophead(contexts))) {
209  CTX_store_free(ctx);
210  }
211 }
212 
213 /* is python initialized? */
214 
216 {
217  return C->data.py_init;
218 }
219 void CTX_py_init_set(bContext *C, bool value)
220 {
221  C->data.py_init = value;
222 }
223 
225 {
226  return C->data.py_context;
227 }
229 {
230  return C->data.py_context_orig;
231 }
232 
233 void CTX_py_state_push(bContext *C, struct bContext_PyState *pystate, void *value)
234 {
235  pystate->py_context = C->data.py_context;
236  pystate->py_context_orig = C->data.py_context_orig;
237 
238  C->data.py_context = value;
239  C->data.py_context_orig = value;
240 }
242 {
243  C->data.py_context = pystate->py_context;
244  C->data.py_context_orig = pystate->py_context_orig;
245 }
246 
247 /* data context utility functions */
248 
252  const char **dir;
253  short type; /* 0: normal, 1: seq */
254 };
255 
257  const char *member,
258  const StructRNA *member_type,
259  void *fall_through)
260 {
261 #ifdef WITH_PYTHON
262  if (UNLIKELY(C && CTX_py_dict_get(C))) {
264  memset(&result, 0, sizeof(bContextDataResult));
265  BPY_context_member_get((bContext *)C, member, &result);
266 
267  if (result.ptr.data) {
268  if (RNA_struct_is_a(result.ptr.type, member_type)) {
269  return result.ptr.data;
270  }
271 
272  CLOG_WARN(&LOG,
273  "PyContext '%s' is a '%s', expected a '%s'",
274  member,
275  RNA_struct_identifier(result.ptr.type),
276  RNA_struct_identifier(member_type));
277  }
278  }
279 #else
280  UNUSED_VARS(C, member, member_type);
281 #endif
282 
283  /* don't allow UI context access from non-main threads */
284  if (!BLI_thread_is_main()) {
285  return NULL;
286  }
287 
288  return fall_through;
289 }
290 
292 {
293  bScreen *screen;
294  ScrArea *area;
295  ARegion *region;
296  int done = 0, recursion = C->data.recursion;
297  int ret = 0;
298 
299  memset(result, 0, sizeof(bContextDataResult));
300 #ifdef WITH_PYTHON
301  if (CTX_py_dict_get(C)) {
302  if (BPY_context_member_get(C, member, result)) {
303  return 1;
304  }
305  }
306 #endif
307 
308  /* don't allow UI context access from non-main threads */
309  if (!BLI_thread_is_main()) {
310  return done;
311  }
312 
313  /* we check recursion to ensure that we do not get infinite
314  * loops requesting data from ourselves in a context callback */
315 
316  /* Ok, this looks evil...
317  * if (ret) done = -(-ret | -done);
318  *
319  * Values in order of importance
320  * (0, -1, 1) - Where 1 is highest priority
321  */
322  if (done != 1 && recursion < 1 && C->wm.store) {
323  C->data.recursion = 1;
324 
326  &C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
327 
328  if (entry) {
329  result->ptr = entry->ptr;
330  done = 1;
331  }
332  }
333  if (done != 1 && recursion < 2 && (region = CTX_wm_region(C))) {
334  C->data.recursion = 2;
335  if (region->type && region->type->context) {
336  ret = region->type->context(C, member, result);
337  if (ret) {
338  done = -(-ret | -done);
339  }
340  }
341  }
342  if (done != 1 && recursion < 3 && (area = CTX_wm_area(C))) {
343  C->data.recursion = 3;
344  if (area->type && area->type->context) {
345  ret = area->type->context(C, member, result);
346  if (ret) {
347  done = -(-ret | -done);
348  }
349  }
350  }
351 
352  if (done != 1 && recursion < 4 && (screen = CTX_wm_screen(C))) {
353  bContextDataCallback cb = screen->context;
354  C->data.recursion = 4;
355  if (cb) {
356  ret = cb(C, member, result);
357  if (ret) {
358  done = -(-ret | -done);
359  }
360  }
361  }
362 
363  C->data.recursion = recursion;
364 
365  return done;
366 }
367 
368 static void *ctx_data_pointer_get(const bContext *C, const char *member)
369 {
371  if (C && ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
373  return result.ptr.data;
374  }
375 
376  return NULL;
377 }
378 
379 static int ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
380 {
381  /* if context is NULL, pointer must be NULL too and that is a valid return */
382  if (C == NULL) {
383  *pointer = NULL;
384  return 1;
385  }
386 
388  if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
390  *pointer = result.ptr.data;
391  return 1;
392  }
393 
394  *pointer = NULL;
395  return 0;
396 }
397 
398 static int ctx_data_collection_get(const bContext *C, const char *member, ListBase *list)
399 {
401  if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
403  *list = result.list;
404  return 1;
405  }
406 
407  BLI_listbase_clear(list);
408 
409  return 0;
410 }
411 
412 static int ctx_data_base_collection_get(const bContext *C, const char *member, ListBase *list)
413 {
414  ListBase ctx_object_list;
415  if ((ctx_data_collection_get(C, member, &ctx_object_list) == false) ||
416  BLI_listbase_is_empty(&ctx_object_list)) {
417  BLI_listbase_clear(list);
418  return 0;
419  }
420 
422  memset(&result, 0, sizeof(bContextDataResult));
423 
425  ViewLayer *view_layer = CTX_data_view_layer(C);
426 
427  bool ok = false;
428 
429  CollectionPointerLink *ctx_object;
430  for (ctx_object = ctx_object_list.first; ctx_object; ctx_object = ctx_object->next) {
431  Object *ob = ctx_object->ptr.data;
432  Base *base = BKE_view_layer_base_find(view_layer, ob);
433  if (base != NULL) {
435  ok = true;
436  }
437  }
439  BLI_freelistN(&ctx_object_list);
440 
441  *list = result.list;
442  return ok;
443 }
444 
445 PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
446 {
448  if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
450  return result.ptr;
451  }
452 
453  return PointerRNA_NULL;
454 }
455 
457 {
459 
460  if (ptr.data) {
461  if (RNA_struct_is_a(ptr.type, type)) {
462  return ptr;
463  }
464 
465  CLOG_WARN(&LOG,
466  "member '%s' is '%s', not '%s'",
467  member,
470  }
471 
472  return PointerRNA_NULL;
473 }
474 
476 {
478 
479  if (ptr.data && RNA_struct_is_a(ptr.type, type)) {
480  return ptr;
481  }
482 
483  return PointerRNA_NULL;
484 }
485 
486 ListBase CTX_data_collection_get(const bContext *C, const char *member)
487 {
489  if (ctx_data_get((bContext *)C, member, &result) == CTX_RESULT_OK) {
491  return result.list;
492  }
493 
494  ListBase list = {NULL, NULL};
495  return list;
496 }
497 
498 int /*eContextResult*/ CTX_data_get(
499  const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type)
500 {
503 
504  if (ret == CTX_RESULT_OK) {
505  *r_ptr = result.ptr;
506  *r_lb = result.list;
507  *r_type = result.type;
508  }
509  else {
510  memset(r_ptr, 0, sizeof(*r_ptr));
511  memset(r_lb, 0, sizeof(*r_lb));
512  *r_type = 0;
513  }
514 
515  return ret;
516 }
517 
518 static void data_dir_add(ListBase *lb, const char *member, const bool use_all)
519 {
520  LinkData *link;
521 
522  if ((use_all == false) && STREQ(member, "scene")) { /* exception */
523  return;
524  }
525 
526  if (BLI_findstring(lb, member, offsetof(LinkData, data))) {
527  return;
528  }
529 
530  link = MEM_callocN(sizeof(LinkData), "LinkData");
531  link->data = (void *)member;
532  BLI_addtail(lb, link);
533 }
534 
542  const bool use_store,
543  const bool use_rna,
544  const bool use_all)
545 {
547  ListBase lb;
548  bScreen *screen;
549  ScrArea *area;
550  ARegion *region;
551  int a;
552 
553  memset(&lb, 0, sizeof(lb));
554 
555  if (use_rna) {
556  char name[256], *nameptr;
557  int namelen;
558 
559  PropertyRNA *iterprop;
560  PointerRNA ctx_ptr;
561  RNA_pointer_create(NULL, &RNA_Context, (void *)C, &ctx_ptr);
562 
563  iterprop = RNA_struct_iterator_property(ctx_ptr.type);
564 
565  RNA_PROP_BEGIN (&ctx_ptr, itemptr, iterprop) {
566  nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
567  data_dir_add(&lb, name, use_all);
568  if (nameptr) {
569  if (name != nameptr) {
570  MEM_freeN(nameptr);
571  }
572  }
573  }
574  RNA_PROP_END;
575  }
576  if (use_store && C->wm.store) {
577  bContextStoreEntry *entry;
578 
579  for (entry = C->wm.store->entries.first; entry; entry = entry->next) {
580  data_dir_add(&lb, entry->name, use_all);
581  }
582  }
583  if ((region = CTX_wm_region(C)) && region->type && region->type->context) {
584  memset(&result, 0, sizeof(result));
585  region->type->context(C, "", &result);
586 
587  if (result.dir) {
588  for (a = 0; result.dir[a]; a++) {
589  data_dir_add(&lb, result.dir[a], use_all);
590  }
591  }
592  }
593  if ((area = CTX_wm_area(C)) && area->type && area->type->context) {
594  memset(&result, 0, sizeof(result));
595  area->type->context(C, "", &result);
596 
597  if (result.dir) {
598  for (a = 0; result.dir[a]; a++) {
599  data_dir_add(&lb, result.dir[a], use_all);
600  }
601  }
602  }
603  if ((screen = CTX_wm_screen(C)) && screen->context) {
604  bContextDataCallback cb = screen->context;
605  memset(&result, 0, sizeof(result));
606  cb(C, "", &result);
607 
608  if (result.dir) {
609  for (a = 0; result.dir[a]; a++) {
610  data_dir_add(&lb, result.dir[a], use_all);
611  }
612  }
613  }
614 
615  return lb;
616 }
617 
619 {
620  return CTX_data_dir_get_ex(C, true, false, false);
621 }
622 
623 bool CTX_data_equals(const char *member, const char *str)
624 {
625  return (STREQ(member, str));
626 }
627 
628 bool CTX_data_dir(const char *member)
629 {
630  return member[0] == '\0';
631 }
632 
634 {
635  RNA_id_pointer_create(id, &result->ptr);
636 }
637 
639 {
640  RNA_pointer_create(id, type, data, &result->ptr);
641 }
642 
644 {
645  CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add");
646  RNA_id_pointer_create(id, &link->ptr);
647 
648  BLI_addtail(&result->list, link);
649 }
650 
652 {
653  CollectionPointerLink *link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
654  RNA_pointer_create(id, type, data, &link->ptr);
655 
656  BLI_addtail(&result->list, link);
657 }
658 
659 int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBase *))
660 {
661  ListBase list;
662 
663  if (func(C, &list)) {
664  int tot = BLI_listbase_count(&list);
665  BLI_freelistN(&list);
666  return tot;
667  }
668 
669  return 0;
670 }
671 
673 {
674  result->dir = dir;
675 }
676 
678 {
679  result->type = type;
680 }
681 
683 {
684  return result->type;
685 }
686 
687 /* window manager context */
688 
690 {
691  return C->wm.manager;
692 }
693 
695 {
696  return (bool)C->wm.manager->is_interface_locked;
697 }
698 
700 {
701  return ctx_wm_python_context_get(C, "window", &RNA_Window, C->wm.window);
702 }
703 
705 {
706  return ctx_wm_python_context_get(C, "workspace", &RNA_WorkSpace, C->wm.workspace);
707 }
708 
710 {
711  return ctx_wm_python_context_get(C, "screen", &RNA_Screen, C->wm.screen);
712 }
713 
715 {
716  return ctx_wm_python_context_get(C, "area", &RNA_Area, C->wm.area);
717 }
718 
720 {
722  return (area) ? area->spacedata.first : NULL;
723 }
724 
726 {
727  return ctx_wm_python_context_get(C, "region", &RNA_Region, C->wm.region);
728 }
729 
731 {
732  ARegion *region = CTX_wm_region(C);
733  return (region) ? region->regiondata : NULL;
734 }
735 
736 struct ARegion *CTX_wm_menu(const bContext *C)
737 {
738  return C->wm.menu;
739 }
740 
742 {
743  return C->wm.gizmo_group;
744 }
745 
747 {
748  return C->wm.manager ? C->wm.manager->message_bus : NULL;
749 }
750 
752 {
753  if (C->wm.manager) {
754  return &(C->wm.manager->reports);
755  }
756 
757  return NULL;
758 }
759 
761 {
763  if (area && area->spacetype == SPACE_VIEW3D) {
764  return area->spacedata.first;
765  }
766  return NULL;
767 }
768 
770 {
772  ARegion *region = CTX_wm_region(C);
773 
774  if (area && area->spacetype == SPACE_VIEW3D) {
775  if (region && region->regiontype == RGN_TYPE_WINDOW) {
776  return region->regiondata;
777  }
778  }
779  return NULL;
780 }
781 
783 {
785  if (area && area->spacetype == SPACE_TEXT) {
786  return area->spacedata.first;
787  }
788  return NULL;
789 }
790 
792 {
794  if (area && area->spacetype == SPACE_CONSOLE) {
795  return area->spacedata.first;
796  }
797  return NULL;
798 }
799 
801 {
803  if (area && area->spacetype == SPACE_IMAGE) {
804  return area->spacedata.first;
805  }
806  return NULL;
807 }
808 
810 {
812  if (area && area->spacetype == SPACE_PROPERTIES) {
813  return area->spacedata.first;
814  }
815  return NULL;
816 }
817 
819 {
821  if (area && area->spacetype == SPACE_FILE) {
822  return area->spacedata.first;
823  }
824  return NULL;
825 }
826 
828 {
830  if (area && area->spacetype == SPACE_SEQ) {
831  return area->spacedata.first;
832  }
833  return NULL;
834 }
835 
837 {
839  if (area && area->spacetype == SPACE_OUTLINER) {
840  return area->spacedata.first;
841  }
842  return NULL;
843 }
844 
846 {
848  if (area && area->spacetype == SPACE_NLA) {
849  return area->spacedata.first;
850  }
851  return NULL;
852 }
853 
855 {
857  if (area && area->spacetype == SPACE_NODE) {
858  return area->spacedata.first;
859  }
860  return NULL;
861 }
862 
864 {
866  if (area && area->spacetype == SPACE_GRAPH) {
867  return area->spacedata.first;
868  }
869  return NULL;
870 }
871 
873 {
875  if (area && area->spacetype == SPACE_ACTION) {
876  return area->spacedata.first;
877  }
878  return NULL;
879 }
880 
882 {
884  if (area && area->spacetype == SPACE_INFO) {
885  return area->spacedata.first;
886  }
887  return NULL;
888 }
889 
891 {
893  if (area && area->spacetype == SPACE_USERPREF) {
894  return area->spacedata.first;
895  }
896  return NULL;
897 }
898 
900 {
902  if (area && area->spacetype == SPACE_CLIP) {
903  return area->spacedata.first;
904  }
905  return NULL;
906 }
907 
909 {
911  if (area && area->spacetype == SPACE_TOPBAR) {
912  return area->spacedata.first;
913  }
914  return NULL;
915 }
916 
918 {
920  if (area && area->spacetype == SPACE_SPREADSHEET) {
921  return area->spacedata.first;
922  }
923  return NULL;
924 }
925 
927 {
928  C->wm.manager = wm;
929  C->wm.window = NULL;
930  C->wm.screen = NULL;
931  C->wm.area = NULL;
932  C->wm.region = NULL;
933 }
934 
935 #ifdef WITH_PYTHON
936 # define PYCTX_REGION_MEMBERS "region", "region_data"
937 # define PYCTX_AREA_MEMBERS "area", "space_data", PYCTX_REGION_MEMBERS
938 # define PYCTX_SCREEN_MEMBERS "screen", PYCTX_AREA_MEMBERS
939 # define PYCTX_WINDOW_MEMBERS "window", "scene", "workspace", PYCTX_SCREEN_MEMBERS
940 #endif
941 
943 {
944  C->wm.window = win;
945  if (win) {
946  C->data.scene = win->scene;
947  }
948  C->wm.workspace = (win) ? BKE_workspace_active_get(win->workspace_hook) : NULL;
949  C->wm.screen = (win) ? BKE_workspace_active_screen_get(win->workspace_hook) : NULL;
950  C->wm.area = NULL;
951  C->wm.region = NULL;
952 
953 #ifdef WITH_PYTHON
954  if (C->data.py_context != NULL) {
955  BPY_context_dict_clear_members(C, PYCTX_WINDOW_MEMBERS);
956  }
957 #endif
958 }
959 
961 {
962  C->wm.screen = screen;
963  C->wm.area = NULL;
964  C->wm.region = NULL;
965 
966 #ifdef WITH_PYTHON
967  if (C->data.py_context != NULL) {
968  BPY_context_dict_clear_members(C, PYCTX_SCREEN_MEMBERS);
969  }
970 #endif
971 }
972 
974 {
975  C->wm.area = area;
976  C->wm.region = NULL;
977 
978 #ifdef WITH_PYTHON
979  if (C->data.py_context != NULL) {
980  BPY_context_dict_clear_members(C, PYCTX_AREA_MEMBERS);
981  }
982 #endif
983 }
984 
986 {
987  C->wm.region = region;
988 
989 #ifdef WITH_PYTHON
990  if (C->data.py_context != NULL) {
991  BPY_context_dict_clear_members(C, PYCTX_REGION_MEMBERS);
992  }
993 #endif
994 }
995 
997 {
998  C->wm.menu = menu;
999 }
1000 
1002 {
1003  C->wm.gizmo_group = gzgroup;
1004 }
1005 
1006 void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
1007 {
1008  C->wm.operator_poll_msg = msg;
1009 }
1010 
1012 {
1013  return IFACE_(C->wm.operator_poll_msg);
1014 }
1015 
1016 /* data context */
1017 
1019 {
1020  Main *bmain;
1021  if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain)) {
1022  return bmain;
1023  }
1024 
1025  return C->data.main;
1026 }
1027 
1029 {
1030  C->data.main = bmain;
1031  BKE_sound_init_main(bmain);
1032 }
1033 
1035 {
1036  Scene *scene;
1037  if (ctx_data_pointer_verify(C, "scene", (void *)&scene)) {
1038  return scene;
1039  }
1040 
1041  return C->data.scene;
1042 }
1043 
1045 {
1046  ViewLayer *view_layer;
1047 
1048  if (ctx_data_pointer_verify(C, "view_layer", (void *)&view_layer)) {
1049  return view_layer;
1050  }
1051 
1052  wmWindow *win = CTX_wm_window(C);
1054  if (win) {
1055  view_layer = BKE_view_layer_find(scene, win->view_layer_name);
1056  if (view_layer) {
1057  return view_layer;
1058  }
1059  }
1060 
1062 }
1063 
1065 {
1067  return RE_engines_find(scene->r.engine);
1068 }
1069 
1078 {
1079  ViewLayer *view_layer = CTX_data_view_layer(C);
1080  LayerCollection *layer_collection;
1081 
1082  if (ctx_data_pointer_verify(C, "layer_collection", (void *)&layer_collection)) {
1083  if (BKE_view_layer_has_collection(view_layer, layer_collection->collection)) {
1084  return layer_collection;
1085  }
1086  }
1087 
1088  /* fallback */
1089  return BKE_layer_collection_get_active(view_layer);
1090 }
1091 
1093 {
1094  Collection *collection;
1095  if (ctx_data_pointer_verify(C, "collection", (void *)&collection)) {
1096  return collection;
1097  }
1098 
1099  LayerCollection *layer_collection = CTX_data_layer_collection(C);
1100  if (layer_collection) {
1101  return layer_collection->collection;
1102  }
1103 
1104  /* fallback */
1106  return scene->master_collection;
1107 }
1108 
1110  const Object *ob,
1111  const eObjectMode object_mode)
1112 {
1113  // Object *obedit = CTX_data_edit_object(C);
1114  if (obedit) {
1115  switch (obedit->type) {
1116  case OB_MESH:
1117  return CTX_MODE_EDIT_MESH;
1118  case OB_CURVE:
1119  return CTX_MODE_EDIT_CURVE;
1120  case OB_SURF:
1121  return CTX_MODE_EDIT_SURFACE;
1122  case OB_FONT:
1123  return CTX_MODE_EDIT_TEXT;
1124  case OB_ARMATURE:
1125  return CTX_MODE_EDIT_ARMATURE;
1126  case OB_MBALL:
1127  return CTX_MODE_EDIT_METABALL;
1128  case OB_LATTICE:
1129  return CTX_MODE_EDIT_LATTICE;
1130  }
1131  }
1132  else {
1133  // Object *ob = CTX_data_active_object(C);
1134  if (ob) {
1135  if (object_mode & OB_MODE_POSE) {
1136  return CTX_MODE_POSE;
1137  }
1138  if (object_mode & OB_MODE_SCULPT) {
1139  return CTX_MODE_SCULPT;
1140  }
1141  if (object_mode & OB_MODE_WEIGHT_PAINT) {
1142  return CTX_MODE_PAINT_WEIGHT;
1143  }
1144  if (object_mode & OB_MODE_VERTEX_PAINT) {
1145  return CTX_MODE_PAINT_VERTEX;
1146  }
1147  if (object_mode & OB_MODE_TEXTURE_PAINT) {
1148  return CTX_MODE_PAINT_TEXTURE;
1149  }
1150  if (object_mode & OB_MODE_PARTICLE_EDIT) {
1151  return CTX_MODE_PARTICLE;
1152  }
1153  if (object_mode & OB_MODE_PAINT_GPENCIL) {
1154  return CTX_MODE_PAINT_GPENCIL;
1155  }
1156  if (object_mode & OB_MODE_EDIT_GPENCIL) {
1157  return CTX_MODE_EDIT_GPENCIL;
1158  }
1159  if (object_mode & OB_MODE_SCULPT_GPENCIL) {
1160  return CTX_MODE_SCULPT_GPENCIL;
1161  }
1162  if (object_mode & OB_MODE_WEIGHT_GPENCIL) {
1163  return CTX_MODE_WEIGHT_GPENCIL;
1164  }
1165  if (object_mode & OB_MODE_VERTEX_GPENCIL) {
1166  return CTX_MODE_VERTEX_GPENCIL;
1167  }
1168  }
1169  }
1170 
1171  return CTX_MODE_OBJECT;
1172 }
1173 
1175 {
1176  Object *obedit = CTX_data_edit_object(C);
1177  Object *obact = obedit ? NULL : CTX_data_active_object(C);
1178  return CTX_data_mode_enum_ex(obedit, obact, obact ? obact->mode : OB_MODE_OBJECT);
1179 }
1180 
1181 /* would prefer if we can use the enum version below over this one - Campbell */
1182 /* must be aligned with above enum */
1183 static const char *data_mode_strings[] = {
1184  "mesh_edit", "curve_edit", "surface_edit", "text_edit",
1185  "armature_edit", "mball_edit", "lattice_edit", "posemode",
1186  "sculpt_mode", "weightpaint", "vertexpaint", "imagepaint",
1187  "particlemode", "objectmode", "greasepencil_paint", "greasepencil_edit",
1188  "greasepencil_sculpt", "greasepencil_weight", "greasepencil_vertex", NULL,
1189 };
1191  "Must have a string for each context mode")
1192 const char *CTX_data_mode_string(const bContext *C)
1193 {
1195 }
1196 
1198 {
1199  C->data.scene = scene;
1200 
1201 #ifdef WITH_PYTHON
1202  if (C->data.py_context != NULL) {
1204  }
1205 #endif
1206 }
1207 
1209 {
1211 
1212  if (scene) {
1213  return scene->toolsettings;
1214  }
1215 
1216  return NULL;
1217 }
1218 
1220 {
1221  return ctx_data_collection_get(C, "selected_ids", list);
1222 }
1223 
1225 {
1226  return ctx_data_collection_get(C, "selected_nodes", list);
1227 }
1228 
1230 {
1231  return ctx_data_collection_get(C, "selected_editable_objects", list);
1232 }
1233 
1235 {
1236  return ctx_data_base_collection_get(C, "selected_editable_objects", list);
1237 }
1238 
1240 {
1241  return ctx_data_collection_get(C, "editable_objects", list);
1242 }
1243 
1245 {
1246  return ctx_data_base_collection_get(C, "editable_objects", list);
1247 }
1248 
1250 {
1251  return ctx_data_collection_get(C, "selected_objects", list);
1252 }
1253 
1255 {
1256  return ctx_data_base_collection_get(C, "selected_objects", list);
1257 }
1258 
1260 {
1261  return ctx_data_collection_get(C, "visible_objects", list);
1262 }
1263 
1265 {
1266  return ctx_data_base_collection_get(C, "visible_objects", list);
1267 }
1268 
1270 {
1271  return ctx_data_collection_get(C, "selectable_objects", list);
1272 }
1273 
1275 {
1276  return ctx_data_base_collection_get(C, "selectable_objects", list);
1277 }
1278 
1280 {
1281  return ctx_data_pointer_get(C, "active_object");
1282 }
1283 
1285 {
1286  Object *ob = ctx_data_pointer_get(C, "active_object");
1287 
1288  if (ob == NULL) {
1289  return NULL;
1290  }
1291 
1292  ViewLayer *view_layer = CTX_data_view_layer(C);
1293  return BKE_view_layer_base_find(view_layer, ob);
1294 }
1295 
1297 {
1298  return ctx_data_pointer_get(C, "edit_object");
1299 }
1300 
1302 {
1303  return ctx_data_pointer_get(C, "edit_image");
1304 }
1305 
1307 {
1308  return ctx_data_pointer_get(C, "edit_text");
1309 }
1310 
1312 {
1313  return ctx_data_pointer_get(C, "edit_movieclip");
1314 }
1315 
1317 {
1318  return ctx_data_pointer_get(C, "edit_mask");
1319 }
1320 
1322 {
1323  return ctx_data_pointer_get(C, "active_bone");
1324 }
1325 
1327 {
1328  return ctx_data_pointer_get(C, "edit_cachefile");
1329 }
1330 
1332 {
1333  return ctx_data_collection_get(C, "selected_bones", list);
1334 }
1335 
1337 {
1338  return ctx_data_collection_get(C, "selected_editable_bones", list);
1339 }
1340 
1342 {
1343  return ctx_data_collection_get(C, "visible_bones", list);
1344 }
1345 
1347 {
1348  return ctx_data_collection_get(C, "editable_bones", list);
1349 }
1350 
1352 {
1353  return ctx_data_pointer_get(C, "active_pose_bone");
1354 }
1355 
1357 {
1358  return ctx_data_collection_get(C, "selected_pose_bones", list);
1359 }
1360 
1362 {
1363  return ctx_data_collection_get(C, "selected_pose_bones_from_active_object", list);
1364 }
1365 
1367 {
1368  return ctx_data_collection_get(C, "visible_pose_bones", list);
1369 }
1370 
1372 {
1373  return ctx_data_pointer_get(C, "gpencil_data");
1374 }
1375 
1377 {
1378  return ctx_data_pointer_get(C, "active_gpencil_layer");
1379 }
1380 
1382 {
1383  return ctx_data_pointer_get(C, "active_gpencil_frame");
1384 }
1385 
1387 {
1388  return ctx_data_collection_get(C, "visible_gpencil_layers", list);
1389 }
1390 
1392 {
1393  return ctx_data_collection_get(C, "editable_gpencil_layers", list);
1394 }
1395 
1397 {
1398  return ctx_data_collection_get(C, "editable_gpencil_strokes", list);
1399 }
1400 
1402 {
1403  Main *bmain = CTX_data_main(C);
1405  ViewLayer *view_layer = CTX_data_view_layer(C);
1406  Depsgraph *depsgraph = BKE_scene_ensure_depsgraph(bmain, scene, view_layer);
1407  /* Dependency graph might have been just allocated, and hence it will not be marked.
1408  * This confuses redo system due to the lack of flushing changes back to the original data.
1409  * In the future we would need to check whether the CTX_wm_window(C) is in editing mode (as an
1410  * opposite of playback-preview-only) and set active flag based on that. */
1412  return depsgraph;
1413 }
1414 
1416 {
1418  /* TODO(sergey): Assert that the dependency graph is fully evaluated.
1419  * Note that first the depsgraph and scene post-eval hooks needs to run extra round of updates
1420  * first to make check here really reliable. */
1421  return depsgraph;
1422 }
1423 
1425 {
1427  Main *bmain = CTX_data_main(C);
1429  return depsgraph;
1430 }
1431 
1433 {
1435  ViewLayer *view_layer = CTX_data_view_layer(C);
1436  return BKE_scene_get_depsgraph(scene, view_layer);
1437 }
@ CTX_DATA_TYPE_POINTER
Definition: BKE_context.h:220
@ CTX_DATA_TYPE_COLLECTION
Definition: BKE_context.h:221
eContextObjectMode
Definition: BKE_context.h:114
@ CTX_MODE_EDIT_GPENCIL
Definition: BKE_context.h:130
@ CTX_MODE_EDIT_CURVE
Definition: BKE_context.h:116
@ CTX_MODE_PAINT_TEXTURE
Definition: BKE_context.h:126
@ CTX_MODE_EDIT_SURFACE
Definition: BKE_context.h:117
@ CTX_MODE_WEIGHT_GPENCIL
Definition: BKE_context.h:132
@ CTX_MODE_PARTICLE
Definition: BKE_context.h:127
@ CTX_MODE_SCULPT
Definition: BKE_context.h:123
@ CTX_MODE_VERTEX_GPENCIL
Definition: BKE_context.h:133
@ CTX_MODE_OBJECT
Definition: BKE_context.h:128
@ CTX_MODE_EDIT_MESH
Definition: BKE_context.h:115
@ CTX_MODE_EDIT_TEXT
Definition: BKE_context.h:118
@ CTX_MODE_EDIT_ARMATURE
Definition: BKE_context.h:119
@ CTX_MODE_SCULPT_GPENCIL
Definition: BKE_context.h:131
@ CTX_MODE_EDIT_LATTICE
Definition: BKE_context.h:121
@ CTX_MODE_PAINT_GPENCIL
Definition: BKE_context.h:129
@ CTX_MODE_PAINT_VERTEX
Definition: BKE_context.h:125
@ CTX_MODE_EDIT_METABALL
Definition: BKE_context.h:120
@ CTX_MODE_PAINT_WEIGHT
Definition: BKE_context.h:124
@ CTX_MODE_POSE
Definition: BKE_context.h:122
#define CTX_MODE_NUM
Definition: BKE_context.h:135
const char * CTX_data_mode_string(const bContext *C)
eContextResult
Definition: BKE_context.h:81
@ CTX_RESULT_OK
Definition: BKE_context.h:83
int(* bContextDataCallback)(const bContext *C, const char *member, bContextDataResult *result)
Definition: BKE_context.h:94
struct LayerCollection * BKE_layer_collection_get_active(struct ViewLayer *view_layer)
Definition: layer.c:630
struct ViewLayer * BKE_view_layer_default_view(const struct Scene *scene)
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
Definition: layer.c:394
bool BKE_view_layer_has_collection(struct ViewLayer *view_layer, const struct Collection *collection)
struct ViewLayer * BKE_view_layer_find(const struct Scene *scene, const char *layer_name)
struct Depsgraph * BKE_scene_get_depsgraph(const struct Scene *scene, const struct ViewLayer *view_layer)
struct Depsgraph * BKE_scene_ensure_depsgraph(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer)
Definition: scene.c:3526
void BKE_scene_graph_evaluated_ensure(struct Depsgraph *depsgraph, struct Main *bmain)
Definition: scene.c:2718
void BKE_sound_init_main(struct Main *bmain)
struct WorkSpace * BKE_workspace_active_get(struct WorkSpaceInstanceHook *hook) GETTER_ATTRS
Definition: workspace.c:535
struct bScreen * BKE_workspace_active_screen_get(const struct WorkSpaceInstanceHook *hook) GETTER_ATTRS
#define BLI_assert(a)
Definition: BLI_assert.h:58
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:257
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void void void void void BLI_duplicatelist(struct ListBase *dst, const struct ListBase *src) ATTR_NONNULL(1
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:128
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:547
void * BLI_findstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
void * BLI_rfindstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
int BLI_thread_is_main(void)
Definition: threads.cc:234
#define ARRAY_SIZE(arr)
#define UNUSED_VARS(...)
#define UNLIKELY(x)
#define STREQ(a, b)
#define IFACE_(msgid)
int BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result)
#define BPY_context_dict_clear_members(C,...)
Definition: BPY_extern.h:91
#define CLOG_WARN(clg_ref,...)
Definition: CLG_log.h:203
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
void DEG_make_active(struct Depsgraph *depsgraph)
Definition: depsgraph.cc:344
Object groups, one object can be in many groups at once.
eObjectMode
@ OB_MODE_VERTEX_GPENCIL
@ OB_MODE_EDIT_GPENCIL
@ OB_MODE_PARTICLE_EDIT
@ OB_MODE_WEIGHT_PAINT
@ OB_MODE_WEIGHT_GPENCIL
@ OB_MODE_SCULPT
@ OB_MODE_SCULPT_GPENCIL
@ OB_MODE_POSE
@ OB_MODE_TEXTURE_PAINT
@ OB_MODE_OBJECT
@ OB_MODE_VERTEX_PAINT
@ OB_MODE_PAINT_GPENCIL
Object is a sort of wrapper for general info.
@ OB_LATTICE
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_ARMATURE
@ OB_MESH
@ OB_CURVE
@ 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
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
#define RNA_PROP_END
Definition: RNA_access.h:1268
StructRNA RNA_Region
StructRNA RNA_ObjectBase
StructRNA RNA_Context
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
Definition: RNA_access.h:1261
StructRNA RNA_Screen
StructRNA RNA_WorkSpace
StructRNA RNA_Window
StructRNA RNA_Area
#define C
Definition: RandGen.cpp:39
short CTX_data_type_get(bContextDataResult *result)
Definition: context.c:682
int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type)
Definition: context.c:498
struct SpaceTopBar * CTX_wm_space_topbar(const bContext *C)
Definition: context.c:908
int CTX_data_visible_pose_bones(const bContext *C, ListBase *list)
Definition: context.c:1366
void CTX_data_main_set(bContext *C, Main *bmain)
Definition: context.c:1028
int CTX_data_selectable_objects(const bContext *C, ListBase *list)
Definition: context.c:1269
ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
Definition: context.c:445
bContext * CTX_copy(const bContext *C)
Definition: context.c:112
void CTX_store_set(bContext *C, bContextStore *store)
Definition: context.c:186
int CTX_data_visible_bones(const bContext *C, ListBase *list)
Definition: context.c:1341
bool CTX_wm_interface_locked(const bContext *C)
Definition: context.c:694
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings)==CTX_MODE_NUM+1, "Must have a string for each context mode") const
Definition: context.c:1190
struct SpaceClip * CTX_wm_space_clip(const bContext *C)
Definition: context.c:899
int ctx_data_list_count(const bContext *C, int(*func)(const bContext *, ListBase *))
Definition: context.c:659
struct SpaceInfo * CTX_wm_space_info(const bContext *C)
Definition: context.c:881
bGPDframe * CTX_data_active_gpencil_frame(const bContext *C)
Definition: context.c:1381
void CTX_data_dir_set(bContextDataResult *result, const char **dir)
Definition: context.c:672
struct ARegion * CTX_wm_menu(const bContext *C)
Definition: context.c:736
PointerRNA CTX_data_pointer_get_type_silent(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:475
struct SpaceNode * CTX_wm_space_node(const bContext *C)
Definition: context.c:854
struct SpaceProperties * CTX_wm_space_properties(const bContext *C)
Definition: context.c:809
void CTX_data_id_list_add(bContextDataResult *result, ID *id)
Definition: context.c:643
int CTX_data_selected_bones(const bContext *C, ListBase *list)
Definition: context.c:1331
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1296
bool CTX_data_equals(const char *member, const char *str)
Definition: context.c:623
bool CTX_py_init_get(bContext *C)
Definition: context.c:215
int CTX_data_visible_objects(const bContext *C, ListBase *list)
Definition: context.c:1259
const char * CTX_wm_operator_poll_msg_get(bContext *C)
Definition: context.c:1011
void CTX_data_pointer_set(bContextDataResult *result, ID *id, StructRNA *type, void *data)
Definition: context.c:638
Depsgraph * CTX_data_depsgraph_on_load(const bContext *C)
Definition: context.c:1432
int CTX_data_editable_objects(const bContext *C, ListBase *list)
Definition: context.c:1239
Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
static eContextResult ctx_data_get(bContext *C, const char *member, bContextDataResult *result)
Definition: context.c:291
int CTX_data_selected_editable_bases(const bContext *C, ListBase *list)
Definition: context.c:1234
int CTX_data_selected_objects(const bContext *C, ListBase *list)
Definition: context.c:1249
bContextStore * CTX_store_add(ListBase *contexts, const char *name, const PointerRNA *ptr)
Definition: context.c:126
Collection * CTX_data_collection(const bContext *C)
Definition: context.c:1092
struct Base * CTX_data_active_base(const bContext *C)
Definition: context.c:1284
RegionView3D * CTX_wm_region_view3d(const bContext *C)
Definition: context.c:769
void CTX_py_state_push(bContext *C, struct bContext_PyState *pystate, void *value)
Definition: context.c:233
bool CTX_data_dir(const char *member)
Definition: context.c:628
static void data_dir_add(ListBase *lb, const char *member, const bool use_all)
Definition: context.c:518
void CTX_data_id_pointer_set(bContextDataResult *result, ID *id)
Definition: context.c:633
static const char * data_mode_strings[]
Definition: context.c:1183
void * CTX_py_dict_get(const bContext *C)
Definition: context.c:224
struct SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
Definition: context.c:836
void * CTX_py_dict_get_orig(const bContext *C)
Definition: context.c:228
void CTX_wm_gizmo_group_set(bContext *C, struct wmGizmoGroup *gzgroup)
Definition: context.c:1001
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1424
void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
Definition: context.c:926
bContext * CTX_create(void)
Definition: context.c:105
Depsgraph * CTX_data_expect_evaluated_depsgraph(const bContext *C)
Definition: context.c:1415
void CTX_py_init_set(bContext *C, bool value)
Definition: context.c:219
int CTX_data_editable_gpencil_layers(const bContext *C, ListBase *list)
Definition: context.c:1391
int CTX_data_selected_editable_bones(const bContext *C, ListBase *list)
Definition: context.c:1336
struct Mask * CTX_data_edit_mask(const bContext *C)
Definition: context.c:1316
struct SpaceSeq * CTX_wm_space_seq(const bContext *C)
Definition: context.c:827
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:456
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Definition: context.c:1401
struct SpaceNla * CTX_wm_space_nla(const bContext *C)
Definition: context.c:845
int CTX_data_editable_bones(const bContext *C, ListBase *list)
Definition: context.c:1346
struct SpaceSpreadsheet * CTX_wm_space_spreadsheet(const bContext *C)
Definition: context.c:917
bContextStore * CTX_store_copy(bContextStore *store)
Definition: context.c:191
void CTX_store_free(bContextStore *store)
Definition: context.c:199
int CTX_data_visible_bases(const bContext *C, ListBase *list)
Definition: context.c:1264
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
Definition: context.c:1006
static int ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
Definition: context.c:379
struct MovieClip * CTX_data_edit_movieclip(const bContext *C)
Definition: context.c:1311
Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
int CTX_data_editable_bases(const bContext *C, ListBase *list)
Definition: context.c:1244
struct wmGizmoGroup * CTX_wm_gizmo_group(const bContext *C)
Definition: context.c:741
SpaceLink * CTX_wm_space_data(const bContext *C)
Definition: context.c:719
void CTX_free(bContext *C)
Definition: context.c:119
ListBase CTX_data_dir_get(const bContext *C)
Definition: context.c:618
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1279
wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
bContextStore * CTX_store_add_all(ListBase *contexts, bContextStore *context)
Definition: context.c:154
ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
struct EditBone * CTX_data_active_bone(const bContext *C)
Definition: context.c:1321
void CTX_py_state_pop(bContext *C, struct bContext_PyState *pystate)
Definition: context.c:241
struct SpaceUserPref * CTX_wm_space_userpref(const bContext *C)
Definition: context.c:890
LayerCollection * CTX_data_layer_collection(const bContext *C)
Definition: context.c:1077
void CTX_wm_screen_set(bContext *C, bScreen *screen)
Definition: context.c:960
void CTX_data_scene_set(bContext *C, Scene *scene)
Definition: context.c:1197
int CTX_data_selected_ids(const bContext *C, ListBase *list)
Definition: context.c:1219
ListBase CTX_data_dir_get_ex(const bContext *C, const bool use_store, const bool use_rna, const bool use_all)
Definition: context.c:541
struct SpaceGraph * CTX_wm_space_graph(const bContext *C)
Definition: context.c:863
bGPDlayer * CTX_data_active_gpencil_layer(const bContext *C)
Definition: context.c:1376
struct Image * CTX_data_edit_image(const bContext *C)
Definition: context.c:1301
static int ctx_data_collection_get(const bContext *C, const char *member, ListBase *list)
Definition: context.c:398
void * CTX_wm_region_data(const bContext *C)
Definition: context.c:730
void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void *data)
Definition: context.c:651
ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
int CTX_data_selected_pose_bones(const bContext *C, ListBase *list)
Definition: context.c:1356
void CTX_store_free_list(ListBase *contexts)
Definition: context.c:205
int CTX_data_visible_gpencil_layers(const bContext *C, ListBase *list)
Definition: context.c:1386
enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit, const Object *ob, const eObjectMode object_mode)
Definition: context.c:1109
void CTX_wm_window_set(bContext *C, wmWindow *win)
Definition: context.c:942
void CTX_wm_menu_set(bContext *C, ARegion *menu)
Definition: context.c:996
View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:760
bGPdata * CTX_data_gpencil_data(const bContext *C)
Definition: context.c:1371
static int ctx_data_base_collection_get(const bContext *C, const char *member, ListBase *list)
Definition: context.c:412
struct SpaceAction * CTX_wm_space_action(const bContext *C)
Definition: context.c:872
static void * ctx_data_pointer_get(const bContext *C, const char *member)
Definition: context.c:368
WorkSpace * CTX_wm_workspace(const bContext *C)
Definition: context.c:704
int CTX_data_selectable_bases(const bContext *C, ListBase *list)
Definition: context.c:1274
struct ReportList * CTX_wm_reports(const bContext *C)
Definition: context.c:751
static CLG_LogRef LOG
Definition: context.c:65
int CTX_data_selected_bases(const bContext *C, ListBase *list)
Definition: context.c:1254
static void * ctx_wm_python_context_get(const bContext *C, const char *member, const StructRNA *member_type, void *fall_through)
Definition: context.c:256
struct wmMsgBus * CTX_wm_message_bus(const bContext *C)
Definition: context.c:746
bScreen * CTX_wm_screen(const bContext *C)
Definition: context.c:709
struct SpaceText * CTX_wm_space_text(const bContext *C)
Definition: context.c:782
int CTX_data_selected_nodes(const bContext *C, ListBase *list)
Definition: context.c:1224
RenderEngineType * CTX_data_engine_type(const bContext *C)
Definition: context.c:1064
int CTX_data_selected_editable_objects(const bContext *C, ListBase *list)
Definition: context.c:1229
ToolSettings * CTX_data_tool_settings(const bContext *C)
Definition: context.c:1208
void CTX_wm_area_set(bContext *C, ScrArea *area)
Definition: context.c:973
void CTX_wm_region_set(bContext *C, ARegion *region)
Definition: context.c:985
struct CacheFile * CTX_data_edit_cachefile(const bContext *C)
Definition: context.c:1326
int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
Definition: context.c:1396
struct SpaceImage * CTX_wm_space_image(const bContext *C)
Definition: context.c:800
ListBase CTX_data_collection_get(const bContext *C, const char *member)
Definition: context.c:486
int CTX_data_selected_pose_bones_from_active_object(const bContext *C, ListBase *list)
Definition: context.c:1361
struct SpaceConsole * CTX_wm_space_console(const bContext *C)
Definition: context.c:791
wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
struct SpaceFile * CTX_wm_space_file(const bContext *C)
Definition: context.c:818
void CTX_data_type_set(bContextDataResult *result, short type)
Definition: context.c:677
struct Text * CTX_data_edit_text(const bContext *C)
Definition: context.c:1306
enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
Definition: context.c:1174
struct bPoseChannel * CTX_data_active_pose_bone(const bContext *C)
Definition: context.c:1351
bContextStore * CTX_store_get(bContext *C)
Definition: context.c:181
Scene scene
const Depsgraph * depsgraph
RenderEngineType * RE_engines_find(const char *idname)
Definition: engine.c:108
#define str(s)
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
static unsigned a[3]
Definition: RandGen.cpp:92
static void area(int d1, int d2, int e1, int e2, float weights[2])
return ret
const char * RNA_struct_identifier(const StructRNA *type)
Definition: rna_access.c:723
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:844
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:122
char * RNA_struct_name_get_alloc(PointerRNA *ptr, char *fixedbuf, int fixedlen, int *r_len)
Definition: rna_access.c:1049
const PointerRNA PointerRNA_NULL
Definition: rna_access.c:71
PropertyRNA * RNA_struct_iterator_property(StructRNA *type)
Definition: rna_access.c:771
struct SELECTID_Context context
Definition: select_engine.c:47
bContextDataCallback context
Definition: BKE_screen.h:200
void * regiondata
short regiontype
struct ARegionType * type
Definition: DNA_ID.h:273
struct Collection * collection
void * data
Definition: DNA_listBase.h:42
void * last
Definition: DNA_listBase.h:47
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
char engine[32]
struct Collection * master_collection
string name
Definition: scene.h:222
struct ToolSettings * toolsettings
struct RenderData r
const char ** dir
Definition: context.c:252
ListBase list
Definition: context.c:251
PointerRNA ptr
Definition: context.c:250
struct bContextStoreEntry * next
Definition: BKE_context.h:99
ListBase entries
Definition: BKE_context.h:108
void * py_context_orig
Definition: BKE_context.h:163
struct wmWindow * window
Definition: context.c:75
struct bContext::@83 wm
struct Main * main
Definition: context.c:88
const char * operator_poll_msg
Definition: context.c:83
struct bContextStore * store
Definition: context.c:82
struct bScreen * screen
Definition: context.c:77
struct bContext::@84 data
struct ARegion * region
Definition: context.c:79
int recursion
Definition: context.c:91
void * py_context_orig
Definition: context.c:99
struct wmGizmoGroup * gizmo_group
Definition: context.c:81
void * py_context
Definition: context.c:94
struct WorkSpace * workspace
Definition: context.c:76
struct ScrArea * area
Definition: context.c:78
int thread
Definition: context.c:70
struct wmWindowManager * manager
Definition: context.c:74
struct ARegion * menu
Definition: context.c:80
bool py_init
Definition: context.c:93
struct Scene * scene
Definition: context.c:89
void * context
struct Scene * scene
char view_layer_name[64]
struct WorkSpaceInstanceHook * workspace_hook
PointerRNA * ptr
Definition: wm_files.c:3157