| author | |
| committer | |
| log | 7fa0a044d4ce21f3b46a35cf584c04fbd14d3670 |
| tree | 1a6b9a93d6d1d3fbcbe2802648dcdc6793a1ba97 |
| parent | 106dd8015f89db1985fbef6fe8c726da1057838b |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
7 files changed, 211 insertions(+), 28 deletions(-)
crates/app/src/export_ui.rs+13-12| ... | ... | @@ -223,8 +223,6 @@ impl Studio { |
| 223 | 223 | control.update_progress(&initial_progress); |
| 224 | 224 | let ctrl_worker = control.clone(); |
| 225 | 225 | let proxy = self.redraw_proxy.clone(); |
| 226 | let export_device = self.engine.device_arc(); | |
| 227 | let export_queue = self.engine.queue_arc(); | |
| 228 | 226 | let (tx, rx) = mpsc::channel(); |
| 229 | 227 | |
| 230 | 228 | let handle = std::thread::Builder::new() |
| ... | ... | @@ -235,16 +233,19 @@ impl Studio { |
| 235 | 233 | let _ = p.send_event(UserEvent::Redraw); |
| 236 | 234 | } |
| 237 | 235 | }; |
| 238 | let mut export_engine = Engine::new_with_device( | |
| 239 | export_device, | |
| 240 | export_queue, | |
| 241 | EXPORT_VRAM_BUDGET_BYTES, | |
| 242 | EXPORT_MEDIA_BUDGET_BYTES, | |
| 243 | ); | |
| 244 | let outcome = match job(&mut export_engine, &ctrl_worker, &notify_redraw) { | |
| 245 | Ok(msg) => ExportOutcome::Completed(msg), | |
| 246 | Err(e) if e == "Cancelled" => ExportOutcome::Cancelled, | |
| 247 | Err(e) => ExportOutcome::Failed(e), | |
| 236 | // Dedicated headless wgpu::Device so background export never submits onto | |
| 237 | // the window surface's Device while a live window resize calls Surface::configure. | |
| 238 | let outcome = match Engine::new_headless() { | |
| 239 | Ok(mut export_engine) => { | |
| 240 | export_engine.set_vram_budget_mb(EXPORT_VRAM_BUDGET_BYTES / (1024 * 1024)); | |
| 241 | export_engine.media.set_budget_mb(EXPORT_MEDIA_BUDGET_BYTES / (1024 * 1024)); | |
| 242 | match job(&mut export_engine, &ctrl_worker, &notify_redraw) { | |
| 243 | Ok(msg) => ExportOutcome::Completed(msg), | |
| 244 | Err(e) if e == "Cancelled" => ExportOutcome::Cancelled, | |
| 245 | Err(e) => ExportOutcome::Failed(e), | |
| 246 | } | |
| 247 | } | |
| 248 | Err(e) => ExportOutcome::Failed(format!("Failed to initialize export GPU: {e}")), | |
| 248 | 249 | }; |
| 249 | 250 | let _ = tx.send(outcome); |
| 250 | 251 | notify_redraw(); |
crates/app/src/main.rs+61-9| ... | ... | @@ -295,11 +295,12 @@ impl Studio { |
| 295 | 295 | let inspector = InspectorState::new(&ui_theme); |
| 296 | 296 | let add_tool = AddToolLauncher::new(); |
| 297 | 297 | let ram_cache = RamFrameCache::default(); |
| 298 | // Dedicated headless wgpu::Device so background lookahead never submits onto | |
| 299 | // the window surface's Device while a live window resize calls Surface::configure. | |
| 298 | 300 | let prefetcher = if interactive { |
| 299 | Some(RamPrefetcher::new_with_device( | |
| 300 | engine.device_arc(), | |
| 301 | engine.queue_arc(), | |
| 301 | Some(RamPrefetcher::new( | |
| 302 | 302 | ram_cache.clone(), |
| 303 | engine::ram_cache::default_prefetch_vram_budget_mb(), | |
| 303 | 304 | )) |
| 304 | 305 | } else { |
| 305 | 306 | None |
| ... | ... | @@ -790,13 +791,20 @@ impl Studio { |
| 790 | 791 | } |
| 791 | 792 | FlowAction::ViewNode(_, id) | FlowAction::RequestRename(id) if deleted || id.0 >= self.comp.nodes.len() => {} |
| 792 | 793 | FlowAction::ViewNode(slot, id) => { |
| 793 | self.viewers[slot].viewed_node = Some(id); | |
| 794 | self.viewers[slot].dirty = true; | |
| 795 | self.flow.viewed_nodes[slot] = Some(id); | |
| 796 | if slot == 1 { | |
| 797 | self.ensure_viewer2_open(); | |
| 794 | if self.viewers[slot].viewed_node == Some(id) { | |
| 795 | self.clear_viewer(slot); | |
| 796 | } else { | |
| 797 | self.viewers[slot].viewed_node = Some(id); | |
| 798 | self.viewers[slot].dirty = true; | |
| 799 | self.flow.viewed_nodes[slot] = Some(id); | |
| 800 | if slot == 1 { | |
| 801 | self.ensure_viewer2_open(); | |
| 802 | } | |
| 798 | 803 | } |
| 799 | 804 | } |
| 805 | FlowAction::ClearViewer(slot) => { | |
| 806 | self.clear_viewer(slot); | |
| 807 | } | |
| 800 | 808 | FlowAction::ClearViewers => { |
| 801 | 809 | self.clear_viewers(); |
| 802 | 810 | } |
| ... | ... | @@ -1143,7 +1151,9 @@ impl WindowHost { |
| 1143 | 1151 | self.access.update_views(&mut self.studio.ui, "Fission", f64::from(self.studio.scale), |_| Vec::new()); |
| 1144 | 1152 | |
| 1145 | 1153 | if !self.occluded && let Some(frame) = self.surface.frame(&self.studio.renderer, Some(&mut self.studio.ui))? { |
| 1146 | self.studio.paint(&frame.target, pixels)?; | |
| 1154 | let tex_size = frame.target.texture().size(); | |
| 1155 | let paint_pixels = [tex_size.width, tex_size.height]; | |
| 1156 | self.studio.paint(&frame.target, paint_pixels)?; | |
| 1147 | 1157 | self.surface.present(&self.studio.renderer, frame); |
| 1148 | 1158 | } |
| 1149 | 1159 | if wants_more && !self.occluded { |
| ... | ... | @@ -1598,4 +1608,46 @@ mod tests { |
| 1598 | 1608 | ); |
| 1599 | 1609 | ui.end(); |
| 1600 | 1610 | } |
| 1611 | ||
| 1612 | #[test] | |
| 1613 | fn pressing_1_or_2_second_time_clears_active_viewer() { | |
| 1614 | let mut studio = studio(); | |
| 1615 | let bg = id(&studio, "BG1"); | |
| 1616 | let merge = id(&studio, "Merge1"); | |
| 1617 | studio.clear_viewers(); | |
| 1618 | studio.flow.primary = Some(bg); | |
| 1619 | ||
| 1620 | let press = |ch: &str| ui::Event::KeyInput { | |
| 1621 | physical: PhysicalKey::Code(if ch == "1" { | |
| 1622 | winit::keyboard::KeyCode::Digit1 | |
| 1623 | } else { | |
| 1624 | winit::keyboard::KeyCode::Digit2 | |
| 1625 | }), | |
| 1626 | key: Key::Character(ch.into()), | |
| 1627 | text: Some(ch.into()), | |
| 1628 | unshifted: Key::Character(ch.into()), | |
| 1629 | modifiers: ModifiersState::empty(), | |
| 1630 | state: ElementState::Pressed, | |
| 1631 | repeat: false, | |
| 1632 | }; | |
| 1633 | ||
| 1634 | // First press of `1` assigns BG1 to Viewer 1. | |
| 1635 | assert!(handle_global_shortcut(&mut studio, &press("1"))); | |
| 1636 | assert_eq!(studio.viewers[0].viewed_node, Some(bg)); | |
| 1637 | assert_eq!(studio.flow.viewed_nodes[0], Some(bg)); | |
| 1638 | ||
| 1639 | // Second press of `1` while BG1 is active clears Viewer 1. | |
| 1640 | assert!(handle_global_shortcut(&mut studio, &press("1"))); | |
| 1641 | assert_eq!(studio.viewers[0].viewed_node, None); | |
| 1642 | assert_eq!(studio.flow.viewed_nodes[0], None); | |
| 1643 | ||
| 1644 | // Selecting Merge1 and pressing `2` assigns Viewer 2; pressing `2` again clears Viewer 2. | |
| 1645 | studio.flow.primary = Some(merge); | |
| 1646 | assert!(handle_global_shortcut(&mut studio, &press("2"))); | |
| 1647 | assert_eq!(studio.viewers[1].viewed_node, Some(merge)); | |
| 1648 | assert_eq!(studio.flow.viewed_nodes[1], Some(merge)); | |
| 1649 | assert!(handle_global_shortcut(&mut studio, &press("2"))); | |
| 1650 | assert_eq!(studio.viewers[1].viewed_node, None); | |
| 1651 | assert_eq!(studio.flow.viewed_nodes[1], None); | |
| 1652 | } | |
| 1601 | 1653 | } |
crates/app/src/menus.rs+43-2| ... | ... | @@ -12,8 +12,27 @@ use winit::event::ElementState; |
| 12 | 12 | use winit::keyboard::{Key, KeyCode, NamedKey, PhysicalKey}; |
| 13 | 13 | |
| 14 | 14 | pub(crate) fn native_open_comp_dialog() -> Option<PathBuf> { |
| 15 | let script = r#"POSIX path of (choose file with prompt "Open Fusion Composition" of type {"comp"})"#; | |
| 16 | let out = ProcessCommand::new("osascript").args(["-e", script]).output().ok()?; | |
| 15 | // Use AppKit NSOpenPanel via JXA so `.comp` resolves to Fusion's registered UTI | |
| 16 | // (`com.blackmagic-design.fusion.composition`) when installed and to a dynamic UTI otherwise. | |
| 17 | // AppleScript's `choose file of type {"comp"}` grays out `.comp` files when Fusion is installed. | |
| 18 | let script = r#" | |
| 19 | ObjC.import("AppKit"); | |
| 20 | const app = $.NSApplication.sharedApplication; | |
| 21 | app.setActivationPolicy($.NSApplicationActivationPolicyAccessory); | |
| 22 | app.activateIgnoringOtherApps(true); | |
| 23 | const panel = $.NSOpenPanel.openPanel; | |
| 24 | panel.title = "Open Fusion Composition"; | |
| 25 | panel.prompt = "Open"; | |
| 26 | panel.canChooseFiles = true; | |
| 27 | panel.canChooseDirectories = false; | |
| 28 | panel.allowsMultipleSelection = false; | |
| 29 | panel.allowedFileTypes = $(["comp", "autocomp"]); | |
| 30 | panel.runModal == $.NSModalResponseOK ? ObjC.unwrap(panel.URL.path) : ""; | |
| 31 | "#; | |
| 32 | let out = ProcessCommand::new("osascript") | |
| 33 | .args(["-l", "JavaScript", "-e", script]) | |
| 34 | .output() | |
| 35 | .ok()?; | |
| 17 | 36 | if !out.status.success() { |
| 18 | 37 | return None; |
| 19 | 38 | } |
| ... | ... | @@ -324,6 +343,28 @@ pub(crate) fn handle_global_shortcut(studio: &mut Studio, event: &ui::Event) -> |
| 324 | 343 | studio.clear_viewers(); |
| 325 | 344 | return true; |
| 326 | 345 | } |
| 346 | if !studio.flow.is_modal_active() && !studio.spline.is_modal_active() { | |
| 347 | let viewer_slot = match event { | |
| 348 | ui::Event::KeyInput { key: Key::Character(c), modifiers, state: ElementState::Pressed, repeat: false, .. } | |
| 349 | | ui::Event::Key { key: Key::Character(c), modifiers, .. } | |
| 350 | if !modifiers.shift_key() | |
| 351 | && !modifiers.super_key() | |
| 352 | && !modifiers.control_key() | |
| 353 | && !modifiers.alt_key() => | |
| 354 | { | |
| 355 | match c.as_str() { | |
| 356 | "1" => Some(0), | |
| 357 | "2" => Some(1), | |
| 358 | _ => None, | |
| 359 | } | |
| 360 | } | |
| 361 | _ => None, | |
| 362 | }; | |
| 363 | if let Some(slot) = viewer_slot { | |
| 364 | studio.toggle_viewer_slot(slot); | |
| 365 | return true; | |
| 366 | } | |
| 367 | } | |
| 327 | 368 | } |
| 328 | 369 | // Canvas panes receive `KeyInput`; every other pane receives `Key`. |
| 329 | 370 | if !studio.ui.popups_open() |
crates/app/src/playback_ui.rs+37| ... | ... | @@ -359,6 +359,43 @@ impl Studio { |
| 359 | 359 | .open("Viewer 2".to_owned(), Place::Beside(target_group, Side::Right)); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | pub(crate) fn clear_viewer(&mut self, slot: usize) { | |
| 363 | if slot >= self.viewers.len() { | |
| 364 | return; | |
| 365 | } | |
| 366 | if slot == 0 { | |
| 367 | self.cancel_prefetch(); | |
| 368 | } | |
| 369 | self.viewers[slot].clear(); | |
| 370 | self.flow.viewed_nodes[slot] = None; | |
| 371 | } | |
| 372 | ||
| 373 | /// Assigns the currently selected node to `slot` (`0` = Viewer 1, `1` = Viewer 2), | |
| 374 | /// or clears `slot` if that node is already active there (or if nothing is selected). | |
| 375 | pub(crate) fn toggle_viewer_slot(&mut self, slot: usize) { | |
| 376 | if slot >= self.viewers.len() { | |
| 377 | return; | |
| 378 | } | |
| 379 | let target = self.flow.primary.filter(|id| id.0 < self.comp.nodes.len()); | |
| 380 | match target { | |
| 381 | Some(id) if self.viewers[slot].viewed_node == Some(id) => { | |
| 382 | self.clear_viewer(slot); | |
| 383 | } | |
| 384 | Some(id) => { | |
| 385 | self.viewers[slot].viewed_node = Some(id); | |
| 386 | self.viewers[slot].dirty = true; | |
| 387 | self.flow.viewed_nodes[slot] = Some(id); | |
| 388 | if slot == 1 { | |
| 389 | self.ensure_viewer2_open(); | |
| 390 | } | |
| 391 | } | |
| 392 | None if self.viewers[slot].viewed_node.is_some() => { | |
| 393 | self.clear_viewer(slot); | |
| 394 | } | |
| 395 | None => {} | |
| 396 | } | |
| 397 | } | |
| 398 | ||
| 362 | 399 | pub(crate) fn clear_viewers(&mut self) { |
| 363 | 400 | self.cancel_prefetch(); |
| 364 | 401 | for v in &mut self.viewers { |
crates/flow/src/lib.rs+51-4| ... | ... | @@ -134,6 +134,8 @@ pub enum FlowAction { |
| 134 | 134 | SelectionChanged(Option<NodeId>), |
| 135 | 135 | /// Slot 0 = Viewer 1 (`1` key), Slot 1 = Viewer 2 (`2` key). |
| 136 | 136 | ViewNode(usize, NodeId), |
| 137 | /// Clear a single viewer slot (pressing `1` or `2` a second time when active). | |
| 138 | ClearViewer(usize), | |
| 137 | 139 | /// `` ` `` key: clear both Viewer 1 and Viewer 2. |
| 138 | 140 | ClearViewers, |
| 139 | 141 | /// Graph topology or node state mutated (optional affected node for subtree bust). |
| ... | ... | @@ -249,6 +251,10 @@ impl FlowView { |
| 249 | 251 | } |
| 250 | 252 | } |
| 251 | 253 | |
| 254 | pub fn is_modal_active(&self) -> bool { | |
| 255 | self.modal.is_some() | |
| 256 | } | |
| 257 | ||
| 252 | 258 | pub fn resize(&mut self, size: [f32; 2]) { |
| 253 | 259 | self.size = [ |
| 254 | 260 | if size[0].is_finite() { size[0].max(1.0) } else { 1.0 }, |
| ... | ... | @@ -786,14 +792,30 @@ impl FlowView { |
| 786 | 792 | } |
| 787 | 793 | "1" if plain => { |
| 788 | 794 | if let Some(id) = self.primary { |
| 789 | self.viewed_nodes[0] = Some(id); | |
| 790 | actions.push(FlowAction::ViewNode(0, id)); | |
| 795 | if self.viewed_nodes[0] == Some(id) { | |
| 796 | self.viewed_nodes[0] = None; | |
| 797 | actions.push(FlowAction::ClearViewer(0)); | |
| 798 | } else { | |
| 799 | self.viewed_nodes[0] = Some(id); | |
| 800 | actions.push(FlowAction::ViewNode(0, id)); | |
| 801 | } | |
| 802 | } else if self.viewed_nodes[0].is_some() { | |
| 803 | self.viewed_nodes[0] = None; | |
| 804 | actions.push(FlowAction::ClearViewer(0)); | |
| 791 | 805 | } |
| 792 | 806 | } |
| 793 | 807 | "2" if plain => { |
| 794 | 808 | if let Some(id) = self.primary { |
| 795 | self.viewed_nodes[1] = Some(id); | |
| 796 | actions.push(FlowAction::ViewNode(1, id)); | |
| 809 | if self.viewed_nodes[1] == Some(id) { | |
| 810 | self.viewed_nodes[1] = None; | |
| 811 | actions.push(FlowAction::ClearViewer(1)); | |
| 812 | } else { | |
| 813 | self.viewed_nodes[1] = Some(id); | |
| 814 | actions.push(FlowAction::ViewNode(1, id)); | |
| 815 | } | |
| 816 | } else if self.viewed_nodes[1].is_some() { | |
| 817 | self.viewed_nodes[1] = None; | |
| 818 | actions.push(FlowAction::ClearViewer(1)); | |
| 797 | 819 | } |
| 798 | 820 | } |
| 799 | 821 | "p" if plain && !self.scope.is_root() => read_only_notice(actions), |
| ... | ... | @@ -1611,6 +1633,31 @@ mod tests { |
| 1611 | 1633 | assert!(history.in_group()); |
| 1612 | 1634 | } |
| 1613 | 1635 | |
| 1636 | #[test] | |
| 1637 | fn viewer_hotkeys_1_and_2_toggle_off_when_already_active() { | |
| 1638 | let (mut comp, mut flow) = group_flow(); | |
| 1639 | let mut history = CompHistory::new(); | |
| 1640 | let bg = id(&comp, "BG1"); | |
| 1641 | flow.selected.insert(bg); | |
| 1642 | flow.primary = Some(bg); | |
| 1643 | ||
| 1644 | let a1 = key(&mut flow, &mut comp, &mut history, Key::Character("1".into()), ModifiersState::empty()); | |
| 1645 | assert!(matches!(a1.as_slice(), [FlowAction::ViewNode(0, id)] if *id == bg)); | |
| 1646 | assert_eq!(flow.viewed_nodes[0], Some(bg)); | |
| 1647 | ||
| 1648 | let a2 = key(&mut flow, &mut comp, &mut history, Key::Character("1".into()), ModifiersState::empty()); | |
| 1649 | assert!(matches!(a2.as_slice(), [FlowAction::ClearViewer(0)])); | |
| 1650 | assert_eq!(flow.viewed_nodes[0], None); | |
| 1651 | ||
| 1652 | let a3 = key(&mut flow, &mut comp, &mut history, Key::Character("2".into()), ModifiersState::empty()); | |
| 1653 | assert!(matches!(a3.as_slice(), [FlowAction::ViewNode(1, id)] if *id == bg)); | |
| 1654 | assert_eq!(flow.viewed_nodes[1], Some(bg)); | |
| 1655 | ||
| 1656 | let a4 = key(&mut flow, &mut comp, &mut history, Key::Character("2".into()), ModifiersState::empty()); | |
| 1657 | assert!(matches!(a4.as_slice(), [FlowAction::ClearViewer(1)])); | |
| 1658 | assert_eq!(flow.viewed_nodes[1], None); | |
| 1659 | } | |
| 1660 | ||
| 1614 | 1661 | fn button(pressed: bool) -> ui::Event { |
| 1615 | 1662 | ui::Event::Button { button: MouseButton::Left, pressed, at: Instant::now() } |
| 1616 | 1663 | } |
crates/model/src/lib.rs+2-1| ... | ... | @@ -319,7 +319,8 @@ mod tests { |
| 319 | 319 | }"#; |
| 320 | 320 | |
| 321 | 321 | let mut comp = Comp::from_fusion_str(src).expect("parse synthetic comp"); |
| 322 | assert!(!is_supported_tool("SurfaceTracker")); | |
| 322 | assert!(!is_supported_tool("MagicMask")); | |
| 323 | assert!(is_supported_tool("SurfaceTracker")); | |
| 323 | 324 | assert!(is_supported_tool("BrightnessContrast")); |
| 324 | 325 | assert!(is_supported_tool("Renderer3D")); |
| 325 | 326 |
crates/spline/src/lib.rs+4| ... | ... | @@ -131,6 +131,10 @@ impl SplineView { |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | pub fn is_modal_active(&self) -> bool { | |
| 135 | self.modal.is_some() | |
| 136 | } | |
| 137 | ||
| 134 | 138 | pub fn resize(&mut self, size: [f32; 2]) { |
| 135 | 139 | self.size = [ |
| 136 | 140 | if size[0].is_finite() { size[0].max(1.0) } else { 1.0 }, |