diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-02-06 02:59:03 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-02-07 03:32:11 +0300 |
commit | 9eca281e880a1359a57bc3dece87dd1f2cf81621 (patch) | |
tree | 2c6228ff6af873621156e3c32831fd38800bbb4a /source | |
parent | e360080a04e0615eb036612834b6ddcd1816365d (diff) |
Added Context.editable_objects/bases
This is useful when you want visible + editable objects, but you don't
want to require the items to be selected as well.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_context.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/context.c | 10 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_context.c | 19 |
3 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h index f7af3a7f8ec..65a68a4387c 100644 --- a/source/blender/blenkernel/BKE_context.h +++ b/source/blender/blenkernel/BKE_context.h @@ -246,6 +246,9 @@ void CTX_data_scene_set(bContext *C, struct Scene *bmain); int CTX_data_selected_editable_objects(const bContext *C, ListBase *list); int CTX_data_selected_editable_bases(const bContext *C, ListBase *list); +int CTX_data_editable_objects(const bContext *C, ListBase *list); +int CTX_data_editable_bases(const bContext *C, ListBase *list); + int CTX_data_selected_objects(const bContext *C, ListBase *list); int CTX_data_selected_bases(const bContext *C, ListBase *list); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index d223a3aff9e..5b7698544e0 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -987,6 +987,16 @@ int CTX_data_selected_editable_bases(const bContext *C, ListBase *list) return ctx_data_collection_get(C, "selected_editable_bases", list); } +int CTX_data_editable_objects(const bContext *C, ListBase *list) +{ + return ctx_data_collection_get(C, "editable_objects", list); +} + +int CTX_data_editable_bases(const bContext *C, ListBase *list) +{ + return ctx_data_collection_get(C, "editable_bases", list); +} + int CTX_data_selected_objects(const bContext *C, ListBase *list) { return ctx_data_collection_get(C, "selected_objects", list); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 87c0ce398e5..8a7ee3a5fe7 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -75,6 +75,7 @@ static unsigned int context_layers(bScreen *sc, Scene *scene, ScrArea *sa_ctx) const char *screen_context_dir[] = { "scene", "visible_objects", "visible_bases", "selectable_objects", "selectable_bases", "selected_objects", "selected_bases", + "editable_objects", "editable_bases", "selected_editable_objects", "selected_editable_bases", "visible_bones", "editable_bones", "selected_bones", "selected_editable_bones", "visible_pose_bones", "selected_pose_bones", "active_bone", "active_pose_bone", @@ -179,6 +180,24 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } + else if (CTX_data_equals(member, "editable_objects") || CTX_data_equals(member, "editable_bases")) { + const unsigned int lay = context_layers(sc, scene, sa); + int editable_objects = CTX_data_equals(member, "editable_objects"); + + /* Visible + Editable, but not necessarily selected */ + for (base = scene->base.first; base; base = base->next) { + if (((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) && (base->lay & lay)) { + if (0 == BKE_object_is_libdata(base->object)) { + if (editable_objects) + CTX_data_id_list_add(result, &base->object->id); + else + CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); + } + } + } + CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); + return 1; + } else if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; EditBone *ebone, *flipbone = NULL; |