From 49d41b5a4354f1e35e2336fdea231bf2957a7552 Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Sun, 6 Mar 2022 19:16:22 +0100 Subject: [PATCH] Adding some arbitrary limits to the zoom out/in. --- src/view/chapter_view.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/view/chapter_view.c b/src/view/chapter_view.c index e773de5..089b78a 100644 --- a/src/view/chapter_view.c +++ b/src/view/chapter_view.c @@ -70,9 +70,19 @@ set_image_dimensions (GtkWidget *picture, GdkPaintable *paintable = gtk_picture_get_paintable (GTK_PICTURE (picture)); GtkWidget *views_leaflet = GTK_WIDGET (chapter_visor_data->views_leaflet); gdouble scale_factor = log (scale) / 20 + log (chapter_visor_data->zoom); - chapter_visor_data->zoom = pow (M_E, scale_factor); - guint width = gtk_widget_get_allocated_width - (views_leaflet) * chapter_visor_data->zoom; + gdouble final_zoom = pow (M_E, scale_factor); + guint views_leaflet_width = gtk_widget_get_allocated_width (views_leaflet); + if (final_zoom > 3) { + final_zoom = 3; + } + if (final_zoom < 1/3) { + final_zoom = 1/3; + } + chapter_visor_data->zoom = final_zoom; + if (views_leaflet_width > 600) { + views_leaflet_width = 300; + } + guint width = views_leaflet_width * chapter_visor_data->zoom; gdk_paintable_compute_concrete_size ( paintable, width,