4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2008 Blender Foundation.
21 * All rights reserved.
24 * ***** END GPL LICENSE BLOCK *****
30 #include "DNA_object_types.h"
31 #include "DNA_scene_types.h"
32 #include "DNA_screen_types.h"
34 #include "BKE_context.h"
35 #include "BKE_utildefines.h"
37 #include "RNA_access.h"
39 int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
41 bScreen *sc= CTX_wm_screen(C);
42 Scene *scene= sc->scene;
45 if(CTX_data_dir(member)) {
46 static const char *dir[] = {
47 "scene", "selected_objects", "selected_bases", "active_base",
48 "active_object", "edit_object", NULL};
50 CTX_data_dir_set(result, dir);
53 else if(CTX_data_equals(member, "scene")) {
54 CTX_data_id_pointer_set(result, &scene->id);
57 else if(CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) {
58 int selected_objects= CTX_data_equals(member, "selected_objects");
60 for(base=scene->base.first; base; base=base->next) {
61 if((base->flag & SELECT) && (base->lay & scene->lay)) {
63 CTX_data_id_list_add(result, &base->object->id);
65 CTX_data_list_add(result, &scene->id, &RNA_UnknownType, base);
71 else if(CTX_data_equals(member, "active_base")) {
73 CTX_data_pointer_set(result, &scene->id, &RNA_UnknownType, &scene->basact);
77 else if(CTX_data_equals(member, "active_object")) {
79 CTX_data_id_pointer_set(result, &scene->basact->object->id);
83 else if(CTX_data_equals(member, "edit_object")) {
84 /* convenience for now, 1 object per scene in editmode */
86 CTX_data_id_pointer_set(result, &scene->obedit->id);