P6a: mobile music surface (keyboard-primary instrument pane)

The mobile Piano Roll becomes a unified, keyboard-primary instrument surface
(wireframe Plate 04/08): a playable keyboard as the base, revealing a
Synthesia-style falling-notes roll above it when the pane is tall enough.

- Shared keyboard geometry (panes/keyboard_layout.rs): width-driven, pan-aware
  pitch->x, so the roll's note columns stay aligned with the Virtual Piano keys.
  Shared keyboard_octave + keyboard_pan_x in SharedPaneState.
- Piano Roll vertical mode (is_mobile): notes as columns falling toward an amber
  now-line by the keys, tempo-map converted (beats->seconds) so onsets cross the
  line exactly when they sound. Vertical drag scrubs the timeline; horizontal
  drag smoothly scrolls the keys (snaps to nearest key on release). Long-press
  creates a note (drag to size) or resizes an existing one; pan suppresses it.
  The keyboard is embedded (reuses Virtual Piano render + MIDI); the standalone
  VirtualPiano stack slot is removed. show_roll is driven by the snapped pane
  size-class so the keyboard<->roll reveal lands on a stack snap point.
- Virtual Piano: renders via the shared layout on mobile, colors playback_notes
  like pressed keys, gates note-on/glissando to presses that start on the keys
  (never gating release), and hides QWERTY hints on mobile.
- Transport formats by document.timeline_mode (Measures->bar.beat.tick,
  Frames->MM:SS:FF, Seconds->MM:SS.mmm) — per project type, like desktop.
