diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-10-14 17:20:20 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-10-14 17:20:20 +0400 |
commit | c7c2e3de1ea805096d2047f4321d928ce427b00f (patch) | |
tree | 5281cacf572eeee557811a5bce479e086b67b99b | |
parent | cd202a1a24a7ef1ca396df4e679b240915fbc446 (diff) |
set scene, currently UI is in the render buttons, should be moved to a scene buttons area.
added a property flag PROP_ID_SELF_CHECK, so properties can be set to point to anything but themselves.
-rw-r--r-- | release/scripts/ui/buttons_scene.py | 5 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 46 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 21 |
6 files changed, 61 insertions, 34 deletions
diff --git a/release/scripts/ui/buttons_scene.py b/release/scripts/ui/buttons_scene.py index ce4adef354d..c4679d40a10 100644 --- a/release/scripts/ui/buttons_scene.py +++ b/release/scripts/ui/buttons_scene.py @@ -25,14 +25,15 @@ class SCENE_PT_render(RenderButtonsPanel): def draw(self, context): layout = self.layout - - rd = context.scene.render_data + scene = context.scene + rd = scene.render_data row = layout.row() row.itemO("screen.render", text="Image", icon='ICON_RENDER_STILL') row.item_booleanO("screen.render", "animation", True, text="Animation", icon='ICON_RENDER_ANIMATION') layout.itemR(rd, "display_mode", text="Display") + layout.itemR(scene, "set", text="Set Scene") # XXX - this should get its own 'scene buttons' class SCENE_PT_layers(RenderButtonsPanel): __label__ = "Layers" diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 576f5cbb984..20160946ff3 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -126,47 +126,51 @@ typedef enum PropertyFlag { /* editable means the property is editable in the user * interface, properties are editable by default except * for pointers and collections. */ - PROP_EDITABLE = 1, + PROP_EDITABLE = 1<<0, /* this property is editable even if it is lib linked, * meaning it will get lost on reload, but it's useful * for editing. */ - PROP_LIB_EXCEPTION = 65536, + PROP_LIB_EXCEPTION = 1<<16, /* animateable means the property can be driven by some * other input, be it animation curves, expressions, .. * properties are animateable by default except for pointers * and collections */ - PROP_ANIMATEABLE = 2, + PROP_ANIMATEABLE = 1<<1, /* icon */ - PROP_ICONS_CONSECUTIVE = 4096, + PROP_ICONS_CONSECUTIVE = 1<12, /* hidden in the user interface */ - PROP_HIDDEN = 524288, + PROP_HIDDEN = 1<<19, /* function paramater flags */ - PROP_REQUIRED = 4, - PROP_RETURN = 8, - PROP_RNAPTR = 2048, - + PROP_REQUIRED = 1<<2, + PROP_RETURN = 1<<3, + PROP_RNAPTR = 1<<11, /* registering */ - PROP_REGISTER = 16, - PROP_REGISTER_OPTIONAL = 16|32, + PROP_REGISTER = 1<<4, + PROP_REGISTER_OPTIONAL = (1<<4)|(1<<5), /* pointers */ - PROP_ID_REFCOUNT = 64, - PROP_NEVER_NULL = 262144, + PROP_ID_REFCOUNT = 1<<6, + + /* disallow assigning a variable to its self, eg an object tracking its self + * only apply this to types that are derived from an ID ()*/ + PROP_ID_SELF_CHECK = 1<<20, + + PROP_NEVER_NULL = 1<<18, /* internal flags */ - PROP_BUILTIN = 128, - PROP_EXPORT = 256, - PROP_RUNTIME = 512, - PROP_IDPROPERTY = 1024, - PROP_RAW_ACCESS = 8192, - PROP_RAW_ARRAY = 16384, - PROP_FREE_POINTERS = 32768, - PROP_DYNAMIC = 131072 /* for dynamic arrays, and retvals of type string */ + PROP_BUILTIN = 1<<7, + PROP_EXPORT = 1<<8, + PROP_RUNTIME = 1<<9, + PROP_IDPROPERTY = 1<<10, + PROP_RAW_ACCESS = 1<<13, + PROP_RAW_ARRAY = 1<<14, + PROP_FREE_POINTERS = 1<<15, + PROP_DYNAMIC = 1<<17 /* for dynamic arrays, and retvals of type string */ } PropertyFlag; typedef struct CollectionPropertyIterator { diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 63b58f27c53..7e473fcb096 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -144,6 +144,11 @@ static void rna_print_data_get(FILE *f, PropertyDefRNA *dp) fprintf(f, " %s *data= (%s*)(ptr->data);\n", dp->dnastructname, dp->dnastructname); } +static void rna_print_id_get(FILE *f, PropertyDefRNA *dp) +{ + fprintf(f, " ID *id= ptr->id.data;\n"); +} + static char *rna_alloc_function_name(const char *structname, const char *propname, const char *type) { AllocDefRNA *alloc; @@ -530,6 +535,11 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr else { rna_print_data_get(f, dp); + if(prop->flag & PROP_ID_SELF_CHECK) { + rna_print_id_get(f, dp); + fprintf(f, " if(id==value.data) return;\n\n"); + } + if(prop->flag & PROP_ID_REFCOUNT) { fprintf(f, "\n if(data->%s)\n", dp->dnaname); fprintf(f, " id_us_min((ID*)data->%s);\n", dp->dnaname); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 03fead8c54f..046f1ea1030 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1452,7 +1452,7 @@ static void rna_def_mesh(BlenderRNA *brna) /* TODO, should this be allowed to be its self? */ prop= RNA_def_property(srna, "texture_mesh", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "texcomesh"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_ui_text(prop, "Texture Mesh", "Use another mesh for texture indicies (vertex indicies must be aligned)."); /* UV textures */ diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 6f2d455f660..2f40cacbda6 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -223,14 +223,6 @@ static void rna_Object_parent_type_set(PointerRNA *ptr, int value) ED_object_parent(ob, ob->parent, value, ob->parsubstr); } -static void rna_Object_track_set(PointerRNA *ptr, PointerRNA value) -{ - Object *ob= (Object*)ptr->data; - - if(ob != value.data) - ob->track= value.data; -} - static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *C, PointerRNA *ptr, int *free) { Object *ob= (Object*)ptr->data; @@ -1219,8 +1211,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); prop= RNA_def_property(srna, "track", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_funcs(prop, NULL, "rna_Object_track_set", NULL); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); RNA_def_property_ui_text(prop, "Track", "Object being tracked to define the rotation (Old Track)."); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_dependency_update"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index d254c7c9eee..03c7a06818d 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -110,6 +110,19 @@ static void rna_Scene_active_object_set(PointerRNA *ptr, PointerRNA value) scene->basact= NULL; } +static void rna_Scene_set_set(PointerRNA *ptr, PointerRNA value) +{ + Scene *scene= (Scene*)ptr->data; + Scene *set= (Scene*)value.data; + Scene *nested_set; + + for(nested_set= set; nested_set; nested_set= nested_set->set) { + if(nested_set==scene) + return; + } + + scene->set= set; +} static int layer_set(int lay, const int *values) { @@ -2084,6 +2097,14 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Camera", "Active camera used for rendering the scene."); + prop= RNA_def_property(srna, "set", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "set"); + RNA_def_property_struct_type(prop, "Scene"); + //RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); + RNA_def_property_pointer_funcs(prop, NULL, "rna_Scene_set_set", NULL); + RNA_def_property_ui_text(prop, "Set Scene", "Background set scene."); + prop= RNA_def_property(srna, "active_object", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_pointer_funcs(prop, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL); |