Check in the fan curve work

This commit is contained in:
Luke D. Jones
2024-03-13 18:57:38 +13:00
parent b6e3e5e823
commit f4f7a1e648
9 changed files with 258 additions and 152 deletions

View File

@@ -22,7 +22,6 @@ export component AuraPowerGroup inherits Rectangle {
color: Palette.alternate-foreground;
horizontal-alignment: TextHorizontalAlignment.center;
text <=> root.group-title;
}
row := HorizontalBox {

View File

@@ -4,8 +4,8 @@ export component ColourSlider inherits VerticalLayout {
spacing: 10px;
in-out property <bool> enabled;
property <string> hex: "#FF0000";
in-out property <float> c1value<=> c1.value;
in-out property <float> c2value<=> c2.value;
in-out property <float> c1value <=> c1.value;
in-out property <float> c2value <=> c2.value;
property <color> base_colour: Colors.red;
in-out property <color> final_colour: Colors.red;
in-out property <brush> colourbox: final_colour;
@@ -151,7 +151,6 @@ export component ColourSlider inherits VerticalLayout {
border-radius: 7px;
border-color: Palette.border;
background <=> root.colourbox;
}
}
}

View File

@@ -24,7 +24,6 @@ export component SystemSlider inherits RogItem {
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
Text {
@@ -63,7 +62,6 @@ export component SystemToggle inherits RogItem {
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
}
@@ -94,7 +92,6 @@ export component SystemToggleVert inherits RogItem {
horizontal-alignment: TextHorizontalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
HorizontalLayout {
@@ -102,7 +99,7 @@ export component SystemToggleVert inherits RogItem {
padding-bottom: 10px;
Switch {
checked <=> root.checked;
toggled => {
toggled => {
root.toggled(root.checked)
}
}
@@ -125,7 +122,6 @@ export component SystemDropdown inherits RogItem {
vertical-alignment: TextVerticalAlignment.center;
color: Palette.control-foreground;
text <=> root.text;
}
}

View File

@@ -3,98 +3,111 @@ import { Palette } from "std-widgets.slint";
export struct Node { x: length, y: length}
export component Graph inherits Rectangle {
preferred-height: 100%;
preferred-width: 100%;
pure callback verify_positions([Node], length, length) -> [Node];
in-out property <[Node]> nodes;
in property <Node> node_min: { x: 0px, y: 0px };
in property <Node> node_max: { x: 100px, y: 100px };
property <length> graph_padding: 20px;
graph := Rectangle {
width: root.width - root.graph_padding * 2;
height: root.height - root.graph_padding * 2;
x: root.graph_padding;
y: root.graph_padding;
function scale_x_to_graph(x: length) -> length {
((x - node_min.x) / (node_max.x - node_min.x)) * graph.width
}function scale_y_to_graph(y: length) -> length {
((y - node_min.y) / (node_max.y - node_min.y)) * graph.height
}function scale_x_to_node(x: length) -> length {
(x / graph.width) * (node_max.x - node_min.x)
}function scale_y_to_node(y: length) -> length {
(y / graph.height) * (node_max.y - node_min.y)
}for l[idx] in nodes: path := Rectangle {
if idx + 1 != nodes.length: Path {
viewbox-width: self.width / 1px;
viewbox-height: self.height / 1px;
stroke: Palette.control-foreground;
stroke-width: 2px;
MoveTo {
x: scale_x_to_graph(nodes[idx].x) / 1px;
y: graph.height / 1px - scale_y_to_graph(nodes[idx].y) / 1px;
}
for l[idx] in nodes: path := Rectangle {
if idx + 1 != nodes.length: Path {
viewbox-width: self.width / 1px;
viewbox-height: self.height / 1px;
stroke: Palette.control-foreground;
stroke-width: 2px;
MoveTo {
x: nodes[idx].x / 1px;
y: root.height / 1px - nodes[idx].y / 1px;
}
LineTo {
x: nodes[idx + 1].x / 1px;
y: root.height / 1px - nodes[idx + 1].y / 1px;
LineTo {
x: scale_x_to_graph(nodes[idx + 1].x) / 1px;
y: graph.height / 1px - scale_y_to_graph(nodes[idx + 1].y) / 1px;
}
}
}
}
for n[idx] in nodes: Rectangle {
states [
for n[idx] in nodes: Rectangle {
states [
pressed when touch.pressed: {
state.background: Palette.selection-background;
}
hover when touch.has-hover: {
state.background: Palette.accent-background;
}
]state := Rectangle {
background: Palette.control-foreground;
x: n.x - self.width / 2;
y: root.height - n.y - self.height / 2;
width: 18px;
height: self.width;
border-radius: self.width / 2;
property <length> pad: self.border-radius / 2;
state.background: Palette.selection-background;
}
hover when touch.has-hover: {
state.background: Palette.accent-background;
}
]state := Rectangle {
background: Palette.control-foreground;
x: scale_x_to_graph(n.x) - self.width / 2;
y: graph.height - scale_y_to_graph(n.y) - self.height / 2;
width: 18px;
height: self.width;
border-radius: self.width / 2;
property <length> pad: 1px;
touch := TouchArea {
function check() {
if idx + 1 < nodes.length && idx > 0 {
if n.x + self.mouse-x - self.pressed-x > nodes[idx + 1].x {
n.x = nodes[idx + 1].x - pad;
} else if n.x + self.mouse-x - self.pressed-x < nodes[idx - 1].x {
n.x = nodes[idx - 1].x + pad;
}
touch := TouchArea {
function check() {
if idx + 1 < nodes.length && idx > 0 {
if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) > nodes[idx + 1].x {
n.x = nodes[idx + 1].x - pad;
} else if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) < nodes[idx - 1].x {
n.x = nodes[idx - 1].x + pad;
}
if n.y + self.height - self.mouse-y - self.pressed-y > nodes[idx + 1].y {
n.y = nodes[idx + 1].y - pad;
} else if n.y + self.height - self.mouse-y - self.pressed-y < nodes[idx - 1].y {
n.y = nodes[idx - 1].y + pad;
}
} else if idx == 0 {
if n.x + self.mouse-x - self.pressed-x < 0.0 {
n.x = 1px;
} else if n.x + self.mouse-x - self.pressed-x > nodes[idx + 1].x {
n.x = nodes[idx + 1].x - pad;
}
if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) > nodes[idx + 1].y {
n.y = nodes[idx + 1].y - pad;
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) < nodes[idx - 1].y {
n.y = nodes[idx - 1].y + pad;
}
} else if idx == 0 {
if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) < 0.0 {
n.x = 1px;
} else if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) > nodes[idx + 1].x {
n.x = nodes[idx + 1].x - pad;
}
if n.y - self.mouse-y - self.pressed-y < 0.0 {
n.y = 1px;
} else if n.y + self.height - self.mouse-y - self.pressed-y > nodes[idx + 1].y {
n.y = nodes[idx + 1].y - pad;
}
} else if idx == nodes.length - 1 {
if n.x + self.mouse-x - self.pressed-x > root.width {
n.x = root.width - 1px;
} else if n.x + self.mouse-x - self.pressed-x < nodes[idx - 1].x {
n.x = nodes[idx - 1].x + pad;
}
if n.y - scale_y_to_node(self.mouse-y - self.pressed-y) < 0.0 {
n.y = 1px;
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) > nodes[idx + 1].y {
n.y = nodes[idx + 1].y - pad;
}
} else if idx == nodes.length - 1 {
if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) > scale_x_to_node(graph.width) {
n.x = scale_x_to_node(graph.width - 1px);
} else if n.x + scale_x_to_node(self.mouse-x - self.pressed-x) < nodes[idx - 1].x {
n.x = nodes[idx - 1].x + pad;
}
if n.y - self.mouse-y - self.pressed-y > root.height {
n.y = root.height - 1px;
} else if n.y + self.height - self.mouse-y - self.pressed-y < nodes[idx - 1].y {
n.y = nodes[idx - 1].y + pad;
if n.y - scale_y_to_node(self.mouse-y - self.pressed-y) > scale_y_to_node(graph.height) {
n.y = scale_y_to_node(graph.height - 1px);
} else if n.y + scale_y_to_node(self.height - self.mouse-y - self.pressed-y) < nodes[idx - 1].y {
n.y = nodes[idx - 1].y + pad;
}
}
}moved => {
if (self.pressed) {
n.x += scale_x_to_node(self.mouse-x - self.pressed-x);
n.y -= scale_y_to_node(self.mouse-y - self.pressed-y);
self.check();
// nodes[idx] = n;
}
}moved => {
if (self.pressed) {
n.x += self.mouse-x - self.pressed-x;
n.y -= self.mouse-y - self.pressed-y;
}
clicked => {
self.check();
// nodes[idx] = n;
}
mouse-cursor: move;
}
clicked => {
self.check();
}
mouse-cursor: move;
}
}
}

View File

@@ -7,8 +7,8 @@ component SideBarItem inherits Rectangle {
padding: 10px;
in property <bool> selected;
in property <bool> has-focus;
in-out property <string> text<=> label.text;
callback clicked<=>touch.clicked;
in-out property <string> text <=> label.text;
callback clicked <=> touch.clicked;
min-height: self.visible ? l.preferred-height + 10px : 0px;
// min-width: self.visible ? l.preferred-width + 10px : 0px;
states [
@@ -54,7 +54,7 @@ component SideBarItem inherits Rectangle {
export component SideBar inherits Rectangle {
in property <[string]> model: [];
in property <[bool]> available: [];
in property <string> title<=> label.text;
in property <string> title <=> label.text;
out property <int> current-item: 0;
out property <int> current-focused: fs.has-focus ? fs.focused-tab : -1;
// The currently focused tab