- In-pane instrument header (name + Presets + REC). Recording is driven from the
  app each frame (not the Timeline pane's render) so REC works regardless of
  visible panes, and stopping playback stops recording.
- Compose/Record intent opens Timeline + instrument pane; mobile central panel is
  full-bleed (no inner margin) so panes sit flush.
- phone-ui-sketches.html: inst-bar moved to the top of the music surface.
This commit is contained in:
Skyler Lehmkuhl
2026-07-02 07:50:37 -04:00
parent 77eb2c2d33
commit b14972f657
10 changed files with 1482 additions and 35 deletions
@@ -19,18 +19,24 @@ struct Intent {
focus: usize,
/// Initial mobile stack window: (window_top, window_count).
window: (usize, usize),
/// Initial pane weights (relative heights) for the window.
weights: [f32; 3],
}
fn intents(pal: &Palette) -> [Intent; 6] {
let [coral, cyan, amber, pink, violet] = pal.accents;
let even = [1.0, 1.0, 1.0];
// Compose/Record: compressed Timeline ribbon on top; the tall Piano Roll (which now hosts the
// instrument header + keyboard as one surface) fills the rest.
let music = [0.4, 1.6, 1.0];
[
// Stage indices (see super::STACK): Stage=2, Timeline=3, PianoRoll=4, VirtualPiano=5.
Intent { label: "Draw", icon: icons::BRUSH, accent: coral, focus: 5, window: (2, 1) },
Intent { label: "Animate", icon: icons::FILM, accent: cyan, focus: 0, window: (2, 2) },
Intent { label: "Compose", icon: icons::MUSIC, accent: amber, focus: 2, window: (3, 3) },
Intent { label: "Record", icon: icons::MIC, accent: pink, focus: 2, window: (3, 3) },
Intent { label: "Edit video", icon: icons::CLAPPERBOARD, accent: violet, focus: 1, window: (2, 2) },
Intent { label: "Blank", icon: icons::SQUARE_DASHED, accent: pal.text_dim, focus: 0, window: (2, 2) },
Intent { label: "Draw", icon: icons::BRUSH, accent: coral, focus: 5, window: (2, 1), weights: even },
Intent { label: "Animate", icon: icons::FILM, accent: cyan, focus: 0, window: (2, 2), weights: even },
Intent { label: "Compose", icon: icons::MUSIC, accent: amber, focus: 2, window: (3, 2), weights: music },
Intent { label: "Record", icon: icons::MIC, accent: pink, focus: 2, window: (3, 2), weights: music },
Intent { label: "Edit video", icon: icons::CLAPPERBOARD, accent: violet, focus: 1, window: (2, 2), weights: even },
Intent { label: "Blank", icon: icons::SQUARE_DASHED, accent: pal.text_dim, focus: 0, window: (2, 2), weights: even },
]
}
@@ -92,7 +98,7 @@ pub fn render(app: &mut EditorApp, ctx: &egui::Context) {
app.create_new_project_with_focus(intent.focus);
app.mobile_state.window_top = intent.window.0;
app.mobile_state.window_count = intent.window.1;
app.mobile_state.weights = [1.0, 1.0, 1.0];
app.mobile_state.weights = intent.weights;
}
}
@@ -89,21 +89,21 @@ pub enum StackPane {
AssetLibrary,
Stage,
Timeline,
/// The instrument surface: keyboard-primary on mobile, hosting the falling-notes roll above the
/// keys (the standalone Virtual Piano is embedded here, so it isn't a separate stack slot).
PianoRoll,
VirtualPiano,
/// Node editor, or (toggled) the instrument/preset browser.
NodeInstrument,
ScriptEditor,
}
/// The stack order. Index into this is a pane's stable slot id.
pub const STACK: [StackPane; 8] = [
pub const STACK: [StackPane; 7] = [
StackPane::Outliner,
StackPane::AssetLibrary,
StackPane::Stage,
StackPane::Timeline,
StackPane::PianoRoll,
StackPane::VirtualPiano,
StackPane::NodeInstrument,
StackPane::ScriptEditor,
];
@@ -118,7 +118,6 @@ impl StackPane {
StackPane::Stage => PaneType::Stage,
StackPane::Timeline => PaneType::Timeline,
StackPane::PianoRoll => PaneType::PianoRoll,
StackPane::VirtualPiano => PaneType::VirtualPiano,
StackPane::NodeInstrument => {
if show_instruments {
PaneType::PresetBrowser
@@ -136,8 +135,7 @@ impl StackPane {
StackPane::AssetLibrary => "Assets",
StackPane::Stage => "Stage",
StackPane::Timeline => "Timeline",
StackPane::PianoRoll => "Piano Roll",
StackPane::VirtualPiano => "Keys",
StackPane::PianoRoll => "Instrument",
StackPane::NodeInstrument => {
if show_instruments {
"Instruments"
@@ -332,6 +330,20 @@ pub fn render_mobile_shell(
region
};
// Decide whether the instrument pane (PianoRoll = STACK index 4) reveals the roll, from the
// *committed* (snapped) window weights — so the keyboard↔roll transition lands on a stack snap
// rather than at an arbitrary mid-drag height. Roll shows once the pane is past the smallest snap.
rc.shared.instrument_show_roll = {
let idx = 4i32 - state.window_top as i32;
if idx >= 0 && (idx as usize) < state.window_count {
let sum: f32 = state.weights[..state.window_count].iter().map(|w| w.max(0.0)).sum();
let w = if sum > 0.0 { state.weights[idx as usize].max(0.0) / sum } else { 0.0 };
w > 0.30 // 0.25 preset ⇒ keyboard only; 0.33/0.5/0.75 ⇒ keyboard + roll
} else {
true
}
};
stack::render(ui, stack_rect, rc, state, &pal);
if inspector_shown {
@@ -345,6 +357,16 @@ pub fn render_mobile_shell(
// Omnibutton FAB (radial tool menu) — drawn above the stack region, on top of everything else.
omni::render(ui, region, rc, state, &pal);
// Instrument-browser request from the music pane's header → show the Preset Browser fullscreen.
if *rc.shared.open_instrument_browser {
*rc.shared.open_instrument_browser = false;
state.show_instruments = true;
state.window_top = 5; // Node/Instrument band (PresetBrowser when show_instruments)
state.window_count = 1;
state.weights = [1.0, 1.0, 1.0];
state.anim = None;
}
// Top bar (filename + ⌕ palette + ⋯ commands). Its menus overlay the whole shell, so it's last.
topbar::render(ui, topbar_rect, available_rect, rc, state, &pal);
@@ -40,9 +40,24 @@ pub fn render(ui: &mut egui::Ui, rect: egui::Rect, shared: &mut SharedPaneState,
}
}
// --- Timecode (MM:SS:FF) ---
let fps = shared.action_executor.document().framerate.max(1.0);
let tc = format_timecode(*shared.playback_time, fps);
// --- Playhead readout: format follows the project's TimelineMode (set at creation by type). ---
let t = *shared.playback_time;
let tc = {
use lightningbeam_core::document::TimelineMode;
let doc = shared.action_executor.document();
match doc.timeline_mode {
TimelineMode::Measures => {
let pos = lightningbeam_core::beat_time::time_to_measure(t, doc.tempo_map(), &doc.time_signature);
format!("{}.{}.{:02}", pos.measure, pos.beat, pos.tick / 10)
}
TimelineMode::Frames => format_timecode(t, doc.framerate.max(1.0)),
TimelineMode::Seconds => {
let total = t.max(0.0);
let m = (total / 60.0).floor() as u32;
format!("{:02}:{:06.3}", m, total % 60.0)
}
}
};
let tc_left = btn_rect.right() + 12.0;
painter.text(
egui::pos2(tc_left, cy),