Several bugfixes

- Fixed event invisibility when offset is after event's half width
- Fixed event being shown outside timeline component
- When timer reaches 24:00:00, new day is automatically started
This commit is contained in:
Alexey 2025-09-12 13:59:12 +03:00
commit b5e9a4115a
7 changed files with 79 additions and 27 deletions

View file

@ -24,16 +24,24 @@ global TimeString {
}
export component Timeline inherits Rectangle {
callback new-day-started;
in-out property<bool> updating: true;
in-out property<[TimelineEvent]> events: [];
in-out property<int> visible-time: 3600;
property<int> visible-offset: max(offset, visible-time);
in-out property<int> offset: 0;
out property<int> max-offset: 24 * 3600 - 1;
timer := Timer {
interval: 1s;
running: updating;
triggered => {
if (offset >= max-offset) {
root.new-day-started();
offset = 0;
return;
}
offset += 1;
}
}
@ -70,10 +78,10 @@ export component Timeline inherits Rectangle {
y: parent.height / 4;
z: 1;
width: event.finished ?
(event.duration) / visible-time * parent.width + min(real-x, 0):
min(parent.width - self.x, event.duration / visible-time * parent.width + min(real-x, 0)):
parent.width - self.x;
height: parent.height / 2;
visible: self.real-x + self.width > 0 && self.real-x < parent.width;
visible: self.width > 0 && self.real-x < parent.width;
border-color: black;
border-width: 1px;
background: red;