diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index 54f85cb120..412c142599 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -42,8 +42,6 @@ gimp_image_add_hguide (GimpImage *image, GimpGuide *guide; g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); - g_return_val_if_fail (position >= 0 && - position <= gimp_image_get_height (image), NULL); guide = gimp_guide_new (GIMP_ORIENTATION_HORIZONTAL, image->gimp->next_guide_id++); @@ -66,8 +64,6 @@ gimp_image_add_vguide (GimpImage *image, GimpGuide *guide; g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); - g_return_val_if_fail (position >= 0 && - position <= gimp_image_get_width (image), NULL); guide = gimp_guide_new (GIMP_ORIENTATION_VERTICAL, image->gimp->next_guide_id++); @@ -137,12 +133,6 @@ gimp_image_move_guide (GimpImage *image, { g_return_if_fail (GIMP_IS_IMAGE (image)); g_return_if_fail (GIMP_IS_GUIDE (guide)); - g_return_if_fail (position >= 0); - - if (gimp_guide_get_orientation (guide) == GIMP_ORIENTATION_HORIZONTAL) - g_return_if_fail (position <= gimp_image_get_height (image)); - else - g_return_if_fail (position <= gimp_image_get_width (image)); if (gimp_guide_is_custom (guide)) push_undo = FALSE; diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 604cb49d25..23b22a1d8c 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -2821,10 +2821,30 @@ gimp_image_get_xcf_version (GimpImage *image, if (g_list_length (gimp_image_get_selected_layers (image)) > 1) { ADD_REASON (g_strdup_printf (_("Multiple layer selection was " - "added in %s"), "GIMP 2.10.20")); + "added in %s"), "GIMP 3.0.0")); version = MAX (14, version); } + if ((list = gimp_image_get_guides (image))) + { + for (; list; list = g_list_next (list)) + { + gint32 position = gimp_guide_get_position (list->data); + + if (position < 0 || + (gimp_guide_get_orientation (list->data) == GIMP_ORIENTATION_HORIZONTAL && + position > gimp_image_get_height (image)) || + /* vertical guide. */ + position > gimp_image_get_width (image)) + { + ADD_REASON (g_strdup_printf (_("Off-canvas guides " + "added in %s"), "GIMP 3.0.0")); + version = MAX (15, version); + break; + } + } + } + #undef ADD_REASON switch (version) @@ -2854,6 +2874,11 @@ gimp_image_get_xcf_version (GimpImage *image, if (gimp_version) *gimp_version = 210; if (version_string) *version_string = "GIMP 2.10"; break; + case 14: + case 15: + if (gimp_version) *gimp_version = 300; + if (version_string) *version_string = "GIMP 3.0"; + break; } if (version_reason && reasons) diff --git a/app/tools/gimpguidetool.c b/app/tools/gimpguidetool.c index 55d5732155..5e1db2ee19 100644 --- a/app/tools/gimpguidetool.c +++ b/app/tools/gimpguidetool.c @@ -176,9 +176,7 @@ gimp_guide_tool_button_release (GimpTool *tool, n_non_custom_guides += ! guide->custom; - if (guide->position == GIMP_GUIDE_POSITION_UNDEFINED || - guide->position < 0 || - guide->position > max_position) + if (guide->position == GIMP_GUIDE_POSITION_UNDEFINED) { remove_guides = TRUE; } diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c index 462ae8ac1e..6bf0d505ef 100644 --- a/app/xcf/xcf-load.c +++ b/app/xcf/xcf-load.c @@ -889,8 +889,14 @@ xcf_load_image_props (XcfInfo *info, xcf_read_int32 (info, (guint32 *) &position, 1); xcf_read_int8 (info, (guint8 *) &orientation, 1); - /* skip -1 guides from old XCFs */ - if (position < 0) + /* Some very old XCF had -1 guides which have been + * skipped since 2003 (commit 909a28ced2). + * Then XCF up to version 14 only had positive guide + * positions. + * Since XCF 15 (GIMP 3.0), off-canvas guides became a + * thing. + */ + if (info->file_version < 15 && position < 0) continue; GIMP_LOG (XCF, "prop guide orientation=%d position=%d", @@ -899,11 +905,23 @@ xcf_load_image_props (XcfInfo *info, switch (orientation) { case XCF_ORIENTATION_HORIZONTAL: - gimp_image_add_hguide (image, position, FALSE); + if (info->file_version < 15 && position > gimp_image_get_height (image)) + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, + "Ignoring off-canvas horizontal guide (position %d) in XCF %d file", + position, info->file_version); + else + gimp_image_add_hguide (image, position, FALSE); break; case XCF_ORIENTATION_VERTICAL: - gimp_image_add_vguide (image, position, FALSE); + if (info->file_version < 15 && position > gimp_image_get_width (image)) + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, + "Ignoring off-canvas vertical guide (position %d) in XCF %d file", + position, info->file_version); + else + gimp_image_add_vguide (image, position, FALSE); break; default: diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index 6853573d5d..d079b0a549 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -82,7 +82,8 @@ static GimpXcfLoaderFunc * const xcf_loaders[] = xcf_load_image, /* version 11 */ xcf_load_image, /* version 12 */ xcf_load_image, /* version 13 */ - xcf_load_image /* version 14 */ + xcf_load_image, /* version 14 */ + xcf_load_image /* version 15 */ }; diff --git a/devel-docs/xcf.txt b/devel-docs/xcf.txt index 0a64c1a944..0692b9c17e 100644 --- a/devel-docs/xcf.txt +++ b/devel-docs/xcf.txt @@ -176,10 +176,14 @@ other than 8-bit gamma), zlib compression and 64-bit offsets for XCF files bigger than 4GB. Version 14: -Since GIMP 2.10.20, released on 2020-MM-DD. +Since GIMP 3.0.0, released on TODO. Allows multiple layers to have the property PROP_ACTIVE_LAYER, hence multiple layers selected at once. +Version 15: +Since GIMP 3.0.0, released on TODO. +PROP_GUIDES now allows off-canvas guide positions, i.e. negative +positions and over canvas-dimensions positions. 1. BASIC CONCEPTS ================= @@ -872,7 +876,9 @@ PROP_GUIDES (editing state) It appears if any guides have been defined. Some old XCF files define guides with negative coordinates; those - should be ignored by readers. + should be ignored by readers for XCF < 15. Since XCF 15, off-canvas + guides are possible, such as negative coordinates or bigger than the + canvas width/height. PROP_PATHS uint32 23 Type identification