Group viewport context menu properties and preview controls
This commit is contained in:
parent
ab8209301a
commit
ccdfb5af4e
|
|
@ -361,6 +361,34 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
}
|
||||
pub(super) fn crop_preview_quick_controls(&mut self, ui: &mut egui::Ui, i: usize) {
|
||||
let id = self.layout.layer_info(i).id;
|
||||
let Some(preview) = self.capture.layers.get_mut(&id) else {
|
||||
ui.weak("Configure capture to choose an input.");
|
||||
return;
|
||||
};
|
||||
ui.separator();
|
||||
ui.checkbox(&mut preview.enabled, "Enable input preview");
|
||||
let has_image = preview.enabled
|
||||
&& preview.texture.is_some()
|
||||
&& preview.source == self.layout.formats().source_for[i];
|
||||
let mut opacity = if has_image {
|
||||
preview.guides * 100.0
|
||||
} else {
|
||||
100.0
|
||||
};
|
||||
if ui
|
||||
.add_enabled(
|
||||
has_image,
|
||||
egui::Slider::new(&mut opacity, 0.0..=100.0)
|
||||
.text("Crop guide opacity")
|
||||
.suffix("%"),
|
||||
)
|
||||
.changed()
|
||||
{
|
||||
preview.guides = opacity / 100.0;
|
||||
}
|
||||
}
|
||||
pub(super) fn crop_preview_controls(&mut self, ui: &mut egui::Ui, i: usize) {
|
||||
let id = self.layout.layer_info(i).id;
|
||||
let source = self.layout.formats().source_for[i];
|
||||
|
|
|
|||
|
|
@ -1914,29 +1914,27 @@ impl Editor {
|
|||
fn layer_context_menu(&mut self, ui: &mut egui::Ui) {
|
||||
ui.set_min_width(210.0);
|
||||
if let Some(id) = self.layer_ui.context_layer {
|
||||
self.layer_actions_menu(ui, id);
|
||||
self.layer_organize_menu(ui, id);
|
||||
ui.separator();
|
||||
}
|
||||
self.snapping_menu(ui);
|
||||
ui.separator();
|
||||
let selected = self.layout.selected_indices();
|
||||
if !selected.is_empty() {
|
||||
if ui.button("Copy layer values").clicked() {
|
||||
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());
|
||||
}
|
||||
ui.separator();
|
||||
}
|
||||
if let Some(i) = self.layout.selected() {
|
||||
ui.weak(self.layout.layer_label(i));
|
||||
for (title, tab) in [
|
||||
("Source properties…", PropertyTab::Source),
|
||||
("Layer properties…", PropertyTab::Layer),
|
||||
("Crop properties…", PropertyTab::Crop),
|
||||
("Mapping properties…", PropertyTab::Mapping),
|
||||
("Configure capture…", PropertyTab::Preview),
|
||||
] {
|
||||
if ui.button(title).clicked() {
|
||||
if self.format_draft.as_ref().is_none_or(|d| !d.is_for(i)) {
|
||||
self.format_draft = Some(FormatDraft::new(&self.layout, i));
|
||||
}
|
||||
self.property_tab = tab;
|
||||
ui.close_menu();
|
||||
}
|
||||
}
|
||||
let crop_label = if self.edit_content {
|
||||
"Done adjusting crop"
|
||||
} else {
|
||||
|
|
@ -1990,17 +1988,34 @@ impl Editor {
|
|||
self.resize_ratio_option(ui);
|
||||
ui.menu_button("Align…", |ui| self.alignment_menu(ui));
|
||||
ui.separator();
|
||||
if ui.button("Copy layer values").clicked() {
|
||||
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 let Some(i) = self.layout.selected() {
|
||||
ui.menu_button("Properties", |ui| {
|
||||
for (title, tab) in [
|
||||
("Source properties…", PropertyTab::Source),
|
||||
("Layer properties…", PropertyTab::Layer),
|
||||
("Crop properties…", PropertyTab::Crop),
|
||||
("Mapping properties…", PropertyTab::Mapping),
|
||||
] {
|
||||
if ui.button(title).clicked() {
|
||||
if self.format_draft.as_ref().is_none_or(|d| !d.is_for(i)) {
|
||||
self.format_draft = Some(FormatDraft::new(&self.layout, i));
|
||||
}
|
||||
self.property_tab = tab;
|
||||
ui.close_menu();
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.menu_button("Input preview & crop guides", |ui| {
|
||||
if ui.button("Configure capture…").clicked() {
|
||||
if self.format_draft.as_ref().is_none_or(|d| !d.is_for(i)) {
|
||||
self.format_draft = Some(FormatDraft::new(&self.layout, i));
|
||||
}
|
||||
self.property_tab = PropertyTab::Preview;
|
||||
ui.close_menu();
|
||||
}
|
||||
self.crop_preview_quick_controls(ui, i);
|
||||
});
|
||||
ui.separator();
|
||||
}
|
||||
if ui.button("Lock selected layers").clicked() {
|
||||
for &i in &selected {
|
||||
|
|
@ -2018,8 +2033,14 @@ impl Editor {
|
|||
self.sync();
|
||||
ui.close_menu();
|
||||
}
|
||||
}
|
||||
if let Some(id) = self.layer_ui.context_layer {
|
||||
self.layer_delete_menu(ui, id);
|
||||
}
|
||||
if !selected.is_empty() || self.layer_ui.context_layer.is_some() {
|
||||
ui.separator();
|
||||
}
|
||||
self.snapping_menu(ui);
|
||||
ui.menu_button("Reference images", |ui| self.reference_actions_menu(ui));
|
||||
if ui.button("Output format…").clicked() {
|
||||
self.output_draft = Some(OutputDraft::new(self.layout.formats().output));
|
||||
|
|
@ -7422,6 +7443,7 @@ mod tests {
|
|||
(false, "Source properties…", PropertyTab::Source),
|
||||
(false, "Layer properties…", PropertyTab::Layer),
|
||||
(false, "Crop properties…", PropertyTab::Crop),
|
||||
(false, "Mapping properties…", PropertyTab::Mapping),
|
||||
(false, "Configure capture…", PropertyTab::Preview),
|
||||
(true, "Lock selected layers", PropertyTab::Layer),
|
||||
] {
|
||||
|
|
@ -7448,6 +7470,32 @@ mod tests {
|
|||
let output = frame(&mut app, &ctx, vec![]);
|
||||
assert_eq!(app.layout.selection_mask(), [true, grouped]);
|
||||
assert_eq!(*app.layout.layers(), before);
|
||||
let output = if !grouped {
|
||||
let submenu = if tab == PropertyTab::Preview {
|
||||
"Input preview & crop guides"
|
||||
} else {
|
||||
"Properties"
|
||||
};
|
||||
let pos = output
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|s| match &s.shape {
|
||||
egui::Shape::Text(t) if t.galley.text() == submenu => {
|
||||
Some(t.pos + t.galley.size() / 2.0)
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.expect("property submenu");
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::PointerMoved(pos), mouse(pos, true)],
|
||||
);
|
||||
frame(&mut app, &ctx, vec![mouse(pos, false)]);
|
||||
frame(&mut app, &ctx, vec![])
|
||||
} else {
|
||||
output
|
||||
};
|
||||
let pos = output
|
||||
.shapes
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ impl LayerUi {
|
|||
}
|
||||
impl Editor {
|
||||
pub(super) fn layer_actions_menu(&mut self, ui: &mut egui::Ui, id: usize) {
|
||||
self.layer_organize_menu(ui, id);
|
||||
self.layer_delete_menu(ui, id);
|
||||
}
|
||||
pub(super) fn layer_organize_menu(&mut self, ui: &mut egui::Ui, id: usize) {
|
||||
let Some(i) = (0..self.layout.layers().len()).find(|&i| self.layout.layer_info(i).id == id)
|
||||
else {
|
||||
return;
|
||||
|
|
@ -121,6 +125,12 @@ impl Editor {
|
|||
ui.close_menu();
|
||||
}
|
||||
});
|
||||
}
|
||||
pub(super) fn layer_delete_menu(&mut self, ui: &mut egui::Ui, id: usize) {
|
||||
let Some(i) = (0..self.layout.layers().len()).find(|&i| self.layout.layer_info(i).id == id)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let can_delete =
|
||||
self.layout.layers().len() > 1 && self.layout.visible(i) && !self.layout.locked(i);
|
||||
if ui
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
- Group viewport context-menu property windows under Properties and capture under
|
||||
Input preview & crop guides, with quick preview/opacity controls. Keep common
|
||||
editing actions direct, move Delete after Lock/Hide, and group canvas options
|
||||
at the bottom. UI tests exercise property submenus and multi-selection actions.
|
||||
|
||||
- Allow Midra mapping & transfer to open while offline, with Connection settings
|
||||
available and scope/mapping controls hidden until connected. UI regression
|
||||
coverage verifies offline opening does not start a read or send.
|
||||
|
|
|
|||
|
|
@ -154,3 +154,17 @@ Mirror/Opposite resizing still require exactly two layers.
|
|||
Project JSON is version 12, with tested migration from older supported versions.
|
||||
Every format’s **Selected layers…** action exports just the current selection,
|
||||
including a single layer. All/visible export remains available.
|
||||
|
||||
## Viewport context menu
|
||||
|
||||
Right-click a layer for rename/folder actions, copy/paste, crop adjustment,
|
||||
aspect-ratio locking and alignment. **Properties** groups the Source, Layer,
|
||||
Crop and Mapping windows. **Input preview & crop guides → Configure capture…**
|
||||
opens the Preview tab; an existing preview also offers an enable toggle and crop
|
||||
guide opacity directly in that submenu. Opacity is adjustable only with an
|
||||
available preview image. Input selection stays in the window, so long input
|
||||
lists do not interfere with the context menu.
|
||||
|
||||
Lock, Hide and Delete follow the editing controls. Snapping, Reference images
|
||||
and Output format are together at the bottom. Multiple selection retains its
|
||||
Resize together and alignment actions.
|
||||
|
|
|
|||
Loading…
Reference in New Issue