[Bf-blender-cvs] [f388b31ad19] temp-udim-images: Add UI option for specifying the tile name
Lukas Stockner
noreply at git.blender.org
Tue Jun 12 21:47:15 CEST 2018
Commit: f388b31ad19f0e266f3965f5a69356181b5e0fd3
Author: Lukas Stockner
Date: Tue Jun 12 21:43:23 2018 +0200
Branches: temp-udim-images
https://developer.blender.org/rBf388b31ad19f0e266f3965f5a69356181b5e0fd3
Add UI option for specifying the tile name
This UI is just for development purposes, it's not exactly great.
===================================================================
M release/scripts/startup/bl_ui/space_image.py
M source/blender/makesrna/intern/rna_image.c
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py
index bc1883799f8..e0a55326aab 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -750,6 +750,10 @@ class IMAGE_PT_tile_properties(Panel):
row.operator("image.add_tile")
row.operator("image.remove_tile")
+ layout.prop(sima, "current_tile")
+ tile = ima.tiles[sima.current_tile]
+ layout.prop(tile, "label")
+
class IMAGE_PT_tools_transform_uvs(Panel, UVToolsPanel):
bl_label = "Transform"
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 252b26d2883..ee16087e766 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -494,6 +494,34 @@ static void rna_render_slots_active_index_set(PointerRNA *ptr, int value)
CLAMP(image->render_slot, 0, IMA_MAX_RENDER_SLOT - 1);
}
+static void rna_Image_tiles_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ Image *image = (Image *)ptr->id.data;
+ rna_iterator_array_begin(iter, (void *)image->tiles, sizeof(ImageTile), image->num_tiles, 0, NULL);
+}
+
+static ImageTile *rna_ImageTile_new(Image *image, const char *label)
+{
+ ImageTile *tile = BKE_image_add_tile(image, label);
+
+ WM_main_add_notifier(NC_IMAGE | ND_DRAW, NULL);
+
+ return tile;
+}
+
+static void rna_ImageTile_remove_last(Image *image)
+{
+ BKE_image_remove_tile(image);
+ WM_main_add_notifier(NC_IMAGE | ND_DRAW, NULL);
+}
+
+static int rna_ImageTile_index_get(PointerRNA *ptr)
+{
+ Image *image = (Image *)ptr->id.data;
+ ImageTile *tile = (ImageTile *)ptr->data;
+ return CLAMPIS(tile - image->tiles, 0, image->num_tiles);
+}
+
#else
static void rna_def_imageuser(BlenderRNA *brna)
@@ -632,6 +660,45 @@ static void rna_def_render_slots(BlenderRNA *brna)
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
}
+static void rna_def_image_tile(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+ srna = RNA_def_struct(brna, "ImageTile", NULL);
+ RNA_def_struct_ui_text(srna, "Image Tile", "Properties of the image tile");
+
+ prop = RNA_def_property(srna, "label", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "label");
+ RNA_def_property_ui_text(prop, "Label", "Tile label");
+ RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
+
+ prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
+ RNA_def_property_int_funcs(prop, "rna_ImageTile_index_get", NULL, NULL);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Index", "Tile index");
+}
+
+static void rna_def_image_tiles(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "ImageTiles");
+ srna = RNA_def_struct(brna, "ImageTiles", NULL);
+ RNA_def_struct_sdna(srna, "Image");
+ RNA_def_struct_ui_text(srna, "Image Tiles", "Collection of the image tiles");
+
+ func = RNA_def_function(srna, "new", "rna_ImageTile_new");
+ RNA_def_function_ui_description(func, "Add a tile to the image");
+ parm = RNA_def_string(func, "label", NULL, 0, "", "Optional label for the tile");
+ parm = RNA_def_pointer(func, "result", "ImageTile", "", "Newly created image tile");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "remove_last", "rna_ImageTile_remove_last");
+ RNA_def_function_ui_description(func, "Remove the last image tile");
+}
+
static void rna_def_image(BlenderRNA *brna)
{
StructRNA *srna;
@@ -810,6 +877,13 @@ static void rna_def_image(BlenderRNA *brna)
"rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
RNA_def_property_srna(prop, "RenderSlots");
+ prop = RNA_def_property(srna, "tiles", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ImageTile");
+ RNA_def_property_ui_text(prop, "Image Tiles", "Tiles of the image");
+ RNA_def_property_collection_funcs(prop, "rna_Image_tiles_begin", "rna_iterator_array_next",
+ "rna_iterator_array_end", "rna_iterator_array_get", NULL, NULL, NULL, NULL);
+ rna_def_image_tiles(brna, prop);
+
/*
* Image.has_data and Image.depth are temporary,
* Update import_obj.py when they are replaced (Arystan)
@@ -897,6 +971,7 @@ void RNA_def_image(BlenderRNA *brna)
{
rna_def_render_slot(brna);
rna_def_render_slots(brna);
+ rna_def_image_tile(brna);
rna_def_image(brna);
rna_def_imageuser(brna);
rna_def_image_packed_files(brna);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index c0a51e60c72..fb82efa298c 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1075,6 +1075,19 @@ static const EnumPropertyItem *rna_SpaceImageEditor_pivot_itemf(
return pivot_items;
}
+static void rna_SpaceImageEditor_current_tile_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax)
+{
+ SpaceImage *sima = (SpaceImage *)ptr->data;
+
+ *min = 0;
+ if (sima->image && sima->image->source == IMA_SRC_TILED) {
+ *max = sima->image->num_tiles - 1;
+ }
+ else {
+ *max = 0;
+ }
+}
+
/* Space Text Editor */
static void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, int value)
@@ -3130,6 +3143,12 @@ static void rna_def_space_image(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, "rna_SpaceImageEditor_zoom_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Zoom", "Zoom factor");
+ prop = RNA_def_property(srna, "current_tile", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "curtile");
+ RNA_def_property_int_funcs(prop, NULL, NULL, "rna_SpaceImageEditor_current_tile_range");
+ RNA_def_property_ui_text(prop, "Current Tile", "The currently selected tile");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
+
/* image draw */
prop = RNA_def_property(srna, "show_repeat", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_TILE);
More information about the Bf-blender-cvs
mailing list