aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-10-25 17:59:37 +0200
committerThomas White <taw@physics.org>2021-10-25 17:59:37 +0200
commit40ed4e6a72fd70c487aaafb58bc4c74cfaa6bfa8 (patch)
treee0dd78fba87ced09a2fbf0f9b371ebb606d5aec3
parenta99dec5f78e36c6659306c3a063a47b13e69b233 (diff)
CrystFELImageView: fix scrollbar adjustment ranges
Fixes: https://gitlab.desy.de/thomas.white/crystfel/-/issues/18
-rw-r--r--src/crystfelimageview.c19
-rw-r--r--src/crystfelimageview.h4
2 files changed, 10 insertions, 13 deletions
diff --git a/src/crystfelimageview.c b/src/crystfelimageview.c
index 101f86ec..39fba0f9 100644
--- a/src/crystfelimageview.c
+++ b/src/crystfelimageview.c
@@ -113,14 +113,15 @@ static void configure_scroll_adjustments(CrystFELImageView *iv)
double pos = gtk_adjustment_get_value(iv->hadj);
double vis_size = iv->visible_width / iv->zoom;
gtk_adjustment_configure(iv->hadj, pos,
- 0.0, iv->detector_w,
+ iv->min_x, iv->min_x+iv->detector_w*1.1,
0.0001, 0.1, vis_size);
}
if ( iv->vadj != NULL ) {
double pos = gtk_adjustment_get_value(iv->vadj);
double vis_size = iv->visible_height / iv->zoom;
gtk_adjustment_configure(iv->vadj, pos,
- 0.0, iv->detector_h,
+ -iv->max_y,
+ -(iv->max_y-iv->detector_h*1.1),
0.0001, 0.1, vis_size);
}
}
@@ -615,8 +616,8 @@ static gint draw_sig(GtkWidget *window, cairo_t *cr, CrystFELImageView *iv)
cairo_get_matrix(cr, &m);
cairo_scale(cr, iv->zoom, iv->zoom);
- cairo_translate(cr, iv->offs_x, iv->offs_y);
cairo_scale(cr, 1.0, -1.0);
+
cairo_translate(cr, -gtk_adjustment_get_value(iv->hadj),
gtk_adjustment_get_value(iv->vadj));
@@ -1016,7 +1017,6 @@ static int rerender_image(CrystFELImageView *iv)
{
int i;
double min_x, min_y, max_x, max_y;
- double border;
double scale_top;
if ( iv->image == NULL ) return 0;
@@ -1043,17 +1043,14 @@ static int rerender_image(CrystFELImageView *iv)
if ( iv->pixbufs[i] == NULL ) return 1;
}
- detgeom_pixel_extents(iv->image->detgeom, &min_x, &min_y,
+ detgeom_pixel_extents(iv->image->detgeom,
+ &min_x, &min_y,
&max_x, &max_y);
iv->detector_w = max_x - min_x;
iv->detector_h = max_y - min_y;
- border = iv->detector_w * 0.1;
- iv->detector_w += border;
- iv->detector_h += border;
+ iv->min_x = min_x - iv->detector_w*0.05;
+ iv->max_y = max_y + iv->detector_h*0.05;
if ( iv->zoom < 0.0 ) {
- /* Set initial values */
- iv->offs_x = -min_x + border/2.0;
- iv->offs_y = max_y + border/2.0;
iv->zoom = 1.0/iv->image->detgeom->panels[0].pixel_pitch;
}
configure_scroll_adjustments(iv);
diff --git a/src/crystfelimageview.h b/src/crystfelimageview.h
index 7d3ac1f6..c53e4980 100644
--- a/src/crystfelimageview.h
+++ b/src/crystfelimageview.h
@@ -80,8 +80,8 @@ struct _crystfelimageview
double drag_start_y;
double drag_start_sp_x;
double drag_start_sp_y;
- double offs_x;
- double offs_y;
+ double min_x;
+ double max_y;
const struct image *image;