[epiphany] Add additional zoom steps



commit 922986a8c181d510ef864937993cc76b32b1ccc7
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Wed Dec 19 13:15:25 2018 +0100

    Add additional zoom steps
    
    Change zoom steps to be more fine-grained and match with the other browsers.
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/492

 lib/ephy-zoom.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++----------
 lib/ephy-zoom.h |  4 ++--
 2 files changed, 50 insertions(+), 12 deletions(-)
---
diff --git a/lib/ephy-zoom.c b/lib/ephy-zoom.c
index 3d9013fcf..53fd4e507 100644
--- a/lib/ephy-zoom.c
+++ b/lib/ephy-zoom.c
@@ -21,20 +21,58 @@
 #include "config.h"
 #include "ephy-zoom.h"
 
+#define NUM_ZOOM_STEPS 14
+
+static float
+zoom_steps [NUM_ZOOM_STEPS] =
+{
+  0.30f,
+  0.50f,
+  0.67f,
+  0.80f,
+  0.90f,
+  1.00f,
+  1.10f,
+  1.20f,
+  1.33f,
+  1.50f,
+  1.70f,
+  2.00f,
+  2.40f,
+  3.00f
+};
+
 float
 ephy_zoom_get_changed_zoom_level (float level, int steps)
 {
-  float new_level = level;
-
-  if (steps == -1) {
-    new_level -= 0.25;
-    if (new_level < ZOOM_MINIMAL)
-      new_level = ZOOM_MINIMAL;
-  } else if (steps == 1) {
-    new_level += 0.25;
-    if (new_level > ZOOM_MAXIMAL)
-      new_level = ZOOM_MAXIMAL;
+  float new_level;
+  gint i;
+
+  for (i = 0; i < NUM_ZOOM_STEPS; i++) {
+    if (zoom_steps[i] == level)
+      break;
   }
 
+  if (i == NUM_ZOOM_STEPS) {
+    /* No exact step found, try to find the nearest value */
+    for (i = 0; i < NUM_ZOOM_STEPS - 1; i++) {
+      if (zoom_steps[i] > level && zoom_steps[i + 1] < level)
+        break;
+    }
+  }
+
+  if (i == NUM_ZOOM_STEPS) {
+    /* Still no match? Set it to default (1.0) */
+    i = 5;
+  }
+
+  if (steps == -1 && i > 0) {
+    new_level = zoom_steps[i - 1];
+  } else if (steps == 1 && i < NUM_ZOOM_STEPS - 1) {
+    new_level = zoom_steps[i + 1];
+  } else {
+    /* Ensure that we have a consistent value */
+    new_level = level;
+  }
   return new_level;
 }
diff --git a/lib/ephy-zoom.h b/lib/ephy-zoom.h
index 05bd18b79..7014c6e8f 100644
--- a/lib/ephy-zoom.h
+++ b/lib/ephy-zoom.h
@@ -27,8 +27,8 @@
 
 G_BEGIN_DECLS
 
-#define ZOOM_MINIMAL  (0.5)
-#define ZOOM_MAXIMAL  (2.5)
+#define ZOOM_MINIMAL  (0.30f)
+#define ZOOM_MAXIMAL  (3.00f)
 #define ZOOM_IN       (-1.0)
 #define ZOOM_OUT      (-2.0)
 


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