Pseudo pseudorandom color picker

This commit is contained in:
Alexey 2025-09-18 16:30:37 +03:00
commit 218ee49a8b
7 changed files with 75 additions and 15 deletions

View file

@ -1,8 +1,11 @@
import { Palette } from "theme.slint";
export struct TimelineEvent {
start: int,
duration: int,
finished: bool,
label: string
label: string,
color-id: int
}
global TimeString {
@ -26,6 +29,7 @@ global TimeString {
export component Timeline inherits Rectangle {
callback new-day-started;
callback clicked <=> ta.clicked;
background: Palette.background;
in-out property<bool> updating: true;
in-out property<[TimelineEvent]> events: [];
@ -52,7 +56,6 @@ export component Timeline inherits Rectangle {
preferred-height: 100%;
}
background: gray;
border-width: 1px;
border-color: black;
Rectangle {
@ -63,19 +66,21 @@ export component Timeline inherits Rectangle {
height: parent.height / 2;
border-color: black;
border-width: 1px;
background: purple;
background: Palette.timeline;
}
Text {
x: 0;
y: parent.height - self.height;
text: TimeString.from(visible-offset - visible-time);
color: Palette.background-text;
}
Text {
x: parent.width - self.width;
y: parent.height - self.height;
text: TimeString.from(visible-offset);
color: Palette.background-text;
}
for event in events: timeline-event := Rectangle {
@ -91,13 +96,14 @@ export component Timeline inherits Rectangle {
visible: self.width > 0 && self.real-x < parent.width;
border-color: black;
border-width: 1px;
background: red;
background: Palette.event-colors[event.color-id];
Text {
x: 0;
y: -self.height;
text: event.label;
visible: timeline-event.visible;
color: Palette.background-text;
}
start-txt := Text {
x: 0;
@ -108,6 +114,7 @@ export component Timeline inherits Rectangle {
visible: timeline-event.visible &&
(self.width * 2 < timeline-event.width ||
(!end-txt.visible && self.width < timeline-event.width));
color: Palette.event-text[event.color-id];
}
end-txt := Text {
x: timeline-event.width - self.width;
@ -116,6 +123,7 @@ export component Timeline inherits Rectangle {
TimeString.from(event.start + event.duration) :
TimeString.from(visible-offset);
visible: timeline-event.visible && timeline-event.width - self.width * 2 > 0;
color: Palette.event-text[event.color-id];
}
}
@children