From b5b2d3638c118ea181152f43df5b26b1b5b6ffb1 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Wed, 18 Nov 2026 14:22:21 +0100 Subject: [PATCH] Remove legacy input controls and layer-send staging --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/canvas-pilot/src/device_ui.rs | 52 +- crates/canvas-pilot/src/format_ui.rs | 27 +- crates/canvas-pilot/src/gui.rs | 4 +- crates/canvas-pilot/src/input_ui.rs | 626 ------------------ crates/canvas-pilot/src/localization.rs | 1 - crates/canvas-pilot/src/project_ui.rs | 13 +- docs/canvas-pilot/changelog.md | 7 + docs/canvas-pilot/guide/advanced-exchange.md | 24 +- docs/canvas-pilot/guide/files.md | 4 +- docs/canvas-pilot/guide/formats-and-crop.md | 40 +- .../input-settings-refactor.task.md | 8 +- docs/interfaces/midra-device-send.md | 16 +- 14 files changed, 86 insertions(+), 740 deletions(-) delete mode 100644 crates/canvas-pilot/src/input_ui.rs diff --git a/Cargo.lock b/Cargo.lock index 021153f..7208cea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -602,7 +602,7 @@ dependencies = [ [[package]] name = "canvas-pilot" -version = "0.9.55" +version = "0.9.56" dependencies = [ "base64 0.22.1", "craft-dwg", diff --git a/Cargo.toml b/Cargo.toml index be731e6..e4aed6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"] resolver = "3" [workspace.package] -version = "0.9.55" +version = "0.9.56" edition = "2024" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot" diff --git a/crates/canvas-pilot/src/device_ui.rs b/crates/canvas-pilot/src/device_ui.rs index ee5562a..55b2e76 100644 --- a/crates/canvas-pilot/src/device_ui.rs +++ b/crates/canvas-pilot/src/device_ui.rs @@ -102,7 +102,8 @@ enum Destination { #[derive(Default)] pub(super) struct DeviceUi { - pub(super) input_edits: input_ui::InputEdits, + pub(super) saved_input_proposals: Vec, + pub(super) local_source_editing: bool, pub open: bool, pub(super) scope: TransferScope, import_closing: bool, @@ -217,7 +218,7 @@ impl DeviceUi { .iter() .position(|s| s.id == screen) .ok_or_else(|| format!("Linked screen {screen} is unavailable."))?; - let mut plan = Plan::prepare( + let plan = Plan::prepare( snapshot, layout, index, @@ -229,8 +230,6 @@ impl DeviceUi { }, self.sizing, )?; - self.input_edits - .extend_plan(snapshot, &mappings, &mut plan)?; Ok(plan) }) .collect() @@ -402,19 +401,6 @@ impl DeviceUi { } } impl Editor { - pub(super) fn advanced_input_controls(&mut self, ui: &mut egui::Ui, i: usize) { - self.device.input_edits.show( - ui, - self.device.snapshot.as_ref(), - self.layout - .layer_info(i) - .send_mapping - .current_links() - .next(), - self.layout.layer_info(i).id, - ); - } - pub(super) fn layer_mapping_controls(&mut self, ui: &mut egui::Ui, i: usize) { let original = self.layout.layer_info(i).load_mapping.clone(); let mut link = original.clone(); @@ -769,7 +755,7 @@ impl Editor { ui.label(tr(ui.ctx(), "ui.device-ip-port")); if ui.add_enabled(self.device.pending.is_none(), egui::TextEdit::singleline(&mut self.device.host).hint_text("192.168.10.146:3000")).changed() { self.device.snapshot = None; - self.device.input_edits.clear(); + self.device.local_source_editing = false; self.device.reset_mappings(); self.device.error.clear(); self.device.message.clear(); @@ -779,7 +765,7 @@ impl Editor { for host in self.device.recent_hosts.clone() { if ui.button(&host).on_hover_text(tr(ui.ctx(), "ui.connect-to-this-machine-read-only")).clicked() { self.device.host = host; - self.device.input_edits.clear(); + self.device.local_source_editing = false; self.device.reset_mappings(); self.device.fetch(ctx); ui.close(); @@ -792,7 +778,7 @@ impl Editor { if ui.add_enabled(self.device.pending.is_none(), egui::Button::new(if self.device.online() { "Refresh connection" } else { "Connect" })).clicked() { self.device.fetch(ctx); } if ui.add_enabled(self.device.online() && self.device.pending.is_none(), egui::Button::new(tr(ui.ctx(), "ui.disconnect"))).clicked() { self.device.snapshot = None; - self.device.input_edits.clear(); + self.device.local_source_editing = false; self.device.reset_mappings(); self.device.message.clear(); } @@ -916,7 +902,7 @@ impl Editor { }).collect(); let previous = targets.clone(); 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); + &mut self.device.target, &mut self.device.sizing, self.device.pending.is_some(), self.device.allow_program); for (id, destination) in targets { if previous.get(&id) != Some(&destination) { let i = (0..self.layout.layers().len()).find(|&i| self.layout.layer_info(i).id == id).unwrap(); @@ -1141,7 +1127,6 @@ fn send_review( sizing: &mut Sizing, busy: bool, allow_program: bool, - input_edits: &input_ui::InputEdits, ) -> Option { let screen = &snapshot.screens[screen_index]; if !allow_program { @@ -1285,11 +1270,7 @@ fn send_review( &mappings, *target_mode, *sizing, - ) - .and_then(|mut plan| { - input_edits.extend_plan(snapshot, &mappings, &mut plan)?; - Ok(plan) - }) { + ) { Ok(plan) => { ui.label(format!( "{:?} · screen {} · physical bank {} · {} changed fields", @@ -1407,6 +1388,12 @@ mod tests { .unwrap(); let state = DeviceUi { snapshot: Some(snapshot.clone()), + saved_input_proposals: canvas_pilot::project::Project::from_json(include_str!( + "../../../docs/interfaces/canvas-pilot-v16.example.json" + )) + .unwrap() + .input_proposals, + local_source_editing: true, ..Default::default() }; assert_eq!( @@ -1418,6 +1405,12 @@ mod tests { vec![(layout.layer_info(0).id, link("2"))] ); let plan = state.linked_plans(&layout).unwrap(); + assert!( + plan.iter() + .flat_map(|p| &p.changes) + .all(|change| !change.path.iter().any(|part| part == "inputList")) + ); + assert!( plan[0] .changes @@ -1925,7 +1918,6 @@ mod tests { &mut Sizing::OutputBox, false, allow, - &input_ui::InputEdits::default(), ); }); }); @@ -2091,7 +2083,6 @@ mod tests { &mut Sizing::OutputBox, false, false, - &input_ui::InputEdits::default(), ) }); }); @@ -2114,7 +2105,6 @@ mod tests { &mut Sizing::OutputBox, false, false, - &input_ui::InputEdits::default(), ) }); }); @@ -2286,7 +2276,6 @@ mod tests { &mut Sizing::OutputBox, false, false, - &input_ui::InputEdits::default() ) .is_none() ); @@ -2451,7 +2440,6 @@ mod tests { &mut Sizing::OutputBox, false, false, - &input_ui::InputEdits::default(), ); }); }); diff --git a/crates/canvas-pilot/src/format_ui.rs b/crates/canvas-pilot/src/format_ui.rs index e6f4e81..b97c862 100644 --- a/crates/canvas-pilot/src/format_ui.rs +++ b/crates/canvas-pilot/src/format_ui.rs @@ -401,12 +401,12 @@ impl Editor { self.inputs.selected = snapshot.profile.input_from_source(&layer.source).unwrap_or(0); } } - ui.small("Device preprocessing is edited per input in the shared window. Local source geometry below is retained for existing projects."); - ui.collapsing("Legacy input proposals / layer-send compatibility", |ui| self.advanced_input_controls(ui, i)); + ui.small("Device preprocessing is edited in the shared window. The local source model below only affects the editor layout."); + ui.checkbox(&mut self.device.local_source_editing, "Edit local source geometry"); ui.separator(); ui.label(tr(ui.ctx(), "ui.editor-source-model-local-geometry")); ui.small(tr(ui.ctx(), "ui.these-dimensions-describe-the-editor-source-not-a-device-timing-command-local-input-c")); - ui.add_enabled_ui(self.device.input_edits.enabled, |ui| { + ui.add_enabled_ui(self.device.local_source_editing, |ui| { ui.horizontal(|ui| { ui.label(tr(ui.ctx(), "ui.editor-input")); egui::ComboBox::from_id_salt("source-id").selected_text(format!("Input {}",d.source_id+1)).show_ui(ui,|ui| { @@ -502,7 +502,7 @@ impl Editor { _=>{} } let pending = d.pending(&self.layout); - if apply_button(ui,&tr(ui.ctx(), "action.apply-source"), pending && self.device.input_edits.enabled).clicked() { + if apply_button(ui,&tr(ui.ctx(), "action.apply-source"), pending && self.device.local_source_editing).clicked() { match d.apply(&mut self.layout, position_reference, self.keep_aspect_ratio) { Ok(())=>{self.sync();d=FormatDraft::new(&self.layout,i);},Err(e)=>d.error=e } } ui.small(tr(ui.ctx(), "ui.source-changes-require-apply-switching-tabs-keeps-pending-source-edits")); @@ -1248,7 +1248,7 @@ mod tests { property_tab: PropertyTab::Source, ..Default::default() }; - app.device.input_edits.enabled = true; + app.device.local_source_editing = true; let crop = Crop { left: 20.0, right: 20.0, @@ -1692,18 +1692,9 @@ mod tests { app.format_draft = Some(draft); click_text(&mut app, &ctx, "Apply source changes"); assert_eq!(app.layout.formats(), &before); - assert!(!app.device.input_edits.enabled); - click_text( - &mut app, - &ctx, - "Legacy input proposals / layer-send compatibility", - ); - click_text( - &mut app, - &ctx, - "Edit advanced input settings and include my edits when sending", - ); - assert!(app.device.input_edits.enabled); + assert!(!app.device.local_source_editing); + click_text(&mut app, &ctx, "Edit local source geometry"); + assert!(app.device.local_source_editing); click_text(&mut app, &ctx, "Apply source changes"); assert_eq!(app.layout.formats().input(1).unwrap(), [1920.0, 1000.0]); assert!(!app.device.sending); @@ -1716,7 +1707,7 @@ mod tests { keep_aspect_ratio: false, ..Default::default() }; - app.device.input_edits.enabled = true; + app.device.local_source_editing = true; let ctx = egui::Context::default(); let before = app.layout.layers().clone(); let formats = app.layout.formats().clone(); diff --git a/crates/canvas-pilot/src/gui.rs b/crates/canvas-pilot/src/gui.rs index 0317be2..8328e4f 100644 --- a/crates/canvas-pilot/src/gui.rs +++ b/crates/canvas-pilot/src/gui.rs @@ -7,8 +7,6 @@ mod device_ui; mod document_reference_ui; #[path = "format_ui.rs"] mod format_ui; -#[path = "input_ui.rs"] -mod input_ui; #[path = "inputs_window.rs"] mod inputs_window; #[path = "layers_ui.rs"] @@ -8612,7 +8610,7 @@ mod tests { app.layout.select(Some(0)); app.format_draft = Some(FormatDraft::new(&app.layout, 0)); app.property_tab = PropertyTab::Source; - app.device.input_edits.enabled = true; + app.device.local_source_editing = true; frame(&mut app, &ctx, vec![]); click_text(&mut app, &ctx, "Input 1"); click_text(&mut app, &ctx, "Input 8"); diff --git a/crates/canvas-pilot/src/input_ui.rs b/crates/canvas-pilot/src/input_ui.rs deleted file mode 100644 index 9971d41..0000000 --- a/crates/canvas-pilot/src/input_ui.rs +++ /dev/null @@ -1,626 +0,0 @@ -//! Explicit device edits and separately saved, inactive input-setting proposals. -use super::*; -use canvas_pilot::{ - device::Snapshot, - device_send::{Change, Plan}, -}; -use serde_json::{Value, json}; -use std::collections::{BTreeMap, BTreeSet}; - -#[derive(Default)] -pub(super) struct InputEdits { - pub enabled: bool, - pub saved: Vec, - message: Option, - // Only fields actually edited are staged; opening the tab never stages defaults. - values: BTreeMap, -} - -fn input_path(snapshot: &Snapshot, screen: &str, bank: &str, layer: &str) -> Option { - let input = snapshot.raw.pointer(&format!("/device/screenList/items/{screen}/presetList/items/{bank}/liveLayerList/items/{layer}/source/pp/input"))?.as_str()?; - let base = format!("/device/inputList/items/{input}"); - let plug = snapshot - .raw - .pointer(&format!("{base}/status/pp/plug"))? - .as_str()?; - Some(format!("{base}/plugList/items/{plug}/settings")) -} - -fn setting_label(value: &str) -> String { - match value { - "NATIVE" => "Native".into(), - "SIGNAL" => "Signal".into(), - "CUSTOM" => "Custom".into(), - "LAYER_SETTING" => "Layer setting".into(), - "CENTERED" => "Centered".into(), - "FULLSCREEN" => "Full screen".into(), - "CROPPED" => "Cropped".into(), - "NONE" => "None".into(), - "LETTERBOX_1_78" => "Letterbox 1.78:1".into(), - "LETTERBOX_1_85" => "Letterbox 1.85:1".into(), - "LETTERBOX_2_35" => "Letterbox 2.35:1".into(), - "PILLARBOX_1_33" => "Pillarbox 1.33:1".into(), - _ => value.replace('_', ":"), - } -} - -impl InputEdits { - pub fn clear(&mut self) { - self.enabled = false; - self.values.clear(); - self.message = None; - } - - pub fn show( - &mut self, - ui: &mut egui::Ui, - snapshot: Option<&Snapshot>, - link: Option<&canvas_pilot::DeviceLink>, - layer_id: usize, - ) { - if let Some(saved) = self.saved.iter().find(|p| p.layer_id == layer_id).cloned() { - ui.label(format!( - "Saved proposal: {} · plug {} (inactive until staged)", - saved.input, saved.plug - )); - for (key, value) in &saved.settings { - ui.small(format!("{key}: {value}")); - } - let can_stage = - self.enabled && snapshot.is_some_and(|s| Self::proposal_matches(&saved, s, link)); - if ui - .add_enabled( - can_stage, - egui::Button::new(tr(ui.ctx(), "ui.stage-saved-input-proposal")), - ) - .clicked() - && let Some(snapshot) = snapshot - { - self.message = Some(match self.stage_proposal(&saved, snapshot, link) { - Ok(()) => "Proposal staged. Review mappings before sending.".into(), - Err(error) => error, - }); - } - ui.small(tr(ui.ctx(), "ui.to-stage-connect-match-this-layer-s-saved-mapping-and-routed-input-plug-then-enable-a")); - if ui - .button(tr(ui.ctx(), "ui.remove-saved-input-proposal")) - .clicked() - { - self.saved.retain(|p| p.layer_id != layer_id); - } - } - if let Some(message) = &self.message { - ui.label(message); - } - if snapshot.is_some_and(|s| !s.profile.advanced_inputs()) { - ui.label(tr(ui.ctx(), "ui.shared-input-corrections-for-this-adapter-are-managed-in-webrcs-layer-crop-and-zoom-r")); - return; - } - ui.label(tr( - ui.ctx(), - "ui.advanced-use-only-when-you-need-to-correct-an-input-and-understand-the-effect", - )); - ui.label(tr(ui.ctx(), "ui.these-device-controls-map-one-for-one-to-webrcs-advanced-input-settings-content-ratio")); - ui.label(tr(ui.ctx(), "ui.input-crop-removes-source-edges-before-dynamic-layer-crop-zoom-it-does-not-resize-the")); - if ui - .checkbox( - &mut self.enabled, - tr( - ui.ctx(), - "ui.edit-advanced-input-settings-and-include-my-edits-when-sending", - ), - ) - .changed() - && !self.enabled - { - self.values.clear(); - } - ui.small(tr(ui.ctx(), "ui.off-by-default-only-edited-device-fields-are-sent-and-only-with-layers-using-that-inp")); - let Some((snapshot, base)) = snapshot.and_then(|snapshot| { - let link = link?; - let screen = snapshot.screens.iter().find(|s| s.id == link.screen)?; - input_path(snapshot, &link.screen, &screen.preview_bank, &link.layer) - .map(|base| (snapshot, base)) - }) else { - ui.small(tr(ui.ctx(), "ui.connect-and-map-this-layer-to-a-midra-input-source-to-inspect-its-advanced-settings-n")); - return; - }; - ui.small(format!( - "Shared input: {} · plug {} (from linked Preview layer)", - base.split('/').nth(4).unwrap_or("?"), - base.split('/').nth(7).unwrap_or("?") - )); - ui.add_enabled_ui(self.enabled, |ui| { - for (suffix, label, options) in [ - ( - "aspect/pp/signal", - "Content ratio", - &[ - "NATIVE", "5_4", "4_3", "16_10", "15_9", "16_9", "21_9", "256_135", "64_27", - ][..], - ), - ( - "aspect/pp/transformTo", - "Transform to", - &[ - "SIGNAL", "5_4", "4_3", "16_10", "15_9", "16_9", "21_9", "CUSTOM", - ][..], - ), - ( - "aspect/pp/layerFill", - "Layer fill option", - &["LAYER_SETTING", "1_1", "CENTERED", "FULLSCREEN", "CROPPED"][..], - ), - ( - "cropping/control/pp/predefined", - "Input crop preset", - &[ - "NONE", - "LETTERBOX_1_78", - "LETTERBOX_1_85", - "LETTERBOX_2_35", - "PILLARBOX_1_33", - ][..], - ), - ] { - let path = format!("{base}/{suffix}"); - let Some(original) = snapshot.raw.pointer(&path) else { - continue; - }; - let mut value = self - .values - .get(&path) - .unwrap_or(original) - .as_str() - .unwrap_or_default() - .to_owned(); - let before = value.clone(); - ui.horizontal(|ui| { - ui.label(label); - egui::ComboBox::from_id_salt(&path) - .selected_text(setting_label(&value)) - .show_ui(ui, |ui| { - for option in options { - ui.stable_selectable_value( - &mut value, - (*option).into(), - setting_label(option), - ); - } - }); - }); - if value != before { - self.stage(path, json!(value), original); - } - } - for (suffix, label, min, max, scale) in [ - ( - "aspect/pp/customRatio", - "Custom aspect ratio ", - 250., - 10000., - 0.001, - ), - ( - "cropping/control/pp/left", - "Input crop left ", - 0., - 8191., - 1., - ), - ( - "cropping/control/pp/right", - "Input crop right ", - 0., - 8191., - 1., - ), - ("cropping/control/pp/top", "Input crop top ", 0., 8191., 1.), - ( - "cropping/control/pp/bottom", - "Input crop bottom ", - 0., - 8191., - 1., - ), - ] { - let path = format!("{base}/{suffix}"); - let Some(original) = snapshot.raw.pointer(&path) else { - continue; - }; - let mut value = self - .values - .get(&path) - .unwrap_or(original) - .as_f64() - .unwrap_or_default() - * scale; - if ui - .add( - egui::DragValue::new(&mut value) - .range(min * scale..=max * scale) - .speed(scale) - .prefix(label) - .max_decimals(if scale == 1. { 0 } else { 3 }), - ) - .changed() - { - self.stage(path, json!((value / scale).round() as i64), original); - } - } - }); - let prefix = format!("{base}/"); - let settings: BTreeMap<_, _> = self - .values - .iter() - .filter_map(|(path, value)| { - path.strip_prefix(&prefix) - .map(|key| (key.to_owned(), value.clone())) - }) - .collect(); - if ui - .add_enabled( - !settings.is_empty(), - egui::Button::new(tr( - ui.ctx(), - "ui.save-staged-input-edits-as-a-project-proposal", - )), - ) - .clicked() - && let Some(link) = link - { - let proposal = canvas_pilot::input_proposal::InputProposal { - layer_id, - device_link: link.clone(), - input: base.split('/').nth(4).unwrap_or_default().into(), - plug: base.split('/').nth(7).unwrap_or_default().into(), - settings, - }; - if proposal.validate().is_ok() { - self.saved.retain(|p| p.layer_id != layer_id); - self.saved.push(proposal); - } - } - ui.small(tr(ui.ctx(), "ui.saving-a-proposal-is-opt-in-project-saves-and-extra-parameter-exports-retain-it-reope")); - ui.small(tr(ui.ctx(), "ui.edits-wait-for-send-opening-this-tab-or-enabling-the-checkbox-sends-nothing-refresh-l")); - } - fn proposal_matches( - proposal: &canvas_pilot::input_proposal::InputProposal, - snapshot: &Snapshot, - link: Option<&canvas_pilot::DeviceLink>, - ) -> bool { - proposal.validate().is_ok() - && snapshot.profile.advanced_inputs() - && link == Some(&proposal.device_link) - && snapshot - .screens - .iter() - .find(|s| s.id == proposal.device_link.screen) - .and_then(|s| { - input_path( - snapshot, - &s.id, - &s.preview_bank, - &proposal.device_link.layer, - ) - }) - .as_deref() - == Some(proposal.base().as_str()) - } - fn stage_proposal( - &mut self, - proposal: &canvas_pilot::input_proposal::InputProposal, - snapshot: &Snapshot, - link: Option<&canvas_pilot::DeviceLink>, - ) -> Result<(), String> { - if !self.enabled || !Self::proposal_matches(proposal, snapshot, link) { - return Err( - "Enable edits and verify the saved layer, input and plug mapping first.".into(), - ); - } - let values: Vec<_> = proposal - .settings - .iter() - .map(|(key, value)| { - let path = format!("{}/{key}", proposal.base()); - let original = snapshot - .raw - .pointer(&path) - .ok_or("Refresh device: proposal field unavailable.")? - .clone(); - Ok((path, value.clone(), original)) - }) - .collect::>()?; - for (path, value, original) in values { - self.stage(path, value, &original); - } - Ok(()) - } - fn stage(&mut self, path: String, value: Value, original: &Value) { - if &value == original { - self.values.remove(&path); - } else { - self.values.insert(path, value); - } - } - pub fn extend_plan( - &self, - snapshot: &Snapshot, - mappings: &[(usize, String)], - plan: &mut Plan, - ) -> Result<(), String> { - if !self.enabled || !snapshot.profile.advanced_inputs() { - return Ok(()); - } - let inputs: BTreeSet<_> = mappings - .iter() - .filter_map(|(_, layer)| input_path(snapshot, &plan.screen, &plan.bank, layer)) - .collect(); - let mut changes = Vec::new(); - for (path, after) in &self.values { - if !inputs - .iter() - .any(|base| path.starts_with(&format!("{base}/"))) - { - continue; - } - let before = snapshot - .raw - .pointer(path) - .ok_or("Refresh the device: a staged input setting is unavailable.")?; - if before != after { - changes.push(Change { - path: path - .trim_start_matches('/') - .split('/') - .map(str::to_owned) - .collect(), - before: before.clone(), - after: after.clone(), - }); - } - } - changes.append(&mut plan.changes); - plan.changes = changes; - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use canvas_pilot::device_send::Target; - - fn fixture() -> Snapshot { - Snapshot { - profile: Default::default(), - identity: "Test".into(), - screens: vec![], - raw: json!({"device": {"inputList": {"items": {"INPUT_4": {"status": {"pp": {"plug": "2"}}, "plugList": {"items": {"2": {"settings": {"aspect": {"pp": {"signal": "NATIVE", "transformTo": "SIGNAL", "customRatio": 1333, "layerFill": "LAYER_SETTING"}}, "cropping": {"control": {"pp": {"left": 0, "right": 0, "top": 0, "bottom": 0, "predefined": "NONE", "xUpdate": true}}}}}}}}}}, "screenList": {"items": {"1": {"presetList": {"items": {"UP": {"liveLayerList": {"items": {"1": {"source": {"pp": {"input": "INPUT_4"}}}, "2": {"source": {"pp": {"input": "INPUT_NONE"}}}}}}, "DOWN": {"liveLayerList": {"items": {"1": {"source": {"pp": {"input": "INPUT_NONE"}}}}}}}}}}}}}), - } - } - fn empty_plan() -> Plan { - Plan { - profile: Default::default(), - observed: vec![], - screen: "1".into(), - bank: "UP".into(), - target: Target::Preview, - changes: vec![], - } - } - - #[test] - fn connected_source_controls_open_read_only_and_unchecking_discards_edits() { - let mut snapshot = fixture(); - snapshot.screens.push(canvas_pilot::device::Screen { - id: "1".into(), - resolution: [1920, 1080], - preview_bank: "UP".into(), - program_bank: "DOWN".into(), - layers: vec![], - }); - let link = canvas_pilot::DeviceLink { - family: Default::default(), - screen: "1".into(), - layer: "1".into(), - }; - let ctx = egui::Context::default(); - let mut edits = InputEdits::default(); - let mut draw = |edits: &mut InputEdits, events| { - ctx.run_ui( - egui::RawInput { - screen_rect: Some(egui::Rect::from_min_size( - egui::Pos2::ZERO, - egui::vec2(900., 1000.), - )), - events, - ..Default::default() - }, - |root_ui| { - egui::CentralPanel::default().show(root_ui, |ui| { - edits.show(ui, Some(&snapshot), Some(&link), 1) - }); - }, - ) - }; - draw(&mut edits, vec![]); - let output = draw(&mut edits, vec![]); - assert!(!edits.enabled); - assert!(edits.values.is_empty()); - assert!(output.shapes.iter().any(|shape| matches!(&shape.shape, egui::Shape::Text(t) if t.galley.text() == "Content ratio"))); - let pos = output - .shapes - .iter() - .find_map(|shape| match &shape.shape { - egui::Shape::Text(t) - if t.galley.text() - == "Edit advanced input settings and include my edits when sending" => - { - Some(t.pos + egui::vec2(10., 5.)) - } - _ => None, - }) - .unwrap(); - let click = |edits: &mut InputEdits, - draw: &mut dyn FnMut( - &mut InputEdits, - Vec, - ) -> egui::FullOutput| { - draw( - edits, - vec![ - egui::Event::PointerMoved(pos), - super::super::tests::mouse(pos, true), - ], - ); - draw(edits, vec![super::super::tests::mouse(pos, false)]); - }; - click(&mut edits, &mut draw); - assert!(edits.enabled); - assert!(edits.values.is_empty()); - edits.stage("test".into(), json!(40), &json!(0)); - click(&mut edits, &mut draw); - assert!(!edits.enabled); - assert!(edits.values.is_empty()); - } - - #[test] - fn default_enable_only_and_unrelated_layers_never_write_inputs() { - let snapshot = fixture(); - let mappings = [(1, "1".into())]; - let mut edits = InputEdits::default(); - let mut plan = empty_plan(); - edits.extend_plan(&snapshot, &mappings, &mut plan).unwrap(); - assert!(plan.changes.is_empty()); - edits.enabled = true; - edits.extend_plan(&snapshot, &mappings, &mut plan).unwrap(); - assert!(plan.changes.is_empty()); - let path = format!( - "{}/cropping/control/pp/left", - input_path(&snapshot, "1", "UP", "1").unwrap() - ); - edits.stage(path.clone(), json!(40), &json!(0)); - edits - .extend_plan(&snapshot, &[(2, "2".into())], &mut plan) - .unwrap(); - assert!(plan.changes.is_empty()); - edits.extend_plan(&snapshot, &mappings, &mut plan).unwrap(); - assert_eq!(plan.changes.len(), 1); - assert_eq!(plan.changes[0].path.join("/"), path.trim_start_matches('/')); - assert_eq!(plan.changes[0].after, json!(40)); - // Program has a different routed source and must not receive Preview input edits. - let mut program = empty_plan(); - program.bank = "DOWN".into(); - program.target = Target::Program; - edits - .extend_plan(&snapshot, &mappings, &mut program) - .unwrap(); - assert!(program.changes.is_empty()); - edits.enabled = false; - let mut disabled = empty_plan(); - edits - .extend_plan(&snapshot, &mappings, &mut disabled) - .unwrap(); - assert!(disabled.changes.is_empty()); - edits.clear(); - assert!(edits.values.is_empty()); - assert!(!edits.enabled); - } - - #[test] - fn reverted_values_are_not_staged_and_duplicate_routes_are_written_once() { - let snapshot = fixture(); - let path = format!( - "{}/aspect/pp/transformTo", - input_path(&snapshot, "1", "UP", "1").unwrap() - ); - let mut edits = InputEdits { - enabled: true, - ..Default::default() - }; - edits.stage(path.clone(), json!("16_9"), &json!("SIGNAL")); - let mut plan = empty_plan(); - edits - .extend_plan(&snapshot, &[(1, "1".into()), (2, "1".into())], &mut plan) - .unwrap(); - assert_eq!(plan.changes.len(), 1); - edits.stage(path, json!("SIGNAL"), &json!("SIGNAL")); - assert!(edits.values.is_empty()); - } - #[test] - fn restored_proposals_are_inert_and_stage_only_after_route_and_field_review() { - let mut snapshot = fixture(); - snapshot.screens.push(canvas_pilot::device::Screen { - id: "1".into(), - resolution: [1920, 1080], - preview_bank: "UP".into(), - program_bank: "DOWN".into(), - layers: vec![], - }); - let proposal = canvas_pilot::input_proposal::InputProposal { - layer_id: 1, - device_link: canvas_pilot::DeviceLink { - family: Default::default(), - screen: "1".into(), - layer: "1".into(), - }, - input: "INPUT_4".into(), - plug: "2".into(), - settings: [ - ("aspect/pp/transformTo".into(), json!("CUSTOM")), - ("aspect/pp/customRatio".into(), json!(1778)), - ] - .into(), - }; - let mut edits = InputEdits { - saved: vec![proposal.clone()], - ..Default::default() - }; - let link = Some(&proposal.device_link); - let mut plan = empty_plan(); - edits - .extend_plan(&snapshot, &[(1, "1".into())], &mut plan) - .unwrap(); - assert!(plan.changes.is_empty()); - assert!(edits.stage_proposal(&proposal, &snapshot, link).is_err()); - edits.enabled = true; - edits - .extend_plan(&snapshot, &[(1, "1".into())], &mut plan) - .unwrap(); - assert!( - plan.changes.is_empty(), - "Enabling alone must not stage saved data" - ); - let mut wrong = proposal.clone(); - wrong.input = "INPUT_9".into(); - assert!(edits.stage_proposal(&wrong, &snapshot, link).is_err()); - assert!(edits.stage_proposal(&proposal, &snapshot, None).is_err()); - let mut missing = snapshot.clone(); - missing - .raw - .pointer_mut("/device/inputList/items/INPUT_4/plugList/items/2/settings/aspect/pp") - .unwrap() - .as_object_mut() - .unwrap() - .remove("transformTo"); - assert!(edits.stage_proposal(&proposal, &missing, link).is_err()); - assert!( - edits.values.is_empty(), - "Missing fields reject staging atomically" - ); - edits.stage_proposal(&proposal, &snapshot, link).unwrap(); - edits - .extend_plan(&snapshot, &[(1, "1".into())], &mut plan) - .unwrap(); - assert_eq!(plan.changes.len(), 2); - assert!(plan.changes.iter().all(|c| { - c.path - .join("/") - .starts_with("device/inputList/items/INPUT_4/plugList/items/2/settings/aspect/pp/") - })); - edits.clear(); - assert!(!edits.enabled && edits.values.is_empty()); - assert_eq!(edits.saved, vec![proposal]); - } -} diff --git a/crates/canvas-pilot/src/localization.rs b/crates/canvas-pilot/src/localization.rs index 114a9a8..1e9ac88 100644 --- a/crates/canvas-pilot/src/localization.rs +++ b/crates/canvas-pilot/src/localization.rs @@ -504,7 +504,6 @@ mod tests { include_str!("capture_ui.rs"), include_str!("layers_ui.rs"), include_str!("format_ui.rs"), - include_str!("input_ui.rs"), include_str!("ratio_ui.rs"), include_str!("reference_ui.rs"), include_str!("recovery_ui.rs"), diff --git a/crates/canvas-pilot/src/project_ui.rs b/crates/canvas-pilot/src/project_ui.rs index 0ab152a..40dfbb9 100644 --- a/crates/canvas-pilot/src/project_ui.rs +++ b/crates/canvas-pilot/src/project_ui.rs @@ -85,8 +85,7 @@ impl Editor { let mut p = Project::from_layout(&self.layout); p.input_proposals = self .device - .input_edits - .saved + .saved_input_proposals .iter() .filter(|proposal| { p.layers.iter().any(|l| { @@ -162,8 +161,8 @@ impl Editor { } = prepared; let e = project.editor; self.device.reset_mappings(); - self.device.input_edits.clear(); - self.device.input_edits.saved = project.input_proposals; + self.device.local_source_editing = false; + self.device.saved_input_proposals = project.input_proposals; self.capture.clear_preview(); let mut layer_ui = layers_ui::LayerUi::default(); layer_ui.collapsed = project.workspace.collapsed_folders.into_iter().collect(); @@ -785,15 +784,15 @@ mod tests { "../../../docs/interfaces/canvas-pilot-v16.example.json" )) .unwrap(); - app.device.input_edits.enabled = true; + app.device.local_source_editing = true; app.install_project(&ctx, project.clone()).unwrap(); - assert!(!app.device.input_edits.enabled); + assert!(!app.device.local_source_editing); assert_eq!(app.project().input_proposals, project.input_proposals); app.layout.set_device_link(0, None).unwrap(); assert!(app.project().input_proposals.is_empty()); app.install_project(&ctx, Project::from_layout(&Layout::default())) .unwrap(); - assert!(app.device.input_edits.saved.is_empty()); + assert!(app.device.saved_input_proposals.is_empty()); } #[test] diff --git a/docs/canvas-pilot/changelog.md b/docs/canvas-pilot/changelog.md index 0ecab91..bb5c941 100644 --- a/docs/canvas-pilot/changelog.md +++ b/docs/canvas-pilot/changelog.md @@ -4,6 +4,13 @@ ## Unreleased +### v0.9.56 + +- Removed legacy input proposal controls and the input-setting additions to layer + sends. Native device edits now use the shared Input settings window exclusively. + Local source geometry has its own editor-only permission. Existing saved + proposals remain preserved and inactive without changing project/export schemas. + ### v0.9.55 - Added a shared **Input settings** window, independent of layer selection, with diff --git a/docs/canvas-pilot/guide/advanced-exchange.md b/docs/canvas-pilot/guide/advanced-exchange.md index ce9e3b2..ecc17f0 100644 --- a/docs/canvas-pilot/guide/advanced-exchange.md +++ b/docs/canvas-pilot/guide/advanced-exchange.md @@ -29,7 +29,7 @@ means a supported exchange format exported with extra parameters and reopened th | Editable blanking masks (Layer / Source) | ✅ | ❌ | ✅ | | Resize pivots and group resize settings | ✅ | ❌ | ✅ | | Saved device screen/layer links (not physical source routing) | ✅ | ❌ | ✅ | -| Opt-in saved device input correction proposals, restored inactive | ✅ | ❌ | ✅ | +| Previously saved input correction proposals, preserved inactive | ✅ | ❌ | ✅ | | Reference images and their individual settings | ✅ | ❌ | ❌ | | Capture assignments and saved preview stills | ✅ | ❌ | ❌ | | Selection, camera, guides, snapping and workspace settings | ✅ | ❌ | ✅ [2](#editing-notes) | @@ -60,22 +60,14 @@ This is separate from plain geometry import and export snapshot restoration. ## Saved input corrections -In the advanced input controls, explicitly choose **Save staged input edits as a -project proposal** to retain the corrections you have staged. Projects save these -proposals; Silver exports include them only when **Include extra Canvas Pilot -parameters (experimental)** is enabled. Saving a proposal is optional and separate -from staging or sending it. +Previously saved input correction proposals remain preserved in projects and in +Silver exports with **Include extra Canvas Pilot parameters (experimental)**. +They remain inactive: the legacy controls for creating, staging and sending them +have been removed. No saved proposal automatically changes an input. -Proposals cover Content ratio, Transform to, custom ratio, layer fill, input crop -preset and the four input crop edges. Local source dimensions/crops and shared -source assignments already belong to the project and need no proposal. - -Opening a project or restoring a snapshot leaves corrections **inactive**. Connect, -check the layer's device mapping and routed input/plug, enable advanced input edits, -and choose **Stage saved input proposal**. Review before sending. A changed mapping, -input/plug or missing device field prevents staging. Corrections affect shared -inputs and can therefore affect other layers and Program. Removing a saved proposal -does not undo device changes or discard separately staged edits. +For new device edits, use [Input settings…](formats-and-crop.md#shared-device-input-settings). +Its drafts are session-only and require their own explicit review and send. Local +source dimensions/crops and shared source assignments still belong to the project. For practical examples across editors, see [what gets lost between formats](conversion-losses.md). diff --git a/docs/canvas-pilot/guide/files.md b/docs/canvas-pilot/guide/files.md index 82cff3d..9aeeb61 100644 --- a/docs/canvas-pilot/guide/files.md +++ b/docs/canvas-pilot/guide/files.md @@ -370,7 +370,7 @@ Midra layer lists omit unassigned source slots (`NONE` or empty). Assigned input Destination choices in **Midra mapping & transfer…** 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. The direct send button is available beside Midra mapping & transfer and in Export; in **All layers** scope it includes unselected, hidden and locked linked layers, grouped by screen. Its label changes to **Send selected links** or **Send folder links** in those scopes. Midra mapping & transfer… opens mapping configuration for the current scope. 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. +Every explicit layer-layout send 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. @@ -451,7 +451,7 @@ refresh reopens paused until you capture or resume it explicitly. Connection history, startup connection, theme and Program permission remain in application preferences. Unsaved drafts, undo history, open menus, active editing gestures and pending device operations are temporary. Transfer scope, target bank, -sizing strategy and the permission to send advanced input edits remain session choices. +sizing strategy and shared input-window drafts remain session choices. Explicitly saved input correction proposals persist, but always reopen inactive. See [saved input corrections](advanced-exchange.md#saved-input-corrections). See the [complete persistence audit](../../interfaces/canvas-pilot-persistence-audit.md) diff --git a/docs/canvas-pilot/guide/formats-and-crop.md b/docs/canvas-pilot/guide/formats-and-crop.md index 2c2f662..5650750 100644 --- a/docs/canvas-pilot/guide/formats-and-crop.md +++ b/docs/canvas-pilot/guide/formats-and-crop.md @@ -123,29 +123,14 @@ Pending changes make Apply solid purple. This applies to position/size, output resolution drafts, source/input formats, names/folders, and mapped imports. Each section tracks its own values; reverting an edit clears its pending state. -**Source is an advanced section**, disabled until **Edit advanced input settings -and include my edits when sending** is checked. Its device controls mirror the -linked Preview layer's current input and active plug in WebRCS Advanced Input: -content ratio, transform ratio, custom ratio, layer fill, input crop preset and -four pixel crop edges. Usually keep these settings on the Midra. Input crop -runs before dynamic layer crop/zoom without resizing the layer bounding box; -this is device processing, not an editor-only effect. Inputs are shared, so an -input edit can also affect other layers and Program. +**Source** links to the [shared Input settings window](#shared-device-input-settings) +for native device preprocessing. These input-only edits require their own explicit +review and send; a layer-layout send never includes them. -Opening Source, checking the box, or changing a value does not send. Only fields -actually edited are staged for the next explicit Send, and only when that send -includes a destination routed to the same input/plug. Untouched aspect/crop -settings stay as they are on the machine. Unchecking discards staged edits. -The permission and staged device edits are session-only: disconnecting, changing the device -address or loading a project clears them. Source routing is never changed. -Refresh/load after sending to inspect the resulting device content dimensions. - -The separately labeled **Editor source model (local geometry)** retains the -existing offline format/input-resolution calculations, also gated by the checkbox. -Its native dimensions are metadata, not device timing commands. Its local input -correction still folds into exported *layer* crop; it does not configure the -shared hardware input. Apply source changes commits this local model, whereas -the device controls above wait for Send. +**Edit local source geometry** unlocks the separate offline source model. Its +native dimensions are metadata, not device timing commands. Local input correction +still folds into exported *layer* crop; it does not configure the shared hardware +input. **Apply source changes** commits this local model only. Layer properties has five tabs: **Source** for native/input resolution and input crop, **Layer** for the final visible box, **Crop** for content zoom and offset, @@ -318,8 +303,8 @@ layer cropping or masking. They can correct stretched content, but an arbitrary ratio can also introduce distortion. Leave Native / Signal Aspect Ratio unless correction is intentional. -Canvas Pilot already exposes both device selectors under **Source → Edit -advanced input settings**, with Custom ratio encoded in thousandths (0.250–10.000). +Canvas Pilot exposes both device selectors in **Input settings…**, with Custom +ratio displayed as 0.250–10.000:1 and encoded in thousandths. They are staged device controls, not persistent local image deformation. Merely opening the controls never writes. A local source resolution is a separate quantity and should not be changed just to pretend a ratio correction occurred. @@ -363,6 +348,7 @@ input replaces its draft with device values. If another controller, signal or pl changes, refresh and review before sending. After changing input geometry, reload its affected layers before sending their layout. -Existing local source geometry and saved inactive input proposals remain under -**Legacy input proposals / layer-send compatibility**. Their previous save/export -behavior is preserved. They are distinct from this window's native input edits. +Local source geometry remains available through **Edit local source geometry** +in the Source tab. Older saved input proposals are preserved as inactive data; +the legacy proposal editing/staging controls have been removed. Neither is sent +by the shared input window unless you explicitly enter and review device edits. diff --git a/docs/development/input-settings-refactor.task.md b/docs/development/input-settings-refactor.task.md index 102966d..302f559 100644 --- a/docs/development/input-settings-refactor.task.md +++ b/docs/development/input-settings-refactor.task.md @@ -62,8 +62,7 @@ Neither observation establishes physical-device capture pipeline behavior. The current window uses session-only, per-input drafts. Existing project source geometry and inert input proposals remain compatible; they have not been migrated -into a new persistent input schema. Legacy layer-send proposals remain behind a -compatibility expander. New input-window edits never add local layer crop/zoom. +into a new persistent input schema. Legacy layer-send proposal controls and staging were removed in v0.9.56. New input-window edits never add local layer crop/zoom. Aquilon definitions were checked against its served WebRCS app and native state: unsigned color values, KEEP_INPUT_RATIO, larger horizontal crop range, aspect @@ -72,8 +71,9 @@ and targeted; ordinary layout fetches do not acquire these additional controls. ## Refactor boundaries -- `input_ui.rs`: current drafts/proposals are reached through a layer's mapped - Preview input. Extract input/plug identity and controls from layer selection. +- Completed: removed `input_ui.rs` and legacy layer-bound staging controls. + `device_inputs.rs` and `inputs_window.rs` own the shared input-editing path; + stored proposals remain inert compatibility data. - `device_send.rs`: local source input crop is currently added to layer crop. Do not simply remove that addition: existing projects depend on its geometry. - `formats.rs` and `Layout::configure`: shared local source edits reframe consumers; diff --git a/docs/interfaces/midra-device-send.md b/docs/interfaces/midra-device-send.md index f1061ba..34da21f 100644 --- a/docs/interfaces/midra-device-send.md +++ b/docs/interfaces/midra-device-send.md @@ -182,7 +182,11 @@ linked sends and loads skip the layer. These edits are undoable and never issue device commands. Connected selectors use discovered screens/layers; offline editing accepts positive numeric IDs. Project schema and version are unchanged. -## Opt-in advanced input edits (transient) +## Historical opt-in advanced input edits (through v0.9.55) + +Removed in v0.9.56: these UI/staging controls and their layer-plan extension no +longer exist. Existing saved proposals remain inert and round-trip as before. +The independent shared-input editor below is the only device-input editing path. The Source tab's device controls map one-for-one to the installed WebRCS Advanced Input settings. They are separate from the editor's local source model @@ -297,7 +301,7 @@ without changing editor sources, layer geometry, routing or preset selection. Only edited fields are sent after fresh signal/plug/settings checks; readback is verified. There is no automatic retry, rollback or preset-apply pulse. Partial failures are reported and require refresh. This does not migrate existing source -geometry or saved layer-bound input proposals; that compatibility path remains. +geometry or saved layer-bound input proposals; only their saved data and local geometry compatibility remain. Aquilon 6.2 uses `IN_N`, `KEEP_INPUT_RATIO` and unsigned 0–255 color controls (neutral 128), with hue 90–270 (neutral 180). Midra uses `INPUT_N`, `SIGNAL`, signed @@ -328,3 +332,11 @@ Manual diagnostic: `cargo run -p canvas-pilot --example check_device_inputs -- H changes Input 1 crop and restores the original values. Run only against an expressly authorized test device. An optional second argument saves before/after PNGs in an existing temporary directory. It is never part of CI or physical-output acceptance. + +### Removal of legacy controls (v0.9.56) + +Layer send plans no longer accept staged input-setting extensions. Shared-input +sends remain separate and explicit. The local source-model permission is now an +independent editor-only checkbox. Existing serialized `input_proposals` are retained +and filtered by the same layer/link identity rules, but cannot be activated by the +removed UI. No project, recovery or exchange schema/version change is required.