Capture Midra input stills and load reference projects asynchronously
This commit is contained in:
parent
3eccae3b80
commit
839e2154d1
|
|
@ -0,0 +1,219 @@
|
|||
use super::*;
|
||||
use midra_layout::device_capture;
|
||||
type CaptureJob = std::sync::mpsc::Receiver<Result<super::super::reference::Reference, String>>;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct CaptureUi {
|
||||
pub open: bool,
|
||||
input: u32,
|
||||
host: String,
|
||||
pending: Option<CaptureJob>,
|
||||
preview: Option<super::super::reference::Reference>,
|
||||
error: String,
|
||||
last_request: Option<std::time::Instant>,
|
||||
discard_result: bool,
|
||||
}
|
||||
impl CaptureUi {
|
||||
pub(super) fn clear_preview(&mut self) {
|
||||
self.preview = None;
|
||||
self.open = false;
|
||||
self.discard_result = true;
|
||||
}
|
||||
fn cooling_down(&self) -> bool {
|
||||
self.last_request
|
||||
.is_some_and(|t| t.elapsed() < std::time::Duration::from_secs(5))
|
||||
}
|
||||
}
|
||||
impl Editor {
|
||||
pub(super) fn capture_window(&mut self, ctx: &egui::Context) {
|
||||
if self.capture.host != self.device.host || !self.device.online() {
|
||||
self.capture.discard_result = true;
|
||||
self.capture.preview = None;
|
||||
self.capture.host = self.device.host.clone();
|
||||
}
|
||||
if let Some(rx) = &self.capture.pending {
|
||||
let result = match rx.try_recv() {
|
||||
Ok(result) => Some(result),
|
||||
Err(std::sync::mpsc::TryRecvError::Empty) => None,
|
||||
Err(_) => Some(Err("Input capture stopped unexpectedly.".into())),
|
||||
};
|
||||
if let Some(result) = result {
|
||||
self.capture.pending = None;
|
||||
if self.capture.discard_result {
|
||||
self.capture.discard_result = false;
|
||||
} else {
|
||||
match result {
|
||||
Ok(reference) => self.capture.preview = Some(reference),
|
||||
Err(error) => self.capture.error = error,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !self.capture.open {
|
||||
return;
|
||||
}
|
||||
let cooling_down = self.capture.cooling_down();
|
||||
let inputs = self
|
||||
.device
|
||||
.snapshot
|
||||
.as_ref()
|
||||
.map(device_capture::inputs)
|
||||
.unwrap_or_default();
|
||||
if !inputs.iter().any(|i| i.id == self.capture.input) {
|
||||
self.capture.input = inputs
|
||||
.iter()
|
||||
.find(|i| i.signal && i.enabled)
|
||||
.or(inputs.first())
|
||||
.map(|i| i.id)
|
||||
.unwrap_or(0);
|
||||
}
|
||||
let mut open = true;
|
||||
let mut capture = false;
|
||||
let mut add = false;
|
||||
egui::Window::new("Capture Midra input").open(&mut open).default_width(560.0).collapsible(false).show(ctx, |ui| {
|
||||
ui.label("Capture a still input preview from WebRCS and add it as a fixed reference image.");
|
||||
ui.small("Snapshots are reduced-resolution images, not a live feed. Their size depends on the device's snapshot settings.");
|
||||
let before = self.capture.input;
|
||||
ui.add_enabled_ui(self.capture.pending.is_none(), |ui| {
|
||||
egui::ComboBox::from_label("Input").selected_text(format!("Input {}", self.capture.input)).show_ui(ui, |ui| {
|
||||
for input in &inputs {
|
||||
ui.selectable_value(&mut self.capture.input, input.id, format!("Input {}{}", input.id, if input.signal { "" } else { " · no signal at last refresh" }));
|
||||
}
|
||||
});
|
||||
});
|
||||
if before != self.capture.input { self.capture.preview = None; self.capture.pending = None; self.capture.error.clear(); }
|
||||
let input = inputs.iter().find(|i| i.id == self.capture.input);
|
||||
if input.is_some_and(|i| !i.enabled) {
|
||||
ui.label("Snapshots are disabled for this input. Enable input snapshots in WebRCS and refresh the connection.");
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
capture = ui.add_enabled(!cooling_down && self.capture.pending.is_none() && input.is_some_and(|i| i.enabled), egui::Button::new("Capture still")).clicked();
|
||||
if self.capture.pending.is_some() {
|
||||
ui.spinner();
|
||||
if ui.button("Cancel capture").clicked() { self.capture.discard_result = true; }
|
||||
}
|
||||
});
|
||||
ui.small("Manual capture only · at most one request every 5 seconds · no background refresh.");
|
||||
if cooling_down { ui.small("Capture available again shortly."); ctx.request_repaint_after(std::time::Duration::from_secs(1)); }
|
||||
if let Some(reference) = &self.capture.preview {
|
||||
ui.label(format!("{} · {} × {} px", reference.name, reference.size[0], reference.size[1]));
|
||||
ui.add(egui::Image::new(&reference.texture).max_size(Vec2::new(512.0, 320.0)));
|
||||
if let Some((severe, warning)) = reference.warning(self.layout.formats().output) {
|
||||
ui.colored_label(if severe { ui.visuals().error_fg_color } else { theme::palette(ctx).amber }, warning);
|
||||
}
|
||||
add = ui.button("Add as reference").clicked();
|
||||
}
|
||||
if !self.capture.error.is_empty() { ui.colored_label(ui.visuals().error_fg_color, &self.capture.error); }
|
||||
});
|
||||
self.capture.open = open;
|
||||
if !open {
|
||||
self.capture.discard_result = true;
|
||||
}
|
||||
if capture {
|
||||
self.capture.last_request = Some(std::time::Instant::now());
|
||||
self.capture.discard_result = false;
|
||||
self.capture.preview = None;
|
||||
self.capture.error.clear();
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
self.capture.pending = Some(rx);
|
||||
let host = self.device.host.clone();
|
||||
let input = self.capture.input;
|
||||
let ctx = ctx.clone();
|
||||
std::thread::spawn(move || {
|
||||
let result = device_capture::capture(&host, input).and_then(|bytes| {
|
||||
super::super::reference::Reference::load(
|
||||
&ctx,
|
||||
&egui::DroppedFile {
|
||||
name: format!("Midra input {input} · {host}"),
|
||||
bytes: Some(bytes.into()),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
});
|
||||
let _ = tx.send(result);
|
||||
ctx.request_repaint();
|
||||
});
|
||||
}
|
||||
if add && let Some(reference) = self.capture.preview.take() {
|
||||
if self.references.len() + self.reference_pending.len() >= 32
|
||||
|| self.references.iter().map(|r| r.bytes.len()).sum::<usize>()
|
||||
+ reference.bytes.len()
|
||||
> 64 * 1024 * 1024
|
||||
{
|
||||
self.capture.error = "Reference image limit reached; remove an image first.".into();
|
||||
self.capture.preview = Some(reference);
|
||||
} else {
|
||||
self.references.push(reference);
|
||||
self.reference_selected = Some(self.references.len() - 1);
|
||||
self.capture.open = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::tests::{click_text, frame};
|
||||
use super::*;
|
||||
#[test]
|
||||
fn capture_is_manual_throttled_and_only_adds_on_request() {
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = Editor::default();
|
||||
app.device.host = "127.0.0.1".into();
|
||||
app.device.snapshot = Some(midra_layout::device::Snapshot {
|
||||
identity: "Test".into(),
|
||||
screens: vec![],
|
||||
raw: serde_json::json!({"device":{"inputList":{"items":{"INPUT_3":{"status":{"pp":{"isAvailable":true,"plug":"1"}},"snapshot":{"pp":{"enable":true}}}}}}}),
|
||||
});
|
||||
app.capture.host = app.device.host.clone();
|
||||
app.capture.open = true;
|
||||
let mut bytes = std::io::Cursor::new(Vec::new());
|
||||
image::RgbaImage::from_pixel(2, 2, image::Rgba([255, 0, 0, 255]))
|
||||
.write_to(&mut bytes, image::ImageFormat::Png)
|
||||
.unwrap();
|
||||
let reference = super::super::super::reference::Reference::load(
|
||||
&ctx,
|
||||
&egui::DroppedFile {
|
||||
name: "Captured input".into(),
|
||||
bytes: Some(bytes.into_inner().into()),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
app.capture.pending = Some(rx);
|
||||
app.capture.last_request = Some(std::time::Instant::now());
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
assert!(app.capture.cooling_down());
|
||||
assert!(app.references.is_empty());
|
||||
tx.send(Ok(reference)).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
assert!(app.capture.preview.is_some());
|
||||
assert!(app.references.is_empty());
|
||||
let requested = app.capture.last_request;
|
||||
click_text(&mut app, &ctx, "Capture still");
|
||||
assert!(app.capture.pending.is_none());
|
||||
assert_eq!(app.capture.last_request, requested);
|
||||
click_text(&mut app, &ctx, "Add as reference");
|
||||
assert_eq!(app.references.len(), 1);
|
||||
assert_eq!(app.project().references.len(), 1);
|
||||
assert!(!app.capture.open);
|
||||
app.capture.last_request =
|
||||
Some(std::time::Instant::now() - std::time::Duration::from_secs(6));
|
||||
assert!(!app.capture.cooling_down());
|
||||
}
|
||||
#[test]
|
||||
fn cancelling_keeps_request_in_flight_and_discards_its_result() {
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = Editor::default();
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
app.capture.pending = Some(rx);
|
||||
app.capture.clear_preview();
|
||||
assert!(app.capture.pending.is_some());
|
||||
tx.send(Err("cancelled response".into())).unwrap();
|
||||
app.capture_window(&ctx);
|
||||
assert!(app.capture.pending.is_none());
|
||||
assert!(app.capture.error.is_empty());
|
||||
assert!(app.references.is_empty());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,179 @@
|
|||
//! Explicit, bounded reads of WebRCS input snapshot PNGs.
|
||||
use crate::device::Snapshot;
|
||||
use std::{io::Read, net::IpAddr, time::Duration};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Input {
|
||||
pub id: u32,
|
||||
pub signal: bool,
|
||||
pub enabled: bool,
|
||||
}
|
||||
pub fn inputs(snapshot: &Snapshot) -> Vec<Input> {
|
||||
let Some(items) = snapshot
|
||||
.raw
|
||||
.pointer("/device/inputList/items")
|
||||
.and_then(|v| v.as_object())
|
||||
else {
|
||||
return Vec::new();
|
||||
};
|
||||
let mut inputs: Vec<_> = items
|
||||
.iter()
|
||||
.filter_map(|(key, value)| {
|
||||
if !value.pointer("/status/pp/isAvailable")?.as_bool()? {
|
||||
return None;
|
||||
}
|
||||
let id = key.strip_prefix("INPUT_")?.parse::<u32>().ok()?;
|
||||
if !(1..=16).contains(&id) {
|
||||
return None;
|
||||
}
|
||||
let plug = value.pointer("/status/pp/plug")?.as_str()?;
|
||||
Some(Input {
|
||||
id,
|
||||
signal: value
|
||||
.pointer(&format!("/plugList/items/{plug}/status/signal/pp/isValid"))
|
||||
.and_then(|v| v.as_bool())
|
||||
.unwrap_or(false),
|
||||
enabled: value
|
||||
.pointer("/snapshot/pp/enable")
|
||||
.and_then(|v| v.as_bool())
|
||||
.unwrap_or(false),
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
inputs.sort_by_key(|input| input.id);
|
||||
inputs
|
||||
}
|
||||
|
||||
/// A single on-demand GET; no routing, capture-library or device-setting writes.
|
||||
pub fn capture(host: &str, input: u32) -> Result<Vec<u8>, String> {
|
||||
if !(1..=16).contains(&input) {
|
||||
return Err("Select an input between 1 and 16.".into());
|
||||
}
|
||||
let ip: IpAddr = host
|
||||
.trim()
|
||||
.parse()
|
||||
.map_err(|_| "Enter a device IP address.")?;
|
||||
let authority = match ip {
|
||||
IpAddr::V4(ip) => ip.to_string(),
|
||||
IpAddr::V6(ip) => format!("[{ip}]"),
|
||||
};
|
||||
read_image(&format!(
|
||||
"http://{authority}/api/device/snapshots/inputs/{input}"
|
||||
))
|
||||
}
|
||||
fn read_image(url: &str) -> Result<Vec<u8>, String> {
|
||||
const LIMIT: u64 = 16 * 1024 * 1024;
|
||||
let client = reqwest::blocking::Client::builder()
|
||||
.timeout(Duration::from_secs(20))
|
||||
.connect_timeout(Duration::from_secs(5))
|
||||
.no_proxy()
|
||||
.redirect(reqwest::redirect::Policy::none())
|
||||
.build()
|
||||
.map_err(|e| e.to_string())?;
|
||||
let response = client
|
||||
.get(url)
|
||||
.header("Cache-Control", "no-cache")
|
||||
.send()
|
||||
.and_then(|r| r.error_for_status())
|
||||
.map_err(|e| format!("Cannot capture input preview: {e}"))?;
|
||||
if !response.status().is_success() {
|
||||
return Err("The snapshot endpoint redirected instead of returning an image.".into());
|
||||
}
|
||||
if response.content_length().is_some_and(|size| size > LIMIT) {
|
||||
return Err("Input preview exceeds 16 MiB.".into());
|
||||
}
|
||||
let mut bytes = Vec::new();
|
||||
response
|
||||
.take(LIMIT + 1)
|
||||
.read_to_end(&mut bytes)
|
||||
.map_err(|e| e.to_string())?;
|
||||
if bytes.len() as u64 > LIMIT {
|
||||
return Err("Input preview exceeds 16 MiB.".into());
|
||||
}
|
||||
if !bytes.starts_with(b"\x89PNG\r\n\x1a\n") {
|
||||
return Err("Midra did not return a PNG input preview. Check input signal and WebRCS snapshot availability.".into());
|
||||
}
|
||||
Ok(bytes)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
fn response(status: &str, headers: &str, bytes: &[u8]) -> Result<Vec<u8>, String> {
|
||||
let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let url = format!(
|
||||
"http://{}/api/device/snapshots/inputs/3",
|
||||
listener.local_addr().unwrap()
|
||||
);
|
||||
let reply = format!("HTTP/1.1 {status}\r\nConnection: close\r\n{headers}\r\n");
|
||||
let bytes = bytes.to_vec();
|
||||
let server = std::thread::spawn(move || {
|
||||
let (mut stream, _) = listener.accept().unwrap();
|
||||
let mut reader = BufReader::new(stream.try_clone().unwrap());
|
||||
let mut line = String::new();
|
||||
reader.read_line(&mut line).unwrap();
|
||||
assert_eq!(line, "GET /api/device/snapshots/inputs/3 HTTP/1.1\r\n");
|
||||
loop {
|
||||
line.clear();
|
||||
reader.read_line(&mut line).unwrap();
|
||||
if line == "\r\n" {
|
||||
break;
|
||||
}
|
||||
}
|
||||
stream.write_all(reply.as_bytes()).unwrap();
|
||||
let _ = stream.write_all(&bytes);
|
||||
});
|
||||
let result = read_image(&url);
|
||||
server.join().unwrap();
|
||||
result
|
||||
}
|
||||
#[test]
|
||||
fn snapshot_reads_are_bounded_and_reject_errors_redirects_and_non_images() {
|
||||
let png = b"\x89PNG\r\n\x1a\n";
|
||||
assert_eq!(
|
||||
response("200 OK", "Content-Length: 8\r\n", png).unwrap(),
|
||||
png
|
||||
);
|
||||
assert!(response("200 OK", "Content-Length: 3\r\n", b"bad").is_err());
|
||||
assert!(response("503 Unavailable", "Content-Length: 0\r\n", b"").is_err());
|
||||
assert!(
|
||||
response(
|
||||
"302 Found",
|
||||
"Location: http://127.0.0.1/other\r\nContent-Length: 0\r\n",
|
||||
b""
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(response("200 OK", "Content-Length: 16777217\r\n", b"").is_err());
|
||||
assert!(capture("not a host", 1).is_err());
|
||||
assert!(capture("127.0.0.1", 0).is_err());
|
||||
}
|
||||
#[test]
|
||||
fn input_choices_use_available_hardware_and_current_plug_signal() {
|
||||
let snapshot = Snapshot {
|
||||
identity: String::new(),
|
||||
screens: vec![],
|
||||
raw: serde_json::json!({"device":{"inputList":{"items":{
|
||||
"INPUT_3":{"status":{"pp":{"isAvailable":true,"plug":"2"}},"snapshot":{"pp":{"enable":true}},"plugList":{"items":{"2":{"status":{"signal":{"pp":{"isValid":true}}}}}}},
|
||||
"INPUT_2":{"status":{"pp":{"isAvailable":true,"plug":"1"}}},
|
||||
"INPUT_11":{"status":{"pp":{"isAvailable":false,"plug":"1"}}}
|
||||
}}}}),
|
||||
};
|
||||
assert_eq!(
|
||||
inputs(&snapshot),
|
||||
vec![
|
||||
Input {
|
||||
id: 2,
|
||||
signal: false,
|
||||
enabled: false
|
||||
},
|
||||
Input {
|
||||
id: 3,
|
||||
signal: true,
|
||||
enabled: true
|
||||
}
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ pub(super) struct DeviceUi {
|
|||
message: String,
|
||||
pub(super) host: String,
|
||||
pending: Option<Receiver<Result<device::Snapshot, String>>>,
|
||||
snapshot: Option<device::Snapshot>,
|
||||
pub(super) snapshot: Option<device::Snapshot>,
|
||||
loading: Option<Vec<(usize, midra_layout::MidraLink)>>,
|
||||
screen: usize,
|
||||
destinations: Vec<Destination>,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
use super::*;
|
||||
#[path = "capture_ui.rs"]
|
||||
mod capture_ui;
|
||||
#[path = "device_ui.rs"]
|
||||
mod device_ui;
|
||||
#[path = "format_ui.rs"]
|
||||
|
|
@ -39,6 +41,7 @@ enum NavigationTool {
|
|||
|
||||
pub struct Editor {
|
||||
device: device_ui::DeviceUi,
|
||||
capture: capture_ui::CaptureUi,
|
||||
layer_ui: layers_ui::LayerUi,
|
||||
settings: settings::Store,
|
||||
recovery: recovery_ui::Recovery,
|
||||
|
|
@ -260,6 +263,7 @@ impl Default for Editor {
|
|||
fn default() -> Self {
|
||||
let mut this = Self {
|
||||
device: Default::default(),
|
||||
capture: Default::default(),
|
||||
layer_ui: Default::default(),
|
||||
settings: settings::Store::default(),
|
||||
recovery: recovery_ui::Recovery::default(),
|
||||
|
|
@ -3213,7 +3217,9 @@ impl Editor {
|
|||
{
|
||||
self.apply_fields();
|
||||
}
|
||||
let blocked = self.files.new_requested
|
||||
self.poll_project_job();
|
||||
let blocked = self.files.loading.is_some()
|
||||
|| self.files.new_requested
|
||||
|| self.files.new_after_save
|
||||
|| self.files.new_ready
|
||||
|| (self.fields_edited && self.fields_pending())
|
||||
|
|
@ -3231,8 +3237,10 @@ impl Editor {
|
|||
self.poll_reference();
|
||||
let palette = theme::palette(ctx);
|
||||
let dropped = ctx.input(|i| i.raw.dropped_files.clone());
|
||||
for file in &dropped {
|
||||
self.load_reference(ctx, file);
|
||||
if self.files.loading.is_none() {
|
||||
for file in &dropped {
|
||||
self.load_reference(ctx, file);
|
||||
}
|
||||
}
|
||||
if !blocked {
|
||||
self.shortcuts(ctx);
|
||||
|
|
@ -3323,10 +3331,15 @@ impl Editor {
|
|||
}
|
||||
self.workspace(ui)
|
||||
});
|
||||
if self.files.loading.is_some() {
|
||||
self.project_windows(ctx);
|
||||
return;
|
||||
}
|
||||
self.paste_window(ctx);
|
||||
self.reference_window(ctx);
|
||||
self.output_window(ctx);
|
||||
self.formats_window(ctx);
|
||||
self.capture_window(ctx);
|
||||
self.project_windows(ctx);
|
||||
self.new_project_window(ctx);
|
||||
self.preferences_window(ctx);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
//! Layer geometry, reversible edits and bounded imports.
|
||||
pub mod device;
|
||||
pub mod device_capture;
|
||||
pub mod device_send;
|
||||
use std::collections::HashMap;
|
||||
pub mod exchange;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@ use super::*;
|
|||
use base64::{Engine, engine::general_purpose::STANDARD};
|
||||
use midra_layout::project::{Project, Reference as SavedReference, write_file};
|
||||
use std::path::PathBuf;
|
||||
pub(super) struct PreparedProject {
|
||||
project: Project,
|
||||
layout: Layout,
|
||||
references: Vec<super::super::reference::Reference>,
|
||||
}
|
||||
type LoadedProject = (PreparedProject, Option<PathBuf>, Option<u64>);
|
||||
type ProjectJob = std::sync::mpsc::Receiver<Result<Option<LoadedProject>, String>>;
|
||||
type ExportJob = std::sync::mpsc::Receiver<Result<(PathBuf, Vec<u8>), String>>;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -11,7 +18,9 @@ pub(super) struct FileUi {
|
|||
pub(super) new_requested: bool,
|
||||
pub(super) new_after_save: bool,
|
||||
pub(super) new_ready: bool,
|
||||
opening: Option<(PathBuf, Project)>,
|
||||
opening: Option<PathBuf>,
|
||||
pub(super) loading: Option<ProjectJob>,
|
||||
loading_recovery: bool,
|
||||
writing: Option<(PathBuf, Vec<u8>)>,
|
||||
pub(super) message: Option<String>,
|
||||
exchange_options: midra_layout::exchange::Options,
|
||||
|
|
@ -19,6 +28,34 @@ pub(super) struct FileUi {
|
|||
export_codec: midra_layout::interchange::Codec,
|
||||
export_job: Option<ExportJob>,
|
||||
}
|
||||
impl PreparedProject {
|
||||
fn prepare(ctx: &egui::Context, project: Project) -> Result<Self, String> {
|
||||
let layout = project.layout()?;
|
||||
let references = project
|
||||
.references
|
||||
.iter()
|
||||
.map(|r| {
|
||||
let file = egui::DroppedFile {
|
||||
name: r.name.clone(),
|
||||
bytes: Some(r.bytes()?.into()),
|
||||
..Default::default()
|
||||
};
|
||||
let mut reference = super::super::reference::Reference::load(ctx, &file)?;
|
||||
reference.visible = r.visible;
|
||||
reference.opacity = r.opacity;
|
||||
reference.preserve_ratio = r.preserve_ratio;
|
||||
reference.native_size = r.native_size;
|
||||
reference.offset = r.offset;
|
||||
Ok::<_, String>(reference)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(Self {
|
||||
project,
|
||||
layout,
|
||||
references,
|
||||
})
|
||||
}
|
||||
}
|
||||
impl Editor {
|
||||
pub(super) fn project(&self) -> Project {
|
||||
let mut p = Project::from_layout(&self.layout);
|
||||
|
|
@ -56,31 +93,28 @@ impl Editor {
|
|||
"Wait for the device send and readback before opening another project.".into(),
|
||||
);
|
||||
}
|
||||
let layout = project.layout()?;
|
||||
let references = project
|
||||
.references
|
||||
.iter()
|
||||
.map(|r| {
|
||||
let file = egui::DroppedFile {
|
||||
name: r.name.clone(),
|
||||
bytes: Some(r.bytes()?.into()),
|
||||
..Default::default()
|
||||
};
|
||||
let mut reference = super::super::reference::Reference::load(ctx, &file)?;
|
||||
reference.visible = r.visible;
|
||||
reference.opacity = r.opacity;
|
||||
reference.preserve_ratio = r.preserve_ratio;
|
||||
reference.native_size = r.native_size;
|
||||
reference.offset = r.offset;
|
||||
Ok::<_, String>(reference)
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let prepared = PreparedProject::prepare(ctx, project)?;
|
||||
self.install_prepared(prepared)
|
||||
}
|
||||
fn install_prepared(&mut self, prepared: PreparedProject) -> Result<(), String> {
|
||||
if self.device.sending {
|
||||
return Err(
|
||||
"Wait for the device send and readback before opening another project.".into(),
|
||||
);
|
||||
}
|
||||
let PreparedProject {
|
||||
project,
|
||||
layout,
|
||||
references,
|
||||
} = prepared;
|
||||
let e = project.editor;
|
||||
self.device.reset_mappings();
|
||||
self.device.input_edits.clear();
|
||||
// Replace only after both the document and embedded image are ready.
|
||||
self.capture.clear_preview();
|
||||
// Replace only after both the document and embedded images are ready.
|
||||
*self = Self {
|
||||
device: std::mem::take(&mut self.device),
|
||||
capture: std::mem::take(&mut self.capture),
|
||||
settings: std::mem::take(&mut self.settings),
|
||||
recovery: std::mem::take(&mut self.recovery),
|
||||
snapping: self.snapping,
|
||||
|
|
@ -105,6 +139,79 @@ impl Editor {
|
|||
self.sync();
|
||||
Ok(())
|
||||
}
|
||||
pub(super) fn start_project_job(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
recovery: bool,
|
||||
read: impl FnOnce() -> Result<Option<(Project, Option<PathBuf>, Option<u64>)>, String>
|
||||
+ Send
|
||||
+ 'static,
|
||||
) {
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
self.files.loading = Some(rx);
|
||||
self.files.loading_recovery = recovery;
|
||||
let ctx = ctx.clone();
|
||||
std::thread::spawn(move || {
|
||||
let result = read().and_then(|loaded| {
|
||||
loaded
|
||||
.map(|(project, path, time)| {
|
||||
PreparedProject::prepare(&ctx, project).map(|p| (p, path, time))
|
||||
})
|
||||
.transpose()
|
||||
});
|
||||
let _ = tx.send(result);
|
||||
ctx.request_repaint();
|
||||
});
|
||||
}
|
||||
pub(super) fn poll_project_job(&mut self) {
|
||||
let Some(rx) = &self.files.loading else {
|
||||
return;
|
||||
};
|
||||
let result = match rx.try_recv() {
|
||||
Ok(result) => result,
|
||||
Err(std::sync::mpsc::TryRecvError::Empty) => return,
|
||||
Err(_) => Err("Project reader stopped unexpectedly.".into()),
|
||||
};
|
||||
let recovery = self.files.loading_recovery;
|
||||
self.files.loading = None;
|
||||
let result = result.and_then(|loaded| {
|
||||
if let Some((prepared, path, time)) = loaded {
|
||||
self.install_prepared(prepared)?;
|
||||
self.files.message = Some(if recovery {
|
||||
"Recovery restored".into()
|
||||
} else {
|
||||
format!(
|
||||
"Opened {}",
|
||||
path.as_ref()
|
||||
.map(|p| p.display().to_string())
|
||||
.unwrap_or_default()
|
||||
)
|
||||
});
|
||||
self.files.project_path = path;
|
||||
self.files.manual_saved_at = time;
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
if let Err(error) = result {
|
||||
let message = format!("Cannot open project; current work kept: {error}");
|
||||
if recovery {
|
||||
self.recovery.restore_failed = true;
|
||||
self.recovery.error = Some(format!(
|
||||
"Recovery could not be restored: {error}. The file is preserved."
|
||||
));
|
||||
}
|
||||
self.files.message = Some(message);
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub(super) fn wait_project_job(&mut self) {
|
||||
let until = std::time::Instant::now() + std::time::Duration::from_secs(5);
|
||||
while self.files.loading.is_some() && std::time::Instant::now() < until {
|
||||
self.poll_project_job();
|
||||
std::thread::sleep(std::time::Duration::from_millis(1));
|
||||
}
|
||||
assert!(self.files.loading.is_none());
|
||||
}
|
||||
pub(super) fn save_project_as(&mut self) {
|
||||
self.layout.finish_drag();
|
||||
match self.project().to_json() {
|
||||
|
|
@ -209,10 +316,7 @@ impl Editor {
|
|||
.add_filter("Midra Layout project", &["json"])
|
||||
.pick_file()
|
||||
{
|
||||
match Project::read(&path) {
|
||||
Ok(p) => self.files.opening = Some((path, p)),
|
||||
Err(e) => self.files.message = Some(format!("Cannot open project: {e}")),
|
||||
}
|
||||
self.files.opening = Some(path);
|
||||
}
|
||||
}
|
||||
if ui.button("Save project…").clicked() {
|
||||
|
|
@ -352,6 +456,19 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
pub(super) fn project_windows(&mut self, ctx: &egui::Context) {
|
||||
if self.files.loading.is_some() {
|
||||
egui::Window::new("Loading project")
|
||||
.collapsible(false)
|
||||
.show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.spinner();
|
||||
ui.label("Reading project and decoding reference images…");
|
||||
});
|
||||
if !self.files.loading_recovery && ui.button("Cancel loading").clicked() {
|
||||
self.files.loading = None;
|
||||
}
|
||||
});
|
||||
}
|
||||
if let Some(job) = self.files.export_job.take() {
|
||||
match job.try_recv() {
|
||||
Ok(Ok((path, bytes))) => self.queue_write(path, bytes),
|
||||
|
|
@ -394,7 +511,7 @@ impl Editor {
|
|||
});
|
||||
self.files.export_open &= open;
|
||||
}
|
||||
if let Some((path, project)) = self.files.opening.take() {
|
||||
if let Some(path) = self.files.opening.take() {
|
||||
let mut open = true;
|
||||
let mut load = false;
|
||||
let mut cancel = false;
|
||||
|
|
@ -405,15 +522,12 @@ impl Editor {
|
|||
ui.horizontal(|ui| {load=ui.button("Open project").clicked();cancel=ui.button("Cancel").clicked();});
|
||||
});
|
||||
if load {
|
||||
self.files.message = Some(match self.install_project(ctx, project) {
|
||||
Ok(()) => {
|
||||
self.files.project_path = Some(path.clone());
|
||||
format!("Opened {}", path.display())
|
||||
}
|
||||
Err(e) => format!("Cannot open project; current work kept: {e}"),
|
||||
self.start_project_job(ctx, false, move || {
|
||||
let project = Project::read(&path)?;
|
||||
Ok(Some((project, Some(path), None)))
|
||||
});
|
||||
} else if open && !cancel {
|
||||
self.files.opening = Some((path, project));
|
||||
self.files.opening = Some(path);
|
||||
}
|
||||
}
|
||||
if let Some((path, contents)) = self.files.writing.take() {
|
||||
|
|
@ -740,12 +854,16 @@ mod confirmation_tests {
|
|||
let mut next = original.clone();
|
||||
next.output_resolution.width = 2560;
|
||||
next.output_resolution.height = 1440;
|
||||
app.files.opening = Some((PathBuf::from("candidate.midra.json"), next.clone()));
|
||||
let source_dir = tempfile::tempdir().unwrap();
|
||||
let source = source_dir.path().join("candidate.midra.json");
|
||||
std::fs::write(&source, next.to_json().unwrap()).unwrap();
|
||||
app.files.opening = Some(source.clone());
|
||||
click_text(&mut app, &ctx, "Cancel");
|
||||
assert_eq!(app.project(), original);
|
||||
assert!(app.files.opening.is_none());
|
||||
app.files.opening = Some((PathBuf::from("candidate.midra.json"), next.clone()));
|
||||
app.files.opening = Some(source);
|
||||
click_text(&mut app, &ctx, "Open project");
|
||||
app.wait_project_job();
|
||||
assert_eq!(app.project(), next);
|
||||
app.files.message = None;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
|
@ -760,3 +878,80 @@ mod confirmation_tests {
|
|||
assert_eq!(std::fs::read(&path).unwrap(), b"new contents");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod async_tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn loading_is_atomic_cancellable_and_pauses_recovery() {
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = Editor::default();
|
||||
let before = app.project();
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let recovery = dir.path().join("recovery.json");
|
||||
std::fs::write(&recovery, b"keep this recovery").unwrap();
|
||||
app.recovery.path = Some(recovery.clone());
|
||||
let (release, wait) = std::sync::mpsc::channel();
|
||||
let next = before.clone();
|
||||
app.start_project_job(&ctx, false, move || {
|
||||
wait.recv().unwrap();
|
||||
Ok(Some((next, None, None)))
|
||||
});
|
||||
app.poll_project_job();
|
||||
assert!(app.files.loading.is_some());
|
||||
assert_eq!(app.project(), before);
|
||||
app.autosave_recovery(true);
|
||||
assert_eq!(std::fs::read(&recovery).unwrap(), b"keep this recovery");
|
||||
app.files.loading = None; // Cancel loading drops the only receiver.
|
||||
release.send(()).unwrap();
|
||||
app.poll_project_job();
|
||||
assert_eq!(app.project(), before);
|
||||
|
||||
let mut broken = before.clone();
|
||||
broken.references.push(SavedReference {
|
||||
name: "Broken".into(),
|
||||
image_base64: STANDARD.encode(b"invalid PNG"),
|
||||
visible: true,
|
||||
opacity: 1.0,
|
||||
preserve_ratio: false,
|
||||
native_size: false,
|
||||
offset: [0.; 2],
|
||||
});
|
||||
app.start_project_job(&ctx, false, move || Ok(Some((broken, None, None))));
|
||||
app.wait_project_job();
|
||||
assert_eq!(app.project(), before);
|
||||
assert!(
|
||||
app.files
|
||||
.message
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.contains("current work kept")
|
||||
);
|
||||
|
||||
let mut next = before;
|
||||
next.output_resolution.width = 3840;
|
||||
let mut bytes = std::io::Cursor::new(Vec::new());
|
||||
image::RgbaImage::from_pixel(2, 2, image::Rgba([0, 255, 0, 255]))
|
||||
.write_to(&mut bytes, image::ImageFormat::Png)
|
||||
.unwrap();
|
||||
for name in ["First", "Second"] {
|
||||
next.references.push(SavedReference {
|
||||
name: name.into(),
|
||||
image_base64: STANDARD.encode(bytes.get_ref()),
|
||||
visible: name == "First",
|
||||
opacity: 0.5,
|
||||
preserve_ratio: true,
|
||||
native_size: false,
|
||||
offset: [10., 20.],
|
||||
});
|
||||
}
|
||||
let expected = next.clone();
|
||||
app.start_project_job(&ctx, false, move || {
|
||||
Ok(Some((next, Some(PathBuf::from("new.json")), Some(42))))
|
||||
});
|
||||
app.wait_project_job();
|
||||
assert_eq!(app.project(), expected);
|
||||
assert_eq!(app.files.project_path, Some(PathBuf::from("new.json")));
|
||||
assert_eq!(app.files.manual_saved_at, Some(42));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ impl Editor {
|
|||
self.recovery.path = Some(path.clone());
|
||||
self.recovery.error = None;
|
||||
self.recovery.restore_failed = false;
|
||||
let result: Result<(), String> = (|| {
|
||||
self.start_project_job(ctx, true, move || {
|
||||
let file = match std::fs::File::open(&path) {
|
||||
Ok(file) => file,
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(()),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => return Ok(None),
|
||||
Err(e) => return Err(e.to_string()),
|
||||
};
|
||||
let mut bytes = Vec::new();
|
||||
|
|
@ -62,21 +62,19 @@ impl Editor {
|
|||
let project = Project::from_json(
|
||||
&serde_json::to_string(&snapshot.project).map_err(|e| e.to_string())?,
|
||||
)?;
|
||||
self.install_project(ctx, project)?;
|
||||
self.files.project_path = snapshot.project_path;
|
||||
self.files.manual_saved_at = snapshot.manual_saved_at;
|
||||
Ok(())
|
||||
})();
|
||||
if let Err(error) = result {
|
||||
self.recovery.restore_failed = true;
|
||||
self.recovery.error = Some(format!(
|
||||
"Recovery could not be restored: {error}. The file is preserved; save any work separately before retrying."
|
||||
));
|
||||
self.files.message = self.recovery.error.clone();
|
||||
}
|
||||
Ok(Some((
|
||||
project,
|
||||
snapshot.project_path,
|
||||
snapshot.manual_saved_at,
|
||||
)))
|
||||
});
|
||||
}
|
||||
|
||||
pub(super) fn autosave_recovery(&mut self, force: bool) {
|
||||
if self.recovery.path.is_none() || self.recovery.error.is_some() {
|
||||
if self.files.loading.is_some()
|
||||
|| self.recovery.path.is_none()
|
||||
|| self.recovery.error.is_some()
|
||||
{
|
||||
return;
|
||||
}
|
||||
if !force
|
||||
|
|
@ -193,6 +191,7 @@ mod tests {
|
|||
.unwrap();
|
||||
let mut app = Editor::default();
|
||||
app.restore_recovery(&ctx, path);
|
||||
app.wait_project_job();
|
||||
assert!(app.recovery.error.is_none());
|
||||
assert_eq!(app.project(), Project::from_layout(&Layout::default()));
|
||||
}
|
||||
|
|
@ -206,6 +205,7 @@ mod tests {
|
|||
std::fs::write(&named, "leave untouched").unwrap();
|
||||
let mut app = Editor::default();
|
||||
app.restore_recovery(&ctx, path.clone());
|
||||
app.wait_project_job();
|
||||
app.files.project_path = Some(named.clone());
|
||||
app.files.manual_saved_at = Some(now_seconds() - 180);
|
||||
app.layout.nudge(40.0, -20.0).unwrap();
|
||||
|
|
@ -221,6 +221,7 @@ mod tests {
|
|||
assert_eq!(std::fs::read(&path).unwrap(), first);
|
||||
let mut restored = Editor::default();
|
||||
restored.restore_recovery(&ctx, path);
|
||||
restored.wait_project_job();
|
||||
assert!(restored.recovery.error.is_none());
|
||||
assert_eq!(restored.project(), app.project());
|
||||
assert_eq!(restored.files.project_path, Some(named));
|
||||
|
|
@ -240,6 +241,7 @@ mod tests {
|
|||
let mut app = Editor::default();
|
||||
let before = app.project();
|
||||
app.restore_recovery(&ctx, path.clone());
|
||||
app.wait_project_job();
|
||||
assert!(app.recovery.error.is_some());
|
||||
assert!(app.recovery.restore_failed);
|
||||
assert_eq!(app.project(), before);
|
||||
|
|
@ -260,6 +262,7 @@ mod tests {
|
|||
let path = dir.path().join("last_project.json");
|
||||
let mut app = Editor::default();
|
||||
app.restore_recovery(&ctx, path.clone());
|
||||
app.wait_project_job();
|
||||
app.layout.nudge(123.0, 0.0).unwrap();
|
||||
app.sync();
|
||||
app.autosave_recovery(true);
|
||||
|
|
@ -274,6 +277,7 @@ mod tests {
|
|||
assert!(app.files.manual_saved_at.is_none());
|
||||
let mut restored = Editor::default();
|
||||
restored.restore_recovery(&ctx, path);
|
||||
restored.wait_project_job();
|
||||
assert_eq!(restored.project(), app.project());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,17 @@ impl Editor {
|
|||
ui.close_menu();
|
||||
self.import_reference_file(ui.ctx());
|
||||
}
|
||||
if ui
|
||||
.add_enabled(
|
||||
self.device.online(),
|
||||
egui::Button::new("Capture Midra input…"),
|
||||
)
|
||||
.on_disabled_hover_text("Connect to Midra first.")
|
||||
.clicked()
|
||||
{
|
||||
self.capture.open = true;
|
||||
ui.close_menu();
|
||||
}
|
||||
if self.references.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
# Midra input preview stills
|
||||
|
||||
This is a device-read interface, not a new project or export format. Verified on
|
||||
Eikos 4K firmware 3.3.10, WebRCS `app.e42fce4879f318b28cde.js`.
|
||||
|
||||
## Discovery and request
|
||||
|
||||
The connected snapshot's `/device/inputList/items/INPUT_N` supplies:
|
||||
|
||||
- `status.pp.isAvailable`: only existing hardware inputs appear.
|
||||
- `status.pp.plug`: selects `plugList.items[plug].status.signal.pp.isValid`
|
||||
for the last-read signal indicator.
|
||||
- `snapshot.pp.enable`: capture is disabled in the editor when WebRCS snapshots
|
||||
are disabled. The application does not write this field or snapshot size.
|
||||
|
||||
One explicit **Capture still** issues
|
||||
`GET http://<configured-IP>/api/device/snapshots/inputs/N`, with N an integer
|
||||
1–16 and `Cache-Control: no-cache`. IPv4 and IPv6 literal addresses are accepted;
|
||||
no proxy or redirect is followed. No retries, polling, WebSocket subscription,
|
||||
still-library capture or source-routing/preset writes are involved.
|
||||
|
||||
Only one request may be in flight, with at least five seconds between starts.
|
||||
Closing/cancelling discards the result but does not permit a second request until
|
||||
the first completes or times out. The request has a 5-second connection timeout
|
||||
and 20-second overall timeout. Device-provided resolution is retained; no request
|
||||
to increase resolution or refresh frequency is made.
|
||||
|
||||
## Response and validation
|
||||
|
||||
A successful response must be a PNG, at most 16 MiB, and pass the common image
|
||||
decoder's dimensions/allocation limits. HTTP errors, redirects, invalid PNGs,
|
||||
oversize responses and decode errors leave references unchanged.
|
||||
The active-input test returned 512 × 288 pixels; an inactive input returned a
|
||||
blank 128 × 128 PNG. The device controls image freshness (Last-Modified) and
|
||||
resolution; GET fetches the latest available snapshot, not a guaranteed
|
||||
new full-resolution frame. Signal indicators may be stale until reconnect/refresh.
|
||||
|
||||
## Editor and persistence
|
||||
|
||||
The dialog displays the image and its actual pixel dimensions. **Add as reference**
|
||||
is explicit and obeys the 32-image/64 MiB combined-reference limits. Existing
|
||||
upscale/aspect warnings apply. Capture alone does not add, replace or move anything.
|
||||
Changing device address/disconnecting invalidates the pending preview; input changes
|
||||
clear the old preview. A cancelled/late result cannot become a new reference.
|
||||
|
||||
The initial image name contains the input number and configured device IP.
|
||||
Added stills use the existing [project v10 reference object](midra-layout.md):
|
||||
name, embedded PNG image_base64, visible, opacity, preserve_ratio,
|
||||
native_size, offset. No new fields, version or migration are needed.
|
||||
Reloading a project makes no capture requests. Captures are fixed viewport guides,
|
||||
not layer-content textures, live feeds or export placeholders. Generic artwork
|
||||
exports include them only through the existing visible-reference/background option.
|
||||
Automatic refresh and separate image-file saving are not implemented.
|
||||
|
|
@ -17,6 +17,12 @@ and reference decoding must succeed before replacing the editor. No file at
|
|||
measurement-point autosaves. The startup device connection remains governed by
|
||||
application settings, not recovery.
|
||||
|
||||
Startup/Retry reads, validation and embedded-image decoding run on a background
|
||||
worker. No partial project is installed. Checkpoints (including normal-exit
|
||||
checkpoints) are suspended until loading completes, so an unfinished or failed
|
||||
restore cannot overwrite the previous recovery file. Failures retain the file
|
||||
and pause recovery as before. The envelope remains version 1.
|
||||
|
||||
Checkpoints run at most every two seconds, outside active pointer/resize gestures,
|
||||
and on normal exit. Identical snapshots are skipped. Writes use the existing
|
||||
same-directory temporary-file, file-sync and atomic replacement helper. A failed
|
||||
|
|
|
|||
|
|
@ -98,7 +98,12 @@ external files, URLs or device endpoints are accessed on load. Image dimensions
|
|||
are decoded from the bytes. The existing image loader enforces a 64 MiB encoded
|
||||
file limit, maximum 8192 pixels per side (or the GPU texture limit if smaller),
|
||||
and a 256 MiB decoder allocation limit. Bad image data aborts opening and leaves
|
||||
the current editor unchanged.
|
||||
the current editor unchanged. Project file reading/parsing, validation and reference
|
||||
decoding run in a background worker. The editor is replaced only after every
|
||||
image succeeds; Cancel loading ignores late worker results. Recovery checkpoints
|
||||
pause during loading. Texture upload/presentation still depends on the GUI/GPU.
|
||||
Captured Midra stills use the same reference object and embedded PNG bytes, with
|
||||
no device request on reload; no schema/version change is required.
|
||||
|
||||
Editor object:
|
||||
|
||||
|
|
@ -228,7 +233,7 @@ Midra links belong to layer identity and survive selection changes, refresh, ren
|
|||
|
||||
Midra destinations are identified by the pair **screen ID + layer ID**: Screen 1
|
||||
Layer 1 and Screen 2 Layer 1 are distinct links. Both IDs are already persisted
|
||||
in project version 5; no schema change is needed. Opening **Apply changes…** or
|
||||
in project version 5; no schema change is needed. Opening **Midra mapping & transfer…** or
|
||||
**Configure Midra export…** restores the first selected layer's available linked
|
||||
screen. Destination choices display both IDs. Browsing another screen does not
|
||||
retarget existing links; choosing a destination there explicitly replaces that
|
||||
|
|
|
|||
|
|
@ -151,3 +151,18 @@ pulse after geometry writes, even when no geometry fields differ. A direct pulse
|
|||
was sent to the connected Eikos to apply its already-staged layout. The operator confirmed that the physical multiviewer Preview then matched WebRCS, establishing the missing apply pulse as the cause. Layer status `OFF` is not
|
||||
sufficient evidence that the operator's layers are disabled, and must not be used
|
||||
as that diagnosis.
|
||||
|
||||
## Input preview capture checked on 2026-11-14
|
||||
|
||||
The same WebRCS client exposes GET /api/device/snapshots/inputs/:id.
|
||||
A read-only request to active input 3 returned HTTP 200, PNG, 512 × 288
|
||||
(591155 bytes). Input 1, with no signal, returned a blank 128 × 128 PNG.
|
||||
The input state reported snapshots enabled with size 512_512; the active
|
||||
image retained its 16:9 aspect. The response included Last-Modified and
|
||||
Cache-Control max-age=0. No continuous stream or write was needed. Raw input
|
||||
images/state stay temporary and are not committed.
|
||||
|
||||
The implementation fetches a still only on demand, limits concurrent requests
|
||||
to one and enforces a five-second minimum interval. It does not change snapshot
|
||||
enable/size, input routing, capture-library commands or any preset.
|
||||
See [input preview interface](interfaces/midra-input-preview.md).
|
||||
|
|
|
|||
|
|
@ -1,402 +1,123 @@
|
|||
# Midra layout helper: plan and visual proposals
|
||||
# Midra layout helper: implementation status and backlog
|
||||
|
||||
Status: the [Rust/egui positioning draft](midra-layout.md) supports draw.io
|
||||
geometry paste with review, two-layer multi-selection and group movement, box
|
||||
selection, explicit-target alignment, numeric corner positioning/size, undo/redo
|
||||
and camera zoom/pan. Concept A is user-approved.
|
||||
Reference images, output presets/custom resolution, source/input formats and
|
||||
advanced crop-backed content zoom/offset are implemented offline. Device mapping
|
||||
verification includes both sizing modes, Program/Preview write/readback and restoration.
|
||||
GUI connectivity, reviewed sends, container and Centered-crop import are implemented. An authorized Eikos 3.3.10
|
||||
read/Preview-write/restore check passed; see [hardware findings and import bridge](midra-layout-device-check.md). Checklist gates
|
||||
that combine implemented and outstanding work remain open.
|
||||
Target: Analog Way Eikos 4K, running the latest firmware according to the user.
|
||||
Record the actual installed version during compatibility checks; do not infer it
|
||||
from a different Midra generation's documentation. Working name: **Midra Layout**.
|
||||
Reconciled on 2026-11-14 against the current editor, device adapter, regression
|
||||
tests and recorded Eikos 4K firmware 3.3.10 hardware checks. This replaces the
|
||||
original draft checklist: unchecked items below are actual remaining work,
|
||||
not already implemented features awaiting a historical milestone.
|
||||
|
||||
## Reconciled implementation status
|
||||
The original visual proposals are retained below for design context.
|
||||
The [user guide](midra-layout.md) describes current controls; the
|
||||
[device-send contract](interfaces/midra-device-send.md) and
|
||||
[hardware findings](midra-layout-device-check.md) distinguish automated tests,
|
||||
device readback and physical-screen acceptance.
|
||||
|
||||
The offline editor now includes source/input/layer formats and cropping, all eight
|
||||
layer and crop handles, multi-selection/group resizing/alignment, reference import,
|
||||
draw.io/native/SVG and open geometry formats with review, JSON project save/load,
|
||||
nine-format geometry export (including optional native PPTX/FIG and local AI conversion),
|
||||
19 bundled themes, recent-theme history and persistent application preferences.
|
||||
A full Settings window and optional movement snapping with guides/Alt bypass
|
||||
are implemented. Project save/load and theme preferences are no longer future work.
|
||||
## Completed implementation
|
||||
|
||||
Remaining work, in priority order:
|
||||
- [x] Rust/egui workspace app; canonical pixel geometry, stable layer/input IDs,
|
||||
source/input/layer formats, custom output resolutions, corner/center conversion
|
||||
and full-precision geometry with one-decimal display/whole-pixel export.
|
||||
- [x] Multi-layer viewport, selection/marquee, movement/nudging, pointer-centered
|
||||
zoom/pan, fit controls, eight resize handles, aspect lock, pivots, proportional
|
||||
group resizing (same, horizontal mirror, opposite), alignment and undo/redo.
|
||||
- [x] Snapping during movement and resize, pixel grids/rulers, screen-center and
|
||||
quarter guides, other-layer edges and temporary modifier overrides.
|
||||
- [x] Advanced input/layer cropping, content zoom/offset, visual crop handles,
|
||||
reset, double-click entry and translucent retained-content surroundings.
|
||||
- [x] Layer add/remove/rename/order, lock/visibility, collapsible single-level
|
||||
folders, folder selection/rename/reorder and drag organization. Folder eye/lock
|
||||
currently edits member flags in bulk; it is not inherited state.
|
||||
- [x] Multiple fixed reference images, drag/drop/picker, per-image visibility,
|
||||
opacity, native-size/offset, proportional fit/stretch warnings, outline-only
|
||||
layer display and adaptive image filtering.
|
||||
- [x] Reference imports and project/recovery reads, parsing, validation and
|
||||
embedded-image decoding run off the UI thread. Loading is atomic; failures
|
||||
preserve the editor. Manual project loading is cancellable and recovery
|
||||
autosave pauses while loading.
|
||||
- [x] Explicit Midra input snapshot capture: available-input picker, still
|
||||
preview and Add as reference. Manual only, one request at a time and at least
|
||||
five seconds between requests. No live polling or automatic refresh.
|
||||
- [x] Clipboard/import mapping review with per-row target/ignore, independent
|
||||
size/position/available-zoom toggles, draw.io stroke handling and own-copy
|
||||
round trips. Real draw.io clipboard sample and draw.io-exported SVG supported.
|
||||
- [x] Nine-format file exchange: SVG, draw.io, geometry JSON, CSV, DXF, HTML,
|
||||
PPTX, FIG and AI through VectorCraft. Shared geometry, scope and review,
|
||||
optional artwork where supported, page/frame selection and licensing build flag.
|
||||
Two-layer Full HD and UHD templates exist for all nine formats.
|
||||
- [x] Project JSON v10, tested legacy/recovery migration, saved layer links,
|
||||
central application preferences, full Settings, themes and recent-theme list.
|
||||
- [x] Separate Midra connection and mapping/transfer controls, saved address,
|
||||
optional startup connection, online status, explicit direct linked send/load
|
||||
and configurable mapping review. Scope defaults to All with Selected/Folder.
|
||||
Unmapped rows skip; duplicate destinations within a send scope are rejected.
|
||||
- [x] Persistent per-layer screen/layer links, Mapping properties and Unmap.
|
||||
Reordering/visibility do not alter links; alternative folders can reuse targets.
|
||||
- [x] Both device sizing strategies, Centered-crop imports, required preset apply
|
||||
pulse, rounding/reconstruction checks and readback. Preview/Program protocol
|
||||
checks on Eikos 3.3.10 are recorded; Program availability is a user preference.
|
||||
- [x] Advanced shared-input settings are explicitly opt-in; only edited fields
|
||||
are sent while enabled. This supersedes the original “never write input settings”
|
||||
scope. Routing, TAKE and live playback control are not implicit geometry actions.
|
||||
- [x] Geometry/import/UI/mock-device regression tests, workspace CI, coverage,
|
||||
documentation and release build configuration integration.
|
||||
|
||||
1. Stable-ID collections, add/remove/rename, collapsible single-level folders,
|
||||
folder/member drag organization, bulk folder visibility/locking, selected-layer
|
||||
SVG export and project migration are implemented. Nested folders and inherited
|
||||
folder visibility (preserving individual flags across hide/show) remain follow-ups.
|
||||
2. Reference native-size/offset mapping, outline-only display, adaptive filtering
|
||||
and background picture import are implemented. Embedded-image project loading
|
||||
remains synchronous. High-zoom pixel grids/rulers and resize snapping are implemented.
|
||||
3. Additional clipboard adapters after obtaining real application/version samples.
|
||||
4. Device mappings, destination review, both sizing/crop strategies and explicit
|
||||
Program/Preview sends are implemented and hardware readback-tested on Eikos 3.3.10.
|
||||
Physical display/test-image comparison remains an acceptance check.
|
||||
5. Broader firmware verification and non-Centered/masked import conversion remain.
|
||||
The user now permits Program writes and accepts the physical-bank TAKE race;
|
||||
this supersedes the earlier Preview-only restriction.
|
||||
6. Operator-laptop/DPI/OS acceptance, performance measurements and release packaging.
|
||||
## Remaining feature work
|
||||
|
||||
Checked entries below refer to implemented offline behavior. Items combining an
|
||||
implemented feature with an unverified hardware or platform acceptance gate stay
|
||||
open; those gates are not claimed complete merely because automated tests pass.
|
||||
- [ ] **Multiple saved links per layer and link picking.** Add extra destinations
|
||||
without replacing the existing link; every link includes screen and layer.
|
||||
Organization, active-link choice and send/load behavior need user specifications.
|
||||
Version project interfaces and add migration tests when that schema is defined.
|
||||
- [ ] **Further export/workflow cleanup.** Shared transfer scopes, mapping review
|
||||
and direct linked send/load are implemented; further changes await specifications.
|
||||
- [ ] **Nested folders and inherited visibility/locking.** Preserve member flags
|
||||
across ancestor hide/show or lock/unlock rather than overwriting them.
|
||||
- [ ] **Additional native clipboard adapters.** Obtain actual software/version
|
||||
clipboard samples before implementing or claiming Inkscape, Illustrator, Figma,
|
||||
etc. clipboard support. File import is not native clipboard compatibility.
|
||||
- [ ] **Non-Centered/masked Midra layer import.** Expand conversion only after
|
||||
verifying those semantics. Source routing synchronization remains separate
|
||||
from the opt-in shared-input settings editor.
|
||||
- [ ] **Optional capture extensions, if wanted.** Automatic refresh, standalone
|
||||
capture saving and using captured pixels directly as layer-content textures
|
||||
are not implemented. Current captures are ordinary fixed reference images;
|
||||
low device load remains a requirement for any refresh extension.
|
||||
- [ ] **Additional file codecs, if requested.** PDF, PSD, VSDX and ODG are outside
|
||||
the current geometry contract, not promised existing import/export features.
|
||||
|
||||
## Intended workflow
|
||||
## Remaining acceptance and release checks
|
||||
|
||||
Set the output format and preset or custom screen resolution, optionally load a reference picture, then place one or
|
||||
two rectangular live layers visually or by entering exact offsets from a chosen
|
||||
screen corner. Read or copy their equivalent WebRCS position values. Select layers
|
||||
on the canvas or in the right-hand list. All work is local and offline.
|
||||
- [ ] Compare known test images on the physical output for both sizing strategies,
|
||||
asymmetric/extreme crops and source aspects. Device readback is not visual proof.
|
||||
- [ ] Broader firmware/source-format coverage, including exhaustive device limits,
|
||||
all corner/center placements and non-Centered/masked configurations.
|
||||
- [ ] Operator-laptop checks: dense reference at Fit/100%/400%/1600%, large-project
|
||||
loading, GPU memory and measured drag responsiveness; aim for a 60 Hz interaction
|
||||
budget. Worker decoding does not remove GPU texture upload cost.
|
||||
- [ ] Windows/macOS/Wayland clipboard, DPI/GPU presentation and native-dialog checks.
|
||||
Headless Linux interaction tests do not replace platform acceptance.
|
||||
- [ ] Accessibility/tab order, enlarged text, contrast and narrow-window review;
|
||||
verify complete setup → position → crop → paste → copy → undo → send/load workflows.
|
||||
- [ ] Exercise portable release bundles on target machines and complete the release
|
||||
checklist. Build/CI integration already exists; this is packaging acceptance.
|
||||
|
||||
For this plan, “window” means the application window and “layer” means a video
|
||||
rectangle within one screen viewport. There is no additional window/group object.
|
||||
The first release supports two layers; the underlying collection should support
|
||||
more later without promising that every device configuration supports them.
|
||||
## Verification notes
|
||||
|
||||
The reference image is an editing aid, not an additional hardware layer. Screen
|
||||
resolution is independent of the application window size, zoom and image size.
|
||||
Source routing, transitions, playback, masking, rotation, keying, live preview
|
||||
and device control remain outside the offline implementation scope. Device writes
|
||||
remain a later GUI stretch goal (step 10). The separately authorized hardware
|
||||
check is documented above; it does not enable automatic device sends.
|
||||
Input cropping and virtual layer
|
||||
resolutions are implemented offline; device mapping still requires verification.
|
||||
Their coordinate spaces must be designed from the start. See the
|
||||
[resolution and advanced-cropping specification](midra-layout-resolutions.md).
|
||||
Input capture was tested with the connected Eikos on 2026-11-14: a read-only GET
|
||||
returned a 512 × 288 PNG from active input 3; inactive input 1 returned a blank
|
||||
128 × 128 PNG. See [snapshot contract](interfaces/midra-input-preview.md).
|
||||
No input routing, snapshot settings, still-library slot or layer was modified.
|
||||
Snapshot dimensions/freshness are device-controlled and broader firmware behavior
|
||||
remains unverified.
|
||||
|
||||
## Ordered task list
|
||||
The remaining validation entries above deliberately stay open. Implemented code,
|
||||
passing regression tests and protocol readback do not substitute for operator
|
||||
acceptance or physical-screen inspection.
|
||||
|
||||
Complete each acceptance gate before broadening the scope. The first usable
|
||||
positioning draft comprises steps 1–6, including source/output format selection
|
||||
and custom viewport dimensions, and the applicable checks in step 8. Steps 7
|
||||
and 9 follow the draft. Step 9 is committed scope; its device compatibility
|
||||
checks must pass before presenting advanced-crop values as usable in WebRCS.
|
||||
## Coordinate model and historical visual proposals
|
||||
|
||||
### 1. Establish the Eikos 4K coordinate contract
|
||||
|
||||
- [ ] Record device model, exact firmware and relevant WebRCS field labels.
|
||||
- [ ] Check horizontal and vertical origins, signs, pixel units, numeric step,
|
||||
accepted size/position ranges and off-screen placement in that WebRCS version.
|
||||
- [ ] Verify whether the editable bounds refer to the layer rectangle rather
|
||||
than cropped source content. Start with an unmasked, uncropped live layer.
|
||||
- [ ] Check odd widths/heights and half-pixel centers; do not round silently.
|
||||
- [ ] Establish input-crop and layer-crop coordinate spaces, units, processing
|
||||
order, limits and Centered aspect behavior for the later resolution milestone.
|
||||
Separate final visible bounds from any device layer container; do not infer
|
||||
container size or position from the uncropped image's projected dimensions.
|
||||
- [ ] Record examples at all four screen corners and at screen center using a
|
||||
simulator or manual entry in an appropriate test setup, without API calls.
|
||||
|
||||
Gate: a small verified input/output table establishes what the application may
|
||||
label as WebRCS-compatible. The example math below is provisional until then.
|
||||
|
||||
### 2. Review visual direction and prove the viewport
|
||||
|
||||
- [x] Choose a direction from the three proposals below. Approved: A, with
|
||||
B's optional rulers and C's contextual alignment panel later.
|
||||
- [x] Build a disposable viewport interaction spike with two rectangles before
|
||||
committing to the full UI. Rust/egui is the preferred starting point because
|
||||
the repository already uses it; validate interaction quality before settling.
|
||||
- [ ] Prove pointer-centered zoom, pan, selection, hit testing, keyboard nudge,
|
||||
image rendering and display scaling on the target operator laptop.
|
||||
- [ ] Try a dense reference image at Fit, 100%, 400% and 1600% zoom and at several
|
||||
OS display scales. Zooming must not move layer coordinates.
|
||||
- [ ] Review at 1440 × 900 and 1024 × 768 logical window sizes, including enlarged
|
||||
UI text. Keep numerical controls usable with a scrollable right inspector.
|
||||
|
||||
Gate: the viewport feels predictable and shows exact edges clearly. If the
|
||||
toolkit cannot meet these needs, resolve that before building the rest.
|
||||
|
||||
### 3. Implement geometry independently of the UI
|
||||
|
||||
- [x] Add workspace member `crates/midra-layout/` with shared geometry
|
||||
and a desktop binary.
|
||||
- [ ] Model screen dimensions and stable layer IDs with canonical top-left
|
||||
position and final visible size. Keep selection, camera and reference image separate.
|
||||
- [ ] Define source format/native dimensions, input crop, advanced crop and
|
||||
derived device geometry as distinct concepts from day one. Store crop edges
|
||||
and final size as authoritative geometry; content zoom/offset are derived
|
||||
controls. Do not implement crop interactions until after the first draft.
|
||||
- [ ] Implement four-corner offset conversion and inverse WebRCS conversion
|
||||
under the verified device contract.
|
||||
- [x] Switching corner changes the displayed offsets without moving the layer.
|
||||
Resizing keeps the chosen corner and its offsets fixed; moving changes offsets.
|
||||
- [ ] Preserve precision internally. Validate finite numbers, positive sizes and
|
||||
device limits; report unsupported values without silently clamping them.
|
||||
- [ ] Test all corners, inverse round trips, odd dimensions, negative offsets,
|
||||
non-16:9 screens, exact screen edges and resizing from each anchor.
|
||||
|
||||
Gate: viewport scale and UI state cannot affect geometry or conversion results.
|
||||
|
||||
### 4. Build the two-layer positioning workspace
|
||||
|
||||
- [ ] Add screen resolution controls, one/two-layer setup, persistent layer IDs
|
||||
and names, and a right-hand layer list with a selected-layer inspector.
|
||||
- [x] Add source format choices (including 4:3, 16:9 and 16:10) with explicit
|
||||
native pixel dimensions; an aspect ratio alone is not a pixel resolution.
|
||||
- [x] Add output format choices and clearly labeled viewport resolution presets
|
||||
(HD 1280 × 720, Full HD 1920 × 1080, UHD 4K 3840 × 2160), plus manual width
|
||||
and height. Derive the output ratio from custom dimensions, never silently
|
||||
stretch them to match a preset. Other formats can be added after validation.
|
||||
- [x] Changing output dimensions preserves existing layer pixel bounds, flags
|
||||
out-of-screen layers and rechecks reference-image mapping. Validate positive
|
||||
integer dimensions independently of verified device output support; custom
|
||||
planning geometry must not imply that Eikos accepts every output mode.
|
||||
- [x] Support click selection, Shift-click multi-selection, clear selection and
|
||||
list selection for overlapped or off-screen rectangles. Define deterministic
|
||||
overlap hit testing; list order represents preview stacking, not device routing.
|
||||
- [x] Add dragging, exact width/height fields, four-corner selection and inward
|
||||
offsets. Prefer numeric sizing first; add resize handles only with anchor
|
||||
behavior consistent with the geometry contract.
|
||||
- [ ] Show WebRCS horizontal/vertical center values beside corner inputs; make
|
||||
output values read-only initially. Offer per-value copy and labeled plain text
|
||||
for a whole layer. Do not imply plain text is a WebRCS-native clipboard format.
|
||||
- [x] Add arrow nudges of 1 screen pixel and Shift-arrow nudges of 10; focused
|
||||
text fields must receive these keys instead of moving the selection.
|
||||
- [x] Implement Space-drag/middle-button pan, pointer-centered zoom, Fit screen,
|
||||
Fit selection, explicit zoom percentage and a clearly defined 1:1 pixel view.
|
||||
- [x] Keep handles/hit areas legible at every zoom; distinguish UI logical points,
|
||||
screen pixels and physical display pixels on HiDPI screens.
|
||||
- [x] Add visible optional snapping to pixel edges, screen edges and other layer
|
||||
edges during movement. Resize/crop handles retain their own behavior.
|
||||
Exact numeric entry bypasses proximity snapping. Show the active guide
|
||||
and allow a temporary snap override; toggling snapping must not move anything.
|
||||
- [x] Add undo/redo for geometry changes, one undo step per drag or committed
|
||||
field edit, and Escape to cancel an in-progress drag or uncommitted edit.
|
||||
|
||||
Gate: place a layer 120 px from the right and 180 px from the top, change zoom,
|
||||
switch anchors and move it by one pixel without losing track of the real values.
|
||||
Selection and dragging never alter unrelated layers. No selection shows screen
|
||||
and reference settings; multi-selection shows mixed values explicitly.
|
||||
|
||||
### 5. Add accurate reference-picture placement
|
||||
|
||||
- [x] Load PNG/JPEG through a file picker or drag/drop; report decoding failures
|
||||
while preserving the current image. Keep source files unchanged.
|
||||
- [ ] Use a matching-resolution image at screen origin with 1 image pixel per
|
||||
screen pixel. For mismatched dimensions, display the mismatch and require an
|
||||
explicit mapping choice: native pixels with offset, fit preserving aspect, or
|
||||
stretch to screen. Show scale, offsets and any letterboxing.
|
||||
- [ ] Lock the reference by default, add hide/show and opacity controls, and
|
||||
offer outline-only layer display so image edges remain visible.
|
||||
- [ ] Use sharp nearest-neighbor inspection at high zoom and an appropriate
|
||||
downsampled view when zoomed out. Do not confuse filtering with coordinate
|
||||
precision. Reveal the screen-pixel grid only when it is legible.
|
||||
- [ ] Decode large images away from the input/render loop, cap supported image
|
||||
dimensions/memory with useful errors, and preserve viewport responsiveness.
|
||||
|
||||
Gate: a known rectangle in a 1920 × 1080 test image can be matched exactly by a
|
||||
layer; changing image opacity, visibility, zoom or filtering changes no geometry.
|
||||
|
||||
### 6. Add extensible clipboard position import
|
||||
|
||||
- [x] Start with an explicit, documented plain-text geometry format and a
|
||||
paste-preview panel. For example: `x=1160; y=180; width=640; height=360; origin=top-left; unit=px`.
|
||||
- [x] Preview parsed values, origin, units, target layer and before/after bounds.
|
||||
Allow position-only import; importing size must be an explicit choice.
|
||||
- [x] Treat Ctrl/Cmd-V in a focused text input as normal text paste. Elsewhere,
|
||||
open geometry preview; do not mutate the document merely by reading clipboard.
|
||||
- [ ] Define adapters by source format/version. Collect actual clipboard samples
|
||||
from each requested software before claiming support. The first adapter now
|
||||
supports the supplied draw.io mxGraphModel clipboard example. Do not guess an
|
||||
application from an unlabeled number tuple.
|
||||
- [ ] Make points, inches, percentages, source canvas origins, decimal conventions
|
||||
and scale explicit. Ambiguity produces an explanation, not a guessed placement.
|
||||
- [x] Validate the complete proposed edit before applying it atomically, with one
|
||||
undo step. Unknown formats, missing fields and invalid values preserve state.
|
||||
- [ ] Test real fixtures for every added adapter and clipboard failure behavior
|
||||
on supported desktop platforms, including Wayland where applicable.
|
||||
|
||||
Gate: supported data places the selected rectangle correctly; malformed or
|
||||
ambiguous data makes no changes. Ship the basic format first if no external
|
||||
software format has yet been selected; do not claim that completes an adapter.
|
||||
|
||||
### 7. Explicit multi-layer alignment
|
||||
|
||||
- [x] Add Align top and Align left; show the alignment target explicitly:
|
||||
screen, selection bounds or a named reference layer.
|
||||
- [x] For a reference layer, keep that layer fixed and move only the others.
|
||||
For selection bounds, align to the minimum top/left edge. For the screen,
|
||||
align to coordinate zero on the selected axis.
|
||||
- [x] Preserve sizes and the other axis, preview the affected selection, and
|
||||
make each alignment a single undoable operation.
|
||||
- [x] Add right/bottom/center alignment using the same explicit targets.
|
||||
- [x] Add Shift-click toggling in the viewport/list, left-drag box selection,
|
||||
Shift-drag additive selection and Escape cancellation. Group movement/nudging
|
||||
preserves spacing and uses one undo step per action.
|
||||
- [ ] Extend beyond two layers under step 11. No distribution or constraint system yet.
|
||||
|
||||
Gate: two differently sized layers align exactly against the chosen target,
|
||||
regardless of selection order except when explicitly choosing a reference layer.
|
||||
|
||||
### 8. Harden and package the first release
|
||||
|
||||
- [ ] Include empty, invalid-input, reference-load-error, off-screen and clipboard
|
||||
error states in UI review, with an obvious way to recover or frame the selection.
|
||||
- [ ] Verify tab order, keyboard focus, numeric input commit/cancel, contrast and
|
||||
selection indicators that do not rely on color alone.
|
||||
- [ ] Manually exercise screen/reference setup → corner positioning → nudge →
|
||||
paste preview → copy values → undo. Verify results in the target WebRCS setup.
|
||||
- [ ] Add geometry/import regression tests and interaction tests for camera
|
||||
transforms and undo. Establish a smooth-drag baseline on the operator laptop;
|
||||
target a 60 Hz interaction budget, measuring rather than assuming performance.
|
||||
- [ ] Document supported firmware, coordinate conventions, clipboard formats,
|
||||
limits and shortcuts. Keep the root README to a short link/quick start.
|
||||
- [ ] Integrate the actual crate into workspace CI, coverage and manual packaging;
|
||||
run the repository Rust gates, whole-application coverage and relevant packaging
|
||||
tests. Document unavailable device or desktop checks.
|
||||
- [x] Commit each completed task; no automatic release publishing.
|
||||
|
||||
Project JSON save/load and SVG geometry export are implemented and documented in
|
||||
`docs/interfaces/`. Networking remains separate from file export.
|
||||
|
||||
### 9. After the first draft: input and layer resolutions
|
||||
|
||||
- [x] Implement the separate input-crop and advanced-crop stages defined in the
|
||||
[resolution specification](midra-layout-resolutions.md), with no device calls.
|
||||
- [x] Keep Source format selected when Input resolution is Custom. Support exact
|
||||
input dimensions and crop placement, defaulting to equal opposite-side crops.
|
||||
- [x] Expose Layer resolution as the final visible width/height, with optional
|
||||
aspect lock. Add Content zoom and Offset X/Y controls and an explicit content
|
||||
framing mode; moving the layer and moving its content must be distinct actions.
|
||||
- [x] Keep the final box fixed during content framing; store four crop edges and
|
||||
final size, derive zoom/offset, and compose input/layer crops without applying
|
||||
either stage twice. Preserve source-level sharing when two layers use one input.
|
||||
- [x] Test the documented numerical examples, inverse transforms, offset limits,
|
||||
extreme ratios, fractional crops, resizing, shared inputs and undo behavior.
|
||||
- [ ] Verify the device adapter's crop units, Centered mode, layer container size
|
||||
and center position with the actual firmware. Show rounding error; block values
|
||||
that cannot preserve the requested box within the verified device precision.
|
||||
- [ ] Add UI review, documentation and release checks for these features before
|
||||
claiming them as supported. Existing A/B/C mockups depict the positioning draft.
|
||||
|
||||
Gate: the user's 1920 × 1080 source → 1920 × 1000 input → 300 × 250 layer
|
||||
workflow retains a 300 × 250 selectable box through zoom, content offset and
|
||||
placement. The WebRCS settings reproduce the same visible result without masking.
|
||||
|
||||
### 10. Later stretch goal: apply layer format through the WebRCS REST API
|
||||
|
||||
Status: implemented after explicit user authorization, including Program writes.
|
||||
Reviewed WebRCS sends, stale checks, readback and both container strategies are
|
||||
implemented. The physical-bank TAKE race is accepted by the user. Historical
|
||||
Preview-only restrictions below are superseded by this authorization.
|
||||
|
||||
- [x] After offline positioning and advanced cropping are validated, research
|
||||
the supported API for the exact model/firmware using documentation and an
|
||||
isolated simulator or explicitly designated non-live test device. Verify
|
||||
endpoint availability, authentication, units and field semantics rather than
|
||||
assuming an endpoint from the WebRCS UI.
|
||||
- [x] Define the smallest supported operation for applying a layer's format:
|
||||
dimensions and, where needed for the virtual format, crop/aspect settings from
|
||||
the verified device adapter. Identify any required position correction and
|
||||
include it explicitly in the proposed change. Do not alter source routing,
|
||||
transitions or trigger a Take as an implicit side effect.
|
||||
- [x] Keep offline mode as the default. Selecting a device or editing, dragging,
|
||||
pasting, undoing or redoing locally must never automatically send commands.
|
||||
- [x] Present a concrete before/after preview with the device identity, firmware,
|
||||
screen, layer, Program/Preview target and every setting to be changed. Require
|
||||
an explicit user action to send that reviewed change; do not infer that a
|
||||
Preview target is harmless or available without verifying device behavior.
|
||||
- [x] Detect stale device state before applying; require a refreshed review if
|
||||
relevant settings changed. Document whether the API can apply the change
|
||||
atomically. Report partial failures and uncertain outcomes without blind
|
||||
retries or automatic rollback commands against a live system.
|
||||
- [x] Test against mocked transport first, then an explicitly authorized
|
||||
target. Verify that no writes occur on startup, connection, local edits,
|
||||
cancellation or errors, and that only reviewed fields are sent.
|
||||
|
||||
Gate met for the authorized Eikos 3.3.10 protocol/readback checks. The user now
|
||||
permits Program changes; actual writes remain explicit reviewed actions.
|
||||
|
||||
### 11. Later stretch goal: layer management and export scope
|
||||
|
||||
Status: stable-ID collections, add/remove/rename, visibility/locking with undo,
|
||||
folder labels/filtering and all/visible/selected/specific SVG scopes are implemented.
|
||||
Single-level folder expand/collapse and drag reordering are implemented; nested
|
||||
folder trees remain. This local organization can be
|
||||
implemented independently of step 10 and does not authorize device connectivity.
|
||||
Folders are an optional follow-up, not a prerequisite for adding/hiding layers.
|
||||
|
||||
- [x] Replace the fixed two-layer document with a collection using stable local
|
||||
IDs. Add an **Add layer** button and editable names. New local layers start
|
||||
visible and unmapped; adding a planning layer does not create a hardware layer.
|
||||
- [x] Add per-layer **Show / Hide** controls in the layer list. Hidden layers
|
||||
keep their geometry and mapping, remain accessible in the list, and are excluded
|
||||
from canvas drawing and hit testing. Hiding is local only: never send a device
|
||||
hide, clear, opacity or routing command as a side effect.
|
||||
- [ ] Add an **Options → Layer mapping** section that maps each local layer to
|
||||
an explicit device/profile, screen and Midra layer ID. Keep local names and list
|
||||
order independent of hardware identity; reordering or hiding must not remap.
|
||||
- [ ] Hardware export destination review remains; SVG scopes are implemented.
|
||||
Add an export-scope choice: **Specific layer…** or **Visible layers only**.
|
||||
The specific-layer picker uses local names and shows the mapped destination;
|
||||
allow intentionally exporting a hidden layer through this explicit selection.
|
||||
Visible means enabled in the layer list, not currently inside the viewport,
|
||||
uncovered by another layer or selected on the canvas.
|
||||
- [ ] Preview the exact included layers, geometry and destination mappings before
|
||||
export. An empty visible set gives an explanation and produces no output.
|
||||
Preserve deterministic list order and never include excluded layers implicitly.
|
||||
- [ ] For device-targeted exports or a future API send, require mappings for every
|
||||
included layer and reject unsupported destinations or duplicate destination
|
||||
mappings within that export. Alternative local layouts may share a destination
|
||||
when only one is included. Generic coordinate copies may remain unmapped.
|
||||
- [ ] Keep export scope distinct from transport: exporting/copying a configuration
|
||||
does not send it. Future device writes still use step 10's separate reviewed,
|
||||
explicit send action, including an explicit Program/Preview target.
|
||||
- [ ] Creation/visibility undo and project persistence are implemented; device
|
||||
mappings are pending. When session save/load
|
||||
is added, preserve stable IDs, names, geometry, visibility and mappings. Extend
|
||||
selection, paste targeting and undo so they no longer depend on array indices.
|
||||
- [x] Add named single-level folders with expand/collapse, select contents,
|
||||
rename, and drag-to-organize. Folders do not introduce geometry transforms or
|
||||
hardware groups. Collapsing a folder changes only the list display.
|
||||
- [ ] Add nested folders and inherited visibility/locking. Current folder eye/lock
|
||||
controls are atomic bulk member edits (Undo restores mixed flags). Inherited
|
||||
visibility should instead combine each layer's own setting with ancestor flags,
|
||||
preserving child visibility choices across a folder hide/show cycle.
|
||||
- [ ] Test adding layers, hidden-layer selection through the list, stable mappings
|
||||
after reorder, paste/undo targeting, both export scopes, empty scopes, unmapped
|
||||
or conflicting targets, and optional nested-folder visibility. Confirm that
|
||||
organization and export preparation produce no device calls.
|
||||
|
||||
Gate: maintain several local layout alternatives, map them explicitly in Options,
|
||||
then export one named layer or exactly the visible set without changing local
|
||||
geometry, overwriting a conflicting destination silently, or contacting a device.
|
||||
|
||||
### 12. Deferred: two Midra export sizing strategies
|
||||
|
||||
Status: both container strategies are implemented in the reviewed device adapter.
|
||||
They preserve the local visible box and crop intent without changing shared input
|
||||
hardware settings. The device content dimensions must match the editor source.
|
||||
|
||||
- [x] **Output-sized layer:** requested visible dimensions become the container;
|
||||
combined input/layer crops and Centered aspect reconstruct the framing.
|
||||
- [x] **Source-aspect container:** derive a containing rectangle with the incoming
|
||||
source aspect, then fit the retained crop inside it. No physical input format
|
||||
is changed; requesting actual shared input format writes remains outside scope.
|
||||
- [x] Quantize crop fractions and geometry; reconstruct visible dimensions and
|
||||
reject residual size errors above one pixel. Preview exact device fields.
|
||||
- [x] Mock stale state, duplicate targets, no-op, partial failures and readback;
|
||||
test both strategies and Centered-crop import round trips.
|
||||
- [x] Exercise 301 × 251 output, 1920 × 1000 custom input, 200% zoom and +30/−10
|
||||
offsets on real Eikos 3.3.10, for both Preview and Program. Verify and restore.
|
||||
- [ ] Visually compare a known test image on the physical output, including extreme
|
||||
aspect ratios and additional firmware/source formats.
|
||||
|
||||
Gate: protocol/readback and mathematical round-trip checks pass. Physical display
|
||||
acceptance remains distinct from those checks.
|
||||
|
||||
## Coordinate contract to verify
|
||||
|
||||
Proposed internal model: screen origin at its top-left, X increases rightward,
|
||||
Implemented internal model: screen origin at its top-left, X increases rightward,
|
||||
Y increases downward, and a layer's final visible box is `(x, y, width, height)`. Positive corner
|
||||
offsets point inward. A corner means the matching corner of the layer measured
|
||||
from that screen corner; there are not two independent anchor selectors in v1.
|
||||
offsets point inward. Matching corners are the default; the current editor also supports independent
|
||||
screen/layer measurement points and center anchors.
|
||||
|
||||
For screen size `W × H`, layer size `w × h`, and offsets `dx, dy`:
|
||||
|
||||
|
|
@ -407,7 +128,7 @@ For screen size `W × H`, layer size `w × h`, and offsets `dx, dy`:
|
|||
| Bottom left | `dx` | `H - dy - h` |
|
||||
| Bottom right | `W - dx - w` | `H - dy - h` |
|
||||
|
||||
For the uncropped positioning draft, under the user's described center-position convention, WebRCS values are
|
||||
For uncropped geometry, the visible-box center values are
|
||||
`horizontal = x + w/2`, `vertical = y + h/2`. The inverse subtracts the half-size.
|
||||
The corresponding inward margins are `left=x`, `top=y`, `right=W-x-w` and
|
||||
`bottom=H-y-h`. Switching corner just chooses which margins to display.
|
||||
|
|
@ -416,8 +137,8 @@ Example used in every mockup: on a **1920 × 1080** screen, a **640 × 360** lay
|
|||
**120 px from the right** and **180 px from the top** has top-left **1160, 180**
|
||||
and center **1480, 360**. The other layer is at **120, 180**, center **440, 360**.
|
||||
An odd width such as 641 produces a half-pixel center when the left edge is an
|
||||
integer; hardware acceptance/rounding is a compatibility question, not something
|
||||
to hide with display formatting. Advanced cropping must retain these visible-box
|
||||
integer; the device exporter quantizes geometry and verifies reconstruction error.
|
||||
See the device-send interface for container corrections. Advanced cropping must retain these visible-box
|
||||
coordinates while deriving any distinct device container through its adapter.
|
||||
|
||||
## Visual proposals
|
||||
|
|
@ -498,76 +219,8 @@ offline simulator that may help verify behavior without connecting this helper
|
|||
to hardware. Simulator agreement should still be checked against the installed
|
||||
WebRCS version.
|
||||
|
||||
Open compatibility decisions: exact installed firmware and primary operator
|
||||
OS/display scale. Concept A is approved and draw.io is the first clipboard source,
|
||||
with the user-supplied percent-encoded rectangle retained as a regression fixture.
|
||||
|
||||
Reference-picture implementation update: PNG/JPEG/BMP import and file drop are
|
||||
available, with fill-screen or proportion-preserving fit, opacity and visibility.
|
||||
Resolution scaling produces a warning; aspect distortion a severe warning. Both
|
||||
remain non-blocking. Image offsets remain future work; project save/load is implemented.
|
||||
|
||||
Corner-resizing implementation update: selected layers have interactive corner
|
||||
handles with a fixed opposite anchor, ratio locking enabled by default, an explicit
|
||||
free-resize toggle, Escape cancellation and one undo record per gesture. Numeric
|
||||
width/height edits follow the same ratio toggle; pasted source sizes remain exact.
|
||||
|
||||
Formats/framing implementation update: dynamic output presets/custom resolution,
|
||||
source aspect/native dimensions, shared input crops, virtual visible layer sizes,
|
||||
advanced crop-backed zoom/offset, content drag/nudge, test-pattern preview and
|
||||
provisional calculation reports are implemented. Resize/source edits preserve
|
||||
normalized content centers, with explicit review of any required adjustment.
|
||||
Document history includes source, output and layer crops atomically. Firmware
|
||||
container verification, crop quantization and hardware integration remain deferred.
|
||||
|
||||
## Current external/verification gates
|
||||
|
||||
Selected-layer outbound sends now include explicit destinations, bank and target,
|
||||
exact field review, stale checks, one-shot writes and readback. Both sizing modes
|
||||
and Centered-crop import round trips passed Eikos 3.3.10 hardware checks.
|
||||
|
||||
- Physical-screen comparison with test images and additional firmware remains.
|
||||
- Non-Centered aspects, masks and source routing/shared input synchronization are
|
||||
outside the implemented crop adapter. Local input correction is combined into
|
||||
the destination's layer crop; no shared input setting is changed.
|
||||
- Native clipboard adapters beyond the documented text formats need actual application/version
|
||||
samples; no undocumented Illustrator/Inkscape clipboard compatibility is claimed.
|
||||
- Operator-platform acceptance (Windows/macOS, DPI, GPU presentation) and release
|
||||
packaging remain separate from the Linux native UI and headless timing checks.
|
||||
- Embedded-reference project loading is still synchronous. Collapsible single-level folders and drag organization
|
||||
are implemented; nested folder trees remain optional work.
|
||||
|
||||
## Pending stretch goals — specifications to follow
|
||||
|
||||
- [x] **More software export/import formats.** SVG/draw.io, geometry JSON/CSV,
|
||||
DXF and HTML/CSS have documented import/export adapters, artwork capabilities,
|
||||
round-trip tests and Full HD/UHD templates. Inkscape, Illustrator, Affinity and
|
||||
Figma can use SVG; CAD tools use DXF; spreadsheets use CSV. Native PPTX and FIG
|
||||
now use optional ArtCraft Rust codecs; AI uses an optional local VectorCraft
|
||||
converter. All share an export window and import mapping review with a page
|
||||
selector. `no_proprietary` builds exclude these adapters. PDF, PSD, VSDX and ODG
|
||||
remain outside the current geometry contract.
|
||||
|
||||
|
||||
- [ ] **Capture Midra input preview images.** Capture a still preview from a chosen
|
||||
Midra input for inspecting source content and framing in the editor. Verify on
|
||||
the target firmware whether WebRCS exposes previews on request or continuously,
|
||||
and establish the protocol, input identification, image resolution and refresh
|
||||
limits before implementation. Preview availability is not yet verified. Start
|
||||
with explicit capture; automatic refresh and image saving remain to specify.
|
||||
|
||||
- [x] **Folder-based local Midra layouts.** Shared All/Selected/Folder transfer
|
||||
scope defaults to All; folder mode follows folder selection for send/load.
|
||||
Saved links can be reused across alternative folders and manually remapped.
|
||||
Manual import saves links and new-layer folder membership with geometry.
|
||||
- [ ] **Further export and workflow cleanup.** The shared transfer scope is
|
||||
implemented; additional workflow changes still await specifications.
|
||||
- [ ] **Multiple saved layer links and link picking.** Extend the current single
|
||||
saved screen/layer destination per editor layer to support multiple saved links.
|
||||
Provide an **Add link** action to append extra destinations without replacing
|
||||
existing links; each link stores both screen ID and layer ID. Allow choosing
|
||||
which saved link to use for sending or loading. The user will provide specifications for link
|
||||
organization, selection and sending behavior. Update project interfaces,
|
||||
examples and migration tests when the eventual persistence schema is defined.
|
||||
|
||||
These are backlog items only; implementation waits for the forthcoming specifications.
|
||||
The installed firmware is recorded as Eikos 3.3.10. Primary operator OS/display
|
||||
scale and broader platform acceptance remain to verify. Concept A is approved;
|
||||
the user-supplied draw.io clipboard rectangle is retained as a regression fixture.
|
||||
The implementation and backlog at the top of this document supersede the original
|
||||
mockup assumptions.
|
||||
|
|
|
|||
|
|
@ -192,11 +192,11 @@ crop on each vertical side. The retained native region is 600 × 500, scaled by
|
|||
## Device mapping: keep the container separate
|
||||
|
||||
Implemented device adapter: supports both an **output-sized Midra layer with internal
|
||||
cropping** and a **specified-format Midra input (likely 16:9) with derived sizing
|
||||
cropping** and a **source-aspect layer container with derived sizing
|
||||
and cropping**. These use distinct container sizing algorithms, described in
|
||||
[the device exchange contract](interfaces/midra-device-send.md), with hardware
|
||||
write/readback checks on Eikos 3.3.10. Physical-screen comparison remains outstanding. See
|
||||
[the two-strategy export backlog](midra-layout-plan.md#12-deferred-two-midra-export-sizing-strategies).
|
||||
[remaining acceptance checks](midra-layout-plan.md#remaining-acceptance-and-release-checks).
|
||||
|
||||
|
||||
The intended hardware aspect choice is **Centered**, as requested. The
|
||||
|
|
|
|||
|
|
@ -286,24 +286,19 @@ The title is clipped to the banner and appears only without an imported referenc
|
|||
image, at any output resolution. It is not exported to SVG or sent to Midra.
|
||||
|
||||
The initial backdrop is illustrative and adapts to every output resolution/aspect ratio; importing a reference picture replaces it.
|
||||
Live video and verified hardware container/crop conversion remain future work.
|
||||
Project JSON save/load and SVG geometry export are implemented (see below).
|
||||
Project save/load, nine-format geometry exchange, arbitrary layer collections,
|
||||
single-level folders and persistent Midra screen/layer links are implemented.
|
||||
File export offers current/specific/selected/all/visible scopes; device transfers
|
||||
use All/Selected/Folder. Organization never sends commands by itself.
|
||||
|
||||
[Layer management and export scope](midra-layout-plan.md#11-later-stretch-goal-layer-management-and-export-scope)
|
||||
are also later stretch goals: **Add layer**, Midra layer
|
||||
mapping in **Options**, and device-targeted export of a **specific layer** or
|
||||
**visible layers only**. SVG already supports all or visible layers. Optional folders would organize local layers. Visibility and organization
|
||||
will not send commands or change the live device.
|
||||
|
||||
Applying layer format through the WebRCS REST API is a
|
||||
[later stretch goal](midra-layout-plan.md#10-later-stretch-goal-apply-layer-format-through-the-webrcs-rest-api).
|
||||
The currently connected Eikos is live: this work must remain offline, with no
|
||||
device probing or commands. A future integration must preview changes and require
|
||||
an explicit send action; local editing must never update the device automatically.
|
||||
|
||||
The displayed WebRCS values use the planned center-from-top-left convention.
|
||||
Actual firmware coordinate limits, crop behavior and decimal acceptance are not
|
||||
verified yet. Fractional values remain visible rather than silently rounded.
|
||||
The Midra connection and mapping/transfer UI supports explicit sends and loads,
|
||||
with both sizing strategies and Centered crop conversion readback-tested on
|
||||
Eikos 3.3.10. Program sending is enabled by a manual preference. Ordinary local
|
||||
editing does not send; linked send is a direct user action. Physical-output
|
||||
comparison, broader firmware coverage and non-Centered/masked conversion remain
|
||||
[acceptance/backlog work](midra-layout-plan.md#remaining-acceptance-and-release-checks).
|
||||
Visible-box center readouts are distinct from crop-corrected device containers.
|
||||
Internal precision is retained; views show one decimal and exports whole pixels.
|
||||
|
||||
The window can be resized; the screen keeps its aspect ratio, and the right
|
||||
inspector scrolls on shorter windows. Minimum size is 1000 × 720 logical points.
|
||||
|
|
@ -858,7 +853,8 @@ Picture import/drop reads and decodes off the UI thread, retaining the current
|
|||
reference until successful completion. Canceling/removing discards late results;
|
||||
failed replacements keep the current image. Decoder work is serialized to bound
|
||||
peak memory. Minification uses linear filtering, magnification nearest-neighbor.
|
||||
Embedded reference decoding during project load remains synchronous.
|
||||
Project/recovery reads and embedded reference decoding also run in a worker;
|
||||
the editor is installed atomically after all images validate.
|
||||
|
||||
Resize snapping now uses the same preference and Alt inversion as movement snapping.
|
||||
It preserves opposite anchors, aspect ratio and group-resize proportions. Guides
|
||||
|
|
@ -1001,3 +997,26 @@ a layer or open its Crop properties to show its pattern and faded cropped overfl
|
|||
leaving crop editing hides them again. **Show source patterns on other layers
|
||||
while cropping** optionally displays patterns on the other layers during that
|
||||
mode only (except outline-only layers).
|
||||
|
||||
## Capture an input still from Midra
|
||||
|
||||
Connect to Midra, then choose **Import → Capture Midra input…** (also available
|
||||
under the viewport context menu's **Reference images**). Choose an available input,
|
||||
click **Capture still**, inspect the preview, then **Add as reference**. Signal
|
||||
indicators reflect the last connection refresh; an inactive input may return a
|
||||
blank image. If input snapshots are disabled, enable them in WebRCS and refresh
|
||||
the connection.
|
||||
|
||||
Capture is manual: no background polling, no live stream, one request in flight
|
||||
and a minimum five-second gap between requests. Cancel/close ignores the response;
|
||||
another request waits for the old one to finish or time out (20 seconds).
|
||||
The returned resolution/freshness comes from the device; this is not a full-size
|
||||
source recording. Existing image-size/aspect warnings apply before adding.
|
||||
Added stills are fixed references with independent hide/show/remove controls and
|
||||
are embedded in saved projects. They do not become layer-content textures or
|
||||
change source routing. See the [input preview contract](interfaces/midra-input-preview.md).
|
||||
|
||||
Opening a project or restoring recovery now reads, validates and decodes embedded
|
||||
references in a worker. The current editor stays intact until the whole project
|
||||
is ready. Manual loading has a Cancel button; errors keep the old project.
|
||||
Recovery autosave pauses while loading, including on exit.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
- Add manual Midra input-still capture through the verified WebRCS PNG endpoint, with preview/Add as reference, one request at a time and a five-second minimum interval. No live polling or device-setting writes; active-input 512 × 288 and inactive blank-image responses checked on the Eikos.
|
||||
- Load project/recovery files and decode embedded references in a background worker, install atomically, preserve work on errors/cancel and pause recovery autosave while loading. Reconcile the historical plan into completed implementation, remaining features and separate hardware/platform acceptance checks.
|
||||
|
||||
- Add README-linked two-layer PPTX, Figma FIG and Illustrator AI templates in Full HD and UHD 4K. Extend the template generator with format selection and import verification; test native fixture geometry, with AI checked through VectorCraft 0.24.1.
|
||||
|
||||
- Remove the redundant Copy coordinates button from the title header and right-align the device label. Existing copy commands remain available.
|
||||
|
|
|
|||
Loading…
Reference in New Issue