2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation (2008).
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/blenkernel/intern/context.c
31 #include "MEM_guardedalloc.h"
33 #include "DNA_scene_types.h"
34 #include "DNA_screen_types.h"
35 #include "DNA_space_types.h"
36 #include "DNA_view3d_types.h"
37 #include "DNA_windowmanager_types.h"
38 #include "DNA_object_types.h"
39 #include "DNA_linestyle_types.h"
40 #include "DNA_gpencil_types.h"
42 #include "BLI_listbase.h"
43 #include "BLI_string.h"
44 #include "BLI_threads.h"
45 #include "BLI_utildefines.h"
47 #include "BLT_translation.h"
49 #include "BKE_context.h"
51 #include "BKE_screen.h"
52 #include "BKE_sound.h"
54 #include "RNA_access.h"
57 # include "BPY_extern.h"
65 /* windowmanager context */
67 struct wmWindowManager *manager;
68 struct wmWindow *window;
69 struct bScreen *screen;
71 struct ARegion *region;
73 struct bContextStore *store;
74 const char *operator_poll_msg; /* reason for poll failing */
83 int py_init; /* true if python is initialized */
97 bContext *CTX_create(void)
101 C = MEM_callocN(sizeof(bContext), "bContext");
106 bContext *CTX_copy(const bContext *C)
108 bContext *newC = MEM_dupallocN((void *)C);
113 void CTX_free(bContext *C)
120 bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *ptr)
122 bContextStoreEntry *entry;
123 bContextStore *ctx, *lastctx;
125 /* ensure we have a context to put the entry in, if it was already used
126 * we have to copy the context to ensure */
127 ctx = contexts->last;
129 if (!ctx || ctx->used) {
132 ctx = MEM_dupallocN(lastctx);
133 BLI_duplicatelist(&ctx->entries, &lastctx->entries);
136 ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
138 BLI_addtail(contexts, ctx);
141 entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry");
142 BLI_strncpy(entry->name, name, sizeof(entry->name));
145 BLI_addtail(&ctx->entries, entry);
150 bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context)
152 bContextStoreEntry *entry, *tentry;
153 bContextStore *ctx, *lastctx;
155 /* ensure we have a context to put the entries in, if it was already used
156 * we have to copy the context to ensure */
157 ctx = contexts->last;
159 if (!ctx || ctx->used) {
162 ctx = MEM_dupallocN(lastctx);
163 BLI_duplicatelist(&ctx->entries, &lastctx->entries);
166 ctx = MEM_callocN(sizeof(bContextStore), "bContextStore");
168 BLI_addtail(contexts, ctx);
171 for (tentry = context->entries.first; tentry; tentry = tentry->next) {
172 entry = MEM_dupallocN(tentry);
173 BLI_addtail(&ctx->entries, entry);
179 void CTX_store_set(bContext *C, bContextStore *store)
184 bContextStore *CTX_store_copy(bContextStore *store)
188 ctx = MEM_dupallocN(store);
189 BLI_duplicatelist(&ctx->entries, &store->entries);
194 void CTX_store_free(bContextStore *store)
196 BLI_freelistN(&store->entries);
200 void CTX_store_free_list(ListBase *contexts)
204 while ((ctx = BLI_pophead(contexts))) {
209 /* is python initialied? */
211 int CTX_py_init_get(bContext *C)
213 return C->data.py_init;
215 void CTX_py_init_set(bContext *C, int value)
217 C->data.py_init = value;
220 void *CTX_py_dict_get(const bContext *C)
222 return C->data.py_context;
224 void CTX_py_dict_set(bContext *C, void *value)
226 C->data.py_context = value;
229 /* data context utility functions */
231 struct bContextDataResult {
235 short type; /* 0: normal, 1: seq */
238 static void *ctx_wm_python_context_get(
240 const char *member, const StructRNA *member_type,
244 if (UNLIKELY(C && CTX_py_dict_get(C))) {
245 bContextDataResult result;
246 memset(&result, 0, sizeof(bContextDataResult));
247 BPY_context_member_get((bContext *)C, member, &result);
249 if (result.ptr.data) {
250 if (RNA_struct_is_a(result.ptr.type, member_type)) {
251 return result.ptr.data;
254 printf("PyContext '%s' is a '%s', expected a '%s'\n",
256 RNA_struct_identifier(result.ptr.type),
257 RNA_struct_identifier(member_type));
262 UNUSED_VARS(C, member, member_type);
265 /* don't allow UI context access from non-main threads */
266 if (!BLI_thread_is_main())
272 static int ctx_data_get(bContext *C, const char *member, bContextDataResult *result)
277 int done = 0, recursion = C->data.recursion;
280 memset(result, 0, sizeof(bContextDataResult));
282 if (CTX_py_dict_get(C)) {
283 if (BPY_context_member_get(C, member, result)) {
289 /* don't allow UI context access from non-main threads */
290 if (!BLI_thread_is_main())
293 /* we check recursion to ensure that we do not get infinite
294 * loops requesting data from ourselves in a context callback */
296 /* Ok, this looks evil...
297 * if (ret) done = -(-ret | -done);
299 * Values in order of importance
300 * (0, -1, 1) - Where 1 is highest priority
302 if (done != 1 && recursion < 1 && C->wm.store) {
303 bContextStoreEntry *entry;
305 C->data.recursion = 1;
307 entry = BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name));
309 result->ptr = entry->ptr;
313 if (done != 1 && recursion < 2 && (ar = CTX_wm_region(C))) {
314 C->data.recursion = 2;
315 if (ar->type && ar->type->context) {
316 ret = ar->type->context(C, member, result);
317 if (ret) done = -(-ret | -done);
321 if (done != 1 && recursion < 3 && (sa = CTX_wm_area(C))) {
322 C->data.recursion = 3;
323 if (sa->type && sa->type->context) {
324 ret = sa->type->context(C, member, result);
325 if (ret) done = -(-ret | -done);
328 if (done != 1 && recursion < 4 && (sc = CTX_wm_screen(C))) {
329 bContextDataCallback cb = sc->context;
330 C->data.recursion = 4;
332 ret = cb(C, member, result);
333 if (ret) done = -(-ret | -done);
337 C->data.recursion = recursion;
342 static void *ctx_data_pointer_get(const bContext *C, const char *member)
344 bContextDataResult result;
346 if (C && ctx_data_get((bContext *)C, member, &result) == 1) {
347 BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
348 return result.ptr.data;
355 static int ctx_data_pointer_verify(const bContext *C, const char *member, void **pointer)
357 bContextDataResult result;
359 /* if context is NULL, pointer must be NULL too and that is a valid return */
364 else if (ctx_data_get((bContext *)C, member, &result) == 1) {
365 BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
366 *pointer = result.ptr.data;
375 static int ctx_data_collection_get(const bContext *C, const char *member, ListBase *list)
377 bContextDataResult result;
379 if (ctx_data_get((bContext *)C, member, &result) == 1) {
380 BLI_assert(result.type == CTX_DATA_TYPE_COLLECTION);
385 BLI_listbase_clear(list);
390 PointerRNA CTX_data_pointer_get(const bContext *C, const char *member)
392 bContextDataResult result;
394 if (ctx_data_get((bContext *)C, member, &result) == 1) {
395 BLI_assert(result.type == CTX_DATA_TYPE_POINTER);
399 return PointerRNA_NULL;
403 PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
405 PointerRNA ptr = CTX_data_pointer_get(C, member);
408 if (RNA_struct_is_a(ptr.type, type)) {
412 printf("%s: warning, member '%s' is '%s', not '%s'\n",
413 __func__, member, RNA_struct_identifier(ptr.type), RNA_struct_identifier(type));
417 return PointerRNA_NULL;
420 ListBase CTX_data_collection_get(const bContext *C, const char *member)
422 bContextDataResult result;
424 if (ctx_data_get((bContext *)C, member, &result) == 1) {
425 BLI_assert(result.type == CTX_DATA_TYPE_COLLECTION);
429 ListBase list = {NULL, NULL};
434 /* 1:found, -1:found but not set, 0:not found */
435 int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type)
437 bContextDataResult result;
438 int ret = ctx_data_get((bContext *)C, member, &result);
443 *r_type = result.type;
446 memset(r_ptr, 0, sizeof(*r_ptr));
447 memset(r_lb, 0, sizeof(*r_lb));
454 static void data_dir_add(ListBase *lb, const char *member, const bool use_all)
458 if ((use_all == false) && STREQ(member, "scene")) /* exception */
461 if (BLI_findstring(lb, member, offsetof(LinkData, data)))
464 link = MEM_callocN(sizeof(LinkData), "LinkData");
465 link->data = (void *)member;
466 BLI_addtail(lb, link);
471 * \param use_store Use 'C->wm.store'
472 * \param use_rna Use Include the properties from 'RNA_Context'
473 * \param use_all Don't skip values (currently only "scene")
475 ListBase CTX_data_dir_get_ex(const bContext *C, const bool use_store, const bool use_rna, const bool use_all)
477 bContextDataResult result;
484 memset(&lb, 0, sizeof(lb));
487 char name[256], *nameptr;
490 PropertyRNA *iterprop;
492 RNA_pointer_create(NULL, &RNA_Context, (void *)C, &ctx_ptr);
494 iterprop = RNA_struct_iterator_property(ctx_ptr.type);
496 RNA_PROP_BEGIN (&ctx_ptr, itemptr, iterprop)
498 nameptr = RNA_struct_name_get_alloc(&itemptr, name, sizeof(name), &namelen);
499 data_dir_add(&lb, name, use_all);
501 if (name != nameptr) {
508 if (use_store && C->wm.store) {
509 bContextStoreEntry *entry;
511 for (entry = C->wm.store->entries.first; entry; entry = entry->next)
512 data_dir_add(&lb, entry->name, use_all);
514 if ((ar = CTX_wm_region(C)) && ar->type && ar->type->context) {
515 memset(&result, 0, sizeof(result));
516 ar->type->context(C, "", &result);
519 for (a = 0; result.dir[a]; a++)
520 data_dir_add(&lb, result.dir[a], use_all);
522 if ((sa = CTX_wm_area(C)) && sa->type && sa->type->context) {
523 memset(&result, 0, sizeof(result));
524 sa->type->context(C, "", &result);
527 for (a = 0; result.dir[a]; a++)
528 data_dir_add(&lb, result.dir[a], use_all);
530 if ((sc = CTX_wm_screen(C)) && sc->context) {
531 bContextDataCallback cb = sc->context;
532 memset(&result, 0, sizeof(result));
536 for (a = 0; result.dir[a]; a++)
537 data_dir_add(&lb, result.dir[a], use_all);
543 ListBase CTX_data_dir_get(const bContext *C)
545 return CTX_data_dir_get_ex(C, true, false, false);
548 bool CTX_data_equals(const char *member, const char *str)
550 return (STREQ(member, str));
553 bool CTX_data_dir(const char *member)
555 return member[0] == '\0';
558 void CTX_data_id_pointer_set(bContextDataResult *result, ID *id)
560 RNA_id_pointer_create(id, &result->ptr);
563 void CTX_data_pointer_set(bContextDataResult *result, ID *id, StructRNA *type, void *data)
565 RNA_pointer_create(id, type, data, &result->ptr);
568 void CTX_data_id_list_add(bContextDataResult *result, ID *id)
570 CollectionPointerLink *link;
572 link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add");
573 RNA_id_pointer_create(id, &link->ptr);
575 BLI_addtail(&result->list, link);
578 void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void *data)
580 CollectionPointerLink *link;
582 link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add");
583 RNA_pointer_create(id, type, data, &link->ptr);
585 BLI_addtail(&result->list, link);
588 int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBase *))
592 if (func(C, &list)) {
593 int tot = BLI_listbase_count(&list);
594 BLI_freelistN(&list);
601 void CTX_data_dir_set(bContextDataResult *result, const char **dir)
606 void CTX_data_type_set(bContextDataResult *result, short type)
611 short CTX_data_type_get(bContextDataResult *result)
618 /* window manager context */
620 wmWindowManager *CTX_wm_manager(const bContext *C)
622 return C->wm.manager;
625 wmWindow *CTX_wm_window(const bContext *C)
627 return ctx_wm_python_context_get(C, "window", &RNA_Window, C->wm.window);
630 bScreen *CTX_wm_screen(const bContext *C)
632 return ctx_wm_python_context_get(C, "screen", &RNA_Screen, C->wm.screen);
635 ScrArea *CTX_wm_area(const bContext *C)
637 return ctx_wm_python_context_get(C, "area", &RNA_Area, C->wm.area);
640 SpaceLink *CTX_wm_space_data(const bContext *C)
642 ScrArea *sa = CTX_wm_area(C);
643 return (sa) ? sa->spacedata.first : NULL;
646 ARegion *CTX_wm_region(const bContext *C)
648 return ctx_wm_python_context_get(C, "region", &RNA_Region, C->wm.region);
651 void *CTX_wm_region_data(const bContext *C)
653 ARegion *ar = CTX_wm_region(C);
654 return (ar) ? ar->regiondata : NULL;
657 struct ARegion *CTX_wm_menu(const bContext *C)
662 struct ReportList *CTX_wm_reports(const bContext *C)
665 return &(C->wm.manager->reports);
670 View3D *CTX_wm_view3d(const bContext *C)
672 ScrArea *sa = CTX_wm_area(C);
673 if (sa && sa->spacetype == SPACE_VIEW3D)
674 return sa->spacedata.first;
678 RegionView3D *CTX_wm_region_view3d(const bContext *C)
680 ScrArea *sa = CTX_wm_area(C);
681 ARegion *ar = CTX_wm_region(C);
683 if (sa && sa->spacetype == SPACE_VIEW3D)
685 return ar->regiondata;
689 struct SpaceText *CTX_wm_space_text(const bContext *C)
691 ScrArea *sa = CTX_wm_area(C);
692 if (sa && sa->spacetype == SPACE_TEXT)
693 return sa->spacedata.first;
697 struct SpaceConsole *CTX_wm_space_console(const bContext *C)
699 ScrArea *sa = CTX_wm_area(C);
700 if (sa && sa->spacetype == SPACE_CONSOLE)
701 return sa->spacedata.first;
705 struct SpaceImage *CTX_wm_space_image(const bContext *C)
707 ScrArea *sa = CTX_wm_area(C);
708 if (sa && sa->spacetype == SPACE_IMAGE)
709 return sa->spacedata.first;
713 struct SpaceButs *CTX_wm_space_buts(const bContext *C)
715 ScrArea *sa = CTX_wm_area(C);
716 if (sa && sa->spacetype == SPACE_BUTS)
717 return sa->spacedata.first;
721 struct SpaceFile *CTX_wm_space_file(const bContext *C)
723 ScrArea *sa = CTX_wm_area(C);
724 if (sa && sa->spacetype == SPACE_FILE)
725 return sa->spacedata.first;
729 struct SpaceSeq *CTX_wm_space_seq(const bContext *C)
731 ScrArea *sa = CTX_wm_area(C);
732 if (sa && sa->spacetype == SPACE_SEQ)
733 return sa->spacedata.first;
737 struct SpaceOops *CTX_wm_space_outliner(const bContext *C)
739 ScrArea *sa = CTX_wm_area(C);
740 if (sa && sa->spacetype == SPACE_OUTLINER)
741 return sa->spacedata.first;
745 struct SpaceNla *CTX_wm_space_nla(const bContext *C)
747 ScrArea *sa = CTX_wm_area(C);
748 if (sa && sa->spacetype == SPACE_NLA)
749 return sa->spacedata.first;
753 struct SpaceTime *CTX_wm_space_time(const bContext *C)
755 ScrArea *sa = CTX_wm_area(C);
756 if (sa && sa->spacetype == SPACE_TIME)
757 return sa->spacedata.first;
761 struct SpaceNode *CTX_wm_space_node(const bContext *C)
763 ScrArea *sa = CTX_wm_area(C);
764 if (sa && sa->spacetype == SPACE_NODE)
765 return sa->spacedata.first;
769 struct SpaceLogic *CTX_wm_space_logic(const bContext *C)
771 ScrArea *sa = CTX_wm_area(C);
772 if (sa && sa->spacetype == SPACE_LOGIC)
773 return sa->spacedata.first;
777 struct SpaceIpo *CTX_wm_space_graph(const bContext *C)
779 ScrArea *sa = CTX_wm_area(C);
780 if (sa && sa->spacetype == SPACE_IPO)
781 return sa->spacedata.first;
785 struct SpaceAction *CTX_wm_space_action(const bContext *C)
787 ScrArea *sa = CTX_wm_area(C);
788 if (sa && sa->spacetype == SPACE_ACTION)
789 return sa->spacedata.first;
793 struct SpaceInfo *CTX_wm_space_info(const bContext *C)
795 ScrArea *sa = CTX_wm_area(C);
796 if (sa && sa->spacetype == SPACE_INFO)
797 return sa->spacedata.first;
801 struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C)
803 ScrArea *sa = CTX_wm_area(C);
804 if (sa && sa->spacetype == SPACE_USERPREF)
805 return sa->spacedata.first;
809 struct SpaceClip *CTX_wm_space_clip(const bContext *C)
811 ScrArea *sa = CTX_wm_area(C);
812 if (sa && sa->spacetype == SPACE_CLIP)
813 return sa->spacedata.first;
817 void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
826 void CTX_wm_window_set(bContext *C, wmWindow *win)
829 C->wm.screen = (win) ? win->screen : NULL;
831 C->data.scene = C->wm.screen->scene;
836 void CTX_wm_screen_set(bContext *C, bScreen *screen)
838 C->wm.screen = screen;
840 C->data.scene = C->wm.screen->scene;
845 void CTX_wm_area_set(bContext *C, ScrArea *area)
851 void CTX_wm_region_set(bContext *C, ARegion *region)
853 C->wm.region = region;
856 void CTX_wm_menu_set(bContext *C, ARegion *menu)
861 void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
863 C->wm.operator_poll_msg = msg;
866 const char *CTX_wm_operator_poll_msg_get(bContext *C)
868 return IFACE_(C->wm.operator_poll_msg);
873 Main *CTX_data_main(const bContext *C)
877 if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain))
883 void CTX_data_main_set(bContext *C, Main *bmain)
885 C->data.main = bmain;
886 BKE_sound_init_main(bmain);
889 Scene *CTX_data_scene(const bContext *C)
893 if (ctx_data_pointer_verify(C, "scene", (void *)&scene))
896 return C->data.scene;
899 int CTX_data_mode_enum(const bContext *C)
901 Object *obedit = CTX_data_edit_object(C);
904 switch (obedit->type) {
906 return CTX_MODE_EDIT_MESH;
908 return CTX_MODE_EDIT_CURVE;
910 return CTX_MODE_EDIT_SURFACE;
912 return CTX_MODE_EDIT_TEXT;
914 return CTX_MODE_EDIT_ARMATURE;
916 return CTX_MODE_EDIT_METABALL;
918 return CTX_MODE_EDIT_LATTICE;
922 Object *ob = CTX_data_active_object(C);
925 if (ob->mode & OB_MODE_POSE) return CTX_MODE_POSE;
926 else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT;
927 else if (ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT;
928 else if (ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX;
929 else if (ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE;
933 return CTX_MODE_OBJECT;
937 /* would prefer if we can use the enum version below over this one - Campbell */
938 /* must be aligned with above enum */
939 static const char *data_mode_strings[] = {
955 const char *CTX_data_mode_string(const bContext *C)
957 return data_mode_strings[CTX_data_mode_enum(C)];
960 void CTX_data_scene_set(bContext *C, Scene *scene)
962 C->data.scene = scene;
965 ToolSettings *CTX_data_tool_settings(const bContext *C)
967 Scene *scene = CTX_data_scene(C);
970 return scene->toolsettings;
975 int CTX_data_selected_nodes(const bContext *C, ListBase *list)
977 return ctx_data_collection_get(C, "selected_nodes", list);
980 int CTX_data_selected_editable_objects(const bContext *C, ListBase *list)
982 return ctx_data_collection_get(C, "selected_editable_objects", list);
985 int CTX_data_selected_editable_bases(const bContext *C, ListBase *list)
987 return ctx_data_collection_get(C, "selected_editable_bases", list);
990 int CTX_data_editable_objects(const bContext *C, ListBase *list)
992 return ctx_data_collection_get(C, "editable_objects", list);
995 int CTX_data_editable_bases(const bContext *C, ListBase *list)
997 return ctx_data_collection_get(C, "editable_bases", list);
1000 int CTX_data_selected_objects(const bContext *C, ListBase *list)
1002 return ctx_data_collection_get(C, "selected_objects", list);
1005 int CTX_data_selected_bases(const bContext *C, ListBase *list)
1007 return ctx_data_collection_get(C, "selected_bases", list);
1010 int CTX_data_visible_objects(const bContext *C, ListBase *list)
1012 return ctx_data_collection_get(C, "visible_objects", list);
1015 int CTX_data_visible_bases(const bContext *C, ListBase *list)
1017 return ctx_data_collection_get(C, "visible_bases", list);
1020 int CTX_data_selectable_objects(const bContext *C, ListBase *list)
1022 return ctx_data_collection_get(C, "selectable_objects", list);
1025 int CTX_data_selectable_bases(const bContext *C, ListBase *list)
1027 return ctx_data_collection_get(C, "selectable_bases", list);
1030 struct Object *CTX_data_active_object(const bContext *C)
1032 return ctx_data_pointer_get(C, "active_object");
1035 struct Base *CTX_data_active_base(const bContext *C)
1037 return ctx_data_pointer_get(C, "active_base");
1040 struct Object *CTX_data_edit_object(const bContext *C)
1042 return ctx_data_pointer_get(C, "edit_object");
1045 struct Image *CTX_data_edit_image(const bContext *C)
1047 return ctx_data_pointer_get(C, "edit_image");
1050 struct Text *CTX_data_edit_text(const bContext *C)
1052 return ctx_data_pointer_get(C, "edit_text");
1055 struct MovieClip *CTX_data_edit_movieclip(const bContext *C)
1057 return ctx_data_pointer_get(C, "edit_movieclip");
1060 struct Mask *CTX_data_edit_mask(const bContext *C)
1062 return ctx_data_pointer_get(C, "edit_mask");
1065 struct EditBone *CTX_data_active_bone(const bContext *C)
1067 return ctx_data_pointer_get(C, "active_bone");
1070 struct CacheFile *CTX_data_edit_cachefile(const bContext *C)
1072 return ctx_data_pointer_get(C, "edit_cachefile");
1075 int CTX_data_selected_bones(const bContext *C, ListBase *list)
1077 return ctx_data_collection_get(C, "selected_bones", list);
1080 int CTX_data_selected_editable_bones(const bContext *C, ListBase *list)
1082 return ctx_data_collection_get(C, "selected_editable_bones", list);
1085 int CTX_data_visible_bones(const bContext *C, ListBase *list)
1087 return ctx_data_collection_get(C, "visible_bones", list);
1090 int CTX_data_editable_bones(const bContext *C, ListBase *list)
1092 return ctx_data_collection_get(C, "editable_bones", list);
1095 struct bPoseChannel *CTX_data_active_pose_bone(const bContext *C)
1097 return ctx_data_pointer_get(C, "active_pose_bone");
1100 int CTX_data_selected_pose_bones(const bContext *C, ListBase *list)
1102 return ctx_data_collection_get(C, "selected_pose_bones", list);
1105 int CTX_data_visible_pose_bones(const bContext *C, ListBase *list)
1107 return ctx_data_collection_get(C, "visible_pose_bones", list);
1110 bGPdata *CTX_data_gpencil_data(const bContext *C)
1112 return ctx_data_pointer_get(C, "gpencil_data");
1115 bGPDlayer *CTX_data_active_gpencil_layer(const bContext *C)
1117 return ctx_data_pointer_get(C, "active_gpencil_layer");
1120 bGPDpalette *CTX_data_active_gpencil_palette(const bContext *C)
1122 return ctx_data_pointer_get(C, "active_gpencil_palette");
1125 bGPDpalettecolor *CTX_data_active_gpencil_palettecolor(const bContext *C)
1127 return ctx_data_pointer_get(C, "active_gpencil_palettecolor");
1130 bGPDbrush *CTX_data_active_gpencil_brush(const bContext *C)
1132 return ctx_data_pointer_get(C, "active_gpencil_brush");
1135 bGPDframe *CTX_data_active_gpencil_frame(const bContext *C)
1137 return ctx_data_pointer_get(C, "active_gpencil_frame");
1140 int CTX_data_visible_gpencil_layers(const bContext *C, ListBase *list)
1142 return ctx_data_collection_get(C, "visible_gpencil_layers", list);
1145 int CTX_data_editable_gpencil_layers(const bContext *C, ListBase *list)
1147 return ctx_data_collection_get(C, "editable_gpencil_layers", list);
1150 int CTX_data_editable_gpencil_strokes(const bContext *C, ListBase *list)
1152 return ctx_data_collection_get(C, "editable_gpencil_strokes", list);