changeset 2474:f591509cb3d3

Fix #123: Limit image expansion in Fit To Window https://github.com/BestImageViewer/geeqie/issues/123 Additional option in Preferences/Image to limit the expansion of an image in Fit To Window mode. Stops small images being over-magnified.
author Colin Clark <colin.clark@cclark.uk>
date Wed, 03 May 2017 11:30:12 +0100
parents 0f3bfe48d9a7
children 53faa92f790f
files doc/docbook/GuideOptionsImage.xml src/image.c src/options.c src/options.h src/pixbuf-renderer.c src/pixbuf-renderer.h src/preferences.c src/rcfile.c
diffstat 8 files changed, 45 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/doc/docbook/GuideOptionsImage.xml	Tue May 02 09:54:59 2017 +0100
+++ b/doc/docbook/GuideOptionsImage.xml	Wed May 03 11:30:12 2017 +0100
@@ -79,7 +79,7 @@
           <para>
             Enable this to allow Geeqie to increase the image size for images that are smaller than the current view area when the zoom is set to
             <emphasis>Fit image to window</emphasis>
-            .
+            . The value in the adjoining spin box sets the maximum size permitted in percent i.e. 100% is full-size.
           </para>
         </listitem>
       </varlistentry>
--- a/src/image.c	Tue May 02 09:54:59 2017 +0100
+++ b/src/image.c	Wed May 03 11:30:12 2017 +0100
@@ -1743,6 +1743,7 @@
 					"window_limit_value", options->image.max_window_size,
 					"autofit_limit", options->image.limit_autofit_size,
 					"autofit_limit_value", options->image.max_autofit_size,
+					"enlargement_limit_value", options->image.max_enlargement_size,
 
 					NULL);
 
--- a/src/options.c	Tue May 02 09:54:59 2017 +0100
+++ b/src/options.c	Wed May 03 11:30:12 2017 +0100
@@ -93,6 +93,7 @@
 	options->image.limit_autofit_size = FALSE;
 	options->image.limit_window_size = TRUE;
 	options->image.max_autofit_size = 100;
+	options->image.max_enlargement_size = 900;
 	options->image.max_window_size = 90;
 	options->image.scroll_reset_method = SCROLL_RESET_NOCHANGE;
 	options->image.tile_cache_max = 10;
--- a/src/options.h	Tue May 02 09:54:59 2017 +0100
+++ b/src/options.h	Wed May 03 11:30:12 2017 +0100
@@ -74,6 +74,7 @@
 		gint max_window_size;
 		gboolean limit_autofit_size;
 		gint max_autofit_size;
+		gint max_enlargement_size;
 
 		gint tile_cache_max;	/* in megabytes */
 		gint image_cache_max;   /* in megabytes */
--- a/src/pixbuf-renderer.c	Tue May 02 09:54:59 2017 +0100
+++ b/src/pixbuf-renderer.c	Wed May 03 11:30:12 2017 +0100
@@ -105,7 +105,8 @@
 	PROP_WINDOW_LIMIT,
 	PROP_WINDOW_LIMIT_VALUE,
 	PROP_AUTOFIT_LIMIT,
-	PROP_AUTOFIT_LIMIT_VALUE
+	PROP_AUTOFIT_LIMIT_VALUE,
+	PROP_ENLARGEMENT_LIMIT_VALUE
 };
 
 typedef enum {
@@ -329,6 +330,16 @@
 							  100,
 							  G_PARAM_READABLE | G_PARAM_WRITABLE));
 
+	g_object_class_install_property(gobject_class,
+					PROP_ENLARGEMENT_LIMIT_VALUE,
+					g_param_spec_uint("enlargement_limit_value",
+							  "Size increase limit of image when autofitting",
+							  NULL,
+							  100,
+							  999,
+							  500,
+							  G_PARAM_READABLE | G_PARAM_WRITABLE));
+
 
 	signals[SIGNAL_ZOOM] =
 		g_signal_new("zoom",
@@ -530,6 +541,9 @@
 		case PROP_AUTOFIT_LIMIT_VALUE:
 			pr->autofit_limit_size = g_value_get_uint(value);
 			break;
+		case PROP_ENLARGEMENT_LIMIT_VALUE:
+			pr->enlargement_limit_size = g_value_get_uint(value);
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
 			break;
@@ -593,6 +607,9 @@
 		case PROP_AUTOFIT_LIMIT_VALUE:
 			g_value_set_uint(value, pr->autofit_limit_size);
 			break;
+		case PROP_ENLARGEMENT_LIMIT_VALUE:
+			g_value_set_uint(value, pr->enlargement_limit_size);
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
 			break;
@@ -1665,6 +1682,17 @@
 				scale = scale * factor;
 				}
 
