Skip to content

Commit 65248c9

Browse files
authored
Timeline: Clamp event min/max x coord to viewport (#111)
Limit the event canvas-space coordinates to the size of the viewport to stop labels running off the right-hand side of the screen.
1 parent 73c52ba commit 65248c9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lglpy/timeline/drawable/world_drawable.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ def draw(self, gc, vp):
110110
# Round based on final WS position not on WS width
111111
max_x, max_y = vp.transform_ws_to_cs(self.ws.max_x, self.ws.max_y, 2)
112112

113+
# Clamp extents to viewport size
114+
x = max(x, vp.cs.min_x)
115+
max_x = min(max_x, vp.cs.max_x)
116+
113117
# Calculate canvas-space width and height
114118
w = max_x - x + 1
115119
h = max_y - y + 1

0 commit comments

Comments
 (0)