mirror of
https://github.com/storytold/filmcraft.git
synced 2026-11-02 18:09:21 +00:00
* app: focus the Source monitor when a clip is opened in it (#3669) Opening a clip in Source activated its tab but left focus on the Project panel, so Space still acted on Project and did not play the clip. The OpenSource event now also focuses Source. Tested by opening_a_clip_in_source_focuses_it_so_space_plays_it. Fixes #3669 * app: reopen the Source monitor before focusing it (#3669)
This commit is contained in:
@@ -295,7 +295,12 @@ impl FilmcraftApp {
|
||||
let _ = self.apply_dock(craft_ui::docking::Action::Activate { panel: PanelKind::Timeline });
|
||||
}
|
||||
filmcraft_engine::Event::OpenSource(_) => {
|
||||
let _ = self.apply_dock(craft_ui::docking::Action::Activate { panel: PanelKind::Source });
|
||||
// a closed Source panel reopens, and another panel's maximize would hide it
|
||||
if self.ui.keys.maximized.is_some_and(|p| p != PanelKind::Source) {
|
||||
self.ui.keys.maximized = None;
|
||||
}
|
||||
// the clip just opened there is what Space and J/K/L act on next (#3669)
|
||||
self.show_panel(PanelKind::Source);
|
||||
}
|
||||
filmcraft_engine::Event::RevealInProject(item) => self.reveal_in_project(item),
|
||||
filmcraft_engine::Event::Toast { message, .. } => self.status(message),
|
||||
|
||||
@@ -909,3 +909,45 @@ fn menu_bar_menus_use_the_13pt_menu_text() {
|
||||
assert_eq!(font.size, 13.0, "`{label}` in the File menu");
|
||||
}
|
||||
}
|
||||
|
||||
/// #3669: opening a clip in the Source monitor must also focus it, so Space plays that clip.
|
||||
#[test]
|
||||
fn opening_a_clip_in_source_focuses_it_so_space_plays_it() {
|
||||
let (mut d, a, _, _) = inspector_selection_driver();
|
||||
d.click("panel.tab.Project");
|
||||
// what a double-click on a Project item runs
|
||||
d.exec("source.open", json!({"item": a.0}));
|
||||
d.frames(3);
|
||||
assert_eq!(d.app().session.state.source_item, Some(a));
|
||||
assert_eq!(d.app().ui.focused, filmcraft_ui_egui::dock::PanelKind::Source, "Source takes focus");
|
||||
assert!(!d.app().source_playback.clock.playing);
|
||||
d.ok("ui.key", json!({"key": "Space"}));
|
||||
d.frames(2);
|
||||
assert!(d.app().source_playback.clock.playing, "Space plays the Source clip");
|
||||
}
|
||||
|
||||
/// #3669: a closed Source panel is reopened (not left hidden) when a clip opens in it.
|
||||
#[test]
|
||||
fn opening_a_clip_in_source_reopens_a_closed_source_panel() {
|
||||
use filmcraft_ui_egui::dock::PanelKind;
|
||||
let (mut d, a, _, _) = inspector_selection_driver();
|
||||
d.ok("ui.panel.close", json!({"panel": PanelKind::Source.id()}));
|
||||
d.frames(2);
|
||||
assert!(!d.app().ui.dock.contains(&PanelKind::Source), "Source is closed");
|
||||
d.exec("source.open", json!({"item": a.0}));
|
||||
d.frames(3);
|
||||
assert!(d.app().ui.dock.contains(&PanelKind::Source), "Source is docked again");
|
||||
assert_eq!(d.app().ui.focused, PanelKind::Source);
|
||||
}
|
||||
|
||||
/// #3669: another maximized panel no longer hides the Source monitor that just got focus.
|
||||
#[test]
|
||||
fn opening_a_clip_in_source_clears_another_panels_maximize() {
|
||||
use filmcraft_ui_egui::dock::PanelKind;
|
||||
let (mut d, a, _, _) = inspector_selection_driver();
|
||||
d.app().ui.keys.maximized = Some(PanelKind::Project);
|
||||
d.exec("source.open", json!({"item": a.0}));
|
||||
d.frames(3);
|
||||
assert_eq!(d.app().ui.keys.maximized, None, "the maximize is cleared so Source is visible");
|
||||
assert_eq!(d.app().ui.focused, PanelKind::Source);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user