[eog] EogScrollView: Make sure zoom changes at least 1% when mouse zooming



commit eb5a8fc7786607acda93061f3d9d5e52e74e374e
Author: Felix Riemann <friemann gnome org>
Date:   Sat Oct 12 18:33:09 2019 +0200

    EogScrollView: Make sure zoom changes at least 1% when mouse zooming
    
    Otherwise the change is not visible in the UI elements. It also
    makes zooming on lower zoom levels quite tedious as it needs
    lots of mouse wheel revolutions to get somewhere.
    
    Part of #81.

 src/eog-scroll-view.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/eog-scroll-view.c b/src/eog-scroll-view.c
index 454b904e..caf3001c 100644
--- a/src/eog-scroll-view.c
+++ b/src/eog-scroll-view.c
@@ -1072,6 +1072,7 @@ eog_scroll_view_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer
        EogScrollView *view;
        EogScrollViewPrivate *priv;
        double zoom_factor;
+       double min_zoom_factor;
        int xofs, yofs;
 
        view = EOG_SCROLL_VIEW (data);
@@ -1082,27 +1083,33 @@ eog_scroll_view_scroll_event (GtkWidget *widget, GdkEventScroll *event, gpointer
        xofs = gtk_adjustment_get_page_increment (priv->hadj) / 2;
        yofs = gtk_adjustment_get_page_increment (priv->vadj) / 2;
 
+       /* Make sure the user visible zoom factor changes */
+       min_zoom_factor = (priv->zoom + 0.01L) / priv->zoom;
+
        switch (event->direction) {
        case GDK_SCROLL_UP:
-               zoom_factor = priv->zoom_multiplier;
+               zoom_factor = fmax(priv->zoom_multiplier, min_zoom_factor);
+
                xofs = 0;
                yofs = -yofs;
                break;
 
        case GDK_SCROLL_LEFT:
-               zoom_factor = 1.0 / priv->zoom_multiplier;
+               zoom_factor = 1.0 / fmax(priv->zoom_multiplier,
+                                        min_zoom_factor);
                xofs = -xofs;
                yofs = 0;
                break;
 
        case GDK_SCROLL_DOWN:
-               zoom_factor = 1.0 / priv->zoom_multiplier;
+               zoom_factor = 1.0 / fmax(priv->zoom_multiplier,
+                                        min_zoom_factor);
                xofs = 0;
                yofs = yofs;
                break;
 
        case GDK_SCROLL_RIGHT:
-               zoom_factor = priv->zoom_multiplier;
+               zoom_factor = fmax(priv->zoom_multiplier, min_zoom_factor);
                xofs = xofs;
                yofs = 0;
                break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]