Addl fix #521: zoom increment is not multiplicative
[geeqie.git] / src / pixbuf-renderer.c
index 4693943..54a943f 100644 (file)
@@ -149,6 +149,16 @@ static void pr_stereo_temp_disable(PixbufRenderer *pr, gboolean disable);
  *-------------------------------------------------------------------
  */
 
+static void pixbuf_renderer_class_init_wrapper(void *g_class, void *class_data)
+{
+       pixbuf_renderer_class_init(g_class);
+}
+
+static void pixbuf_renderer_init_wrapper(PixbufRenderer *pr, void *class_data)
+{
+       pixbuf_renderer_init(pr);
+}
+
 GType pixbuf_renderer_get_type(void)
 {
        static GType pixbuf_renderer_type = 0;
@@ -160,12 +170,12 @@ GType pixbuf_renderer_get_type(void)
                        sizeof(PixbufRendererClass), /* class_size */
                        NULL,           /* base_init */
                        NULL,           /* base_finalize */
-                       (GClassInitFunc)pixbuf_renderer_class_init,
+                       (GClassInitFunc)pixbuf_renderer_class_init_wrapper,
                        NULL,           /* class_finalize */
                        NULL,           /* class_data */
                        sizeof(PixbufRenderer), /* instance_size */
                        0,              /* n_preallocs */
-                       (GInstanceInitFunc)pixbuf_renderer_init, /* instance_init */
+                       (GInstanceInitFunc)pixbuf_renderer_init_wrapper, /* instance_init */
                        NULL,           /* value_table */
                        };
 
@@ -213,7 +223,7 @@ static void pixbuf_renderer_class_init(PixbufRendererClass *class)
                                                          "Zoom quality",
                                                          NULL,
                                                          GDK_INTERP_NEAREST,
-                                                         GDK_INTERP_HYPER,
+                                                         GDK_INTERP_BILINEAR,
                                                          GDK_INTERP_BILINEAR,
                                                          G_PARAM_READABLE | G_PARAM_WRITABLE));
 
@@ -269,7 +279,7 @@ static void pixbuf_renderer_class_init(PixbufRendererClass *class)
        g_object_class_install_property(gobject_class,
                                        PROP_CACHE_SIZE_DISPLAY,
                                        g_param_spec_uint("cache_display",
-                                                         "Display cache size MB",
+                                                         "Display cache size MiB",
                                                          NULL,
                                                          0,
                                                          128,
@@ -1249,40 +1259,68 @@ static void pr_zoom_adjust_real(PixbufRenderer *pr, gdouble increment,
                        }
                }
 
-       if (increment < 0.0)
+       if (options->image.zoom_style == ZOOM_GEOMETRIC)
                {
-               if (zoom >= 1.0)
+               if (increment < 0.0)
                        {
-                       if (zoom / -(increment - 1.0) < 1.0)
+                       if (zoom >= 1.0)
                                {
-                               zoom = 1.0 / (zoom / (increment - 1.0));
+                               if (zoom / -(increment - 1.0) < 1.0)
+                                       {
+                                       zoom = 1.0 / (zoom / (increment - 1.0));
+                                       }
+                               else
+                                       {
+                                       zoom = zoom / -(increment - 1.0) ;
+                                       }
                                }
                        else
                                {
-                               zoom = zoom / -(increment - 1.0) ;
+                               zoom = zoom * -(increment - 1.0);
                                }
                        }
                else
                        {
-                       zoom = zoom * -(increment - 1.0);
+                       if (zoom <= -1.0 )
+                               {
+                               if (zoom / (increment + 1.0) > -1.0)
+                                       {
+                                       zoom = -(1.0 / (zoom / (increment + 1.0)));
+                                       }
+                               else
+                                       {
+                                       zoom = zoom / (increment + 1.0) ;
+                                       }
+                               }
+                       else
+                               {
+                               zoom = zoom * (increment + 1.0);
+                               }
                        }
                }
        else
                {
-               if (zoom <= -1.0 )
+               if (increment < 0.0)
                        {
-                       if (zoom / (increment + 1.0) > -1.0)
+                       if (zoom >= 1.0 && zoom + increment < 1.0)
                                {
-                               zoom = -(1.0 / (zoom / (increment + 1.0)));
+                               zoom = zoom + increment - 2.0;
                                }
                        else
                                {
-                               zoom = zoom / (increment + 1.0) ;
+                               zoom = zoom + increment;
                                }
                        }
                else
                        {
-                       zoom = zoom * (increment + 1.0);
+                       if (zoom <= -1.0 && zoom + increment > -1.0)
+                               {
+                               zoom = zoom + increment + 2.0;
+                               }
+                       else
+                               {
+                               zoom = zoom + increment;
+                               }
                        }
                }
 
@@ -1762,10 +1800,10 @@ static void pr_zoom_sync(PixbufRenderer *pr, gdouble zoom,
                }
 
        if (force) clamp_flags |= PR_ZOOM_INVALIDATE;
-       (void) pr_parent_window_resize(pr, pr->width, pr->height);
        if (!pr_zoom_clamp(pr, zoom, clamp_flags)) return;
 
        (void) pr_size_clamp(pr);
+       (void) pr_parent_window_resize(pr, pr->width, pr->height);
 
        if (force && new)
                {
@@ -2976,7 +3014,7 @@ gboolean pixbuf_renderer_get_virtual_rect(PixbufRenderer *pr, GdkRectangle *rect
 void pixbuf_renderer_set_size_early(PixbufRenderer *pr, guint width, guint height)
 {
 #if 0
-       /* FIXME: this function does not consider the image orientation,
+       /** @FIXME this function does not consider the image orientation,
        so it probably only breaks something */
        gdouble zoom;
        gint w, h;