Added event start/end timestamps
This commit is contained in:
parent
4650fde884
commit
31281295bb
1 changed files with 21 additions and 2 deletions
|
@ -74,24 +74,43 @@ export component Timeline inherits Rectangle {
|
||||||
|
|
||||||
for event in events: timeline-event := Rectangle {
|
for event in events: timeline-event := Rectangle {
|
||||||
property<length> real-x: ((visible-time - (visible-offset - event.start)) / visible-time) * parent.width;
|
property<length> real-x: ((visible-time - (visible-offset - event.start)) / visible-time) * parent.width;
|
||||||
|
property<length> real-width: event.duration / visible-time * parent.width + min(real-x, 0);
|
||||||
x: max(real-x, 0);
|
x: max(real-x, 0);
|
||||||
y: parent.height / 4;
|
y: parent.height / 4;
|
||||||
z: 1;
|
z: 1;
|
||||||
width: event.finished ?
|
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;
|
parent.width - self.x;
|
||||||
height: parent.height / 2;
|
height: parent.height / 2;
|
||||||
visible: self.width > 0 && self.real-x < parent.width;
|
visible: self.width > 0 && self.real-x < parent.width;
|
||||||
border-color: black;
|
border-color: black;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
background: red;
|
background: red;
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
x: 0;
|
x: 0;
|
||||||
y: -self.height;
|
y: -self.height;
|
||||||
text: event.label;
|
text: event.label;
|
||||||
visible: timeline-event.visible;
|
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
|
@children
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue