]> www.fi.muni.cz Git - evince.git/commitdiff
Account rotation in doc_rect_to_view_rect. Ensure rotation doesnt go out
authorMarco Pesenti Gritti <mpg@redhat.com>
Fri, 29 Jul 2005 17:59:01 +0000 (17:59 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Fri, 29 Jul 2005 17:59:01 +0000 (17:59 +0000)
2005-07-29  Marco Pesenti Gritti  <mpg@redhat.com>

        * shell/ev-view.c: (doc_rect_to_view_rect), (ev_view_rotate_right),
        (ev_view_rotate_left):

        Account rotation in doc_rect_to_view_rect.
        Ensure rotation doesnt go out of bounds.

ChangeLog
shell/ev-view.c

index a3402b9dd7e826583d18f038bf07a5154c5d912f..8c8b169abfe1bc41f2f27f8a771d345ce21183f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-07-29  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * shell/ev-view.c: (doc_rect_to_view_rect), (ev_view_rotate_right),
+       (ev_view_rotate_left):
+
+       Account rotation in doc_rect_to_view_rect.
+       Ensure rotation doesnt go out of bounds.
+
 2005-07-29  Marco Pesenti Gritti  <mpg@redhat.com>
 
        * shell/ev-page-cache.c: (ev_page_cache_get_size):
index e4524eba207448c866be3dc506757325b0113711..6bc088b43a4013751db3018c8b10c5cf972bc495 100644 (file)
@@ -908,16 +908,44 @@ doc_rect_to_view_rect (EvView       *view,
 {
        GdkRectangle page_area;
        GtkBorder border;
+       double x, y, w, h;
        int width, height;
 
+       ev_page_cache_get_size (view->page_cache, page,
+                               view->rotation,
+                               1.0,
+                               &width, &height);
+
+       if (view->rotation == 0) {
+               x = doc_rect->x1;
+               y = doc_rect->y1;
+               w = doc_rect->x2 - doc_rect->x1;
+               h = doc_rect->y2 - doc_rect->y1;
+       } else if (view->rotation == 90) {
+               x = width - doc_rect->y2;
+               y = doc_rect->x1;
+               w = doc_rect->y2 - doc_rect->y1;
+               h = doc_rect->x2 - doc_rect->x1;
+       } else if (view->rotation == 180) {
+               x = width - doc_rect->x2;
+               y = height - doc_rect->y2;
+               w = doc_rect->x2 - doc_rect->x1;
+               h = doc_rect->y2 - doc_rect->y1;
+       } else if (view->rotation == 270) {
+               x = doc_rect->y1;
+               y = height - doc_rect->x2;
+               w = doc_rect->y2 - doc_rect->y1;
+               h = doc_rect->x2 - doc_rect->x1;
+       } else {
+               g_assert_not_reached ();
+       }
+
        get_page_extents (view, page, &page_area, &border);
 
-       width = doc_rect->x2 - doc_rect->x1;
-       height = doc_rect->y2 - doc_rect->y1;
-       view_rect->x = floor (doc_rect->x1 * view->scale) + page_area.x;
-       view_rect->y = floor (doc_rect->y1 * view->scale) + page_area.y;
-       view_rect->width = ceil (width * view->scale);
-       view_rect->height = ceil (height * view->scale);
+       view_rect->x = x * view->scale + page_area.x;
+       view_rect->y = y * view->scale + page_area.y;
+       view_rect->width = w * view->scale;
+       view_rect->height = h * view->scale;
 }
 
 static void
@@ -2309,13 +2337,25 @@ ev_view_set_rotation (EvView *view, int rotation)
 void
 ev_view_rotate_right (EvView *view)
 {
-       ev_view_set_rotation (view, view->rotation + 90);
+       int rotation = view->rotation + 90;
+
+       if (rotation >= 360) {
+               rotation -= 360;
+       }
+
+       ev_view_set_rotation (view, rotation);
 }
 
 void
 ev_view_rotate_left (EvView *view)
 {
-       ev_view_set_rotation (view, view->rotation - 90);
+       int rotation = view->rotation - 90;
+
+       if (rotation < 0) {
+               rotation += 360;
+       }
+
+       ev_view_set_rotation (view, rotation);
 }
 
 static double