From 144fb8ed1f43a83472270d4bdece36a2911188c1 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 11 Jan 2011 22:32:18 +0000 Subject: [PATCH] "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. --- source/blender/makesrna/RNA_access.h | 2 +- source/blender/makesrna/intern/rna_access.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index b713668454e..91d5caf32a0 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -734,7 +734,7 @@ int RNA_property_enum_get_default(PointerRNA *ptr, PropertyRNA *prop); 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); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 7852a5488bd..742483663a6 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2020,6 +2020,12 @@ void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr } } +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 @@ int RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index) 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; } }