[evince] libview: Allow zooming to the limits of the scale
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] libview: Allow zooming to the limits of the scale
- Date: Thu, 5 Oct 2017 17:50:17 +0000 (UTC)
commit 6d299b69e8ee9bd84b3bc51dc7a11af010119194
Author: David King <amigadave amigadave com>
Date: Tue Oct 3 13:57:32 2017 -0300
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.
https://bugzilla.gnome.org/show_bug.cgi?id=788480
libview/ev-view.c | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index ae49674..bb63b50 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -250,6 +250,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 (EvView *view,
gdouble factor);
static void ev_view_zoom_for_size (EvView *view,
@@ -4153,8 +4155,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;
@@ -8090,8 +8091,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;
@@ -8291,6 +8292,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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]