mirror of
https://github.com/storytold/soundcraft.git
synced 2026-12-01 18:26:25 -06:00
Round 2 on craft-libs next-host-input: host canvas claims Alt+1-4, host_body panels, no Ctrl+wheel pinch
This commit is contained in:
+19
-19
@@ -11,9 +11,9 @@ rust-version = "1.95"
|
||||
repository = "https://github.com/storytold/soundcraft"
|
||||
|
||||
[workspace.dependencies]
|
||||
craft-score = { git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-xml = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-mime = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-score = { git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
craft-xml = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
craft-mime = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
# internal
|
||||
soundcraft-interchange = { path = "crates/interchange" }
|
||||
soundcraft-time = { path = "crates/time" }
|
||||
@@ -61,34 +61,34 @@ cpal = "0.18"
|
||||
midir = "=0.11.1"
|
||||
|
||||
# Which file paths stored in a session may be opened.
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-docpath = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
|
||||
# Video containers and bitstreams, shared with the other craft apps.
|
||||
craft-media = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-media = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
# H.264 and ProRes codecs shared with the other Craft apps.
|
||||
craft-video = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", default-features = false, features = ["h264-decode", "prores", "mjpeg"] }
|
||||
craft-video = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe", default-features = false, features = ["h264-decode", "prores", "mjpeg"] }
|
||||
# Audio file formats, codecs and waveform overviews, shared with the other craft apps. It shares
|
||||
# types with craft-media, so both stay on one rev.
|
||||
# Standard MIDI Files and the note/controller model, shared with the other craft apps.
|
||||
craft-midi = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", features = ["serde"] }
|
||||
craft-audio = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", features = ["decode", "lossless-encode", "peaks", "serde"] }
|
||||
craft-time = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-midi = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe", features = ["serde"] }
|
||||
craft-audio = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe", features = ["decode", "lossless-encode", "peaks", "serde"] }
|
||||
craft-time = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
# AAF property-stream framing, shared with the other craft apps.
|
||||
craft-aaf = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-scraft-format = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-aaf = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
craft-scraft-format = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
# craft-update: app-specific pretend versions apply to startup and manual checks.
|
||||
craft-update = { version = "=0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49", features = ["ui"] }
|
||||
craft-mcp-server = { version = "=0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-update = { version = "=0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe", features = ["ui"] }
|
||||
craft-mcp-server = { version = "=0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
|
||||
# ui
|
||||
craft-ui = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-behavior = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-ui = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
craft-behavior = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
# The framework runtime's host: the app's identity, its window services, its key overrides and the theme mode
|
||||
# the framework's components draw in (craft-libs).
|
||||
craft-host = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-keymap = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-theme = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-window = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "b436ae992591173ce53fdb1314421ba2d8897e49" }
|
||||
craft-host = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
craft-keymap = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
craft-theme = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
craft-window = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "55fef13aaf67a61c6393b5a4339bef712b9aa2fe" }
|
||||
egui = { version = "0.37" }
|
||||
# Resizable table columns (About ▸ Contributors / Models); no image loaders.
|
||||
egui_extras = { version = "0.37", default-features = false }
|
||||
|
||||
@@ -76,16 +76,14 @@ impl SoundApp {
|
||||
|
||||
/// Whether `received` is the event `wanted` after egui's input pass. egui rewrites the `repeat`
|
||||
/// flag of `egui::Event::Key` from the keys held in the previous pass, so a scripted press can
|
||||
/// arrive marked as a repeat; the other fields still identify the event. Off macOS the UI
|
||||
/// runtime's input hook turns a smooth Ctrl+wheel event into a pinch step (craft-ui's legacy
|
||||
/// pinch rule), as it does for the host's own touchpad. All other events must match exactly.
|
||||
/// arrive marked as a repeat; the other fields still identify the event. All other events must
|
||||
/// match exactly.
|
||||
pub(crate) fn synthetic_event_received(wanted: &egui::Event, received: &egui::Event) -> bool {
|
||||
match (wanted, received) {
|
||||
(
|
||||
egui::Event::Key { key, physical_key, pressed, modifiers, .. },
|
||||
egui::Event::Key { key: got_key, physical_key: got_physical, pressed: got_pressed, modifiers: got_modifiers, .. },
|
||||
) => key == got_key && physical_key == got_physical && pressed == got_pressed && modifiers == got_modifiers,
|
||||
(egui::Event::MouseWheel { modifiers, .. }, egui::Event::Zoom(_)) => modifiers.ctrl && !modifiers.alt && !modifiers.shift,
|
||||
_ => wanted == received,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,7 +606,8 @@ struct DockSpecs {
|
||||
impl PanelSpecs<Panel> for DockSpecs {
|
||||
fn spec(&self, panel: &Panel) -> PanelSpec {
|
||||
let label = Panel::ALL.iter().position(|p| p == panel).and_then(|index| self.labels.get(index)).cloned().unwrap_or_default();
|
||||
let spec = PanelSpec::new(label).limits(panel_limits(panel));
|
||||
// Every panel is SoundCraft's own egui code: the dock runs it with the window's style.
|
||||
let spec = PanelSpec::new(label).limits(panel_limits(panel)).host_body();
|
||||
if *panel == Panel::Canvas { spec.canvas() } else { spec }
|
||||
}
|
||||
|
||||
@@ -628,12 +629,6 @@ fn session_id(edit: bool) -> egui::Id {
|
||||
egui::Id::unique(("soundcraft-session-view", edit))
|
||||
}
|
||||
|
||||
/// Gives SoundCraft's own views in the dock the app's egui style, as the window's root `Ui` has it: the dock lays
|
||||
/// its parts out with the framework's spacing, and the views measure and scroll with SoundCraft's.
|
||||
fn app_style(ui: &mut egui::Ui) {
|
||||
ui.set_style(ui.ctx().global_style());
|
||||
}
|
||||
|
||||
/// The dock's panels over the app in one pass.
|
||||
struct Panels<'a> {
|
||||
app: &'a mut crate::SoundApp,
|
||||
@@ -643,7 +638,6 @@ struct Panels<'a> {
|
||||
impl DockPanels<Panel> for Panels<'_> {
|
||||
fn body(&mut self, panel: &Panel, ui: &mut egui::Ui, _: &mut BodyCx<'_>) {
|
||||
let app = &mut *self.app;
|
||||
app_style(ui);
|
||||
match panel {
|
||||
// The session view is its group's `group_view`.
|
||||
Panel::Canvas => {}
|
||||
@@ -665,7 +659,6 @@ impl DockPanels<Panel> for Panels<'_> {
|
||||
return None;
|
||||
}
|
||||
crate::framework::host_canvas(ui.ctx(), session_id(self.edit));
|
||||
app_style(ui);
|
||||
ui.painter().rect_filled(rect, 0.0, crate::theme::Tokens::current().window_bg);
|
||||
if self.edit {
|
||||
crate::edit_window::main_area(self.app, ui);
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::sync::{Arc, OnceLock};
|
||||
|
||||
use craft_host::target::ShellInfo;
|
||||
use craft_host::{AppInfo, Host};
|
||||
use craft_keymap::Overrides;
|
||||
use craft_keymap::{Chord, Key, Mods, Overrides};
|
||||
use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts};
|
||||
use craft_ui::runtime::commands::CommandInput;
|
||||
use craft_ui::runtime::env::{RootEnv, Scale};
|
||||
@@ -93,7 +93,8 @@ impl SoundApp {
|
||||
/// (`extra_windows`), so the runtime's zoom and SoundCraft's agree.
|
||||
fn frame_input(&mut self, _output: FrameOutput) -> FrameInput {
|
||||
let mode = if crate::theme::is_light() { craft_theme::Mode::Light } else { craft_theme::Mode::Dark };
|
||||
let root = RootEnv::new().mode(mode).scale(Scale::new(self.extra.applied_scale()));
|
||||
// SoundCraft zooms with Cmd/Ctrl+scroll itself, so a smooth Ctrl+wheel stays a wheel event.
|
||||
let root = RootEnv::new().mode(mode).scale(Scale::new(self.extra.applied_scale())).ctrl_wheel_pinch(false);
|
||||
FrameInput::new(root).commands(CommandInput::new().overrides(command_overrides())).host(Arc::clone(&self.framework_host))
|
||||
}
|
||||
|
||||
@@ -116,11 +117,16 @@ impl SoundApp {
|
||||
}
|
||||
}
|
||||
|
||||
/// The edit-mode keys (Alt+1 to Alt+4, Pro Tools' Shuffle, Slip, Spot and Grid) the session view claims, so Alt-code
|
||||
/// entry leaves them to SoundCraft's shortcuts.
|
||||
const EDIT_MODE_KEYS: [Chord; 4] =
|
||||
[Chord::new(Mods::ALT, Key::Num1), Chord::new(Mods::ALT, Key::Num2), Chord::new(Mods::ALT, Key::Num3), Chord::new(Mods::ALT, Key::Num4)];
|
||||
|
||||
/// Declares the session view `id`, drawn in this pass, as the window's document canvas. With nothing focused it is
|
||||
/// the window's key target: Tab, the edit chords and the clipboard events stay in egui's input for SoundCraft's
|
||||
/// shortcuts, as do the arrows, Enter and the page keys.
|
||||
/// the window's key target: Tab, the edit chords, the clipboard events and the edit-mode keys stay in egui's input for
|
||||
/// SoundCraft's shortcuts, as do the arrows, Enter and the page keys.
|
||||
pub(crate) fn host_canvas(ctx: &egui::Context, id: egui::Id) {
|
||||
const KEYS: KeyUse = KeyUse::CANVAS.with_keep(KeepKeys::Tab).with_edits(EditSet::ALL);
|
||||
const KEYS: KeyUse = KeyUse::CANVAS.with_keep(KeepKeys::Tab).with_edits(EditSet::ALL).with_claims(&EDIT_MODE_KEYS);
|
||||
craft_ui::runtime::focus::host_canvas(ctx, id, KEYS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user