mirror of
https://github.com/storytold/filmcraft.git
synced 2026-10-22 18:22:22 +00:00
Clear leftover Project item selection when making a new bin.
New Bin only selected the folder and started rename, so Clear still targeted clips that were selected before. The trash button and Delete then removed those items and left the bin. Clicking a bin already deselects items; creating one now does the same, and Clear drops the rename field so it does not keep editing a bin that is about to go.
This commit is contained in:
3 files changed
+32
-1
No files matched your search
@@ -1411,6 +1411,7 @@ impl FilmcraftApp {
|
||||
}
|
||||
// Clear in the Project panel removes the selected bin when no item is selected (#587).
|
||||
let clear = if self.ui.focused == PanelKind::Project && id == "project.delete" {
|
||||
self.ui.project_panel.rename = None;
|
||||
crate::panels::project_views::clear_params(&self.session.state.project_selection, self.ui.project_panel.selected_bin)
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -625,7 +625,10 @@ fn footer(app: &mut FilmcraftApp, ui: &mut egui::Ui, bar: Rect, v: &View, action
|
||||
actions.push(("file.newBin".into(), json!({"parent": parent, "panel": pre})));
|
||||
}
|
||||
"project.delete" => match crate::panels::project_views::clear_params(&app.session.state.project_selection, app.ui.project_panel.selected_bin) {
|
||||
Some(p) => actions.push((id.into(), p)),
|
||||
Some(p) => {
|
||||
app.ui.project_panel.rename = None;
|
||||
actions.push((id.into(), p));
|
||||
}
|
||||
None => app.ui.status = tl!("Select items to clear").into(),
|
||||
},
|
||||
_ => actions.push((id.into(), json!({}))),
|
||||
@@ -732,6 +735,7 @@ pub fn panel_menu(app: &mut FilmcraftApp, ui: &mut egui::Ui) -> bool {
|
||||
actions.push(("projectPanel.rename".into(), json!({})));
|
||||
}
|
||||
if item(ui, "delete", tl!("Delete"), clear.is_some(), Some("Backspace")) {
|
||||
app.ui.project_panel.rename = None;
|
||||
actions.push(("project.delete".into(), clear.unwrap_or_default()));
|
||||
}
|
||||
ui.separator();
|
||||
@@ -979,6 +983,9 @@ pub fn new_bin(app: &mut FilmcraftApp, params: &Value) -> Result<Value, String>
|
||||
app.ui.expanded_bins.push(p);
|
||||
}
|
||||
let panel = params.get("panel").and_then(Value::as_str).map_or(shown.prefix, str::to_string);
|
||||
// Clicking a bin already clears the item selection so Clear targets the bin (#587). New Bin
|
||||
// must do the same: leftover clips would otherwise steal the trash button and Delete.
|
||||
let _ = app.session.execute("project.select", json!({"items": []}));
|
||||
app.ui.project_panel.selected_bin = Some(bin);
|
||||
app.ui.project_panel.rename = Some(Rename { item: None, bin: Some(bin), text, panel });
|
||||
Ok(r)
|
||||
|
||||
@@ -570,6 +570,29 @@ fn new_bin_asks_for_its_name() {
|
||||
assert!(d.app().ui.project_panel.rename.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_bin_then_clear_removes_the_bin() {
|
||||
// leftover Project item selection must not keep Clear from removing the new bin
|
||||
let mut d = project_driver();
|
||||
d.exec("project.view.set", json!({"view": "list"}));
|
||||
d.click("project.button.new-item");
|
||||
d.wait_for("project.newItem.file.newColorMatte");
|
||||
d.click("project.newItem.file.newColorMatte");
|
||||
d.click("colorMatte.ok");
|
||||
let items0 = d.app().session.project.items.len();
|
||||
let bins0 = d.app().session.project.root.children.len();
|
||||
assert!(!d.app().session.state.project_selection.is_empty());
|
||||
d.click("project.button.file.newBin");
|
||||
d.frames(2);
|
||||
let bin = d.app().ui.project_panel.selected_bin.expect("the new bin is selected");
|
||||
assert!(d.app().session.state.project_selection.is_empty(), "New Bin clears leftover item selection");
|
||||
d.click("project.button.project.delete");
|
||||
d.frames(2);
|
||||
assert!(d.app().session.project.root.find_bin(filmcraft_project::BinId(bin)).is_none(), "Clear removes the new bin");
|
||||
assert_eq!(d.app().session.project.root.children.len(), bins0);
|
||||
assert_eq!(d.app().session.project.items.len(), items0, "clips already in the project stay");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------ Media Browser
|
||||
|
||||
fn media_dir(tag: &str) -> std::path::PathBuf {
|
||||
|
||||
Reference in new issue
Block a user