Skip to content

Commit

Permalink
Merge pull request #515 from almarklein/prevent-gap
Browse files Browse the repository at this point in the history
Prevent gap when having many small records
  • Loading branch information
almarklein authored Dec 11, 2024
2 parents ce76e2f + 7f7bf89 commit cdb99ff
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions timetagger/app/front.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -2138,15 +2142,15 @@ 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
visible = "bottom"
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}
Expand Down

0 comments on commit cdb99ff

Please sign in to comment.