summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Kareh <[email protected]>2026-03-05 16:18:56 -0500
committerVictor Kareh <[email protected]>2026-03-06 14:40:25 -0500
commit1c45f048d906fa3923620fc0a75cd2b56f960eec (patch)
tree0d5ac706812d9acdb814ad7471f28b80a84fade8
parent2aff670c1b9d922b1f7d23d9fd3b30561466778a (diff)
downloadatril-1c45f048d906fa3923620fc0a75cd2b56f960eec.tar.bz2
atril-1c45f048d906fa3923620fc0a75cd2b56f960eec.tar.xz
libview: Allow zooming to the limits of the scale
If the current zoom level was within one zoom factor of the limit, it was not possible to scroll towards the limit. This made smooth scrolling near the limit awkward, as unless the scroll event had a large delta it was impossible to reach the zoom limit. Non-smooth scrolling was also affected, but it was just much more difficult to trigger. Fix this by allowing zooming while the current zoom level is within one zoom factor of the limit. Add a new ev_view_can_zoom() function to make zooming by a factor (as with smooth scrolling) more convenient. Backported from https://gitlab.gnome.org/GNOME/evince/-/commit/6d299b69
-rw-r--r--libview/ev-view.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 68ca0970..5301079d 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -229,6 +229,8 @@ static double zoom_for_size_automatic (GdkScreen *screen,
gdouble doc_height,
int target_width,
int target_height);
+static gboolean ev_view_can_zoom (EvView *view,
+ gdouble factor);
static void ev_view_zoom_for_size (EvView *view,
int width,
int height);
@@ -3819,8 +3821,7 @@ ev_view_scroll_event (GtkWidget *widget, GdkEventScroll *event)
gdouble delta = event->delta_x + event->delta_y;
gdouble factor = pow (delta < 0 ? ZOOM_IN_FACTOR : ZOOM_OUT_FACTOR, fabs (delta));
- if ((factor < 1.0 && ev_view_can_zoom_out (view)) ||
- (factor >= 1.0 && ev_view_can_zoom_in (view)))
+ if (ev_view_can_zoom (view, factor))
ev_view_zoom (view, factor);
}
break;
@@ -6472,8 +6473,7 @@ zoom_gesture_scale_changed_cb (GtkGestureZoom *gesture,
gtk_gesture_get_bounding_box_center (GTK_GESTURE (gesture), &view->zoom_center_x, &view->zoom_center_y);
- if ((factor < 1.0 && ev_view_can_zoom_out (view)) ||
- (factor >= 1.0 && ev_view_can_zoom_in (view)))
+ if (ev_view_can_zoom (view, factor))
ev_view_zoom (view, factor);
}
@@ -6906,8 +6906,8 @@ update_can_zoom (EvView *view)
min_scale = ev_document_model_get_min_scale (view->model);
max_scale = ev_document_model_get_max_scale (view->model);
- can_zoom_in = (view->scale * ZOOM_IN_FACTOR) <= max_scale;
- can_zoom_out = (view->scale * ZOOM_OUT_FACTOR) > min_scale;
+ can_zoom_in = view->scale <= max_scale;
+ can_zoom_out = view->scale > min_scale;
if (can_zoom_in != view->can_zoom_in) {
view->can_zoom_in = can_zoom_in;
@@ -7099,6 +7099,19 @@ ev_view_reload (EvView *view)
/*** Zoom and sizing mode ***/
+static gboolean
+ev_view_can_zoom (EvView *view, gdouble factor)
+{
+ if (factor == 1.0)
+ return TRUE;
+
+ else if (factor < 1.0) {
+ return ev_view_can_zoom_out (view);
+ } else {
+ return ev_view_can_zoom_in (view);
+ }
+}
+
gboolean
ev_view_can_zoom_in (EvView *view)
{