Move input send controls above editor and preserve capture brightness
This commit is contained in:
parent
7e80311797
commit
6f5c24ed6b
|
|
@ -602,7 +602,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "canvas-pilot"
|
||||
version = "0.9.67"
|
||||
version = "0.9.68"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"craft-dwg",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.9.67"
|
||||
version = "0.9.68"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot"
|
||||
|
|
|
|||
|
|
@ -155,6 +155,14 @@ impl Editor {
|
|||
ui.label(format!("Input {} · plug {} · {}",id,draft.plug,draft.native.map(|n|format!("{} × {} source pixels",n[0],n[1])).unwrap_or("No valid signal dimensions".into())));
|
||||
let consumers: Vec<_> = snapshot.screens.iter().flat_map(|screen| screen.layers.iter().filter(move |layer|snapshot.profile.input_from_source(&layer.source)==Some(id)).map(move|layer|format!("Screen {} / {} · Layer {}",screen.id,screen.preview_bank,layer.id))).collect();
|
||||
ui.collapsing(format!("Known Preview consumers ({})",consumers.len()),|ui|{for consumer in consumers {ui.label(consumer);}ui.small("Program layers, other consumers, backgrounds and multiviewer may also use this input.");});
|
||||
match draft.changes(snapshot) {
|
||||
Ok(changes)=>{
|
||||
if ui.add_enabled(!changes.is_empty() && state.pending.is_none() && !self.device.busy(),egui::Button::new("Send changes")).clicked(){send=Some(draft.clone());}
|
||||
}
|
||||
Err(error)=>{ui.colored_label(theme::palette(ui.ctx()).amber,error);}
|
||||
}
|
||||
if state.pending.is_some(){ui.spinner();ui.label("Sending and verifying input settings…");}
|
||||
if !state.message.is_empty(){ui.label(&state.message);}
|
||||
let before=draft.values.clone();
|
||||
let mut undoing=false;
|
||||
ui.add_enabled_ui(state.pending.is_none() && !self.device.busy(),|ui|{
|
||||
|
|
@ -213,14 +221,7 @@ impl Editor {
|
|||
if before!=draft.values && !undoing && state.edit_start.is_none(){state.edit_start=Some(before);}
|
||||
if !ui.input(|i|i.pointer.any_down()) && let Some(before)=state.edit_start.take(){let history=state.undo.entry(id).or_default();history.push(before);if history.len()>100{history.remove(0);}}
|
||||
ui.separator();
|
||||
match draft.changes(snapshot) {
|
||||
Ok(changes)=>{
|
||||
if ui.add_enabled(!changes.is_empty() && state.pending.is_none() && !self.device.busy(),egui::Button::new("Send changes")).clicked(){send=Some(draft.clone());}
|
||||
}
|
||||
Err(error)=>{ui.colored_label(theme::palette(ui.ctx()).amber,error);}
|
||||
}
|
||||
if state.pending.is_some(){ui.spinner();ui.label("Sending and verifying input settings…");}
|
||||
if !state.message.is_empty(){ui.label(&state.message);}
|
||||
|
||||
});
|
||||
self.inputs.open = open;
|
||||
if refresh && !self.device.busy() {
|
||||
|
|
@ -434,11 +435,14 @@ fn crop_editor(
|
|||
native: native.map(|n| n as u32),
|
||||
aspect: canvas_pilot::formats::Aspect::Custom,
|
||||
};
|
||||
super::format_ui::paint_pattern_clipped(&painter, full, source, Crop::default(), full);
|
||||
// Protection disables editing controls, not the visibility of the source picture.
|
||||
let mut content_painter = painter.clone();
|
||||
content_painter.set_opacity(1.0);
|
||||
super::format_ui::paint_pattern_clipped(&content_painter, full, source, Crop::default(), full);
|
||||
if let Some((texture, geometry)) = preview
|
||||
&& let Some((known, uv)) = geometry.rectangles(full, native)
|
||||
{
|
||||
painter.image(texture, known, uv, Color32::WHITE);
|
||||
content_painter.image(texture, known, uv, Color32::WHITE);
|
||||
}
|
||||
painter.rect_stroke(full, 0., Stroke::new(1., palette.muted), StrokeKind::Inside);
|
||||
let crop = draft.crop();
|
||||
|
|
@ -544,6 +548,78 @@ fn crop_editor(
|
|||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn protected_crop_still_composites_capture_at_full_opacity() {
|
||||
let app = input_app();
|
||||
let mut draft = InputDraft::read(app.device.snapshot.as_ref().unwrap(), 1).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
let texture = ctx.load_texture(
|
||||
"capture-test",
|
||||
egui::ColorImage::filled([4, 4], Color32::RED),
|
||||
Default::default(),
|
||||
);
|
||||
let geometry = CaptureGeometry {
|
||||
native: [1920., 1080.],
|
||||
crop: Crop {
|
||||
left: 480.,
|
||||
right: 480.,
|
||||
top: 270.,
|
||||
bottom: 270.,
|
||||
},
|
||||
};
|
||||
let mut pivot = [1, 1];
|
||||
let mut zoom = 1.;
|
||||
let mut pan = Vec2::ZERO;
|
||||
let mut drag = None;
|
||||
let mut message = String::new();
|
||||
let output = ctx.run_ui(Default::default(), |ui| {
|
||||
ui.add_enabled_ui(false, |ui| {
|
||||
crop_editor(
|
||||
ui,
|
||||
&mut draft,
|
||||
&mut pivot,
|
||||
(&mut zoom, &mut pan),
|
||||
&mut drag,
|
||||
&mut message,
|
||||
Some((texture.id(), geometry)),
|
||||
)
|
||||
});
|
||||
});
|
||||
let mesh = output
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|s| match &s.shape {
|
||||
egui::Shape::Mesh(mesh) if mesh.texture_id == texture.id() => Some(mesh),
|
||||
_ => None,
|
||||
})
|
||||
.expect("capture must be drawn over the pattern even when crop editing is protected");
|
||||
assert!(mesh.vertices.iter().all(|v| v.color == Color32::WHITE));
|
||||
assert!(
|
||||
mesh.vertices
|
||||
.iter()
|
||||
.all(|v| (0.25..=0.75).contains(&v.uv.x) && (0.25..=0.75).contains(&v.uv.y))
|
||||
);
|
||||
assert_eq!(draft.crop().left, 24.);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn send_changes_is_above_the_crop_editor() {
|
||||
let mut app = input_app();
|
||||
let ctx = egui::Context::default();
|
||||
super::super::tests::frame(&mut app, &ctx, vec![]);
|
||||
let output = super::super::tests::frame(&mut app, &ctx, vec![]);
|
||||
let y = |label: &str| {
|
||||
output
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|s| match &s.shape {
|
||||
egui::Shape::Text(t) if t.galley.text() == label => Some(t.pos.y),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap()
|
||||
};
|
||||
assert!(y("Send changes") < y("Input crop"));
|
||||
}
|
||||
#[test]
|
||||
fn input_categories_start_protected_and_full_zoom_clears_asymmetric_crop() {
|
||||
let mut app = input_app();
|
||||
let ctx = egui::Context::default();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### v0.9.68
|
||||
|
||||
- Moved **Send changes**, validation feedback and status above the input editor.
|
||||
- Keep the captured picture and sizing-grid composite at full opacity while
|
||||
**Keep device values** disables crop editing. Verified capture geometry is still
|
||||
required; draft crop changes never reposition or stretch the captured pixels.
|
||||
|
||||
|
||||
### v0.9.67
|
||||
|
||||
- Input editor categories now start with **Keep device values** enabled.
|
||||
|
|
|
|||
|
|
@ -317,12 +317,13 @@ additional controls without downloading the complete device store.
|
|||
|
||||
This edits preprocessing shared by every consumer of that input, including
|
||||
Program and layers outside the project. Nothing is sent while dragging, selecting
|
||||
an input, capturing an image or opening the window. Use **Send changes** to apply the edited fields directly, with fresh device
|
||||
an input, capturing an image or opening the window. Use **Send changes** above the editor to apply the edited fields directly, with fresh device
|
||||
validation and verified readback.
|
||||
|
||||
- **Keep device values:** each category has this toggle. Check it to discard that
|
||||
category’s draft edits, disable its controls and leave it untouched when sending.
|
||||
Crop protection also disables the visual crop editor. Uncheck to edit again.
|
||||
Crop protection also disables the visual crop editor; the captured picture
|
||||
and sizing grid remain at full opacity. Uncheck to edit again.
|
||||
All categories start protected. Uncheck only the categories you want to edit;
|
||||
unchanged fields are never sent. Protection is retained when discarding edits,
|
||||
and all categories return to protected when reloading the input.
|
||||
|
|
|
|||
Loading…
Reference in New Issue