Group Midra load and send actions in the transfer footer

This commit is contained in:
Dandaedre 2026-11-15 11:47:41 +01:00
parent 49c576351b
commit c87bc0de91
3 changed files with 67 additions and 23 deletions

View File

@ -447,28 +447,30 @@ impl Editor {
}
pub(super) fn midra_load_button(&mut self, ui: &mut egui::Ui) {
self.midra_load_control(ui, false);
}
fn midra_load_control(&mut self, ui: &mut egui::Ui, icon: bool) {
let enabled = self.device.online() && self.device.pending.is_none();
let tooltip = if self.device.message.is_empty() {
"Read fresh Preview geometry and cropping from Midra into the linked editor layers. Undo restores the previous layout."
} else {
&self.device.message
};
if ui
.add_enabled(
enabled,
egui::Button::new(if self.device.loading.is_some() {
"Loading…"
} else {
match self.device.scope {
TransferScope::All => "Load linked layers",
TransferScope::Selected => "Load selected links",
TransferScope::Folder(_) => "Load folder links",
}
}),
)
.on_hover_text(tooltip)
.clicked()
{
let label = if self.device.loading.is_some() {
"Loading…"
} else {
match self.device.scope {
TransferScope::All => "Load linked layers",
TransferScope::Selected => "Load selected links",
TransferScope::Folder(_) => "Load folder links",
}
};
let response = if icon {
transfer_button(ui, label, enabled, false)
} else {
ui.add_enabled(enabled, egui::Button::new(label))
};
if response.on_hover_text(tooltip).clicked() {
self.start_scoped_load(ui.ctx());
ui.close_menu();
}
@ -745,7 +747,7 @@ impl Editor {
(info.id, info.midra_link.as_ref().filter(|link| link.screen == screen_id).map(|link| link.layer.clone()).unwrap_or_default())
}).collect();
let previous = targets.clone();
send_plan = send_review(ui, &self.layout, &scope_indices, snapshot, self.device.screen, &mut targets,
let prepared_plan = send_review(ui, &self.layout, &scope_indices, snapshot, self.device.screen, &mut targets,
&mut self.device.target, &mut self.device.sizing, self.device.pending.is_some(), self.device.allow_program, &self.device.input_edits);
for (id, destination) in targets {
if previous.get(&id) != Some(&destination) {
@ -754,7 +756,16 @@ impl Editor {
if let Err(e) = self.layout.set_midra_link(i, link) { self.device.error = e; }
}
}
self.midra_load_button(ui);
ui.separator();
ui.horizontal(|ui| {
self.midra_load_control(ui, true);
let enabled = prepared_plan.is_some() && self.device.pending.is_none();
if transfer_button(ui, "Send mapped layers", enabled, true)
.on_hover_text("Send the mapped editor layers to the selected Midra target")
.clicked() {
send_plan = prepared_plan;
}
});
return;
}
ui.horizontal(|ui| {
@ -907,6 +918,38 @@ impl Editor {
}
}
// Draw arrows as vectors so the transfer buttons do not depend on symbol fonts.
fn transfer_button(ui: &mut egui::Ui, label: &str, enabled: bool, send: bool) -> egui::Response {
let palette = theme::palette(ui.ctx());
let button = egui::Button::new(format!(" {label}")).min_size(ui.spacing().interact_size);
let button = if send {
button.fill(if enabled {
palette.purple
} else {
palette.field
})
} else {
button
};
let response = ui.add_enabled(enabled, button);
response.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, enabled, label));
let center = egui::pos2(response.rect.left() + 10.0, response.rect.center().y);
let direction = if send { -1.0 } else { 1.0 };
let stroke = Stroke::new(1.5_f32, if enabled { palette.text } else { palette.muted });
let tip = center + Vec2::new(0.0, direction * 5.0);
ui.painter()
.line_segment([center - Vec2::new(0.0, direction * 5.0), tip], stroke);
ui.painter().add(egui::Shape::line(
vec![
tip + Vec2::new(-4.0, -direction * 4.0),
tip,
tip + Vec2::new(4.0, -direction * 4.0),
],
stroke,
));
response
}
#[allow(clippy::too_many_arguments)]
fn send_review(
ui: &mut egui::Ui,
@ -1034,7 +1077,6 @@ fn send_review(
.collect();
if let Some(error) = link_conflicts(layout, &links) {
ui.colored_label(ui.visuals().error_fg_color, error);
apply_button(ui, "Send mapped layers", false);
return None;
}
match Plan::prepare(
@ -1067,12 +1109,10 @@ fn send_review(
));
}
});
if apply_button(ui, "Send mapped layers", !busy).clicked() {
return Some(plan);
}
if plan.changes.is_empty() {
ui.weak("Geometry matches the stored values. Send applies them to the hardware.");
}
return (!busy).then_some(plan);
}
Err(error) => {
ui.colored_label(ui.visuals().warn_fg_color, error);

View File

@ -4,6 +4,8 @@
## Unreleased
- Group Load and Send mapped layers on the final row of Midra mapping & transfer, with vector down/up arrows and direction tooltips. Keep send preparation separate from the explicit Send click and retain scope-aware loading.
- Round fractional device-reported content dimensions to whole pixels for centered crop import/readback and send compatibility, with nonblocking before/after warnings. Preserve raw state and fractional box geometry; invalid ranges and genuine source mismatches still fail. Regression tests cover cropped import, warning behavior, both send sizing strategies and invalid ranges.
- Restore recovery sessions silently instead of opening a “Recovery restored” message. Keep recovery failures and retry information visible; regression coverage checks restored edits and absence of the success popup.

View File

@ -70,7 +70,9 @@ are explained in the review. Imports are one undoable edit.
After connecting, open **Export → Midra mapping & transfer…**. Choose editor layers,
map each to a Midra layer, select **Preview** or **Program**, and select a container
strategy: **Output-sized** or **Source aspect**. Expand **Exact device changes** to
review sizes, centers, crop values and aspect, then click **Send mapped layers**.
review sizes, centers, crop values and aspect, then click **Send mapped layers**. The final row groups **Load linked layers**
(down arrow, device to editor) and **Send mapped layers** (up arrow, editor to
device); the Load label follows the selected transfer scope.
The button is disabled while a send is in progress. Matching stored values can still be sent to apply staged geometry to hardware.
The source's native dimensions must match the destination's current content.