Compress mobile layer headers to a swatch; conditional inspector reflow
- Add `is_mobile` to SharedPaneState (set in build_frame). On mobile the timeline layer-header column collapses to a minimal type-colored swatch (1:2 w:h, ~30px), brighter/outlined when active/selected; tapping it selects the layer (handled by the existing header-column input path, which now uses the narrower width). Desktop headers unchanged. - Inspector reflow: the sheet overlaps the stack by default, but when the selected pane would be covered by the sheet, the stack reflows (renders above the sheet) so it stays visible. Restore on dismiss is automatic since reflow only changes the render rect; manual divider moves while the sheet is up persist. Adds stack::pane_bottom_in and inspector::target_slot.
This commit is contained in:
@@ -29,6 +29,18 @@ pub fn is_active(shared: &SharedPaneState) -> bool {
|
||||
!shared.focus.is_none() || !shared.selection.is_empty()
|
||||
}
|
||||
|
||||
/// The stack slot (see `super::STACK`) where the current selection lives, so we can tell if the
|
||||
/// sheet would cover it. Geometry/selection lives on the Stage; clips/layers on the Timeline; etc.
|
||||
pub fn target_slot(shared: &SharedPaneState) -> usize {
|
||||
match &*shared.focus {
|
||||
FocusSelection::Notes { .. } => 4, // PianoRoll
|
||||
FocusSelection::Nodes(_) => 6, // Node/Instrument
|
||||
FocusSelection::Assets(_) => 1, // Asset Library
|
||||
FocusSelection::ClipInstances(_) | FocusSelection::Layers(_) => 3, // Timeline
|
||||
FocusSelection::Geometry { .. } | FocusSelection::None => 2, // Stage
|
||||
}
|
||||
}
|
||||
|
||||
/// A short title describing what's selected.
|
||||
fn title(shared: &SharedPaneState) -> String {
|
||||
use lightningbeam_core::layer::{AnyLayer, AudioLayerType};
|
||||
|
||||
@@ -190,15 +190,32 @@ pub fn render_mobile_shell(
|
||||
available_rect.min,
|
||||
egui::pos2(available_rect.right(), transport_rect.top()),
|
||||
);
|
||||
// The stack always fills the region; the inspector sheet overlays its lower part (no reflow).
|
||||
stack::render(ui, region, rc, state);
|
||||
// When the inspector is up, the sheet overlays the lower part of the stack. If the selected
|
||||
// pane would be *covered* by the sheet, reflow (shrink the stack above the sheet) so it stays
|
||||
// visible; otherwise leave the stack full-height and just overlay. Restoring on dismiss is
|
||||
// automatic — reflow only changes the render rect, not the window state.
|
||||
let inspector_shown = inspector::is_active(&rc.shared);
|
||||
let sheet_h = if inspector_shown {
|
||||
(region.height() * state.inspector_frac).clamp(120.0, region.height() - 60.0)
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let sheet_top = region.bottom() - sheet_h;
|
||||
|
||||
if inspector::is_active(&rc.shared) {
|
||||
let sheet_h = (region.height() * state.inspector_frac).clamp(120.0, region.height() - 60.0);
|
||||
let sheet_rect = egui::Rect::from_min_max(
|
||||
egui::pos2(region.left(), region.bottom() - sheet_h),
|
||||
region.max,
|
||||
);
|
||||
let covered = inspector_shown
|
||||
&& stack::pane_bottom_in(state, region, inspector::target_slot(&rc.shared))
|
||||
.map(|bottom| bottom > sheet_top + 1.0)
|
||||
.unwrap_or(false);
|
||||
let stack_rect = if covered {
|
||||
egui::Rect::from_min_max(region.min, egui::pos2(region.right(), sheet_top))
|
||||
} else {
|
||||
region
|
||||
};
|
||||
|
||||
stack::render(ui, stack_rect, rc, state);
|
||||
|
||||
if inspector_shown {
|
||||
let sheet_rect = egui::Rect::from_min_max(egui::pos2(region.left(), sheet_top), region.max);
|
||||
inspector::render(ui, sheet_rect, region.height(), rc, state);
|
||||
}
|
||||
|
||||
|
||||
@@ -224,6 +224,19 @@ fn nweights(weights: &[f32; 3], count: usize) -> Vec<f32> {
|
||||
w
|
||||
}
|
||||
|
||||
/// The bottom Y of the given stack slot's band within `region` (using the current window +
|
||||
/// weights), or None if that slot isn't in the visible window. Used to decide whether the
|
||||
/// inspector sheet would cover the selected pane.
|
||||
pub fn pane_bottom_in(state: &MobileState, region: egui::Rect, slot: usize) -> Option<f32> {
|
||||
let (top, count) = (state.window_top, state.window_count);
|
||||
if slot < top || slot >= top + count {
|
||||
return None;
|
||||
}
|
||||
let nw = nweights(&state.weights, count);
|
||||
let cum: f32 = nw[..=(slot - top)].iter().sum();
|
||||
Some(region.top() + cum * region.height())
|
||||
}
|
||||
|
||||
/// Lay out `count` panes in `rect` using normalized weights `nw`.
|
||||
fn config_rects(top: usize, count: usize, rect: egui::Rect, nw: &[f32]) -> Vec<(usize, egui::Rect)> {
|
||||
let h = rect.height();
|
||||
|
||||
Reference in New Issue
Block a user