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/image_buttons.c
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/image_buttons.c')
-rw-r--r--source/blender/editors/space_image/image_buttons.c19
1 files changed, 18 insertions, 1 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);