2008-11-07 02:58:25 +00:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation (2008).
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
#include "RNA_types.h"
|
|
|
|
|
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
|
|
|
/* all the list begin functions are added manually here, Main is not in SDNA */
|
|
|
|
|
2008-11-30 00:57:32 +00:00
|
|
|
static void rna_Main_filename_get(PointerRNA *ptr, char *value)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
|
|
|
BLI_strncpy(value, bmain->name, sizeof(bmain->name));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rna_Main_filename_length(PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
|
|
|
return strlen(bmain->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_filename_set(PointerRNA *ptr, const char *value)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
|
|
|
BLI_strncpy(bmain->name, value, sizeof(bmain->name));
|
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
static void rna_Main_scene_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->scene, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_object_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->object, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
2008-11-18 10:57:06 +00:00
|
|
|
static void rna_Main_lamp_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->lamp, NULL);
|
2008-11-18 10:57:06 +00:00
|
|
|
}
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
static void rna_Main_library_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->library, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_mesh_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->mesh, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_curve_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->curve, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_mball_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->mball, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_mat_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->mat, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_tex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->tex, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_image_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->image, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_latt_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->latt, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_camera_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->camera, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_ipo_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->ipo, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_key_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->key, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_world_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->world, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_screen_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->screen, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_script_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->script, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_vfont_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->vfont, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_text_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->text, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_sound_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->sound, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_group_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->group, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_armature_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->armature, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_action_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->action, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_nodetree_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->nodetree, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_brush_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->brush, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_particle_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->particle, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rna_Main_wm_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
Main *bmain= (Main*)ptr->data;
|
2008-11-24 12:12:24 +00:00
|
|
|
rna_iterator_listbase_begin(iter, &bmain->wm, NULL);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void RNA_def_main(BlenderRNA *brna)
|
|
|
|
{
|
|
|
|
StructRNA *srna;
|
|
|
|
PropertyRNA *prop;
|
2008-11-14 17:05:25 +00:00
|
|
|
const char *lists[][5]= {
|
2008-11-30 00:57:32 +00:00
|
|
|
{"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."},
|
2008-11-14 17:05:25 +00:00
|
|
|
{"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks."},
|
|
|
|
{"objects", "Object", "rna_Main_object_begin", "Objects", "Object datablocks."},
|
2008-11-27 00:23:22 +00:00
|
|
|
{"materials", "Material", "rna_Main_mat_begin", "Materials", "Material datablocks."},
|
2008-11-29 01:04:15 +00:00
|
|
|
{"nodetrees", "NodeTree", "rna_Main_nodetree_begin", "Node Trees", "Nodetree datablocks."},
|
2008-11-14 17:05:25 +00:00
|
|
|
{"meshes", "Mesh", "rna_Main_mesh_begin", "Meshes", "Mesh datablocks."},
|
2008-11-18 10:57:06 +00:00
|
|
|
{"lamps", "Lamp", "rna_Main_lamp_begin", "Lamps", "Lamp datablocks."},
|
2008-11-29 19:08:46 +00:00
|
|
|
{"libraries", "Library", "rna_Main_library_begin", "Libraries", "Library datablocks."},
|
2008-11-29 01:04:15 +00:00
|
|
|
{"screens", "Screen", "rna_Main_screen_begin", "Screens", "Screen datablocks."},
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
{"windowmanagers", "WindowManager", "rna_Main_wm_begin", "Window Managers", "Window manager datablocks."},
|
2008-11-30 18:39:49 +00:00
|
|
|
{"images", "Image", "rna_Main_image_begin", "Images", "Image datablocks."},
|
|
|
|
{"lattices", "Lattice", "rna_Main_latt_begin", "Lattices", "Lattice datablocks."},
|
2008-11-30 00:57:32 +00:00
|
|
|
{"curves", "ID", "rna_Main_curve_begin", "Curves", "Curve datablocks."},
|
|
|
|
{"metaballs", "ID", "rna_Main_mball_begin", "Metaballs", "Metaball datablocks."},
|
|
|
|
{"textures", "ID", "rna_Main_tex_begin", "Textures", "Texture datablocks."},
|
|
|
|
{"ipos", "ID", "rna_Main_ipo_begin", "Ipos", "Ipo datablocks."},
|
|
|
|
{"keys", "ID", "rna_Main_key_begin", "Keys", "Key datablocks."},
|
2008-11-30 22:48:43 +00:00
|
|
|
{"worlds", "World", "rna_Main_world_begin", "Worlds", "World datablocks."},
|
2008-11-30 00:57:32 +00:00
|
|
|
{"scripts", "ID", "rna_Main_script_begin", "Scripts", "Script datablocks."},
|
|
|
|
{"vfonts", "ID", "rna_Main_vfont_begin", "VFonts", "VFont datablocks."},
|
|
|
|
{"texts", "ID", "rna_Main_text_begin", "Texts", "Text datablocks."},
|
|
|
|
{"sounds", "ID", "rna_Main_sound_begin", "Sounds", "Sound datablocks."},
|
|
|
|
{"groups", "ID", "rna_Main_group_begin", "Groups", "Group datablocks."},
|
|
|
|
{"armatures", "ID", "rna_Main_armature_begin", "Armatures", "Armature datablocks."},
|
|
|
|
{"actions", "ID", "rna_Main_action_begin", "Actions", "Action datablocks."},
|
|
|
|
{"brushes", "ID", "rna_Main_brush_begin", "Brushes", "Brush datablocks."},
|
|
|
|
{"particles", "ID", "rna_Main_particle_begin", "Particles", "Particle datablocks."},
|
2008-11-14 17:05:25 +00:00
|
|
|
{NULL, NULL, NULL, NULL, NULL}};
|
2008-11-07 02:58:25 +00:00
|
|
|
int i;
|
|
|
|
|
RNA
* More ID property support. What was already possible was showing
ID properties as RNA properties. Now it is possible to define
RNA properties and have an ID property automatically created the
first time it is set (if not set it retuns the default).
* Added support for defining RNA structs and properties at runtime.
This is useful for python and plugins, and could also be used
for operators, not sure yet what is best there, they could be done
in preprocess for speed, but not sure how to do that while keeping
operator registration a single function.
* Added quick functions to get/set properties based on names, to be
used for operators.
* Added some simple support for inheritance, was already doing this
but having it as a feature simplifies things. Two things were added
for this: when defining a struct you can give a 'from' struct whose
properties will be copied, and structs like ID, operator, modifier,
can define a refine callback that will return the more specific type
of the struct like ID -> Object, Mesh, .. .
* Added simple windowmanager wrap with only the registered operators
list, used for testing RNA for operators.
2008-11-21 02:23:46 +00:00
|
|
|
srna= RNA_def_struct(brna, "Main", NULL, "Main");
|
2008-11-07 02:58:25 +00:00
|
|
|
|
2008-11-30 00:57:32 +00:00
|
|
|
prop= RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH);
|
|
|
|
RNA_def_property_string_maxlength(prop, 240);
|
|
|
|
RNA_def_property_string_funcs(prop, "rna_Main_filename_get", "rna_Main_filename_length", "rna_Main_filename_set");
|
|
|
|
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
|
|
|
|
RNA_def_property_ui_text(prop, "Filename", "Path to the .blend file.");
|
|
|
|
|
2008-11-07 02:58:25 +00:00
|
|
|
for(i=0; lists[i][0]; i++)
|
|
|
|
{
|
|
|
|
prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE);
|
|
|
|
RNA_def_property_struct_type(prop, lists[i][1]);
|
2008-11-17 18:44:06 +00:00
|
|
|
RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0);
|
2008-11-14 17:05:25 +00:00
|
|
|
RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]);
|
2008-11-07 02:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|