Preserve scenario viewport when editing a diagram message

This commit is contained in:
2026-09-06 05:43:56 +03:00
parent c6c07cc3a3
commit ae1602ad7a
3 changed files with 46 additions and 8 deletions
+8 -4
View File
@@ -1221,8 +1221,11 @@ pub fn view<'a>(app: &'a App, owner: Id, mut out: Column<'a, Message>) -> Elemen
}
}));
let pending = app.behavior.has_pending();
// Keep the canvas at a stable widget-tree position when a form replaces
// the palette, so Iced retains the user's current sequence viewport.
let mut controls = column![].spacing(12);
if !pending {
out = out
controls = controls
.push(
row![
action("+ Lifeline", event(Event::Start(owner, Tool::Lifeline))),
@@ -1252,7 +1255,7 @@ pub fn view<'a>(app: &'a App, owner: Id, mut out: Column<'a, Message>) -> Elemen
MessageStyle::CallReply
};
if !pending {
out = out.push(
controls = controls.push(
row![
button("Select / reorder")
.on_press(Message::ScenarioCanvas(CanvasEvent::Choose(
@@ -1296,14 +1299,15 @@ pub fn view<'a>(app: &'a App, owner: Id, mut out: Column<'a, Message>) -> Elemen
]
.spacing(6),
);
out = out.push(label(if matches!(tool, CanvasTool::Message(_)) {
controls = controls.push(label(if matches!(tool, CanvasTool::Message(_)) {
"Draw message · choose the highlighted sequence position on a lifeline, then click or drag to another lifeline · Escape cancels"
} else { "Select a lifeline or occurrence · drag the selected occurrence’s ↕ handle to reorder within its sequence" }));
} else {
out = out.push(label(
controls = controls.push(label(
"Pending form · the canvas remains visible · apply or cancel below",
));
}
out = out.push(controls);
let mut scene = Scene::sequence(p, owner, app.selected);
scene.interaction = Some((
context,