From be9a92fd3915ee7451e5d8397120b26c2b9ac99e Mon Sep 17 00:00:00 2001 From: Florent Champigny Date: Thu, 20 Nov 2025 18:55:56 +0100 Subject: [PATCH] feat: timeline test --- .../openflocon/flocon/myapplication/Graph.kt | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/FloconAndroid/sample-android-only/src/main/java/io/github/openflocon/flocon/myapplication/Graph.kt b/FloconAndroid/sample-android-only/src/main/java/io/github/openflocon/flocon/myapplication/Graph.kt index ae7604e3..54ccf75d 100644 --- a/FloconAndroid/sample-android-only/src/main/java/io/github/openflocon/flocon/myapplication/Graph.kt +++ b/FloconAndroid/sample-android-only/src/main/java/io/github/openflocon/flocon/myapplication/Graph.kt @@ -172,14 +172,17 @@ fun LaneCanvas( val width = max(2f, xEnd - xStart) // --- keep partial visibility --- - val intersects = if (xStart < viewportStartPx) { + val intersects = if (xEnd > viewportStartPx && + xStart < viewportStartPx + viewportWidthPx + ) { + true + } else if (xStart <= viewportStartPx) { // draw inky if xEnd > viewportStartPx - xEnd > viewportStartPx - } else if (xEnd > viewportEndPx) { - xStart < viewportEndPx + xEnd >= viewportStartPx + } else if (xEnd >= viewportEndPx) { + xStart <= viewportEndPx } else { - // there's a visible part - (viewportStartPx < xEnd && xEnd < viewportEndPx) || (viewportStartPx < xStart && xStart < viewportEndPx) + false } if (!intersects) return@forEach @@ -225,9 +228,18 @@ fun LaneCanvas( val xEnd = (ev.startMs + ev.durationMs - minStart) * scalePxPerMs val width = max(2f, xEnd - xStart) - val intersects = - xEnd > viewportStartPx && - xStart < viewportStartPx + viewportWidthPx + val intersects = if (xEnd > viewportStartPx && + xStart < viewportStartPx + viewportWidthPx + ) { + true + } else if (xStart <= viewportStartPx) { + // draw inky if xEnd > viewportStartPx + xEnd >= viewportStartPx + } else if (xEnd >= viewportEndPx) { + xStart <= viewportEndPx + } else { + false + } if (!intersects) return@forEach