Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

(fix) Transport adaptive view

Egor Khindikaynen8523f5180872
diff --git a/src/managed/Nota.App/MainWindow.Files.cs b/src/managed/Nota.App/MainWindow.Files.cs
index c7ba2321..c30c5ed8 100644
--- a/src/managed/Nota.App/MainWindow.Files.cs
+++ b/src/managed/Nota.App/MainWindow.Files.cs
@@ -158,6 +158,7 @@ public partial class MainWindow
// the app; the OS window title keeps both for the Dock and window switcher.
DocTitleText.Text = "Nota";
ProjectNameText.Text = ProjectDisplayName();
+ RequestTransportFit();
}
/// <summary>A crash-recovery snapshot to offer on open (set by App at launch). M7-7.</summary>
diff --git a/src/managed/Nota.App/MainWindow.TransportFit.cs b/src/managed/Nota.App/MainWindow.TransportFit.cs
new file mode 100644
index 00000000..a389da77
--- /dev/null
+++ b/src/managed/Nota.App/MainWindow.TransportFit.cs
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The transport bar on a narrow window: rather than clip the right end (master, CPU, Remote)
+// or let the row run past the island's edge, it sheds parts in order of how little they are
+// needed. First what is shown elsewhere or merely informative, then what has a menu entry or
+// a shortcut, last the readouts you set while playing. Stop / play / record, the position,
+// the tempo, the metronome and the view switch never go.
+
+using System;
+using System.Collections.Generic;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Layout;
+using Avalonia.Threading;
+
+namespace Nota.App;
+
+public partial class MainWindow
+{
+ // Each step hides its controls together; steps go in this order and come back in reverse.
+ private Control[][]? _transportShedOrder;
+ private bool _transportFitPosted;
+
+ private Control[][] TransportShedOrder => _transportShedOrder ??= new[]
+ {
+ new Control[] { CpuMeter, CpuSep }, // informative only
+ new Control[] { ProjectNameText }, // moves to the title-bar caption
+ new Control[] { RemoteLabel }, // Remote keeps its glyph, count and dot
+ new Control[] { KeyChip }, // set once per project
+ new Control[] { RemoteBtn }, // View ▸ Connect Phone…
+ new Control[] { FollowBtn }, // View ▸ Follow playhead
+ new Control[] { AutomationToggle }, // ⌘⇧A
+ new Control[] { TimeSigCell }, // set once per project
+ new Control[] { RemotePanel }, // MIDI learn (the panel goes with its last chip)
+ new Control[] { SnapChip }, // the grid; snapping itself stays switchable
+ new Control[] { SnapToggle }, // hold Alt to drag freely
+ new Control[] { LoopSep, LoopCell }, // ⌘L; the range stays visible on the ruler
+ new Control[] { MasterWell }, // the master strip is in the mixer
+ };
+
+ private void InitTransportFit()
+ {
+ TransportBar.SizeChanged += (_, _) => FitTransport();
+ }
+
+ /// <summary>Re-fit after something in the bar changed width (the project name, the
+ /// Re-enable chip). Coalesced to one pass after the current layout.</summary>
+ private void RequestTransportFit()
+ {
+ if (_transportFitPosted) return;
+ _transportFitPosted = true;
+ Dispatcher.UIThread.Post(() => { _transportFitPosted = false; FitTransport(); }, DispatcherPriority.Loaded);
+ }
+
+ /// <summary>Show everything, then hide steps until the row's natural width fits the bar.</summary>
+ private void FitTransport()
+ {
+ double avail = TransportBar.Bounds.Width - TransportBar.Padding.Left - TransportBar.Padding.Right
+ - TransportBar.BorderThickness.Left - TransportBar.BorderThickness.Right;
+ if (avail <= 0) return;
+
+ var order = TransportShedOrder;
+ foreach (var step in order)
+ foreach (var c in step) SetShown(c, true);
+
+ int hidden = 0;
+ while (NaturalTransportWidth() > avail && hidden < order.Length)
+ {
+ foreach (var c in order[hidden]) SetShown(c, false);
+ hidden++;
+ }
+
+ // The name leaves the bar for the caption, so the open project stays on screen.
+ DocTitleText.Text = ProjectNameText.IsVisible ? "Nota" : ProjectDisplayName();
+ TransportGrid.InvalidateMeasure();
+ }
+
+ // Measure unconstrained: the * spacer column collapses, so this is what the row needs.
+ private double NaturalTransportWidth()
+ {
+ TransportGrid.Measure(Avalonia.Size.Infinity);
+ return TransportGrid.DesiredSize.Width;
+ }
+
+ // Toggle and invalidate up to the grid, so the next unconstrained measure of the grid
+ // re-measures the panels in between instead of returning their cached sizes.
+ private void SetShown(Control c, bool on)
+ {
+ if (c.IsVisible == on) return;
+ c.IsVisible = on;
+ for (var p = c.Parent as Layoutable; p is not null; p = p.Parent as Layoutable)
+ {
+ p.InvalidateMeasure();
+ if (ReferenceEquals(p, TransportGrid)) break;
+ }
+ }
+}
diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axaml
index 43416feb..49b59391 100644
--- a/src/managed/Nota.App/MainWindow.axaml
+++ b/src/managed/Nota.App/MainWindow.axaml
@@ -121,10 +121,12 @@
42px recess on Void inside it, so playback reads as one object rather than a row of
buttons. Reads left to right as: which view · what plays · the numbers you set ·
the switches you flip · then, pinned right, what the machine is doing. Launch
- quantize shows only in Session, where it applies. The view switch leads the row. -->
+ quantize shows only in Session, where it applies. The view switch leads the row.
+ When the window is too narrow the row sheds its least-needed parts first —
+ see MainWindow.TransportFit.cs for the order. -->
<Border x:Name="TransportBar" DockPanel.Dock="Top" Classes="transport" Height="{StaticResource Control.TransportBar}"
Margin="12,12,12,0">
- <Grid ColumnDefinitions="Auto,Auto,Auto,Auto,Auto,*,Auto,Auto,Auto,Auto,Auto">
+ <Grid x:Name="TransportGrid" ColumnDefinitions="Auto,Auto,Auto,Auto,Auto,*,Auto,Auto,Auto,Auto,Auto">
<!-- Project name, then the view switch -->
<StackPanel Grid.Column="0" Orientation="Horizontal" Spacing="12" Margin="2,0,14,0" VerticalAlignment="Center">
@@ -171,10 +173,10 @@
<TextBlock Classes="CellLabel" Text="{Binding Transport.PositionUnitText}"/>
</StackPanel>
- <Border Width="1" Height="24" Background="{DynamicResource Brush.Hairline}"/>
+ <Border x:Name="LoopSep" Width="1" Height="24" Background="{DynamicResource Brush.Hairline}"/>
<!-- Loop: the range is the button -->
- <ToggleButton Classes="cell" IsChecked="{Binding Transport.LoopOn}" ToolTip.Tip="Loop the range set on the ruler">
+ <ToggleButton x:Name="LoopCell" Classes="cell" IsChecked="{Binding Transport.LoopOn}" ToolTip.Tip="Loop the range set on the ruler">
<StackPanel Spacing="2">
<TextBlock Classes="CellLabel" Text="LOOP" Foreground="{Binding $parent[ToggleButton].Foreground}"/>
<TextBlock Classes="Mono" FontSize="11" LineHeight="12" MinWidth="58"
@@ -193,7 +195,7 @@
<TextBlock Classes="CellLabel" Text="BPM" HorizontalAlignment="Center"/>
</StackPanel>
<!-- Time signature (drag ↕ each field) -->
- <StackPanel Spacing="2" VerticalAlignment="Center" Margin="7,0" ToolTip.Tip="Set the time signature — drag each field">
+ <StackPanel x:Name="TimeSigCell" Spacing="2" VerticalAlignment="Center" Margin="7,0" ToolTip.Tip="Set the time signature — drag each field">
<StackPanel Orientation="Horizontal" Spacing="1" Height="18">
<Panel x:Name="TimeSigNumHost" Width="16"/>
<TextBlock Classes="Mono" Text="/" FontSize="14" VerticalAlignment="Center"
@@ -312,7 +314,7 @@
<!-- MIDI learn + an input-activity dot, so a silent controller is diagnosable;
Remote (Nota Remote) beside it: off / the number of phones, a dot that flashes on
each touch from a phone. Click opens Connect Phone. -->
- <StackPanel Grid.Column="6" Orientation="Horizontal" Spacing="6" Margin="8,0,0,0">
+ <StackPanel x:Name="RemotePanel" Grid.Column="6" Orientation="Horizontal" Spacing="6" Margin="8,0,0,0">
<ToggleButton x:Name="MidiLearnBtn" Classes="chip"
Click="OnToggleMidiLearn"
ToolTip.Tip="Map a controller — click a control, then move a knob on the controller">
@@ -328,7 +330,7 @@
<StackPanel Orientation="Horizontal" Spacing="7" VerticalAlignment="Center">
<Border x:Name="RemoteGlyph" Width="8" Height="12" CornerRadius="2" BorderThickness="1.5"
BorderBrush="{Binding $parent[Button].Foreground}" VerticalAlignment="Center"/>
- <TextBlock Text="Remote" VerticalAlignment="Center"
+ <TextBlock x:Name="RemoteLabel" Text="Remote" VerticalAlignment="Center"
Foreground="{Binding $parent[Button].Foreground}"/>
<TextBlock x:Name="RemoteCount" Classes="Mono" Text="Off" FontSize="10" VerticalAlignment="Center"
Foreground="{Binding $parent[Button].Foreground}"/>
@@ -338,11 +340,11 @@
</Button>
</StackPanel>
- <Border Grid.Column="7" Width="1" Height="26" Margin="14,0"
+ <Border x:Name="CpuSep" Grid.Column="7" Width="1" Height="26" Margin="14,0"
Background="{DynamicResource Brush.Hairline}"/>
<!-- CPU: live DSP load -->
- <StackPanel Grid.Column="8" Spacing="3" VerticalAlignment="Center">
+ <StackPanel x:Name="CpuMeter" Grid.Column="8" Spacing="3" VerticalAlignment="Center">
<Border Width="52" Height="4" Background="{DynamicResource Brush.SurfaceAbyss}"
CornerRadius="2" ClipToBounds="True">
<Border x:Name="CpuFill" Width="0" HorizontalAlignment="Left" CornerRadius="2"
@@ -352,7 +354,7 @@
</StackPanel>
<!-- Master: fader over its meter, with the gain in dB -->
- <Border Grid.Column="9" Classes="tp-well" Margin="14,0,0,0">
+ <Border x:Name="MasterWell" Grid.Column="9" Classes="tp-well" Margin="14,0,0,0">
<StackPanel Orientation="Horizontal" Spacing="9" VerticalAlignment="Center">
<TextBlock Classes="CellLabel" Text="MST" VerticalAlignment="Center"/>
<StackPanel Spacing="3" VerticalAlignment="Center">
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index ca30a0c5..3e314a7f 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -101,6 +101,7 @@ public partial class MainWindow : Window
}
DataContextChanged += OnDataContextChanged;
BuildDownloadIndicator();
+ InitTransportFit();
// Platform-specific window icon: Windows/Linux get the .ico bundle from
// assets/icons/windows so the taskbar / alt-tab shows the brand mark. macOS
// uses the .icns produced by scripts/bundle-mac.sh for the dock/Finder.
@@ -717,6 +718,6 @@ public partial class MainWindow : Window
internal void SyncReenableAutomation()
{
bool on = _vm is { } vm && vm.Engine.AutomationOverridden;
- if (ReenableAutoBtn.IsVisible != on) ReenableAutoBtn.IsVisible = on;
+ if (ReenableAutoBtn.IsVisible != on) { ReenableAutoBtn.IsVisible = on; RequestTransportFit(); }
}
}