From 31281295bbb0076fa821dde1ae5d95fe5884c1ee Mon Sep 17 00:00:00 2001 From: 2ndbeam <2ndbeam@disroot.org> Date: Mon, 15 Sep 2025 16:54:05 +0300 Subject: [PATCH] Added event start/end timestamps --- ui/timeline.slint | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ui/timeline.slint b/ui/timeline.slint index 66d571a..4b94d03 100644 --- a/ui/timeline.slint +++ b/ui/timeline.slint @@ -74,24 +74,43 @@ export component Timeline inherits Rectangle { for event in events: timeline-event := Rectangle { property real-x: ((visible-time - (visible-offset - event.start)) / visible-time) * parent.width; + property real-width: event.duration / visible-time * parent.width + min(real-x, 0); x: max(real-x, 0); y: parent.height / 4; z: 1; width: event.finished ? - min(parent.width - self.x, event.duration / visible-time * parent.width + min(real-x, 0)): + min(parent.width - self.x, real-width) : parent.width - self.x; height: parent.height / 2; visible: self.width > 0 && self.real-x < parent.width; border-color: black; border-width: 1px; background: red; - + Text { x: 0; y: -self.height; text: event.label; visible: timeline-event.visible; } + start-txt := Text { + x: 0; + y: root.height - self.height - timeline-event.height; + text: timeline-event.x == timeline-event.real-x ? + TimeString.from(event.start) : + TimeString.from(visible-offset - visible-time); + visible: timeline-event.visible && + (self.width * 2 < timeline-event.width || + (!end-txt.visible && self.width < timeline-event.width)); + } + end-txt := Text { + x: timeline-event.width - self.width; + y: root.height - self.height - timeline-event.height; + text: timeline-event.x + timeline-event.real-width <= root.width ? + TimeString.from(event.start + event.duration) : + TimeString.from(visible-offset); + visible: timeline-event.visible && timeline-event.width - self.width * 2 > 0; + } } @children }