From cf03d357a00ce22d1b73c42dfff166faba4044f5 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Sun, 5 Feb 2023 23:56:42 +0100 Subject: [PATCH] slidingView: Add space between images --- src/widgets/sliding_view.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/widgets/sliding_view.rs b/src/widgets/sliding_view.rs index 10157b8..236bd4c 100644 --- a/src/widgets/sliding_view.rs +++ b/src/widgets/sliding_view.rs @@ -19,6 +19,14 @@ static SCROLL_DAMPING_RATIO: f64 = 1.; static SCROLL_MASS: f64 = 0.5; static SCROLL_STIFFNESS: f64 = 500.; +/// Space between images in application pixels +/// +/// This is combined with the percent component +static PAGE_SPACING_FIXED: f32 = 25.; + +/// Space between images as factor of width +const PAGE_SPACING_PERCENT: f32 = 0.02; + mod imp { use super::*; use glib::subclass::Signal; @@ -144,7 +152,7 @@ mod imp { // according to the position that should currently be shown. let x = direction_sign * (page_index as f32 - scroll_position - position_shift) - * width as f32; + * (width as f32 * (1. + PAGE_SPACING_PERCENT) + PAGE_SPACING_FIXED); let transform = gsk::Transform::new().translate(&graphene::Point::new(x, 0.)); page.allocate(width, height, 0, Some(&transform));