Skip to content

Commit 23dba9a

Browse files
committed
--wip--
1 parent af56ee1 commit 23dba9a

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

tools/vista/src/app.rs

+27-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::fmt::Formatter;
22

33
use eframe::{
4-
egui::{pos2, Align2, CentralPanel, Color32, FontId, TopBottomPanel},
5-
epaint::PathStroke,
4+
egui::{pos2, vec2, Align2, CentralPanel, Color32, FontId, Shape, TopBottomPanel},
5+
epaint::{PathStroke, QuadraticBezierShape},
66
App, CreationContext,
77
};
88

@@ -60,9 +60,9 @@ impl App for DependencyInspector {
6060
self.selected_node_index = None;
6161
}
6262
});
63+
6364
CentralPanel::default().show(context, |ui| {
6465
let cycler = self.cyclers.cyclers.get(self.selected_cycler).unwrap();
65-
ui.label(format!("{} {}", cycler.name, cycler.cycle_nodes.len()));
6666

6767
let nodes: Vec<_> = cycler
6868
.setup_nodes
@@ -77,17 +77,25 @@ impl App for DependencyInspector {
7777
if label.clicked {
7878
self.selected_node_index = Some(index);
7979
}
80-
node_points.push(label.rect.right_center());
80+
node_points.push(label.rect.right_center() + vec2(3.0, 0.0));
8181
ui.add_space(5.0);
8282
}
8383

84+
let minimum_x = node_points
85+
.iter()
86+
.map(|point| point.x)
87+
.max_by(f32::total_cmp)
88+
.unwrap_or(0.0)
89+
+ 50.0;
90+
8491
let Some(selected_node_index) = self.selected_node_index else {
8592
return;
8693
};
8794
let selected_node = nodes[selected_node_index];
8895

8996
let mut cross_inputs = Vec::new();
9097
let painter = ui.painter();
98+
let mut count = 0;
9199
for field in &selected_node.contexts.cycle_context {
92100
let path = match field {
93101
Field::Input {
@@ -119,7 +127,7 @@ impl App for DependencyInspector {
119127
continue;
120128
}
121129
};
122-
for (node_index, node) in nodes.iter().enumerate() {
130+
for (node_index, node) in nodes.iter().enumerate().rev() {
123131
if let Some(output) =
124132
node.contexts
125133
.main_outputs
@@ -133,16 +141,26 @@ impl App for DependencyInspector {
133141
_ => None,
134142
})
135143
{
136-
let a = node_points[selected_node_index];
144+
let a = pos2(
145+
minimum_x + count as f32 * 10.0,
146+
node_points[selected_node_index].y,
147+
);
137148
let b = node_points[node_index];
138-
painter.line_segment([a, b], PathStroke::new(1.0, Color32::RED));
149+
let curve = QuadraticBezierShape::from_points_stroke(
150+
[a, pos2(a.x, b.y), b],
151+
false,
152+
Color32::TRANSPARENT,
153+
PathStroke::new(1.0, Color32::RED),
154+
);
139155
painter.text(
140-
(a + b.to_vec2()) / 2.0,
156+
curve.sample(0.9) + vec2(5.0, 0.0),
141157
Align2::LEFT_CENTER,
142-
output,
158+
format!("{output} {count}"),
143159
FontId::default(),
144160
Color32::LIGHT_GRAY,
145161
);
162+
painter.add(Shape::QuadraticBezier(curve));
163+
count += 1;
146164
}
147165
}
148166
}

0 commit comments

Comments
 (0)