"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.
This commit is contained in:
Joshua Leung 2011-01-11 22:32:18 +00:00
parent 37b903e32c
commit 144fb8ed1f
2 changed files with 15 additions and 3 deletions

@ -734,7 +734,7 @@ int RNA_property_enum_get_default(PointerRNA *ptr, PropertyRNA *prop);
PointerRNA RNA_property_pointer_get(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); 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_begin(PointerRNA *ptr, PropertyRNA *prop, CollectionPropertyIterator *iter);
void RNA_property_collection_next(CollectionPropertyIterator *iter); void RNA_property_collection_next(CollectionPropertyIterator *iter);

@ -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) void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop)
{ {
/*IDProperty *idprop;*/ /*IDProperty *idprop;*/
@ -4808,9 +4814,15 @@ int RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
return 1; 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: 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; return 0;
} }
} }