Add paste layer values to the layer context menu
This commit is contained in:
parent
8de8a374ae
commit
8f3095f777
|
|
@ -562,6 +562,15 @@ impl Editor {
|
|||
.map(|i| FormatDraft::new(&self.layout, i));
|
||||
}
|
||||
}
|
||||
fn request_layer_paste(ctx: &egui::Context) {
|
||||
ctx.memory_mut(|m| {
|
||||
if let Some(id) = m.focused() {
|
||||
m.surrender_focus(id);
|
||||
}
|
||||
});
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::RequestPaste);
|
||||
}
|
||||
|
||||
fn open_paste(&mut self, text: String) {
|
||||
let targets = self.layout.selected_indices();
|
||||
let mut p = Paste {
|
||||
|
|
@ -1723,6 +1732,14 @@ impl Editor {
|
|||
self.copy(ui.ctx());
|
||||
ui.close_menu();
|
||||
}
|
||||
if ui
|
||||
.button("Paste layer values")
|
||||
.on_hover_text("Read the clipboard and review which values and layers to apply.")
|
||||
.clicked()
|
||||
{
|
||||
ui.close_menu();
|
||||
Self::request_layer_paste(ui.ctx());
|
||||
}
|
||||
if ui.button("Lock selected layers").clicked() {
|
||||
for &i in &selected {
|
||||
self.layout.set_locked(i, true);
|
||||
|
|
@ -5454,6 +5471,60 @@ mod tests {
|
|||
app.edit_content = false;
|
||||
assert_eq!(app.content_hit(covered, origin, 1.0), None);
|
||||
}
|
||||
#[test]
|
||||
fn context_paste_requests_clipboard_and_reviews_values_before_applying() {
|
||||
let mut app = Editor::default();
|
||||
let ctx = egui::Context::default();
|
||||
let before = app.layout.layers().clone();
|
||||
let output = frame(&mut app, &ctx, vec![]);
|
||||
let pos = layer_rects(&output)[0].center();
|
||||
let secondary = |pressed| egui::Event::PointerButton {
|
||||
pos,
|
||||
button: egui::PointerButton::Secondary,
|
||||
pressed,
|
||||
modifiers: egui::Modifiers::NONE,
|
||||
};
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::PointerMoved(pos), secondary(true)],
|
||||
);
|
||||
frame(&mut app, &ctx, vec![secondary(false)]);
|
||||
let output = frame(&mut app, &ctx, vec![]);
|
||||
let pos = output
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|s| match &s.shape {
|
||||
egui::Shape::Text(t) if t.galley.text() == "Paste layer values" => {
|
||||
Some(t.pos + t.galley.size() / 2.)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.expect("context paste action");
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::PointerMoved(pos), mouse(pos, true)],
|
||||
);
|
||||
let output = frame(&mut app, &ctx, vec![mouse(pos, false)]);
|
||||
assert!(output.viewport_output.values().any(|v| {
|
||||
v.commands
|
||||
.iter()
|
||||
.any(|c| matches!(c, egui::ViewportCommand::RequestPaste))
|
||||
}));
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::Paste(
|
||||
include_str!("../tests/fixtures/drawio-rectangle.txt").into(),
|
||||
)],
|
||||
);
|
||||
let paste = app.paste.as_ref().expect("paste mapping review");
|
||||
assert!(paste.error.is_empty());
|
||||
assert_eq!(paste.shapes.len(), 1);
|
||||
assert_eq!(*app.layout.layers(), before);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn import_menu_requests_clipboard_and_opens_layer_review() {
|
||||
let mut app = Editor::default();
|
||||
|
|
|
|||
|
|
@ -60,13 +60,7 @@ impl Editor {
|
|||
.clicked()
|
||||
{
|
||||
ui.close_menu();
|
||||
ui.ctx().memory_mut(|m| {
|
||||
if let Some(id) = m.focused() {
|
||||
m.surrender_focus(id);
|
||||
}
|
||||
});
|
||||
ui.ctx()
|
||||
.send_viewport_cmd(egui::ViewportCommand::RequestPaste);
|
||||
Self::request_layer_paste(ui.ctx());
|
||||
}
|
||||
ui.separator();
|
||||
ui.weak("Screen reference");
|
||||
|
|
|
|||
|
|
@ -208,7 +208,8 @@ clipboard testing against a running draw.io instance remains to be done.
|
|||
can be toggled on paste. This is not a native WebRCS clipboard payload.
|
||||
|
||||
Right-click a layer for **Source properties**, **Layer properties**, **Crop properties**,
|
||||
**Adjust layer crop**, alignment, copying values, and lock/hide actions. Right-clicking a layer
|
||||
**Adjust layer crop**, alignment, **Copy layer values**, **Paste layer values**, and lock/hide actions.
|
||||
Paste reads the clipboard and opens the existing value/mapping review before applying changes. Right-clicking a layer
|
||||
already in a selection keeps the whole selection and offers **Resize together**.
|
||||
Right-clicking an unselected layer selects it first. Locked/hidden layers remain
|
||||
protected; use the layer list to unlock/show them. Right-click empty canvas for
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
- Add Paste layer values beside Copy layer values in the layer context menu, using the existing clipboard import and mapping review before applying changes.
|
||||
|
||||
- Make Source an advanced, opt-in section with explanations of input aspect correction and pre-layer input crop. Show the linked device input's actual WebRCS aspect/crop controls separately from the local geometry model. Stage only edited fields, include them in scoped sends only while enabled, and pulse input crop updates. The opt-in and staged device edits are session-only and clear on disconnect, address/project change or uncheck. Verified field names/ranges against the connected Eikos WebRCS; regression tests use mock devices, without hardware writes.
|
||||
|
||||
- Add a Mapping properties tab and right-click entry with selectable Midra screen/layer links and Unmap. Unmapped layers are excluded from linked sends/loads; link edits are local, saved with projects and undoable. Move the separate editor input identity selector into Mapping.
|
||||
|
|
|
|||
Loading…
Reference in New Issue