diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-09 13:15:47 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-09 13:17:31 +0400 |
commit | 375d2dc85535b9f08fd2e854c80434eac1c28a67 (patch) | |
tree | 9cb344ef18c86d8286abfb2933d37e98cc48754c /source/blender/makesrna/intern/rna_image.c | |
parent | fe9394741b7ac9ca153c602d6f58664b27438d56 (diff) |
Implement custom names for render slots
Basically the title tells it all, quite straightforward implementation.
The only thing is the image.render_slot which used to represent the active
render slot index is now moved to image.render_slots.active_index.
Reviewers: venomgfx, campbellbarton
Differential Revision: https://developer.blender.org/D821
Diffstat (limited to 'source/blender/makesrna/intern/rna_image.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 88 |
1 files changed, 84 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 90c9cd108cd..2d8e41fd654 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -399,6 +399,43 @@ static int rna_Image_is_float_get(PointerRNA *ptr) return is_float; } +static void rna_Image_render_slots_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Image *image = (Image *)ptr->id.data; + rna_iterator_array_begin(iter, (void*)image->render_slots, sizeof(RenderSlot), IMA_MAX_RENDER_SLOT, 0, NULL); +} + +static PointerRNA rna_render_slots_active_get(PointerRNA *ptr) +{ + Image *image = (Image *)ptr->id.data; + RenderSlot *render_slot = &image->render_slots[image->render_slot]; + + return rna_pointer_inherit_refine(ptr, &RNA_RenderSlot, render_slot); +} + +static void rna_render_slots_active_set(PointerRNA *ptr, PointerRNA value) +{ + Image *image = (Image *)ptr->id.data; + if (value.id.data == image) { + RenderSlot *render_slot = (RenderSlot *)value.data; + int index = render_slot - image->render_slots; + image->render_slot = CLAMPIS(index, 0, IMA_MAX_RENDER_SLOT - 1); + } +} + +static int rna_render_slots_active_index_get(PointerRNA *ptr) +{ + Image *image = (Image *)ptr->id.data; + return image->render_slot; +} + +static void rna_render_slots_active_index_set(PointerRNA *ptr, int value) +{ + Image *image = (Image *)ptr->id.data; + image->render_slot = value; + CLAMP(image->render_slot, 0, IMA_MAX_RENDER_SLOT - 1); +} + #else static void rna_def_imageuser(BlenderRNA *brna) @@ -467,6 +504,45 @@ static void rna_def_imageuser(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Pass", "Pass in multilayer image"); } +static void rna_def_render_slot(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + srna = RNA_def_struct(brna, "RenderSlot", NULL); + RNA_def_struct_ui_text(srna, "Render Slot", "Parameters defining the render slot"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "name"); + RNA_def_property_ui_text(prop, "Name", "Render slot name"); + RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); +} + +static void rna_def_render_slots(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "RenderSlots", NULL); + RNA_def_struct_sdna(srna, "RenderSlot"); + RNA_def_struct_ui_text(srna, "Render Slots", "Collection of the render slots"); + + prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "RenderSlot"); + RNA_def_property_pointer_funcs(prop, "rna_render_slots_active_get", "rna_render_slots_active_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); + RNA_def_property_ui_text(prop, "Active", "Active render slot of the image"); + RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); + + prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_render_slots_active_index_get", + "rna_render_slots_active_index_set", + NULL); + RNA_def_property_range(prop, 0, IMA_MAX_RENDER_SLOT); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Active Index", "Index of an active render slot of the image"); + RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); +} + static void rna_def_image(BlenderRNA *brna) { StructRNA *srna; @@ -668,10 +744,12 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Bindcode", "OpenGL bindcode"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); - prop = RNA_def_property(srna, "render_slot", PROP_INT, PROP_UNSIGNED); - RNA_def_property_range(prop, 0, IMA_MAX_RENDER_SLOT - 1); - RNA_def_property_ui_text(prop, "Render Slot", "The current render slot displayed, only for viewer type images"); - RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL); + prop = RNA_def_property(srna, "render_slots", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "RenderSlot"); + RNA_def_property_ui_text(prop, "Render Slots", "Render slots of the image"); + RNA_def_property_collection_funcs(prop, "rna_Image_render_slots_begin", "rna_iterator_array_next", + "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL); + RNA_def_property_srna(prop, "RenderSlots"); /* * Image.has_data and Image.depth are temporary, @@ -737,6 +815,8 @@ static void rna_def_image(BlenderRNA *brna) void RNA_def_image(BlenderRNA *brna) { + rna_def_render_slot(brna); + rna_def_render_slots(brna); rna_def_image(brna); rna_def_imageuser(brna); } |