diff options
-rw-r--r-- | release/scripts/presets/keyconfig/maya.py | 19 | ||||
-rw-r--r-- | release/scripts/startup/bl_ui/space_image.py | 5 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_buttons.c | 36 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_image_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 88 |
6 files changed, 127 insertions, 30 deletions
diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index 436541d85f8..29573e40d70 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -1419,32 +1419,29 @@ kmi = km.keymap_items.new('object.mode_set', 'TAB', 'PRESS') kmi.properties.mode = 'EDIT' kmi.properties.toggle = True kmi = km.keymap_items.new('wm.context_set_int', 'ONE', 'PRESS') -kmi.properties.data_path = 'space_data.image.render_slot' +kmi.properties.data_path = 'space_data.image.render_slots.active_index' kmi.properties.value = 0 kmi = km.keymap_items.new('wm.context_set_int', 'TWO', 'PRESS') -kmi.properties.data_path = 'space_data.image.render_slot' +kmi.properties.data_path = 'space_data.image.render_slots.active_index' kmi.properties.value = 1 kmi = km.keymap_items.new('wm.context_set_int', 'THREE', 'PRESS') -kmi.properties.data_path = 'space_data.image.render_slot' +kmi.properties.data_path = 'space_data.image.render_slots.active_index' kmi.properties.value = 2 kmi = km.keymap_items.new('wm.context_set_int', 'FOUR', 'PRESS') -kmi.properties.data_path = 'space_data.image.render_slot' +kmi.properties.data_path = 'space_data.image.render_slots.active_index' kmi.properties.value = 3 kmi = km.keymap_items.new('wm.context_set_int', 'FIVE', 'PRESS') -kmi.properties.data_path = 'space_data.image.render_slot' +kmi.properties.data_path = 'space_data.image.render_slots.active_index' kmi.properties.value = 4 kmi = km.keymap_items.new('wm.context_set_int', 'SIX', 'PRESS') -kmi.properties.data_path = 'space_data.image.render_slot' +kmi.properties.data_path = 'space_data.image.render_slots.active_index' kmi.properties.value = 5 kmi = km.keymap_items.new('wm.context_set_int', 'SEVEN', 'PRESS') -kmi.properties.data_path = 'space_data.image.render_slot' +kmi.properties.data_path = 'space_data.image.render_slots.active_index' kmi.properties.value = 6 kmi = km.keymap_items.new('wm.context_set_int', 'EIGHT', 'PRESS') -kmi.properties.data_path = 'space_data.image.render_slot' +kmi.properties.data_path = 'space_data.image.render_slots.active_index' kmi.properties.value = 7 -kmi = km.keymap_items.new('wm.context_set_int', 'NINE', 'PRESS') -kmi.properties.data_path = 'space_data.image.render_slot' -kmi.properties.value = 8 # Map Node Editor km = kc.keymaps.new('Node Editor', space_type='NODE_EDITOR', region_type='WINDOW', modal=False) diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 927e517ef21..0b97a2dda28 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -661,6 +661,11 @@ class IMAGE_PT_view_properties(Panel): sub.active = uvedit.show_stretch sub.row().prop(uvedit, "draw_stretch_type", expand=True) + if ima: + layout.separator() + render_slot = ima.render_slots.active + layout.prop(render_slot, "name", text="Slot Name") + class IMAGE_PT_tools_transform_uvs(Panel, UVToolsPanel): bl_label = "Transform" diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index ed6e6ba1e1b..ffdb8ecfce6 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -284,10 +284,10 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PRE /* ********************* callbacks for standard image buttons *************** */ -static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *render_slot_p) +static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void *image_p) { uiBlock *block = uiLayoutGetBlock(layout); - short *render_slot = render_slot_p; + Image *image = image_p; int slot; uiDefBut(block, LABEL, 0, IFACE_("Slot"), @@ -296,10 +296,15 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void * slot = IMA_MAX_RENDER_SLOT; while (slot--) { - char str[32]; - BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1); + char str[64]; + if (image->render_slots[slot].name[0] != '\0') { + BLI_strncpy(str, image->render_slots[slot].name, sizeof(str)); + } + else { + BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot + 1); + } uiDefButS(block, BUTM, B_NOP, str, 0, 0, - UI_UNIT_X * 5, UI_UNIT_X, render_slot, (float) slot, 0.0, 0, -1, ""); + UI_UNIT_X * 5, UI_UNIT_X, &image->render_slot, (float) slot, 0.0, 0, -1, ""); } } @@ -492,7 +497,7 @@ static void image_user_change(bContext *C, void *iuser_v, void *unused) } #endif -static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, int w, short *render_slot) +static void uiblock_layer_pass_buttons(uiLayout *layout, Image *image, RenderResult *rr, ImageUser *iuser, int w, short *render_slot) { static void *rnd_pt[3]; /* XXX, workaround */ uiBlock *block = uiLayoutGetBlock(layout); @@ -516,8 +521,13 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image /* menu buts */ if (render_slot) { char str[64]; - BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1); - but = uiDefMenuBut(block, ui_imageuser_slot_menu, render_slot, str, 0, 0, wmenu1, UI_UNIT_Y, TIP_("Select Slot")); + if (image->render_slots[*render_slot].name[0] != '\0') { + BLI_strncpy(str, image->render_slots[*render_slot].name, sizeof(str)); + } + else { + BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1); + } + but = uiDefMenuBut(block, ui_imageuser_slot_menu, image, str, 0, 0, wmenu1, UI_UNIT_Y, TIP_("Select Slot")); uiButSetFunc(but, image_multi_cb, rr, iuser); uiButSetMenuFromPulldown(but); } @@ -547,7 +557,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image } } -static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, ImageUser *iuser, short *render_slot) +static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, Image *image, RenderResult *rr, ImageUser *iuser, short *render_slot) { uiBlock *block = uiLayoutGetBlock(layout); uiLayout *row; @@ -569,7 +579,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, but = uiDefIconBut(block, BUT, 0, ICON_TRIA_RIGHT, 0, 0, 0.90f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Next Layer")); uiButSetFunc(but, image_multi_inclay_cb, rr, iuser); - uiblock_layer_pass_buttons(row, rr, iuser, 230 * dpi_fac, render_slot); + uiblock_layer_pass_buttons(row, image, rr, iuser, 230 * dpi_fac, render_slot); /* decrease, increase arrows */ but = uiDefIconBut(block, BUT, 0, ICON_TRIA_LEFT, 0, 0, 0.85f * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Previous Pass")); @@ -691,7 +701,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ rr = BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_arrow_buttons(layout, rr, iuser, &ima->render_slot); + uiblock_layer_pass_arrow_buttons(layout, ima, rr, iuser, &ima->render_slot); BKE_image_release_renderresult(scene, ima); } } @@ -724,7 +734,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char /* multilayer? */ if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) { - uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); + uiblock_layer_pass_arrow_buttons(layout, ima, ima->rr, iuser, NULL); } else if (ima->source != IMA_SRC_GENERATED) { if (compact == 0) { @@ -937,7 +947,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser /* use BKE_image_acquire_renderresult so we get the correct slot in the menu */ rr = BKE_image_acquire_renderresult(scene, ima); - uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type == IMA_TYPE_R_RESULT) ? &ima->render_slot : NULL); + uiblock_layer_pass_buttons(layout, ima, rr, iuser, 160 * dpi_fac, (ima->type == IMA_TYPE_R_RESULT) ? &ima->render_slot : NULL); BKE_image_release_renderresult(scene, ima); } } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 9cb82d8ca9d..9cfd2e645f9 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -327,9 +327,9 @@ static void image_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "toggle", true); /* fast switch to render slots */ - for (i = 0; i < MAX2(IMA_MAX_RENDER_SLOT, 9); i++) { + for (i = 0; i < MIN2(IMA_MAX_RENDER_SLOT, 9); i++) { kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", ONEKEY + i, KM_PRESS, 0, 0); - RNA_string_set(kmi->ptr, "data_path", "space_data.image.render_slot"); + RNA_string_set(kmi->ptr, "data_path", "space_data.image.render_slots.active_index"); RNA_int_set(kmi->ptr, "value", i); } diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index b66772f0bb9..fcb894c9ebf 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -64,6 +64,10 @@ typedef struct ImageUser { } ImageUser; +typedef struct RenderSlot { + char name[64]; /* 64 = MAX_NAME */ +} RenderSlot; + /* iuser->flag */ #define IMA_ANIM_ALWAYS 1 #define IMA_ANIM_REFRESHED 2 @@ -119,6 +123,7 @@ typedef struct Image { char alpha_mode; char pad[7]; + RenderSlot render_slots[8]; /* 8 = IMA_MAX_RENDER_SLOT */ } Image; 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); } |