feat: compressor section for mobile
This commit is contained in:
@@ -10,4 +10,4 @@ This template should help get you started developing with Tauri, React and Types
|
||||
|
||||
- Check end to end behavioour
|
||||
|
||||
- Make phone version (avoid slider move when scrolling horizontaly)
|
||||
- Make phone version (Crown on topbar dont respect phoen padding + Open keyboard on phone when input slider)
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/* CompressorSection.css */
|
||||
|
||||
/* ---------- Page wrapper ---------- */
|
||||
|
||||
.compressor-page {
|
||||
display: contents; /* invisible on desktop; a flex column on phones */
|
||||
}
|
||||
|
||||
.compressor-tabs,
|
||||
.compressor-rotate-hint {
|
||||
display: none; /* phones only */
|
||||
}
|
||||
|
||||
.compressor-panel__label-short {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ---------- Control strip ---------- */
|
||||
|
||||
.compressor-section {
|
||||
container-type: size;
|
||||
position: absolute;
|
||||
@@ -146,6 +165,20 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.compressor-panel__stepper--centered .choice-stepper__input {
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.compressor-panel__stepper--centered .choice-stepper__arrows {
|
||||
flex: 0 0 20%;
|
||||
width: 20%;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
/* ---------- Graph ---------- */
|
||||
|
||||
.compressor-graph__channel {
|
||||
font-size: var(--font-xs);
|
||||
color: var(--text-muted);
|
||||
@@ -230,14 +263,350 @@
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.compressor-panel__stepper--centered .choice-stepper__input {
|
||||
text-align: center;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
/* ---------- Phone (shared) ----------
|
||||
Landscape: tabs (Controls / Compressor response), one view at a time.
|
||||
Portrait: controls only + a hint to rotate for the graph. */
|
||||
|
||||
@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
|
||||
.compressor-page {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--bg-panel);
|
||||
}
|
||||
|
||||
.compressor-panel__stepper--centered .choice-stepper__arrows {
|
||||
flex: 0 0 20%;
|
||||
width: 20%;
|
||||
padding-right: 0;
|
||||
/* ----- Tabs ----- */
|
||||
|
||||
.compressor-tabs {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
gap: var(--space-1);
|
||||
padding: var(--space-1) var(--space-2);
|
||||
border-bottom: var(--border-width) solid var(--border-hairline);
|
||||
}
|
||||
|
||||
.compressor-page .compressor-tabs__tab {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
height: 34px;
|
||||
padding: 0 var(--space-2);
|
||||
|
||||
font-family: var(--font-ui);
|
||||
font-size: var(--font-xs);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
background: var(--bg-void);
|
||||
color: var(--text-muted);
|
||||
border: var(--border-width) solid var(--border-hairline);
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.compressor-page .compressor-tabs__tab[aria-selected='true'] {
|
||||
background: var(--bg-raised);
|
||||
color: var(--text-primary);
|
||||
border-color: var(--accent-brand);
|
||||
}
|
||||
|
||||
/* ----- Which view is visible ----- */
|
||||
|
||||
.compressor-page[data-view='controls'] .compressor-linear-graph-section,
|
||||
.compressor-page[data-view='response'] .compressor-section {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ----- Response view: graph + meters fill everything ----- */
|
||||
|
||||
.compressor-linear-graph-section {
|
||||
flex: 1 1 0;
|
||||
min-height: 0;
|
||||
gap: var(--space-1);
|
||||
padding: var(--space-1);
|
||||
}
|
||||
|
||||
.compressor-graph__title {
|
||||
padding: var(--space-1);
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
|
||||
.compressor-graph__meters {
|
||||
gap: var(--space-1);
|
||||
padding: var(--space-1);
|
||||
}
|
||||
|
||||
/* ----- Controls view: strips, swipe sideways, snap per panel ----- */
|
||||
|
||||
.compressor-section {
|
||||
position: relative;
|
||||
z-index: auto;
|
||||
flex: 1 1 0;
|
||||
height: auto;
|
||||
min-height: 0;
|
||||
|
||||
align-items: stretch;
|
||||
justify-content: flex-start;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.compressor-panels {
|
||||
display: flex;
|
||||
justify-content: flex-start; /* desktop's "center" would clip the left side on overflow */
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
height: auto;
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-2);
|
||||
box-sizing: border-box;
|
||||
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
scroll-snap-type: x proximity;
|
||||
overscroll-behavior-x: contain;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
/* The group is as wide as its strips (never shrunk to the viewport),
|
||||
so .compressor-panels is the only thing that scrolls. */
|
||||
.compressor-section .channel-group {
|
||||
flex: 0 0 auto;
|
||||
width: max-content;
|
||||
max-width: none;
|
||||
margin: 0;
|
||||
padding: 30px var(--space-2) var(--space-2);
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
|
||||
.compressor-section .channel-group__label {
|
||||
top: 7px;
|
||||
font-size: var(--font-sm);
|
||||
}
|
||||
|
||||
.compressor-section .channel-group__items {
|
||||
height: auto;
|
||||
align-self: stretch;
|
||||
justify-content: flex-start;
|
||||
gap: var(--space-2);
|
||||
overflow: visible; /* no nested scroller: it would fight with .compressor-panels */
|
||||
}
|
||||
|
||||
/* Centered when everything fits, left-aligned and scrollable when it doesn't */
|
||||
.compressor-panels > .channel-group:first-child {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.compressor-panels > .channel-group:last-child {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
/* One strip per output: 3 faders + a column with the Ratio / Knee steppers */
|
||||
.compressor-panel {
|
||||
flex: 0 0 auto;
|
||||
width: clamp(260px, 34vw, 320px);
|
||||
height: auto; /* stretches to the row */
|
||||
aspect-ratio: auto;
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
|
||||
.compressor-panel__title {
|
||||
padding-block: var(--space-2);
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
|
||||
.compressor-panel__grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.8fr);
|
||||
grid-template-rows: minmax(0, 1fr);
|
||||
grid-template-areas: 'threshold attack release steppers';
|
||||
gap: var(--space-1);
|
||||
padding: var(--space-2) var(--space-1);
|
||||
}
|
||||
|
||||
.compressor-panel__cell {
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.compressor-panel__cell--steppers {
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.compressor-panel__stepper {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.compressor-panel__cell-label {
|
||||
max-width: 100%;
|
||||
font-size: 10px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.compressor-panel__label-long {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.compressor-panel__label-short {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
/* pan-x: vertical drags move the fader, horizontal swipes still scroll the strip.
|
||||
Applied to the thumb/track too so a swipe that starts on them scrolls. */
|
||||
.compressor-panel__cell:not(.compressor-panel__cell--steppers) > :first-child,
|
||||
.compressor-panel__cell:not(.compressor-panel__cell--steppers) > :first-child * {
|
||||
touch-action: pan-x !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Portrait phone: controls only, 8 panels in 2 rows, each with 2x2 controls ---------- */
|
||||
|
||||
@media (max-width: 768px) and (orientation: portrait) {
|
||||
.compressor-tabs {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.compressor-rotate-hint {
|
||||
flex: 0 0 auto;
|
||||
display: block;
|
||||
padding: var(--space-1) var(--space-2);
|
||||
|
||||
font-family: var(--font-ui);
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
color: var(--text-muted);
|
||||
|
||||
border-bottom: var(--border-width) solid var(--border-hairline);
|
||||
}
|
||||
|
||||
/* Whatever tab was active in landscape, portrait always shows the controls */
|
||||
.compressor-page[data-view] .compressor-linear-graph-section {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.compressor-page[data-view] .compressor-section {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Swipe sideways: both rows move together (Out1-4 on top, Out5-8 below) */
|
||||
.compressor-panels {
|
||||
padding: var(--space-1);
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.compressor-section .channel-group {
|
||||
padding: 28px var(--space-1) var(--space-1);
|
||||
}
|
||||
|
||||
.compressor-section .channel-group__label {
|
||||
top: 6px;
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
|
||||
.compressor-section .channel-group__items {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, clamp(150px, 46vw, 200px));
|
||||
grid-template-rows: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--space-1);
|
||||
}
|
||||
|
||||
.compressor-panel {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
margin: 0;
|
||||
|
||||
/* Each panel is its own size container (like the rows in GainSection):
|
||||
the slider's cqh sizes (thumb, track, readout) scale to the panel height. */
|
||||
container-type: size;
|
||||
}
|
||||
|
||||
.compressor-panel__title {
|
||||
padding-block: 4px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
/* Each panel keeps its 2x2 layout: Thr | Atk, steppers | Rel */
|
||||
.compressor-panel__grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
grid-template-rows: repeat(2, minmax(0, 1fr));
|
||||
grid-template-areas:
|
||||
'threshold attack'
|
||||
'steppers release';
|
||||
gap: 2px;
|
||||
padding: 4px;
|
||||
|
||||
position: relative;
|
||||
z-index: 1; /* paint above the title if a thumb still reaches it */
|
||||
}
|
||||
|
||||
.compressor-panel__label-long {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.compressor-panel__label-short {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.compressor-panel__cell {
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
/* The thumb sticks out of the track by half its height at min/max: leave that
|
||||
room inside the cell instead of clipping it or letting it slide under the title. */
|
||||
.compressor-panel__cell:not(.compressor-panel__cell--steppers) {
|
||||
overflow: visible;
|
||||
padding-block: 3cqh;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.compressor-panel__cell > :first-child {
|
||||
min-height: 0;
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
.compressor-panel__cell--steppers {
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.compressor-panel__cell-label {
|
||||
font-size: 10px;
|
||||
line-height: 1.1;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Landscape phone: thinner strips ---------- */
|
||||
|
||||
@media (max-height: 500px) and (pointer: coarse) {
|
||||
.compressor-panels {
|
||||
padding: var(--space-1) var(--space-2);
|
||||
}
|
||||
|
||||
.compressor-section .channel-group {
|
||||
padding-top: 24px;
|
||||
}
|
||||
|
||||
.compressor-section .channel-group__label {
|
||||
top: 4px;
|
||||
font-size: var(--font-xs);
|
||||
}
|
||||
|
||||
.compressor-panel {
|
||||
width: clamp(240px, 30vw, 300px);
|
||||
}
|
||||
|
||||
.compressor-panel__title {
|
||||
padding-block: var(--space-1);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.compressor-panel__grid {
|
||||
padding: var(--space-1);
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,9 @@ import './CompressorSection.css';
|
||||
import { RATIO_ORDER, RATIO_LABEL, KNEE_VALUES } from '../../constants';
|
||||
|
||||
const COMPRESSOR_SLIDER_PARAMS = [
|
||||
{ key: 'threshold', label: 'Threshold', min: -90, max: 20, step: 0.5, unit: ' dB' },
|
||||
{ key: 'attack', label: 'Attack', min: 1, max: 999, step: 1, unit: ' ms' },
|
||||
{ key: 'release', label: 'Release', min: 10, max: 3000, step: 1, unit: ' ms' },
|
||||
{ key: 'threshold', label: 'Threshold', short: 'Thr', min: -90, max: 20, step: 0.5, unit: ' dB' },
|
||||
{ key: 'attack', label: 'Attack', short: 'Atk', min: 1, max: 999, step: 1, unit: ' ms' },
|
||||
{ key: 'release', label: 'Release', short: 'Rel', min: 10, max: 3000, step: 1, unit: ' ms' },
|
||||
] as const;
|
||||
|
||||
type CompressorParamKey = 'ratio' | 'attack' | 'release' | 'knee' | 'threshold';
|
||||
@@ -35,6 +35,14 @@ type SetCompressorFn = (
|
||||
threshold: number
|
||||
) => Promise<boolean>;
|
||||
|
||||
// Phone only: one view at a time (CSS hides the tabs on desktop)
|
||||
type CompressorView = 'controls' | 'response';
|
||||
|
||||
const COMPRESSOR_VIEWS: { id: CompressorView; label: string }[] = [
|
||||
{ id: 'controls', label: 'Controls' },
|
||||
{ id: 'response', label: 'Compressor response' },
|
||||
];
|
||||
|
||||
function CompressorPanel({
|
||||
channel,
|
||||
dsp,
|
||||
@@ -74,7 +82,10 @@ function CompressorPanel({
|
||||
onChange={(value) => commit({ [param.key]: value } as Partial<CompressorValues>)}
|
||||
style={{ width: '100%', flex: '1 1 auto' }}
|
||||
/>
|
||||
<div className="compressor-panel__cell-label">{param.label}</div>
|
||||
<div className="compressor-panel__cell-label">
|
||||
<span className="compressor-panel__label-long">{param.label}</span>
|
||||
<span className="compressor-panel__label-short">{param.short}</span>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
@@ -112,8 +123,6 @@ function CompressorPanel({
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function CompressorSection({ dsp, set_compressor }: { dsp: DSP; set_compressor: SetCompressorFn }) {
|
||||
const outputs = [
|
||||
OutputChannel.Out1,
|
||||
@@ -128,6 +137,7 @@ function CompressorSection({ dsp, set_compressor }: { dsp: DSP; set_compressor:
|
||||
|
||||
const [activeChannel, setActiveChannel] = useState<OutputChannel>(outputs[0]);
|
||||
const [liveComp, setLiveComp] = useState<Partial<Record<OutputChannel, CompressorValues>>>({});
|
||||
const [view, setView] = useState<CompressorView>('controls');
|
||||
|
||||
const handleLiveValue = (
|
||||
channel: OutputChannel,
|
||||
@@ -170,7 +180,28 @@ function CompressorSection({ dsp, set_compressor }: { dsp: DSP; set_compressor:
|
||||
const activeComp = liveComp[activeChannel] ?? (activeOutputState.compressor as CompressorValues);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="compressor-page" data-view={view}>
|
||||
{/* Phone only (hidden on desktop by CSS): one view at a time */}
|
||||
<div className="compressor-tabs" role="tablist" aria-label="Compressor views">
|
||||
{COMPRESSOR_VIEWS.map((v) => (
|
||||
<button
|
||||
key={v.id}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={view === v.id}
|
||||
className="compressor-tabs__tab"
|
||||
onClick={() => setView(v.id)}
|
||||
>
|
||||
{v.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Portrait phone only (CSS): the graph needs the width of landscape */}
|
||||
<div className="compressor-rotate-hint">
|
||||
Rotate your phone to landscape to see the compressor graph.
|
||||
</div>
|
||||
|
||||
<div className="compressor-linear-graph-section">
|
||||
<div className="compressor-graph-panel">
|
||||
<div className="compressor-graph__title">{activeOutputState.name} - RMS Compressor</div>
|
||||
@@ -191,7 +222,7 @@ function CompressorSection({ dsp, set_compressor }: { dsp: DSP; set_compressor:
|
||||
key={output}
|
||||
label={outputState.name}
|
||||
meter={dsp.output_meters.meters[output]}
|
||||
variant='output'
|
||||
variant="output"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -214,7 +245,7 @@ function CompressorSection({ dsp, set_compressor }: { dsp: DSP; set_compressor:
|
||||
</ChannelGroup>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user