Add frame_duration read-only member to Image RNA struct, returns movie's length in...
authorBastien Montagne <montagne29@wanadoo.fr>
Sat, 26 May 2012 14:53:33 +0000 (14:53 +0000)
committerBastien Montagne <montagne29@wanadoo.fr>
Sat, 26 May 2012 14:53:33 +0000 (14:53 +0000)
source/blender/makesrna/intern/rna_image.c

index b022da9763000741d9b5482d9f1266af5062bc2a..03e446c9d910b4b46671152f42f496ae97ab2a14 100644 (file)
@@ -53,6 +53,7 @@ static EnumPropertyItem image_source_items[] = {
 
 #ifdef RNA_RUNTIME
 
+#include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 
 static void rna_Image_animated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -287,6 +288,15 @@ static int rna_Image_depth_get(PointerRNA *ptr)
        return planes;
 }
 
+static int rna_Image_frame_duration_get(PointerRNA *ptr)
+{
+       Image *im = (Image *)ptr->data;
+
+       if (im->anim)
+               return IMB_anim_get_duration(im->anim, IMB_TC_RECORD_RUN);
+       return 1;
+}
+
 static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
 {
        Image *ima = ptr->id.data;
@@ -629,6 +639,11 @@ static void rna_def_image(BlenderRNA *brna)
        prop = RNA_def_float_vector(srna, "resolution", 2, NULL, 0, 0, "Resolution", "X/Y pixels per meter", 0, 0);
        RNA_def_property_float_funcs(prop, "rna_Image_resolution_get", "rna_Image_resolution_set", NULL);
 
+       prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_UNSIGNED);
+       RNA_def_property_int_funcs(prop, "rna_Image_frame_duration_get", NULL, NULL);
+       RNA_def_property_ui_text(prop, "Duration", "Duration (in frames) of the image (1 when not a video/sequence)");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
        prop = RNA_def_property(srna, "pixels", PROP_FLOAT, PROP_NONE);
        RNA_def_property_flag(prop, PROP_DYNAMIC);
        RNA_def_property_multi_array(prop, 1, NULL);