mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-27 13:54:11 +00:00

* [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
73 lines
No EOL
1.6 KiB
Text
73 lines
No EOL
1.6 KiB
Text
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import { UsecasesPalette } from "styling.slint";
|
|
|
|
component Bar {
|
|
in property <length> bar-height;
|
|
|
|
horizontal-stretch: 1;
|
|
|
|
Rectangle {
|
|
border-radius: 2px;
|
|
y: parent.height - self.height;
|
|
height: bar-height;
|
|
clip: true;
|
|
|
|
Rectangle {
|
|
height: root.height;
|
|
y: parent.height - self.height;
|
|
background: UsecasesPalette.bar-gradient;
|
|
}
|
|
}
|
|
}
|
|
|
|
export component BarBackground inherits Rectangle {
|
|
border-radius: 2px;
|
|
// background: Theme.palette.bar-background-gradient;
|
|
opacity: 0.25;
|
|
}
|
|
|
|
export component ChartPattern {
|
|
in property <int> count;
|
|
|
|
HorizontalLayout {
|
|
spacing: 1px;
|
|
for _ in count : BarBackground {}
|
|
}
|
|
}
|
|
|
|
export component BarChart {
|
|
in property <[float]> model;
|
|
in property <float> min;
|
|
in property <float> max;
|
|
in property <bool> active;
|
|
|
|
cache-rendering-hint: true;
|
|
|
|
ChartPattern {
|
|
count: model.length / 2;
|
|
}
|
|
|
|
layout := HorizontalLayout {
|
|
spacing: 1px;
|
|
|
|
for value in model : Bar {
|
|
private property <float> display-value;
|
|
|
|
min-height: 120px;
|
|
preferred-height: 100%;
|
|
bar-height: parent.height * (display-value - root.min) / (root.max - root.min);
|
|
|
|
states [
|
|
active when active : {
|
|
display-value: value;
|
|
|
|
in {
|
|
animate display-value { duration: 500ms; easing: ease-in-out; }
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
} |