From 7f7bf89040433e1c47fdf923990993030788755c Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Wed, 11 Dec 2024 16:11:58 +0100 Subject: [PATCH] Prevent gap when having many small records --- timetagger/app/front.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/timetagger/app/front.py b/timetagger/app/front.py index 6a0d2e0..a998b71 100644 --- a/timetagger/app/front.py +++ b/timetagger/app/front.py @@ -2129,6 +2129,10 @@ def _determine_record_preferred_pos(self, record, t1, y0, y1, y2, npixels, nsecs ry1 = y0 + npixels * (record.t1 - t1) / nsecs ry2 = y0 + npixels * (t2_or_now - t1) / nsecs + # Get margin for making space for record before its visible + npixels_record = max(0, ry2 - ry1) + visible_margin = min(npixels_record, 40) + # Determine preferred position pref = y = (ry1 + ry2) / 2 visible = "main" @@ -2138,7 +2142,7 @@ def _determine_record_preferred_pos(self, record, t1, y0, y1, y2, npixels, nsecs if ry2 < y1: # Start claiming space before it is visible y -= 2 * (y1 - ry2) - if ry2 < y1 - 40: + if ry2 < y1 - visible_margin: visible = "" elif y > y2 - 20: y = y2 - 20 @@ -2146,7 +2150,7 @@ def _determine_record_preferred_pos(self, record, t1, y0, y1, y2, npixels, nsecs if ry1 > y2: # Start claiming space before it is visible y += 2 * (ry1 - y2) - if ry1 > y2 + 40: + if ry1 > y2 + visible_margin: visible = "" return {"pref": pref, "y": y, "visible": visible}