[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34269] trunk/blender/source/blender/ makesrna: "Pointer" properties can now be reset to some kind of "default" value

Joshua Leung aligorith at gmail.com
Tue Jan 11 23:32:19 CET 2011


Revision: 34269
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34269
Author:   aligorith
Date:     2011-01-11 22:32:18 +0000 (Tue, 11 Jan 2011)
Log Message:
-----------
"Pointer" properties can now be reset to some kind of "default" value
when using the Numpad0 feature to reset properties to their default
values.

While this implementation here is not a full/proper implementation, as
you cannot truly specify a default value for some pointers that may
require something other than NULL (i.e. nothing), this should be good
enough for the vast majority of (editable) cases which are fine if set
to NULL.

This is most noticeable with the Active Keying Set field in the
TimeLine header, where it's now possible to simply use Numpad0 to
clear it instead of using a confusing click+backspace+enter dance to
do the same thing.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_access.c

Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h	2011-01-11 22:06:44 UTC (rev 34268)
+++ trunk/blender/source/blender/makesrna/RNA_access.h	2011-01-11 22:32:18 UTC (rev 34269)
@@ -734,7 +734,7 @@
 
 PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop);
 void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value);
-// TODO: get default pointers...
+PointerRNA RNA_property_pointer_get_default(PointerRNA *ptr, PropertyRNA *prop);
 
 void RNA_property_collection_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter);
 void RNA_property_collection_next(CollectionPropertyIterator *iter);

Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c	2011-01-11 22:06:44 UTC (rev 34268)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c	2011-01-11 22:32:18 UTC (rev 34269)
@@ -2020,6 +2020,12 @@
 	}
 }
 
+PointerRNA RNA_property_pointer_get_default(PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop))
+{
+	//PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
+	return PointerRNA_NULL; // FIXME: there has to be a way...
+}
+
 void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop)
 {
 	/*IDProperty *idprop;*/
@@ -4808,9 +4814,15 @@
 			return 1;
 		}
 		
-		//case PROP_POINTER:
+		case PROP_POINTER:
+		{
+			PointerRNA value= RNA_property_pointer_get_default(ptr, prop);
+			RNA_property_pointer_set(ptr, prop, value);
+			return 1;
+		}
+		
 		default: 
-			// FIXME: many of the other types such as strings and pointers need this implemented too!
+			// FIXME: are there still any cases that haven't been handled? comment out "default" block to check :)
 			return 0;
 	}
 }




More information about the Bf-blender-cvs mailing list