summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 53047b0)
raw | patch | inline | side by side (parent: 53047b0)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 21 Oct 2011 13:02:25 +0000 (15:02 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 21 Oct 2011 13:02:25 +0000 (15:02 +0200) |
src/gtk-tpdfv.c | patch | blob | history |
diff --git a/src/gtk-tpdfv.c b/src/gtk-tpdfv.c
index 4398719385557f7144ca42c674bdf66acfd47630..771dff99871ebd2f2490207790760175caa684e9 100644 (file)
--- a/src/gtk-tpdfv.c
+++ b/src/gtk-tpdfv.c
gtk_tpdfv_t *pdf;
cairo_t *cr;
+ gdouble width, height;
+
+ gdouble page_width = 0.0;
+ gdouble page_height = 0.0;
+
+ double zoom_factor = 1.0;
+ double x, y;
+
pdf = GTK_TPDFV_GET_PRIVATE(tpdfv);
if (! pdf)
event->area.width, event->area.height);
cairo_clip(cr);
- /* zoom, scrolling */
+ poppler_page_get_size(pdf->current_page, &page_width, &page_height);
+ width = (gdouble)tpdfv->allocation.width;
+ height = (gdouble)tpdfv->allocation.height;
+
+ /* zoom */
if (pdf->zoom_mode == TPDFV_ZOOM_CUSTOM) {
- cairo_scale(cr, pdf->zoom_factor, pdf->zoom_factor);
+ zoom_factor = pdf->zoom_factor;
}
else {
- gdouble width;
- gdouble height;
-
- gdouble page_width = 0.0;
- gdouble page_height = 0.0;
-
- double zoom_factor = 1.0;
-
- poppler_page_get_size(pdf->current_page, &page_width, &page_height);
- width = (gdouble)tpdfv->allocation.width;
- height = (gdouble)tpdfv->allocation.height;
-
if (pdf->zoom_mode == TPDFV_ZOOM_WIDTH) {
zoom_factor = (double)(width / page_width);
}
else {
assert(0);
}
-
- cairo_scale(cr, zoom_factor, zoom_factor);
}
+ cairo_scale(cr, zoom_factor, zoom_factor);
+
+ /* centered position / scrolling */
+ x = (double)(width - page_width * zoom_factor) / 2.0 / zoom_factor;
+ y = (double)(height - page_height * zoom_factor) / 2.0 / zoom_factor;
- cairo_translate(cr, pdf->delta_x, pdf->delta_y);
+ cairo_translate(cr, x + pdf->delta_x, y + pdf->delta_y);
poppler_page_render(pdf->current_page, cr);