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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-17 16:10:34 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-17 18:59:26 +0300
commit2a31e0c812c7dfa1645fc1c0692016fa1165b393 (patch)
tree82cb3213a081b6fffcc8b655c25176ad7d6ceb52 /source/blender/editors/space_image
parente8238e1123d9bab7210b922b4fb2d8f395bf70ef (diff)
Images: make it harder to accidentally undo image texture painting changes
Editing properties like generated X/Y size clears any changes to the image, and it's not obvious that this is destructive. Now if the image has been painted on or baked to, buttons to Save or Discard changes will appear and editing the properties will be disabled until doing one of these.
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r--source/blender/editors/space_image/image_buttons.c19
-rw-r--r--source/blender/editors/space_image/image_ops.c14
2 files changed, 31 insertions, 2 deletions
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index 39cb5824627..59896391cca 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -836,6 +836,7 @@ void uiTemplateImage(uiLayout *layout,
Image *ima;
ImageUser *iuser;
Scene *scene = CTX_data_scene(C);
+ SpaceImage *space_image = CTX_wm_space_image(C);
uiLayout *row, *split, *col;
uiBlock *block;
char str[MAX_IMAGE_INFO_LEN];
@@ -877,7 +878,7 @@ void uiTemplateImage(uiLayout *layout,
uiLayoutSetContextPointer(layout, "edit_image", &imaptr);
uiLayoutSetContextPointer(layout, "edit_image_user", userptr);
- if (!compact) {
+ if (!compact && (space_image == NULL || iuser != &space_image->iuser)) {
uiTemplateID(layout,
C,
ptr,
@@ -915,6 +916,18 @@ void uiTemplateImage(uiLayout *layout,
}
}
else {
+ /* Disable editing if image was modified, to avoid losing changes. */
+ const bool is_dirty = BKE_image_is_dirty(ima);
+ if (is_dirty) {
+ row = uiLayoutRow(layout, true);
+ uiItemO(row, IFACE_("Save"), ICON_NONE, "image.save");
+ uiItemO(row, IFACE_("Discard Changes"), ICON_NONE, "image.reload");
+ uiItemS(layout);
+ }
+
+ layout = uiLayoutColumn(layout, false);
+ uiLayoutSetEnabled(layout, !is_dirty);
+
uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE);
if (ima->source != IMA_SRC_GENERATED) {
@@ -943,10 +956,14 @@ void uiTemplateImage(uiLayout *layout,
}
}
+ uiItemS(layout);
+
col = uiLayoutColumn(layout, false);
uiTemplateColorspaceSettings(col, &imaptr, "colorspace_settings");
uiItemR(col, &imaptr, "use_view_as_render", 0, NULL, ICON_NONE);
+ uiItemS(layout);
+
if (ima->source != IMA_SRC_GENERATED) {
if (compact == 0) { /* background image view doesn't need these */
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 873eae07901..03e1d80e267 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -2064,6 +2064,17 @@ static int image_save_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
+static int image_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ if (space_image_file_exists_poll(C)) {
+ return image_save_exec(C, op);
+ }
+ else {
+ WM_operator_name_call(C, "IMAGE_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL);
+ return OPERATOR_CANCELLED;
+ }
+}
+
void IMAGE_OT_save(wmOperatorType *ot)
{
/* identifiers */
@@ -2073,7 +2084,8 @@ void IMAGE_OT_save(wmOperatorType *ot)
/* api callbacks */
ot->exec = image_save_exec;
- ot->poll = space_image_file_exists_poll;
+ ot->invoke = image_save_invoke;
+ ot->poll = image_save_as_poll;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;