diff --git a/CHANGELOG.md b/CHANGELOG.md index 64c61d8..b3430d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Nothing has been released yet. The first release, 0.1.0, will cover what is on ` will land, and it lands there (it used to land to the right of the pointer). Drop a sample on a track, below the tracks for a new audio track, or on a Sampler or Pad Sampler to load it. Drop an instrument on an instrument track to swap its instrument, or below the tracks for a new instrument track; double-clicking an instrument with no instrument track selected adds one. +- The window button shows on every built-in effect with an expanded window, the LFO included, and no longer on cards without one. - Expanded windows for Auto Filter, Channel EQ and Character EQ, with a large display, a live analyser (Pre, Post or Off, and Hold view), In and Out meters and every control laid out in rows, including Character EQ's band Drive. - Expanded windows for Tremolo, Auto-Panner, Chorus, Flanger, Phaser and Ring Mod: a large plot of the effect's diff --git a/README.md b/README.md index 1b64a72..c8cca8d 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ De-Noiser, whose window draws the card's graph at full size over a dB ladder, Pi interval against an A4 reference with the formant strip, Grains, whose window draws the buffer with its pitch and time axes over two cards of controls, Pitch Corrector, whose window draws the correction trace over labelled cent rules, and Shaper, whose window draws its lane tabs and curve editor across the display, and LFO, whose window draws two cycles of its wave across the -window; the other devices open their card in a window for now. +window. Every effect has its window; the instruments and the Rack keep everything in their card. [docs/devices.md](docs/devices.md) explains how they work and how to add one. | Kind | Devices | diff --git a/crates/dstudio-app/src/device_window.rs b/crates/dstudio-app/src/device_window.rs index 6e4ff07..2ffbbca 100644 --- a/crates/dstudio-app/src/device_window.rs +++ b/crates/dstudio-app/src/device_window.rs @@ -3317,6 +3317,20 @@ mod tests { v.knobs.iter().map(|k| k.label.to_string()).collect() } + /// Every built-in effect opens an expanded window; instruments (Synth, Sampler, Drum Rack, + /// Pad Sampler) and the Rack keep everything in their card and have no window button. + #[test] + fn every_effect_has_a_window_and_no_instrument_does() { + use dstudio_core::device::PluginKind; + for def in dstudio_core::builtin::all() { + match def.kind { + PluginKind::Effect if def.id == "device-rack" => assert!(!has_window(def)), + PluginKind::Effect => assert!(has_window(def), "{} has no window", def.id), + PluginKind::Instrument => assert!(!has_window(def), "{} should have no window", def.id), + } + } + } + /// The three windowed devices lay every control inside the window, one control per /// parameter, with the display and both meters. #[test] diff --git a/crates/dstudio-app/src/devices.rs b/crates/dstudio-app/src/devices.rs index d5a5e86..5915294 100644 --- a/crates/dstudio-app/src/devices.rs +++ b/crates/dstudio-app/src/devices.rs @@ -1179,6 +1179,8 @@ impl Controller { self.card_common(d, &mut card); if card.builtin { card.editor_open = self.devices.windows.contains(&d.id); + // Built-ins: only devices with an expanded window show the window button. + card.has_editor = dstudio_core::builtin::def_of(d).is_some_and(crate::device_window::has_window); } card.accent_light = crate::device_mod::is_light(card.accent); card.accent_text = crate::device_mod::accent_text(card.accent); @@ -1879,6 +1881,23 @@ impl Controller { mod tests { use super::*; + /// Built-in cards show the window button exactly when the device has an expanded window: + /// effects (the LFO included) do, the Rack does not. + #[test] + fn builtin_cards_offer_the_window_only_when_there_is_one() { + for (id, want) in [("delay", true), ("lfo", true), ("trance-gate", true), ("device-rack", false)] { + let engine = std::sync::Arc::new(dstudio_engine::Engine::new(dstudio_engine::Config::default()).unwrap()); + let mut c = Controller::new(engine, dstudio_core::Project::default()); + let def = dstudio_core::builtin::find(id).unwrap(); + let track = c.project().tracks[0].id; + assert!(c.execute(Command::AddDevice { track, index: None, device: def.instantiate() }), "{id}"); + let d = c.project().tracks[0].devices.last().unwrap().clone(); + let card = c.card_for(&d, false); + assert!(card.builtin, "{id}"); + assert_eq!(card.has_editor, want, "{id}"); + } + } + #[test] fn custom_plugin_folders_are_added_once_and_never_shadow_a_standard_one() { let mut v = Vec::new(); diff --git a/crates/dstudio-app/ui/device_panel.slint b/crates/dstudio-app/ui/device_panel.slint index bb7dc44..ee81081 100644 --- a/crates/dstudio-app/ui/device_panel.slint +++ b/crates/dstudio-app/ui/device_panel.slint @@ -1547,9 +1547,10 @@ export component CardHeader inherits Rectangle { property fx: root.card.builtin && root.card.modv.kind == 0 && !root.card.sampler.visible; // Cards up to 256 pt show the preset icon instead of the label and the step arrows. property narrow: root.card.width < 256px * zm; - // Every card folds (instruments too); built-in instruments have no device window. + // Every card folds (instruments too). Built-ins show the window button only when they have + // an expanded window (src/device_window.rs has_window); instruments and racks have none. property fold: true; - property window: (root.fx && !root.card.instrument) || (!root.card.builtin && root.card.has-editor); + property window: root.card.has-editor && !(root.card.builtin && root.card.instrument); property remove-x: root.width - 23px * zm; property fold-x: root.remove-x - 18px * zm; property end-x: root.fold ? root.fold-x : root.remove-x; diff --git a/docs/devices.md b/docs/devices.md index b0dc902..1bf9490 100644 --- a/docs/devices.md +++ b/docs/devices.md @@ -67,7 +67,7 @@ flowchart LR Flanger, Phaser, Ring Mod and Character Mod; and the dynamics family: Compressor, Limiter, Gate, Glue Compressor, Character Compressor and Mastering Limiter; Transient Shaper; Multiband Compressor; Delay, Echo and Reverb; Distortion, Tape Saturation, - Soft Clipper and Bit Crusher; Utility, Stereo Widener, Tuner and Spectrum; Trance Gate; De-Clipper, De-Esser, De-Hummer and De-Noiser; Pitch Shifter, Grains and Pitch Corrector; Shaper; LFO), otherwise the card itself in a window. A + Soft Clipper and Bit Crusher; Utility, Stereo Widener, Tuner and Spectrum; Trance Gate; De-Clipper, De-Esser, De-Hummer and De-Noiser; Pitch Shifter, Grains and Pitch Corrector; Shaper; LFO). Every built-in effect has one; the window button shows only on those cards. Instruments (Synth, Sampler, Drum Rack, Pad Sampler) and the Rack keep everything in their card and have no window button. A window is a face 960 pt wide (Ring Mod 860): a top bar (power, presets, the device's header pills), a large display (the card's canvas drawn at window size with its axis and legend), In / Out meters, and rows of controls laid out with the same