+			if (pr->zoom_expand)
+				{
+				gdouble factor = (gdouble)pr->enlargement_limit_size / 100;
+				if (scale > factor)
+					{
+					w = w * factor / scale;
+					h = h * factor / scale;
+					scale = factor;
+					}
+				}
+
 			if (w < 1) w = 1;
 			if (h < 1) h = 1;
 			}
--- a/src/pixbuf-renderer.h	Tue May 02 09:54:59 2017 +0100
+++ b/src/pixbuf-renderer.h	Wed May 03 11:30:12 2017 +0100
@@ -158,6 +158,7 @@
 
 	gboolean autofit_limit;
 	gint autofit_limit_size;
+	gint enlargement_limit_size;
 
 	GdkColor color;
 
--- a/src/preferences.c	Tue May 02 09:54:59 2017 +0100
+++ b/src/preferences.c	Wed May 03 11:30:12 2017 +0100
@@ -236,6 +236,7 @@
 	options->image.max_window_size = c_options->image.max_window_size;
 	options->image.limit_autofit_size = c_options->image.limit_autofit_size;
 	options->image.max_autofit_size = c_options->image.max_autofit_size;
+	options->image.max_enlargement_size = c_options->image.max_enlargement_size;
 	options->image.use_clutter_renderer = c_options->image.use_clutter_renderer;
 	options->progressive_key_scrolling = c_options->progressive_key_scrolling;
 	options->keyboard_scroll_step = c_options->keyboard_scroll_step;
@@ -1478,6 +1479,7 @@
 	GtkWidget *group;
 	GtkWidget *button;
 	GtkWidget *ct_button;
+	GtkWidget *enlargement_button;
 	GtkWidget *table;
 	GtkWidget *spin;
 
@@ -1496,11 +1498,16 @@
 	pref_checkbox_new_int(group, _("Two pass rendering (apply HQ zoom and color correction in second pass)"),
 			      options->image.zoom_2pass, &c_options->image.zoom_2pass);
 
-	pref_checkbox_new_int(group, _("Allow enlargement of image for zoom to fit"),
+	hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
+	enlargement_button = pref_checkbox_new_int(hbox, _("Allow enlargement of image for zoom to fit (max. size in %)"),
 			      options->image.zoom_to_fit_allow_expand, &c_options->image.zoom_to_fit_allow_expand);
+	spin = pref_spin_new_int(hbox, NULL, NULL,
+				 100, 999, 1,
+				 options->image.max_enlargement_size, &c_options->image.max_enlargement_size);
+	pref_checkbox_link_sensitivity(enlargement_button, spin);
 
 	hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
-	ct_button = pref_checkbox_new_int(hbox, _("Limit image size when autofitting (%):"),
+	ct_button = pref_checkbox_new_int(hbox, _("Limit image size when autofitting (% of window):"),
 					  options->image.limit_autofit_size, &c_options->image.limit_autofit_size);
 	spin = pref_spin_new_int(hbox, NULL, NULL,
 				 10, 150, 1,
--- a/src/rcfile.c	Tue May 02 09:54:59 2017 +0100
+++ b/src/rcfile.c	Wed May 03 11:30:12 2017 +0100
@@ -358,6 +358,7 @@
 	WRITE_NL(); WRITE_INT(*options, image.max_window_size);
 	WRITE_NL(); WRITE_BOOL(*options, image.limit_autofit_size);
 	WRITE_NL(); WRITE_INT(*options, image.max_autofit_size);
+	WRITE_NL(); WRITE_INT(*options, image.max_enlargement_size);
 	WRITE_NL(); WRITE_UINT(*options, image.scroll_reset_method);
 	WRITE_NL(); WRITE_INT(*options, image.tile_cache_max);
 	WRITE_NL(); WRITE_INT(*options, image.image_cache_max);
@@ -632,6 +633,7 @@
 		if (READ_INT(*options, image.max_window_size)) continue;
 		if (READ_BOOL(*options, image.limit_autofit_size)) continue;
 		if (READ_INT(*options, image.max_autofit_size)) continue;
+		if (READ_INT(*options, image.max_enlargement_size)) continue;
 		if (READ_UINT_CLAMP(*options, image.scroll_reset_method, 0, PR_SCROLL_RESET_COUNT - 1)) continue;
 		if (READ_INT(*options, image.tile_cache_max)) continue;
 		if (READ_INT(*options, image.image_cache_max)) continue;