Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2019-12-30 21:14:56 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2019-12-30 21:20:54 +0300
commit56ef761381ecdac6c1c379044ccf8b2fb296a9bd (patch)
treef79b19199c1ff83b0bdd696c77bd6ed3b96b4d31 /source/blender/editors/space_image
parenta38840a9b82e037f645b3340aef761abdc4f4f65 (diff)
Image Editor: Initialize Add Tile options from current tile
Previously, non-default alpha or float settings had be set manually. With this change, the Add Tile and Fill Tile operators initialize width, height, alpha and float from the currently selected tile if it has a vaild ImBuf, otherwise from the first tile.
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r--source/blender/editors/space_image/image_ops.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 586d7995ed8..061ed978acd 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -4279,6 +4279,33 @@ static void draw_fill_tile(PointerRNA *ptr, uiLayout *layout)
uiItemR(col[1], ptr, "float", 0, NULL, ICON_NONE);
}
+static void initialize_fill_tile(PointerRNA *ptr, Image *ima, ImageTile *tile)
+{
+ ImageUser iuser;
+ BKE_imageuser_default(&iuser);
+ if (tile != NULL) {
+ iuser.tile = tile->tile_number;
+ }
+
+ /* Acquire ibuf to get the default values.
+ * If the specified tile has no ibuf, try acquiring the main tile instead
+ * (unless the specified tile already was the main tile).*/
+ ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
+ if (ibuf == NULL && (tile != NULL) && (tile->tile_number != 1001)) {
+ ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
+ }
+
+ if (ibuf != NULL) {
+ /* Initialize properties from reference tile. */
+ RNA_int_set(ptr, "width", ibuf->x);
+ RNA_int_set(ptr, "height", ibuf->y);
+ RNA_boolean_set(ptr, "float", ibuf->rect_float != NULL);
+ RNA_boolean_set(ptr, "alpha", ibuf->planes > 24);
+
+ BKE_image_release_ibuf(ima, ibuf, NULL);
+ }
+}
+
static void def_fill_tile(StructOrFunctionRNA *srna)
{
PropertyRNA *prop;
@@ -4358,6 +4385,9 @@ static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev
}
}
+ ImageTile *tile = BLI_findlink(&ima->tiles, ima->active_tile_index);
+ initialize_fill_tile(op->ptr, ima, tile);
+
RNA_int_set(op->ptr, "number", next_number);
RNA_int_set(op->ptr, "count", 1);
RNA_string_set(op->ptr, "label", "");
@@ -4487,17 +4517,7 @@ static int tile_fill_exec(bContext *C, wmOperator *op)
static int tile_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
- Image *ima = CTX_data_edit_image(C);
-
- /* Acquire first tile to get the defaults. */
- ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
- if (ibuf != NULL) {
- RNA_int_set(op->ptr, "width", ibuf->x);
- RNA_int_set(op->ptr, "height", ibuf->y);
- RNA_boolean_set(op->ptr, "float", ibuf->rect_float != NULL);
- RNA_boolean_set(op->ptr, "alpha", ibuf->planes > 24);
- BKE_image_release_ibuf(ima, ibuf, NULL);
- }
+ initialize_fill_tile(op->ptr, CTX_data_edit_image(C), NULL);
return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, 5 * UI_UNIT_Y);
}