clone and stencil layer access added, renamed mask to stencil layer internally
[blender.git] / source / blender / makesrna / intern / rna_main.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
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.
10  *
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.
15  *
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.
19  *
20  * Contributor(s): Blender Foundation (2008).
21  *
22  * ***** END GPL LICENSE BLOCK *****
23  */
24
25 #include <stdlib.h>
26 #include <string.h>
27
28 #include "RNA_define.h"
29 #include "RNA_types.h"
30
31 #include "rna_internal.h"
32
33 #ifdef RNA_RUNTIME
34
35 #include "BKE_main.h"
36 #include "BKE_mesh.h"
37
38 /* all the list begin functions are added manually here, Main is not in SDNA */
39
40 static void rna_Main_filename_get(PointerRNA *ptr, char *value)
41 {
42         Main *bmain= (Main*)ptr->data;
43         BLI_strncpy(value, bmain->name, sizeof(bmain->name));
44 }
45
46 static int rna_Main_filename_length(PointerRNA *ptr)
47 {
48         Main *bmain= (Main*)ptr->data;
49         return strlen(bmain->name);
50 }
51
52 #if 0
53 static void rna_Main_filename_set(PointerRNA *ptr, const char *value)
54 {
55         Main *bmain= (Main*)ptr->data;
56         BLI_strncpy(bmain->name, value, sizeof(bmain->name));
57 }
58 #endif
59
60 static void rna_Main_scene_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
61 {
62         Main *bmain= (Main*)ptr->data;
63         rna_iterator_listbase_begin(iter, &bmain->scene, NULL);
64 }
65
66 static void rna_Main_object_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
67 {
68         Main *bmain= (Main*)ptr->data;
69         rna_iterator_listbase_begin(iter, &bmain->object, NULL);
70 }
71
72 static void rna_Main_lamp_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
73 {
74         Main *bmain= (Main*)ptr->data;
75         rna_iterator_listbase_begin(iter, &bmain->lamp, NULL);
76 }
77
78 static void rna_Main_library_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
79 {
80         Main *bmain= (Main*)ptr->data;
81         rna_iterator_listbase_begin(iter, &bmain->library, NULL);
82 }
83
84 static void rna_Main_mesh_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
85 {
86         Main *bmain= (Main*)ptr->data;
87         rna_iterator_listbase_begin(iter, &bmain->mesh, NULL);
88 }
89
90 static void rna_Main_curve_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
91 {
92         Main *bmain= (Main*)ptr->data;
93         rna_iterator_listbase_begin(iter, &bmain->curve, NULL);
94 }
95
96 static void rna_Main_mball_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
97 {
98         Main *bmain= (Main*)ptr->data;
99         rna_iterator_listbase_begin(iter, &bmain->mball, NULL);
100 }
101
102 static void rna_Main_mat_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
103 {
104         Main *bmain= (Main*)ptr->data;
105         rna_iterator_listbase_begin(iter, &bmain->mat, NULL);
106 }
107
108 static void rna_Main_tex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
109 {
110         Main *bmain= (Main*)ptr->data;
111         rna_iterator_listbase_begin(iter, &bmain->tex, NULL);
112 }
113
114 static void rna_Main_image_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
115 {
116         Main *bmain= (Main*)ptr->data;
117         rna_iterator_listbase_begin(iter, &bmain->image, NULL);
118 }
119
120 static void rna_Main_latt_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
121 {
122         Main *bmain= (Main*)ptr->data;
123         rna_iterator_listbase_begin(iter, &bmain->latt, NULL);
124 }
125
126 static void rna_Main_camera_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
127 {
128         Main *bmain= (Main*)ptr->data;
129         rna_iterator_listbase_begin(iter, &bmain->camera, NULL);
130 }
131
132 #if 0
133 static void rna_Main_key_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
134 {
135         Main *bmain= (Main*)ptr->data;
136         rna_iterator_listbase_begin(iter, &bmain->key, NULL);
137 }
138 #endif
139
140 static void rna_Main_world_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
141 {
142         Main *bmain= (Main*)ptr->data;
143         rna_iterator_listbase_begin(iter, &bmain->world, NULL);
144 }
145
146 static void rna_Main_screen_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
147 {
148         Main *bmain= (Main*)ptr->data;
149         rna_iterator_listbase_begin(iter, &bmain->screen, NULL);
150 }
151
152 static void rna_Main_script_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
153 {
154         Main *bmain= (Main*)ptr->data;
155         rna_iterator_listbase_begin(iter, &bmain->script, NULL);
156 }
157
158 static void rna_Main_vfont_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
159 {
160         Main *bmain= (Main*)ptr->data;
161         rna_iterator_listbase_begin(iter, &bmain->vfont, NULL);
162 }
163
164 static void rna_Main_text_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
165 {
166         Main *bmain= (Main*)ptr->data;
167         rna_iterator_listbase_begin(iter, &bmain->text, NULL);
168 }
169
170 static void rna_Main_sound_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
171 {
172         Main *bmain= (Main*)ptr->data;
173         rna_iterator_listbase_begin(iter, &bmain->sound, NULL);
174 }
175
176 static void rna_Main_group_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
177 {
178         Main *bmain= (Main*)ptr->data;
179         rna_iterator_listbase_begin(iter, &bmain->group, NULL);
180 }
181
182 static void rna_Main_armature_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
183 {
184         Main *bmain= (Main*)ptr->data;
185         rna_iterator_listbase_begin(iter, &bmain->armature, NULL);
186 }
187
188 static void rna_Main_action_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
189 {
190         Main *bmain= (Main*)ptr->data;
191         rna_iterator_listbase_begin(iter, &bmain->action, NULL);
192 }
193
194 static void rna_Main_nodetree_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
195 {
196         Main *bmain= (Main*)ptr->data;
197         rna_iterator_listbase_begin(iter, &bmain->nodetree, NULL);
198 }
199
200 static void rna_Main_brush_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
201 {
202         Main *bmain= (Main*)ptr->data;
203         rna_iterator_listbase_begin(iter, &bmain->brush, NULL);
204 }
205
206 static void rna_Main_particle_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
207 {
208         Main *bmain= (Main*)ptr->data;
209         rna_iterator_listbase_begin(iter, &bmain->particle, NULL);
210 }
211
212 static void rna_Main_gpencil_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
213 {
214         Main *bmain= (Main*)ptr->data;
215         rna_iterator_listbase_begin(iter, &bmain->gpencil, NULL);
216 }
217
218 static void rna_Main_wm_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
219 {
220         Main *bmain= (Main*)ptr->data;
221         rna_iterator_listbase_begin(iter, &bmain->wm, NULL);
222 }
223
224 #ifdef UNIT_TEST
225
226 static PointerRNA rna_Test_test_get(PointerRNA *ptr)
227 {
228         PointerRNA ret= *ptr;
229         ret.type= &RNA_Test;
230
231         return ret;
232 }
233
234 #endif
235
236 #else
237
238 void RNA_def_main(BlenderRNA *brna)
239 {
240         StructRNA *srna;
241         PropertyRNA *prop;
242
243         const char *lists[][5]= {
244                 {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."},
245                 {"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks."},
246                 {"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks."},
247                 {"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks."},
248                 {"nodegroups", "NodeTree", "rna_Main_nodetree_begin", "Node Groups", "Node group datablocks."},
249                 {"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks."}, // "add_mesh", "remove_mesh"
250                 {"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks."},
251                 {"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks."},
252                 {"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks."},
253                 {"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks."},
254                 {"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks."},
255                 {"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks."},
256                 {"curves", "Curve", "rna_Main_curve_begin", "Curves", "Curve datablocks."} ,
257                 {"metaballs", "MetaBall", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks."},
258                 {"vfonts", "VectorFont", "rna_Main_vfont_begin", "Vector Fonts", "Vector font datablocks."},
259                 {"textures", "Texture", "rna_Main_tex_begin", "Textures", "Texture datablocks."},
260                 {"brushes", "Brush", "rna_Main_brush_begin", "Brushes", "Brush datablocks."},
261                 {"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks."},
262                 {"groups", "Group", "rna_Main_group_begin", "Groups", "Group datablocks."},
263 /*              {"keys", "Key", "rna_Main_key_begin", "Keys", "Key datablocks."}, */
264                 {"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks (DEPRECATED)."},
265                 {"texts", "Text", "rna_Main_text_begin", "Texts", "Text datablocks."},
266                 {"sounds", "Sound", "rna_Main_sound_begin", "Sounds", "Sound datablocks."},
267                 {"armatures", "Armature", "rna_Main_armature_begin", "Armatures", "Armature datablocks."},
268                 {"actions", "Action", "rna_Main_action_begin", "Actions", "Action datablocks."},
269                 {"particles", "ParticleSettings", "rna_Main_particle_begin", "Particles", "Particle datablocks."},
270                 {"gpencil", "GreasePencil", "rna_Main_gpencil_begin", "Grease Pencil", "Grease Pencil datablocks."},
271                 {NULL, NULL, NULL, NULL, NULL}};
272         int i;
273         
274         srna= RNA_def_struct(brna, "Main", NULL);
275         RNA_def_struct_ui_text(srna, "Main", "Main data structure representing a .blend file and all its datablocks.");
276         RNA_def_struct_ui_icon(srna, ICON_BLENDER);
277
278         prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH);
279         RNA_def_property_string_maxlength(prop, 240);
280         RNA_def_property_string_funcs(prop, "rna_Main_filename_get", "rna_Main_filename_length", "rna_Main_filename_set");
281         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
282         RNA_def_property_ui_text(prop, "Filename", "Path to the .blend file.");
283
284         for(i=0; lists[i][0]; i++)
285         {
286                 prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE);
287                 RNA_def_property_struct_type(prop, lists[i][1]);
288                 RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
289                 RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]);
290         }
291
292         RNA_api_main(srna);
293
294 #ifdef UNIT_TEST
295
296         RNA_define_verify_sdna(0);
297
298         prop= RNA_def_property(srna, "test", PROP_POINTER, PROP_NONE);
299         RNA_def_property_struct_type(prop, "Test");
300         RNA_def_property_pointer_funcs(prop, "rna_Test_test_get", NULL, NULL);
301
302         RNA_define_verify_sdna(1);
303
304 #endif
305 }
306
307 #endif
308