Integrate persistent canvas controls with scenario lifetime rendering

This commit is contained in:
2026-09-11 12:44:06 -07:00
parent 32334c6631
commit a57c334b30
42 changed files with 11751 additions and 2163 deletions
@@ -277,7 +277,13 @@ impl Rendering {
}
}
pub(in crate::behavior) fn draw_markers(&self, frame: &mut Frame, selected: Id, scale: f32) {
pub(in crate::behavior) fn draw_markers(
&self,
frame: &mut Frame,
selected: Id,
scale: f32,
pan: iced::Vector,
) {
for marker in &self.markers {
let color = if selected == marker.event.occurrence || selected == marker.lifeline {
style::TEAL
@@ -302,10 +308,11 @@ impl Rendering {
},
),
);
if let Some(clip) = birth_label_clip(marker.capsule, scale, frame.size()) {
if let Some(clip) = birth_label_clip(pan, marker.capsule, scale, frame.size()) {
// WGPU clipped frames start with an identity transform;
// neither the parent's scale nor its clip is inherited.
// neither the parent's pan/scale nor its clip is inherited.
frame.with_clip(clip, |label| {
label.translate(pan);
label.scale(scale);
label.fill_text(Text {
content: short(&marker.name, 18),
@@ -330,12 +337,20 @@ impl Rendering {
}
}
fn birth_label_clip(capsule: Rectangle, scale: f32, viewport: Size) -> Option<Rectangle> {
if !scale.is_finite() || scale <= 0. {
fn birth_label_clip(
pan: iced::Vector,
capsule: Rectangle,
scale: f32,
viewport: Size,
) -> Option<Rectangle> {
if !pan.x.is_finite() || !pan.y.is_finite() || !scale.is_finite() || scale <= 0. {
return None;
}
Rectangle::new(
Point::new((capsule.x + 8.) * scale, (capsule.y + 4.) * scale),
Point::new(
pan.x + (capsule.x + 8.) * scale,
pan.y + (capsule.y + 4.) * scale,
),
Size::new((capsule.width - 16.) * scale, (capsule.height - 8.) * scale),
)
.intersection(&Rectangle::new(Point::ORIGIN, viewport))