mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-28 09:09:39 +01:00
#3668: Render Queue: Ctrl+D duplicates the selected item
Edit ▸ Duplicate is application-wide and needs a layer, so with the Render Queue focused its Ctrl/⌘+D key reported "no layer is currently selected". The command now follows the panel focus, as Clear already does: it runs renderQueue.duplicate on the selected item and selects the copy. The menu entry is enabled by the same rule. The context menu's Duplicate is unchanged.
This commit is contained in:
1 parent
dc2380b070
commit
24e3984603
4 files changed
+86
-4
No files matched your search
@@ -125,6 +125,11 @@ pub(crate) fn entry_enabled(app: &EffectcraftApp, e: &MenuEntry) -> bool {
|
||||
if e.command == "edit.clear" && app.ui.focused == PanelKind::RenderQueue {
|
||||
return !app.session.is_rendering() && !app.session.project.render_queue.is_empty();
|
||||
}
|
||||
// Edit ▸ Duplicate copies the selected Render Queue item while that panel has focus
|
||||
// (#3668); the redirect in `invoke` needs the same rule so the entry is not grayed out.
|
||||
if e.command == "edit.duplicate" && app.ui.focused == PanelKind::RenderQueue {
|
||||
return !app.session.is_rendering() && !app.session.project.render_queue.is_empty();
|
||||
}
|
||||
if e.command == "file.close" && super::invoke::no_params(&e.params) && app.ui.focused == PanelKind::RenderQueue {
|
||||
return !app.ui.dock.locked;
|
||||
}
|
||||
|
||||
@@ -281,6 +281,24 @@ pub fn invoke(app: &mut EffectcraftApp, ctx: &egui::Context, id: &str, params: V
|
||||
None => Err("select a Render Queue item first".into()),
|
||||
};
|
||||
}
|
||||
// Duplicate follows panel focus too: in the Render Queue it copies the selected item (#3668),
|
||||
// as its context menu's Duplicate does, instead of reporting that no layer is selected. The
|
||||
// copy takes the selection, so Duplicate again copies the copy.
|
||||
if id == "edit.duplicate" && no_params(¶ms) && app.ui.focused == PanelKind::RenderQueue {
|
||||
if app.session.is_rendering() {
|
||||
return Err("the Render Queue is rendering".into());
|
||||
}
|
||||
let key = egui::Id::unique("rq-ui");
|
||||
let selected = ctx.data(|d| d.get_temp::<(Vec<u64>, Option<u64>)>(key)).and_then(|(_, id)| id);
|
||||
let Some(item) = selected else { return Err("select a Render Queue item first".into()) };
|
||||
let out = run_engine(app, ctx, "renderQueue.duplicate", json!({"item": item}))?;
|
||||
if let Some(copy) = out.get("item").and_then(Value::as_u64) {
|
||||
let mut state: (Vec<u64>, Option<u64>) = ctx.data(|d| d.get_temp(key)).unwrap_or_default();
|
||||
state.1 = Some(copy);
|
||||
ctx.data_mut(|d| d.insert_temp(key, state));
|
||||
}
|
||||
return Ok(out);
|
||||
}
|
||||
// Shift+Delete deletes the Project panel's selection without asking; it does nothing in the
|
||||
// other panels.
|
||||
if id == "project.deleteWithoutConfirmation" {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use effectcraft_engine::Session;
|
||||
use effectcraft_ui_egui::EffectcraftApp;
|
||||
use effectcraft_ui_egui::dock::PanelKind;
|
||||
use egui::{Key, Modifiers};
|
||||
use egui::{Id, Key, Modifiers};
|
||||
use serde_json::json;
|
||||
|
||||
/// A comp with one solid selected at 1 s, and one render item.
|
||||
@@ -20,9 +20,18 @@ fn app() -> EffectcraftApp {
|
||||
/// Press `key` with `modifiers` and run the shortcut dispatcher on it.
|
||||
fn press(app: &mut EffectcraftApp, key: Key, modifiers: Modifiers) {
|
||||
let ctx = egui::Context::default();
|
||||
let raw = egui::RawInput { events: vec![egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers }], ..Default::default() };
|
||||
let mut output = ctx.run_ui(raw, |ui| effectcraft_ui_egui::menus::handle_shortcuts(app, ui.ctx()));
|
||||
output.textures_delta.clear();
|
||||
press_in(&ctx, app, key, modifiers);
|
||||
}
|
||||
|
||||
/// Press `key` with `modifiers` on `ctx`, which keeps the panel state (such as the Render Queue's
|
||||
/// selected item) across presses.
|
||||
fn press_in(ctx: &egui::Context, app: &mut EffectcraftApp, key: Key, modifiers: Modifiers) {
|
||||
// A press and its release, a frame each: a key already down would read as a repeat.
|
||||
for pressed in [true, false] {
|
||||
let raw = egui::RawInput { events: vec![egui::Event::Key { key, physical_key: None, pressed, repeat: false, modifiers }], ..Default::default() };
|
||||
let mut output = ctx.run_ui(raw, |ui| effectcraft_ui_egui::menus::handle_shortcuts(app, ui.ctx()));
|
||||
output.textures_delta.clear();
|
||||
}
|
||||
}
|
||||
|
||||
fn layers(app: &EffectcraftApp) -> usize {
|
||||
@@ -84,3 +93,52 @@ fn the_default_preset_has_no_two_commands_on_one_chord_in_one_scope() {
|
||||
let c = app.session.shortcuts().all_conflicts();
|
||||
assert!(c.is_empty(), "{c:?}");
|
||||
}
|
||||
|
||||
/// The Render Queue keeps its selected item in egui temp data, as the panel does.
|
||||
fn select(ctx: &egui::Context, item: Option<u64>) {
|
||||
ctx.data_mut(|d| d.insert_temp(Id::unique("rq-ui"), (Vec::<u64>::new(), item)));
|
||||
}
|
||||
|
||||
fn selected(ctx: &egui::Context) -> Option<u64> {
|
||||
ctx.data(|d| d.get_temp::<(Vec<u64>, Option<u64>)>(Id::unique("rq-ui"))).and_then(|(_, id)| id)
|
||||
}
|
||||
|
||||
/// #3668: Ctrl/⌘+D in the Render Queue duplicates the selected item (the context menu's
|
||||
/// Duplicate does), rather than reporting that no layer is selected. Each copy takes the
|
||||
/// selection, so a second press copies the copy.
|
||||
#[test]
|
||||
fn cmd_d_duplicates_the_selected_render_queue_item() {
|
||||
let mut app = app();
|
||||
app.session.execute("renderQueue.add", json!({"output": "/out/second.mov"})).unwrap();
|
||||
let ids: Vec<u64> = app.session.project.render_queue.iter().map(|i| i.id).collect();
|
||||
assert_eq!(ids.len(), 2);
|
||||
app.ui.focused = PanelKind::RenderQueue;
|
||||
let ctx = egui::Context::default();
|
||||
select(&ctx, Some(ids[0]));
|
||||
|
||||
press_in(&ctx, &mut app, Key::D, Modifiers::COMMAND);
|
||||
let queue = &app.session.project.render_queue;
|
||||
assert!(app.ui.status.is_empty(), "{}", app.ui.status);
|
||||
assert_eq!(queue.len(), 3, "the queue gained one item");
|
||||
assert_eq!(queue[1].output.output, "/out/main.mov", "the copy sits after the item it copies");
|
||||
assert_eq!(selected(&ctx), Some(queue[1].id), "the copy takes the selection");
|
||||
assert_eq!(app.session.active_comp().map(|c| c.layers.len()), Some(1), "no layer was duplicated");
|
||||
|
||||
press_in(&ctx, &mut app, Key::D, Modifiers::COMMAND);
|
||||
let queue = &app.session.project.render_queue;
|
||||
assert_eq!(queue.len(), 4, "a second press copies the copy");
|
||||
assert_eq!(queue[2].output.output, "/out/main.mov");
|
||||
assert_eq!(selected(&ctx), Some(queue[2].id));
|
||||
}
|
||||
|
||||
/// With no item selected, Ctrl/⌘+D in the Render Queue changes nothing and says what to do.
|
||||
#[test]
|
||||
fn cmd_d_in_the_render_queue_needs_a_selected_item() {
|
||||
let mut app = app();
|
||||
app.ui.focused = PanelKind::RenderQueue;
|
||||
let ctx = egui::Context::default();
|
||||
select(&ctx, None);
|
||||
press_in(&ctx, &mut app, Key::D, Modifiers::COMMAND);
|
||||
assert_eq!(render_items(&app), 1);
|
||||
assert!(app.ui.status.contains("select a Render Queue item first"), "{}", app.ui.status);
|
||||
}
|
||||
@@ -49,6 +49,7 @@ Effects running; most of the rest parallelises.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-15 | minor | Edit ▸ Duplicate (Ctrl/⌘+D) copies the selected Render Queue item while that panel has focus (#3668) |
|
||||
| 2026-10-18 | minor | A shape group's inner Contents (After Effects' elided Vectors group) draws no row: the group's path, fill/stroke and Transform list directly under the group |
|
||||
| 2026-10-13 | minor | Accessibility row, second slice: Info, Flowchart, Script Console and the 3D Camera Tracker block named and keyboard-operable (#1335); no screen reader tested |
|
||||
| 2026-10-13 | minor | Accessibility row: AccessKit audit and contrast tests, Effects & Presets, Settings and Render Queue named and keyboard-operable (#1335); no screen reader tested |
|
||||
|
||||
Reference in new issue
Block a user