diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-19 22:03:38 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-19 22:03:38 +0300 |
commit | 1b94cb752ca18aac122b444261e76dc63022f99f (patch) | |
tree | c0d4ec35be53898e07462f41bb50f7629a3d323e /source/blender/blenkernel/BKE_context.h | |
parent | 77e0199dc386c26aa106a884f24b336fce82d351 (diff) |
Context
* Made it based on string lookups rather than fixed enum, to make
it extensible by python scripts.
* Context callbacks now also have to specify RNA type when returning
pointers or collections. For non-RNA wrapped data, UnknownType can
be used.
* RNA wrapped context. The WM entries are fixed, for data context
only main and scene are defined properties. Other data entries have
to be dynamically looked up.
* I've added some special code in python for the dynamic context
lookups. Tried to hide it behind RNA but didn't find a clean way to
do it yet. Still unused/untested.
* Also minor fix for warning about propertional edit property in
transform code, and fix for usage of operator poll with checking if
it was NULL.
Diffstat (limited to 'source/blender/blenkernel/BKE_context.h')
-rw-r--r-- | source/blender/blenkernel/BKE_context.h | 64 |
1 files changed, 20 insertions, 44 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index e384900e0cb..dbe5c610688 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -33,6 +33,7 @@ extern "C" { #endif #include "DNA_listBase.h" +#include "RNA_types.h" struct ARegion; struct bScreen; @@ -58,6 +59,7 @@ struct wmWindow; struct wmWindowManager; struct SpaceText; struct SpaceImage; +struct ID; /* Structs */ @@ -67,45 +69,8 @@ typedef struct bContext bContext; struct bContextDataResult; typedef struct bContextDataResult bContextDataResult; -enum { - CTX_DATA_MAIN, - CTX_DATA_SCENE, - CTX_DATA_TOOL_SETTINGS, - - CTX_DATA_SELECTED_OBJECTS, - CTX_DATA_SELECTED_BASES, - CTX_DATA_SELECTED_EDITABLE_OBJECTS, - CTX_DATA_SELECTED_EDITABLE_BASES, - CTX_DATA_VISIBLE_OBJECTS, - CTX_DATA_VISIBLE_BASES, - - CTX_DATA_ACTIVE_OBJECT, - CTX_DATA_ACTIVE_BASE, - CTX_DATA_EDIT_OBJECT, - - CTX_DATA_EDIT_IMAGE, - CTX_DATA_EDIT_IMAGE_BUFFER, - - CTX_DATA_EDIT_TEXT, - - CTX_DATA_SELECTED_NODES, - - CTX_DATA_SELECTED_BONES, - CTX_DATA_SELECTED_EDITABLE_BONES, - CTX_DATA_SELECTED_PCHANS, - - CTX_DATA_ACTIVE_BONE, - CTX_DATA_ACTIVE_PCHAN, - - CTX_DATA_VISIBLE_BONES, - CTX_DATA_EDITABLE_BONES, - CTX_DATA_VISIBLE_PCHANS, -}; - -typedef int bContextDataMember; - typedef int (*bContextDataCallback)(const bContext *C, - bContextDataMember member, bContextDataResult *result); + const char *member, bContextDataResult *result); /* Context */ @@ -158,16 +123,28 @@ void CTX_wm_ui_block_set(bContext *C, struct uiBlock *block, bContextDataCallbac - note: listbases consist of LinkData items and must be freed with BLI_freelistN! */ -void CTX_data_pointer_set(bContextDataResult *result, void *data); -void CTX_data_list_add(bContextDataResult *result, void *data); +PointerRNA CTX_data_pointer_get(bContext *C, const char *member); +ListBase CTX_data_collection_get(bContext *C, const char *member); +void CTX_data_get(bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb); + +void CTX_data_id_pointer_set(bContextDataResult *result, struct ID *id); +void CTX_data_pointer_set(bContextDataResult *result, struct ID *id, StructRNA *type, void *data); + +void CTX_data_id_list_add(bContextDataResult *result, struct ID *id); +void CTX_data_list_add(bContextDataResult *result, struct ID *id, StructRNA *type, void *data); + +int CTX_data_equals(const char *member, const char *str); + +/*void CTX_data_pointer_set(bContextDataResult *result, void *data); +void CTX_data_list_add(bContextDataResult *result, void *data);*/ #define CTX_DATA_BEGIN(C, Type, instance, member) \ { \ ListBase ctx_data_list; \ - LinkData *link; \ + CollectionPointerLink *ctx_link; \ CTX_data_##member(C, &ctx_data_list); \ - for(link=ctx_data_list.first; link; link=link->next) { \ - Type instance= link->data; + for(ctx_link=ctx_data_list.first; ctx_link; ctx_link=ctx_link->next) { \ + Type instance= ctx_link->ptr.data; #define CTX_DATA_END \ } \ @@ -202,7 +179,6 @@ struct Base *CTX_data_active_base(const bContext *C); struct Object *CTX_data_edit_object(const bContext *C); struct Image *CTX_data_edit_image(const bContext *C); -struct ImBuf *CTX_data_edit_image_buffer(const bContext *C); struct Text *CTX_data_edit_text(const bContext *C); |