[Bf-blender-cvs] [e0cd5b980fc] master: Image Editor: Add option to create multiple tiles at once

Lukas Stockner noreply at git.blender.org
Wed Dec 18 00:54:01 CET 2019


Commit: e0cd5b980fc5042241d7bd318e97cbc5156eb076
Author: Lukas Stockner
Date:   Wed Dec 18 00:52:06 2019 +0100
Branches: master
https://developer.blender.org/rBe0cd5b980fc5042241d7bd318e97cbc5156eb076

Image Editor: Add option to create multiple tiles at once

Any existing tiles will be skipped.

===================================================================

M	source/blender/editors/space_image/image_ops.c

===================================================================

diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 936b8d2eec5..eb9181f96fa 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -4288,25 +4288,32 @@ static int tile_add_exec(bContext *C, wmOperator *op)
 {
   Image *ima = CTX_data_edit_image(C);
 
-  int tile_number = RNA_int_get(op->ptr, "number");
-
+  int start_tile = RNA_int_get(op->ptr, "number");
+  int end_tile = min_ii(start_tile + RNA_int_get(op->ptr, "count"), IMA_UDIM_MAX);
+  bool fill_tile = RNA_boolean_get(op->ptr, "fill");
   char *label = RNA_string_get_alloc(op->ptr, "label", NULL, 0);
 
-  ImageTile *tile = BKE_image_add_tile(ima, tile_number, label);
-  MEM_freeN(label);
+  bool created_tile = false;
+  for (int tile_number = start_tile; tile_number < end_tile; tile_number++) {
+    ImageTile *tile = BKE_image_add_tile(ima, tile_number, label);
 
-  if (tile == NULL) {
-    return OPERATOR_CANCELLED;
-  }
+    if (tile != NULL) {
+      ima->active_tile_index = BLI_findindex(&ima->tiles, tile);
+
+      if (fill_tile) {
+        do_fill_tile(op->ptr, ima, tile);
+      }
 
-  ima->active_tile_index = BLI_findindex(&ima->tiles, tile);
+      created_tile = true;
+    }
+  }
+  MEM_freeN(label);
 
-  if (RNA_boolean_get(op->ptr, "fill")) {
-    do_fill_tile(op->ptr, ima, tile);
+  if (!created_tile) {
+    return OPERATOR_CANCELLED;
   }
 
   WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
-
   return OPERATOR_FINISHED;
 }
 
@@ -4325,6 +4332,7 @@ static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
   }
 
   RNA_int_set(op->ptr, "number", next_number);
+  RNA_int_set(op->ptr, "count", 1);
   RNA_string_set(op->ptr, "label", "");
 
   return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 5 * UI_UNIT_Y);
@@ -4345,6 +4353,9 @@ static void tile_add_draw(bContext *UNUSED(C), wmOperator *op)
   uiItemL(col[0], IFACE_("Number"), ICON_NONE);
   uiItemR(col[1], &ptr, "number", 0, "", ICON_NONE);
 
+  uiItemL(col[0], IFACE_("Count"), ICON_NONE);
+  uiItemR(col[1], &ptr, "count", 0, "", ICON_NONE);
+
   uiItemL(col[0], IFACE_("Label"), ICON_NONE);
   uiItemR(col[1], &ptr, "label", 0, "", ICON_NONE);
 
@@ -4373,6 +4384,7 @@ void IMAGE_OT_tile_add(wmOperatorType *ot)
 
   RNA_def_int(
       ot->srna, "number", 1002, 1001, INT_MAX, "Number", "UDIM number of the tile", 1001, 1099);
+  RNA_def_int(ot->srna, "count", 1, 1, INT_MAX, "Count", "How many tiles to add", 1, 1000);
   RNA_def_string(ot->srna, "label", NULL, 0, "Label", "Optional tile label");
   RNA_def_boolean(ot->srna, "fill", true, "Fill", "Fill new tile with a generated image");
   def_fill_tile(ot->srna);



More information about the Bf-blender-cvs mailing list