Merge lp:~bratsche/oif/smooth-zooming into lp:~oif-team/oif/evince-gestures-trunk

Proposed by Cody Russell on 2010-11-17
Status: Merged
Merged at revision: 4205
Proposed branch: lp:~bratsche/oif/smooth-zooming
Merge into: lp:~oif-team/oif/evince-gestures-trunk
Diff against target: 107 lines (+36/-18)
3 files modified
libview/ev-view.c (+20/-8)
libview/ev-view.h (+2/-0)
shell/ev-window.c (+14/-10)
To merge this branch: bzr merge lp:~bratsche/oif/smooth-zooming
Reviewer Review Type Date Requested Status
Mohamed IKBEL Boulabiar (community) Approve on 2010-11-22
Duncan McGreggor (community) 2010-11-17 Approve on 2010-11-22
Review via email: mp+41107@code.launchpad.net

Description of the change

Add smooth zooming.

To post a comment you must log in.
Duncan McGreggor (oubiwann) wrote :

This looks great, Cody. Well done! Smooth zooming is total ROCK!

Let's get a code review done on this branch and get it merged :-)

review: Approve
Mohamed IKBEL Boulabiar (boulabiar) wrote :

Works fine, and keeps moving between the predefined Evince zooming levels, so maintains a good compatibility with the standard Evince.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libview/ev-view.c'
2--- libview/ev-view.c 2010-09-15 15:05:47 +0000
3+++ libview/ev-view.c 2010-11-17 22:07:11 +0000
4@@ -5297,27 +5297,39 @@
5 }
6
7 void
8+ev_view_zoom_in_smooth (EvView *view, float factor)
9+{
10+ gdouble scale;
11+
12+ g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
13+
14+ view->pending_scroll = SCROLL_TO_CENTER;
15+ scale = ev_document_model_get_scale (view->model) * factor;
16+ ev_document_model_set_scale (view->model, scale);
17+}
18+
19+void
20 ev_view_zoom_in (EvView *view)
21 {
22+ ev_view_zoom_in_smooth (view, ZOOM_IN_FACTOR);
23+}
24+
25+void
26+ev_view_zoom_out_smooth (EvView *view, float factor)
27+{
28 gdouble scale;
29
30 g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
31
32 view->pending_scroll = SCROLL_TO_CENTER;
33- scale = ev_document_model_get_scale (view->model) * ZOOM_IN_FACTOR;
34+ scale = ev_document_model_get_scale (view->model) * factor;
35 ev_document_model_set_scale (view->model, scale);
36 }
37
38 void
39 ev_view_zoom_out (EvView *view)
40 {
41- gdouble scale;
42-
43- g_return_if_fail (view->sizing_mode == EV_SIZING_FREE);
44-
45- view->pending_scroll = SCROLL_TO_CENTER;
46- scale = ev_document_model_get_scale (view->model) * ZOOM_OUT_FACTOR;
47- ev_document_model_set_scale (view->model, scale);
48+ ev_view_zoom_out_smooth (view, ZOOM_OUT_FACTOR);
49 }
50
51 static double
52
53=== modified file 'libview/ev-view.h'
54--- libview/ev-view.h 2010-07-20 15:07:40 +0000
55+++ libview/ev-view.h 2010-11-17 22:07:11 +0000
56@@ -65,8 +65,10 @@
57 /* Page size */
58 gboolean ev_view_can_zoom_in (EvView *view);
59 void ev_view_zoom_in (EvView *view);
60+void ev_view_zoom_in_smooth (EvView *view, float factor);
61 gboolean ev_view_can_zoom_out (EvView *view);
62 void ev_view_zoom_out (EvView *view);
63+void ev_view_zoom_out_smooth (EvView *view, float factor);
64
65 /* Find */
66 void ev_view_find_next (EvView *view);
67
68=== modified file 'shell/ev-window.c'
69--- shell/ev-window.c 2010-10-12 18:00:39 +0000
70+++ shell/ev-window.c 2010-11-17 22:07:11 +0000
71@@ -5448,22 +5448,26 @@
72 ev_pinch_gesture_update (GtkWindow *window,
73 IdoGestureEvent *event)
74 {
75+ IdoEventGesturePinch *pinch = (IdoEventGesturePinch *)event;
76+ EvWindowPrivate *priv = EV_WINDOW (window)->priv;
77+ gdouble increment = pinch->radius_delta * 0.01;
78+
79+ if (increment < 0.0) increment = -increment;
80+ increment += 1.0;
81+
82+ if (pinch->radius_delta < 0.0) {
83+ ev_document_model_set_sizing_mode (priv->model, EV_SIZING_FREE);
84+ ev_view_zoom_out_smooth (priv->view, (1.0 / increment));
85+ } else if (pinch->radius_delta > 0.0) {
86+ ev_document_model_set_sizing_mode (priv->model, EV_SIZING_FREE);
87+ ev_view_zoom_in_smooth (priv->view, increment);
88+ }
89 }
90
91 static void
92 ev_pinch_gesture_end (GtkWindow *window,
93 IdoGestureEvent *event)
94 {
95- IdoEventGesturePinch *pinch = (IdoEventGesturePinch *)event;
96- EvWindowPrivate *priv = EV_WINDOW (window)->priv;
97-
98- gdouble diff = pinch->radius - priv->pinch_start_radius;
99-
100- if (diff <= -100) {
101- ev_window_cmd_view_zoom_out (NULL, EV_WINDOW (window));
102- } else if (diff >= 100) {
103- ev_window_cmd_view_zoom_in (NULL, EV_WINDOW (window));
104- }
105 }
106
107 static void

Subscribers

People subscribed via source and target branches