From ea4f5eec65669458924273d9343baf137ed88e1a Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 13 Nov 2026 18:50:27 +0100 Subject: [PATCH] Send linked Midra layers without opening export window --- crates/midra-layout/src/device_ui.rs | 97 ++++++++++++++++++++++++---- docs/interfaces/midra-device-send.md | 2 + docs/midra-layout.md | 2 + 3 files changed, 87 insertions(+), 14 deletions(-) diff --git a/crates/midra-layout/src/device_ui.rs b/crates/midra-layout/src/device_ui.rs index d79c7c7..e4e21f2 100644 --- a/crates/midra-layout/src/device_ui.rs +++ b/crates/midra-layout/src/device_ui.rs @@ -163,6 +163,10 @@ impl DeviceUi { Err(error) => { self.snapshot = None; self.error = error; + if was_sending { + self.prepare_send = true; + self.open = true; + } } } } @@ -174,20 +178,26 @@ impl Editor { pub(super) fn midra_send_button(&mut self, ui: &mut egui::Ui, all: bool) { let plans = self.device.linked_plans(&self.layout, all); let enabled = self.device.online() && self.device.pending.is_none(); - let tooltip = match &plans { - Ok(plans) => format!( - "Send {} linked screen(s) to {:?} using saved layer destinations.", - plans.len(), - plans[0].target - ), - Err(e) => e.clone(), + let tooltip = if self.device.sending { + "Sending and checking readback…".into() + } else if !self.device.message.is_empty() { + self.device.message.clone() + } else { + match &plans { + Ok(plans) => format!( + "Send {} linked screen(s) to {:?} using saved layer destinations.", + plans.len(), + plans[0].target + ), + Err(e) => e.clone(), + } }; if apply_button( ui, - if all { - "Send all linked layers" - } else if self.device.sending { + if self.device.sending { "Applying…" + } else if all { + "Send all linked layers" } else { "Apply to Midra" }, @@ -198,11 +208,19 @@ impl Editor { .clicked() { match plans { - Ok(plans) => self.device.send(ui.ctx(), plans), - Err(error) => self.device.error = error, + Ok(plans) => { + self.device.send(ui.ctx(), plans); + if !all { + self.device.prepare_send = true; + self.device.open = true; + } + } + Err(error) => { + self.device.error = error; + self.device.prepare_send = true; + self.device.open = true; + } } - self.device.prepare_send = true; - self.device.open = true; ui.close_menu(); } } @@ -647,6 +665,57 @@ mod tests { } } #[test] + fn send_all_linked_starts_without_opening_export_window() { + let ctx = egui::Context::default(); + let mut app = Editor::default(); + app.device.snapshot = Some(linked_test_snapshot()); + // Empty host ensures the worker cannot contact real hardware. + app.device.host.clear(); + app.layout + .set_midra_link( + 0, + Some(midra_layout::MidraLink { + screen: "1".into(), + layer: "1".into(), + }), + ) + .unwrap(); + app.layout.select(None); + let mut pos = egui::Pos2::ZERO; + for events in [vec![], vec![]] { + let _ = ctx.run( + egui::RawInput { + events, + ..Default::default() + }, + |ctx| { + egui::CentralPanel::default().show(ctx, |ui| { + pos = ui.cursor().min + Vec2::new(30.0, 10.0); + app.midra_send_button(ui, true); + }); + }, + ); + } + for pressed in [true, false] { + let _ = ctx.run( + egui::RawInput { + events: vec![ + egui::Event::PointerMoved(pos), + super::super::tests::mouse(pos, pressed), + ], + ..Default::default() + }, + |ctx| { + egui::CentralPanel::default().show(ctx, |ui| app.midra_send_button(ui, true)); + }, + ); + } + assert!(app.device.sending); + assert!(app.device.pending.is_some()); + assert!(!app.device.open); + assert!(!app.device.prepare_send); + } + #[test] fn status_apply_opens_mapping_without_writing_when_unconfigured() { let ctx = egui::Context::default(); let mut app = Editor::default(); diff --git a/docs/interfaces/midra-device-send.md b/docs/interfaces/midra-device-send.md index 3a0be49..a0f8bfe 100644 --- a/docs/interfaces/midra-device-send.md +++ b/docs/interfaces/midra-device-send.md @@ -92,3 +92,5 @@ matches and the change list is empty. A pulse-write failure is reported separate from geometry-write failure. Geometry readback follows the pulse; a readable store alone does not prove the physical video output updated. The trigger itself is not included in geometry comparisons, because it is a command rather than geometry. + +**Send all linked layers** sends immediately using saved links and the current target and sizing settings, without opening the export window. The button shows progress and its tooltip reports completion. Invalid links or send failures open the export window with the error. diff --git a/docs/midra-layout.md b/docs/midra-layout.md index f222221..3e0b583 100644 --- a/docs/midra-layout.md +++ b/docs/midra-layout.md @@ -629,3 +629,5 @@ Midra layer lists omit unassigned source slots (`NONE` or empty). Assigned input Destination choices in **Configure Midra export…** now save immediately on the editor layer and support Undo. Save the project JSON to keep links across sessions. Links include screen and layer IDs and survive refreshes and selection changes. Choose the empty destination on the linked screen to unlink. **Send all linked layers** is available beside Apply, in Export and in the send window; it includes unselected, hidden and locked linked layers, grouped by screen. The usual Apply action sends selected linked layers. Preview/Program and sizing still use the current export options. Every explicit send now includes WebRCS’s preset apply pulse (`xUpdate` false → true). This applies staged geometry when automatic updates are disabled, including a repeat send where WebRCS already shows the desired values. + +**Send all linked layers** sends immediately using saved links and the current target and sizing settings, without opening the export window. The button shows progress and its tooltip reports completion. Invalid links or send failures open the export window with the error.